documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Copy the current vector to an array
  2097. * @returns a new array with 2 elements: the Vector2 coordinates.
  2098. */
  2099. asArray(): number[];
  2100. /**
  2101. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2102. * @param source defines the source Vector2
  2103. * @returns the current updated Vector2
  2104. */
  2105. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2106. /**
  2107. * Sets the Vector2 coordinates with the given floats
  2108. * @param x defines the first coordinate
  2109. * @param y defines the second coordinate
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFromFloats(x: number, y: number): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. set(x: number, y: number): Vector2;
  2120. /**
  2121. * Add another vector with the current one
  2122. * @param otherVector defines the other vector
  2123. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2124. */
  2125. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2126. /**
  2127. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @param result defines the target vector
  2130. * @returns the unmodified current Vector2
  2131. */
  2132. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2133. /**
  2134. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2135. * @param otherVector defines the other vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2139. /**
  2140. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2141. * @param otherVector defines the other vector
  2142. * @returns a new Vector2
  2143. */
  2144. addVector3(otherVector: Vector3): Vector2;
  2145. /**
  2146. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2147. * @param otherVector defines the other vector
  2148. * @returns a new Vector2
  2149. */
  2150. subtract(otherVector: Vector2): Vector2;
  2151. /**
  2152. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2153. * @param otherVector defines the other vector
  2154. * @param result defines the target vector
  2155. * @returns the unmodified current Vector2
  2156. */
  2157. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2158. /**
  2159. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns the current updated Vector2
  2162. */
  2163. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Multiplies in place the current Vector2 coordinates by the given ones
  2166. * @param otherVector defines the other vector
  2167. * @returns the current updated Vector2
  2168. */
  2169. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2170. /**
  2171. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2172. * @param otherVector defines the other vector
  2173. * @returns a new Vector2
  2174. */
  2175. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2178. * @param otherVector defines the other vector
  2179. * @param result defines the target vector
  2180. * @returns the unmodified current Vector2
  2181. */
  2182. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2185. * @param x defines the first coordinate
  2186. * @param y defines the second coordinate
  2187. * @returns a new Vector2
  2188. */
  2189. multiplyByFloats(x: number, y: number): Vector2;
  2190. /**
  2191. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2192. * @param otherVector defines the other vector
  2193. * @returns a new Vector2
  2194. */
  2195. divide(otherVector: Vector2): Vector2;
  2196. /**
  2197. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @param result defines the target vector
  2200. * @returns the unmodified current Vector2
  2201. */
  2202. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2203. /**
  2204. * Divides the current Vector2 coordinates by the given ones
  2205. * @param otherVector defines the other vector
  2206. * @returns the current updated Vector2
  2207. */
  2208. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2209. /**
  2210. * Gets a new Vector2 with current Vector2 negated coordinates
  2211. * @returns a new Vector2
  2212. */
  2213. negate(): Vector2;
  2214. /**
  2215. * Negate this vector in place
  2216. * @returns this
  2217. */
  2218. negateInPlace(): Vector2;
  2219. /**
  2220. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2221. * @param result defines the Vector3 object where to store the result
  2222. * @returns the current Vector2
  2223. */
  2224. negateToRef(result: Vector2): Vector2;
  2225. /**
  2226. * Multiply the Vector2 coordinates by scale
  2227. * @param scale defines the scaling factor
  2228. * @returns the current updated Vector2
  2229. */
  2230. scaleInPlace(scale: number): Vector2;
  2231. /**
  2232. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2233. * @param scale defines the scaling factor
  2234. * @returns a new Vector2
  2235. */
  2236. scale(scale: number): Vector2;
  2237. /**
  2238. * Scale the current Vector2 values by a factor to a given Vector2
  2239. * @param scale defines the scale factor
  2240. * @param result defines the Vector2 object where to store the result
  2241. * @returns the unmodified current Vector2
  2242. */
  2243. scaleToRef(scale: number, result: Vector2): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Gets a boolean if two vectors are equals
  2253. * @param otherVector defines the other vector
  2254. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2255. */
  2256. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2257. /**
  2258. * Gets a boolean if two vectors are equals (using an epsilon value)
  2259. * @param otherVector defines the other vector
  2260. * @param epsilon defines the minimal distance to consider equality
  2261. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2262. */
  2263. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2264. /**
  2265. * Gets a new Vector2 from current Vector2 floored values
  2266. * @returns a new Vector2
  2267. */
  2268. floor(): Vector2;
  2269. /**
  2270. * Gets a new Vector2 from current Vector2 floored values
  2271. * @returns a new Vector2
  2272. */
  2273. fract(): Vector2;
  2274. /**
  2275. * Gets the length of the vector
  2276. * @returns the vector length (float)
  2277. */
  2278. length(): number;
  2279. /**
  2280. * Gets the vector squared length
  2281. * @returns the vector squared length (float)
  2282. */
  2283. lengthSquared(): number;
  2284. /**
  2285. * Normalize the vector
  2286. * @returns the current updated Vector2
  2287. */
  2288. normalize(): Vector2;
  2289. /**
  2290. * Gets a new Vector2 copied from the Vector2
  2291. * @returns a new Vector2
  2292. */
  2293. clone(): Vector2;
  2294. /**
  2295. * Gets a new Vector2(0, 0)
  2296. * @returns a new Vector2
  2297. */
  2298. static Zero(): Vector2;
  2299. /**
  2300. * Gets a new Vector2(1, 1)
  2301. * @returns a new Vector2
  2302. */
  2303. static One(): Vector2;
  2304. /**
  2305. * Gets a new Vector2 set from the given index element of the given array
  2306. * @param array defines the data source
  2307. * @param offset defines the offset in the data source
  2308. * @returns a new Vector2
  2309. */
  2310. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2311. /**
  2312. * Sets "result" from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @param result defines the target vector
  2316. */
  2317. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2318. /**
  2319. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2320. * @param value1 defines 1st point of control
  2321. * @param value2 defines 2nd point of control
  2322. * @param value3 defines 3rd point of control
  2323. * @param value4 defines 4th point of control
  2324. * @param amount defines the interpolation factor
  2325. * @returns a new Vector2
  2326. */
  2327. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2328. /**
  2329. * 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".
  2330. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2331. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2332. * @param value defines the value to clamp
  2333. * @param min defines the lower limit
  2334. * @param max defines the upper limit
  2335. * @returns a new Vector2
  2336. */
  2337. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2338. /**
  2339. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2340. * @param value1 defines the 1st control point
  2341. * @param tangent1 defines the outgoing tangent
  2342. * @param value2 defines the 2nd control point
  2343. * @param tangent2 defines the incoming tangent
  2344. * @param amount defines the interpolation factor
  2345. * @returns a new Vector2
  2346. */
  2347. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2348. /**
  2349. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2350. * @param start defines the start vector
  2351. * @param end defines the end vector
  2352. * @param amount defines the interpolation factor
  2353. * @returns a new Vector2
  2354. */
  2355. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2356. /**
  2357. * Gets the dot product of the vector "left" and the vector "right"
  2358. * @param left defines first vector
  2359. * @param right defines second vector
  2360. * @returns the dot product (float)
  2361. */
  2362. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2363. /**
  2364. * Returns a new Vector2 equal to the normalized given vector
  2365. * @param vector defines the vector to normalize
  2366. * @returns a new Vector2
  2367. */
  2368. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2369. /**
  2370. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2371. * @param left defines 1st vector
  2372. * @param right defines 2nd vector
  2373. * @returns a new Vector2
  2374. */
  2375. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2385. * @param vector defines the vector to transform
  2386. * @param transformation defines the matrix to apply
  2387. * @returns a new Vector2
  2388. */
  2389. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2390. /**
  2391. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @param result defines the target vector
  2395. */
  2396. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2397. /**
  2398. * Determines if a given vector is included in a triangle
  2399. * @param p defines the vector to test
  2400. * @param p0 defines 1st triangle point
  2401. * @param p1 defines 2nd triangle point
  2402. * @param p2 defines 3rd triangle point
  2403. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2404. */
  2405. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2406. /**
  2407. * Gets the distance between the vectors "value1" and "value2"
  2408. * @param value1 defines first vector
  2409. * @param value2 defines second vector
  2410. * @returns the distance between vectors
  2411. */
  2412. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2413. /**
  2414. * Returns the squared distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the squared distance between vectors
  2418. */
  2419. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns a new Vector2
  2425. */
  2426. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2427. /**
  2428. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2429. * @param p defines the middle point
  2430. * @param segA defines one point of the segment
  2431. * @param segB defines the other point of the segment
  2432. * @returns the shortest distance
  2433. */
  2434. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2435. }
  2436. /**
  2437. * Class used to store (x,y,z) vector representation
  2438. * A Vector3 is the main object used in 3D geometry
  2439. * It can represent etiher the coordinates of a point the space, either a direction
  2440. * Reminder: js uses a left handed forward facing system
  2441. */
  2442. export class Vector3 {
  2443. private static _UpReadOnly;
  2444. private static _ZeroReadOnly;
  2445. /** @hidden */
  2446. _x: number;
  2447. /** @hidden */
  2448. _y: number;
  2449. /** @hidden */
  2450. _z: number;
  2451. /** @hidden */
  2452. _isDirty: boolean;
  2453. /** Gets or sets the x coordinate */
  2454. get x(): number;
  2455. set x(value: number);
  2456. /** Gets or sets the y coordinate */
  2457. get y(): number;
  2458. set y(value: number);
  2459. /** Gets or sets the z coordinate */
  2460. get z(): number;
  2461. set z(value: number);
  2462. /**
  2463. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2464. * @param x defines the first coordinates (on X axis)
  2465. * @param y defines the second coordinates (on Y axis)
  2466. * @param z defines the third coordinates (on Z axis)
  2467. */
  2468. constructor(x?: number, y?: number, z?: number);
  2469. /**
  2470. * Creates a string representation of the Vector3
  2471. * @returns a string with the Vector3 coordinates.
  2472. */
  2473. toString(): string;
  2474. /**
  2475. * Gets the class name
  2476. * @returns the string "Vector3"
  2477. */
  2478. getClassName(): string;
  2479. /**
  2480. * Creates the Vector3 hash code
  2481. * @returns a number which tends to be unique between Vector3 instances
  2482. */
  2483. getHashCode(): number;
  2484. /**
  2485. * Creates an array containing three elements : the coordinates of the Vector3
  2486. * @returns a new array of numbers
  2487. */
  2488. asArray(): number[];
  2489. /**
  2490. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2491. * @param array defines the destination array
  2492. * @param index defines the offset in the destination array
  2493. * @returns the current Vector3
  2494. */
  2495. toArray(array: FloatArray, index?: number): Vector3;
  2496. /**
  2497. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2498. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2499. */
  2500. toQuaternion(): Quaternion;
  2501. /**
  2502. * Adds the given vector to the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the current updated Vector3
  2505. */
  2506. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Adds the given coordinates to the current Vector3
  2509. * @param x defines the x coordinate of the operand
  2510. * @param y defines the y coordinate of the operand
  2511. * @param z defines the z coordinate of the operand
  2512. * @returns the current updated Vector3
  2513. */
  2514. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2515. /**
  2516. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2517. * @param otherVector defines the second operand
  2518. * @returns the resulting Vector3
  2519. */
  2520. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2523. * @param otherVector defines the second operand
  2524. * @param result defines the Vector3 object where to store the result
  2525. * @returns the current Vector3
  2526. */
  2527. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2528. /**
  2529. * Subtract the given vector from the current Vector3
  2530. * @param otherVector defines the second operand
  2531. * @returns the current updated Vector3
  2532. */
  2533. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2534. /**
  2535. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2536. * @param otherVector defines the second operand
  2537. * @returns the resulting Vector3
  2538. */
  2539. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2540. /**
  2541. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2542. * @param otherVector defines the second operand
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2547. /**
  2548. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the resulting Vector3
  2553. */
  2554. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2557. * @param x defines the x coordinate of the operand
  2558. * @param y defines the y coordinate of the operand
  2559. * @param z defines the z coordinate of the operand
  2560. * @param result defines the Vector3 object where to store the result
  2561. * @returns the current Vector3
  2562. */
  2563. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2564. /**
  2565. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2566. * @returns a new Vector3
  2567. */
  2568. negate(): Vector3;
  2569. /**
  2570. * Negate this vector in place
  2571. * @returns this
  2572. */
  2573. negateInPlace(): Vector3;
  2574. /**
  2575. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2576. * @param result defines the Vector3 object where to store the result
  2577. * @returns the current Vector3
  2578. */
  2579. negateToRef(result: Vector3): Vector3;
  2580. /**
  2581. * Multiplies the Vector3 coordinates by the float "scale"
  2582. * @param scale defines the multiplier factor
  2583. * @returns the current updated Vector3
  2584. */
  2585. scaleInPlace(scale: number): Vector3;
  2586. /**
  2587. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2588. * @param scale defines the multiplier factor
  2589. * @returns a new Vector3
  2590. */
  2591. scale(scale: number): Vector3;
  2592. /**
  2593. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2594. * @param scale defines the multiplier factor
  2595. * @param result defines the Vector3 object where to store the result
  2596. * @returns the current Vector3
  2597. */
  2598. scaleToRef(scale: number, result: Vector3): Vector3;
  2599. /**
  2600. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2601. * @param scale defines the scale factor
  2602. * @param result defines the Vector3 object where to store the result
  2603. * @returns the unmodified current Vector3
  2604. */
  2605. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2606. /**
  2607. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2608. * @param origin defines the origin of the projection ray
  2609. * @param plane defines the plane to project to
  2610. * @returns the projected vector3
  2611. */
  2612. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2613. /**
  2614. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2615. * @param origin defines the origin of the projection ray
  2616. * @param plane defines the plane to project to
  2617. * @param result defines the Vector3 where to store the result
  2618. */
  2619. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2620. /**
  2621. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2622. * @param otherVector defines the second operand
  2623. * @returns true if both vectors are equals
  2624. */
  2625. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2626. /**
  2627. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2628. * @param otherVector defines the second operand
  2629. * @param epsilon defines the minimal distance to define values as equals
  2630. * @returns true if both vectors are distant less than epsilon
  2631. */
  2632. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2633. /**
  2634. * Returns true if the current Vector3 coordinates equals the given floats
  2635. * @param x defines the x coordinate of the operand
  2636. * @param y defines the y coordinate of the operand
  2637. * @param z defines the z coordinate of the operand
  2638. * @returns true if both vectors are equals
  2639. */
  2640. equalsToFloats(x: number, y: number, z: number): boolean;
  2641. /**
  2642. * Multiplies the current Vector3 coordinates by the given ones
  2643. * @param otherVector defines the second operand
  2644. * @returns the current updated Vector3
  2645. */
  2646. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2647. /**
  2648. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2649. * @param otherVector defines the second operand
  2650. * @returns the new Vector3
  2651. */
  2652. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2653. /**
  2654. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2655. * @param otherVector defines the second operand
  2656. * @param result defines the Vector3 object where to store the result
  2657. * @returns the current Vector3
  2658. */
  2659. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2660. /**
  2661. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the new Vector3
  2666. */
  2667. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2670. * @param otherVector defines the second operand
  2671. * @returns the new Vector3
  2672. */
  2673. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2676. * @param otherVector defines the second operand
  2677. * @param result defines the Vector3 object where to store the result
  2678. * @returns the current Vector3
  2679. */
  2680. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2681. /**
  2682. * Divides the current Vector3 coordinates by the given ones.
  2683. * @param otherVector defines the second operand
  2684. * @returns the current updated Vector3
  2685. */
  2686. divideInPlace(otherVector: Vector3): Vector3;
  2687. /**
  2688. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2689. * @param other defines the second operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2693. /**
  2694. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2695. * @param other defines the second operand
  2696. * @returns the current updated Vector3
  2697. */
  2698. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2699. /**
  2700. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2701. * @param x defines the x coordinate of the operand
  2702. * @param y defines the y coordinate of the operand
  2703. * @param z defines the z coordinate of the operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2709. * @param x defines the x coordinate of the operand
  2710. * @param y defines the y coordinate of the operand
  2711. * @param z defines the z coordinate of the operand
  2712. * @returns the current updated Vector3
  2713. */
  2714. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2715. /**
  2716. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2717. * Check if is non uniform within a certain amount of decimal places to account for this
  2718. * @param epsilon the amount the values can differ
  2719. * @returns if the the vector is non uniform to a certain number of decimal places
  2720. */
  2721. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2722. /**
  2723. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2724. */
  2725. get isNonUniform(): boolean;
  2726. /**
  2727. * Gets a new Vector3 from current Vector3 floored values
  2728. * @returns a new Vector3
  2729. */
  2730. floor(): Vector3;
  2731. /**
  2732. * Gets a new Vector3 from current Vector3 floored values
  2733. * @returns a new Vector3
  2734. */
  2735. fract(): Vector3;
  2736. /**
  2737. * Gets the length of the Vector3
  2738. * @returns the length of the Vector3
  2739. */
  2740. length(): number;
  2741. /**
  2742. * Gets the squared length of the Vector3
  2743. * @returns squared length of the Vector3
  2744. */
  2745. lengthSquared(): number;
  2746. /**
  2747. * Normalize the current Vector3.
  2748. * Please note that this is an in place operation.
  2749. * @returns the current updated Vector3
  2750. */
  2751. normalize(): Vector3;
  2752. /**
  2753. * Reorders the x y z properties of the vector in place
  2754. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2755. * @returns the current updated vector
  2756. */
  2757. reorderInPlace(order: string): this;
  2758. /**
  2759. * Rotates the vector around 0,0,0 by a quaternion
  2760. * @param quaternion the rotation quaternion
  2761. * @param result vector to store the result
  2762. * @returns the resulting vector
  2763. */
  2764. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2765. /**
  2766. * Rotates a vector around a given point
  2767. * @param quaternion the rotation quaternion
  2768. * @param point the point to rotate around
  2769. * @param result vector to store the result
  2770. * @returns the resulting vector
  2771. */
  2772. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2773. /**
  2774. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2775. * The cross product is then orthogonal to both current and "other"
  2776. * @param other defines the right operand
  2777. * @returns the cross product
  2778. */
  2779. cross(other: Vector3): Vector3;
  2780. /**
  2781. * Normalize the current Vector3 with the given input length.
  2782. * Please note that this is an in place operation.
  2783. * @param len the length of the vector
  2784. * @returns the current updated Vector3
  2785. */
  2786. normalizeFromLength(len: number): Vector3;
  2787. /**
  2788. * Normalize the current Vector3 to a new vector
  2789. * @returns the new Vector3
  2790. */
  2791. normalizeToNew(): Vector3;
  2792. /**
  2793. * Normalize the current Vector3 to the reference
  2794. * @param reference define the Vector3 to update
  2795. * @returns the updated Vector3
  2796. */
  2797. normalizeToRef(reference: Vector3): Vector3;
  2798. /**
  2799. * Creates a new Vector3 copied from the current Vector3
  2800. * @returns the new Vector3
  2801. */
  2802. clone(): Vector3;
  2803. /**
  2804. * Copies the given vector coordinates to the current Vector3 ones
  2805. * @param source defines the source Vector3
  2806. * @returns the current updated Vector3
  2807. */
  2808. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Copies the given floats to the current Vector3 coordinates
  2811. * @param x defines the x coordinate of the operand
  2812. * @param y defines the y coordinate of the operand
  2813. * @param z defines the z coordinate of the operand
  2814. * @returns the current updated Vector3
  2815. */
  2816. copyFromFloats(x: number, y: number, z: number): Vector3;
  2817. /**
  2818. * Copies the given floats to the current Vector3 coordinates
  2819. * @param x defines the x coordinate of the operand
  2820. * @param y defines the y coordinate of the operand
  2821. * @param z defines the z coordinate of the operand
  2822. * @returns the current updated Vector3
  2823. */
  2824. set(x: number, y: number, z: number): Vector3;
  2825. /**
  2826. * Copies the given float to the current Vector3 coordinates
  2827. * @param v defines the x, y and z coordinates of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. setAll(v: number): Vector3;
  2831. /**
  2832. * Get the clip factor between two vectors
  2833. * @param vector0 defines the first operand
  2834. * @param vector1 defines the second operand
  2835. * @param axis defines the axis to use
  2836. * @param size defines the size along the axis
  2837. * @returns the clip factor
  2838. */
  2839. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2840. /**
  2841. * Get angle between two vectors
  2842. * @param vector0 angle between vector0 and vector1
  2843. * @param vector1 angle between vector0 and vector1
  2844. * @param normal direction of the normal
  2845. * @return the angle between vector0 and vector1
  2846. */
  2847. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2848. /**
  2849. * Returns a new Vector3 set from the index "offset" of the given array
  2850. * @param array defines the source array
  2851. * @param offset defines the offset in the source array
  2852. * @returns the new Vector3
  2853. */
  2854. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2855. /**
  2856. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2857. * @param array defines the source array
  2858. * @param offset defines the offset in the source array
  2859. * @returns the new Vector3
  2860. * @deprecated Please use FromArray instead.
  2861. */
  2862. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2863. /**
  2864. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2865. * @param array defines the source array
  2866. * @param offset defines the offset in the source array
  2867. * @param result defines the Vector3 where to store the result
  2868. */
  2869. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2870. /**
  2871. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2872. * @param array defines the source array
  2873. * @param offset defines the offset in the source array
  2874. * @param result defines the Vector3 where to store the result
  2875. * @deprecated Please use FromArrayToRef instead.
  2876. */
  2877. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2878. /**
  2879. * Sets the given vector "result" with the given floats.
  2880. * @param x defines the x coordinate of the source
  2881. * @param y defines the y coordinate of the source
  2882. * @param z defines the z coordinate of the source
  2883. * @param result defines the Vector3 where to store the result
  2884. */
  2885. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2886. /**
  2887. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2888. * @returns a new empty Vector3
  2889. */
  2890. static Zero(): Vector3;
  2891. /**
  2892. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2893. * @returns a new unit Vector3
  2894. */
  2895. static One(): Vector3;
  2896. /**
  2897. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2898. * @returns a new up Vector3
  2899. */
  2900. static Up(): Vector3;
  2901. /**
  2902. * Gets a up Vector3 that must not be updated
  2903. */
  2904. static get UpReadOnly(): DeepImmutable<Vector3>;
  2905. /**
  2906. * Gets a zero Vector3 that must not be updated
  2907. */
  2908. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2909. /**
  2910. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2911. * @returns a new down Vector3
  2912. */
  2913. static Down(): Vector3;
  2914. /**
  2915. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2916. * @param rightHandedSystem is the scene right-handed (negative z)
  2917. * @returns a new forward Vector3
  2918. */
  2919. static Forward(rightHandedSystem?: boolean): Vector3;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2922. * @param rightHandedSystem is the scene right-handed (negative-z)
  2923. * @returns a new forward Vector3
  2924. */
  2925. static Backward(rightHandedSystem?: boolean): Vector3;
  2926. /**
  2927. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2928. * @returns a new right Vector3
  2929. */
  2930. static Right(): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2933. * @returns a new left Vector3
  2934. */
  2935. static Left(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2938. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2939. * @param vector defines the Vector3 to transform
  2940. * @param transformation defines the transformation matrix
  2941. * @returns the transformed Vector3
  2942. */
  2943. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2944. /**
  2945. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2946. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2947. * @param vector defines the Vector3 to transform
  2948. * @param transformation defines the transformation matrix
  2949. * @param result defines the Vector3 where to store the result
  2950. */
  2951. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2952. /**
  2953. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2954. * This method computes tranformed coordinates only, not transformed direction vectors
  2955. * @param x define the x coordinate of the source vector
  2956. * @param y define the y coordinate of the source vector
  2957. * @param z define the z coordinate of the source vector
  2958. * @param transformation defines the transformation matrix
  2959. * @param result defines the Vector3 where to store the result
  2960. */
  2961. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2962. /**
  2963. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2964. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2965. * @param vector defines the Vector3 to transform
  2966. * @param transformation defines the transformation matrix
  2967. * @returns the new Vector3
  2968. */
  2969. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2970. /**
  2971. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2972. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2973. * @param vector defines the Vector3 to transform
  2974. * @param transformation defines the transformation matrix
  2975. * @param result defines the Vector3 where to store the result
  2976. */
  2977. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2978. /**
  2979. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2980. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2981. * @param x define the x coordinate of the source vector
  2982. * @param y define the y coordinate of the source vector
  2983. * @param z define the z coordinate of the source vector
  2984. * @param transformation defines the transformation matrix
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2990. * @param value1 defines the first control point
  2991. * @param value2 defines the second control point
  2992. * @param value3 defines the third control point
  2993. * @param value4 defines the fourth control point
  2994. * @param amount defines the amount on the spline to use
  2995. * @returns the new Vector3
  2996. */
  2997. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2998. /**
  2999. * 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"
  3000. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3001. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3002. * @param value defines the current value
  3003. * @param min defines the lower range value
  3004. * @param max defines the upper range value
  3005. * @returns the new Vector3
  3006. */
  3007. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3008. /**
  3009. * 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"
  3010. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3011. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3012. * @param value defines the current value
  3013. * @param min defines the lower range value
  3014. * @param max defines the upper range value
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3018. /**
  3019. * Checks if a given vector is inside a specific range
  3020. * @param v defines the vector to test
  3021. * @param min defines the minimum range
  3022. * @param max defines the maximum range
  3023. */
  3024. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3025. /**
  3026. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3027. * @param value1 defines the first control point
  3028. * @param tangent1 defines the first tangent vector
  3029. * @param value2 defines the second control point
  3030. * @param tangent2 defines the second tangent vector
  3031. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3032. * @returns the new Vector3
  3033. */
  3034. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3035. /**
  3036. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3037. * @param start defines the start value
  3038. * @param end defines the end value
  3039. * @param amount max defines amount between both (between 0 and 1)
  3040. * @returns the new Vector3
  3041. */
  3042. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3045. * @param start defines the start value
  3046. * @param end defines the end value
  3047. * @param amount max defines amount between both (between 0 and 1)
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3051. /**
  3052. * Returns the dot product (float) between the vectors "left" and "right"
  3053. * @param left defines the left operand
  3054. * @param right defines the right operand
  3055. * @returns the dot product
  3056. */
  3057. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3058. /**
  3059. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3060. * The cross product is then orthogonal to both "left" and "right"
  3061. * @param left defines the left operand
  3062. * @param right defines the right operand
  3063. * @returns the cross product
  3064. */
  3065. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3066. /**
  3067. * Sets the given vector "result" with the cross product of "left" and "right"
  3068. * The cross product is then orthogonal to both "left" and "right"
  3069. * @param left defines the left operand
  3070. * @param right defines the right operand
  3071. * @param result defines the Vector3 where to store the result
  3072. */
  3073. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3074. /**
  3075. * Returns a new Vector3 as the normalization of the given vector
  3076. * @param vector defines the Vector3 to normalize
  3077. * @returns the new Vector3
  3078. */
  3079. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the normalization of the given first vector
  3082. * @param vector defines the Vector3 to normalize
  3083. * @param result defines the Vector3 where to store the result
  3084. */
  3085. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3086. /**
  3087. * Project a Vector3 onto screen space
  3088. * @param vector defines the Vector3 to project
  3089. * @param world defines the world matrix to use
  3090. * @param transform defines the transform (view x projection) matrix to use
  3091. * @param viewport defines the screen viewport to use
  3092. * @returns the new Vector3
  3093. */
  3094. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3095. /** @hidden */
  3096. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3097. /**
  3098. * Unproject from screen space to object space
  3099. * @param source defines the screen space Vector3 to use
  3100. * @param viewportWidth defines the current width of the viewport
  3101. * @param viewportHeight defines the current height of the viewport
  3102. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3103. * @param transform defines the transform (view x projection) matrix to use
  3104. * @returns the new Vector3
  3105. */
  3106. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3107. /**
  3108. * Unproject from screen space to object space
  3109. * @param source defines the screen space Vector3 to use
  3110. * @param viewportWidth defines the current width of the viewport
  3111. * @param viewportHeight defines the current height of the viewport
  3112. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3113. * @param view defines the view matrix to use
  3114. * @param projection defines the projection matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @param result defines the Vector3 where to store the result
  3127. */
  3128. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param sourceX defines the screen space x coordinate to use
  3132. * @param sourceY defines the screen space y coordinate to use
  3133. * @param sourceZ defines the screen space z coordinate to use
  3134. * @param viewportWidth defines the current width of the viewport
  3135. * @param viewportHeight defines the current height of the viewport
  3136. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3137. * @param view defines the view matrix to use
  3138. * @param projection defines the projection matrix to use
  3139. * @param result defines the Vector3 where to store the result
  3140. */
  3141. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3142. /**
  3143. * Gets the minimal coordinate values between two Vector3
  3144. * @param left defines the first operand
  3145. * @param right defines the second operand
  3146. * @returns the new Vector3
  3147. */
  3148. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Gets the maximal coordinate values between two Vector3
  3151. * @param left defines the first operand
  3152. * @param right defines the second operand
  3153. * @returns the new Vector3
  3154. */
  3155. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3156. /**
  3157. * Returns the distance between the vectors "value1" and "value2"
  3158. * @param value1 defines the first operand
  3159. * @param value2 defines the second operand
  3160. * @returns the distance
  3161. */
  3162. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3163. /**
  3164. * Returns the squared distance between the vectors "value1" and "value2"
  3165. * @param value1 defines the first operand
  3166. * @param value2 defines the second operand
  3167. * @returns the squared distance
  3168. */
  3169. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3170. /**
  3171. * Returns a new Vector3 located at the center between "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the new Vector3
  3175. */
  3176. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3177. /**
  3178. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3179. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3180. * to something in order to rotate it from its local system to the given target system
  3181. * Note: axis1, axis2 and axis3 are normalized during this operation
  3182. * @param axis1 defines the first axis
  3183. * @param axis2 defines the second axis
  3184. * @param axis3 defines the third axis
  3185. * @returns a new Vector3
  3186. */
  3187. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3190. * @param axis1 defines the first axis
  3191. * @param axis2 defines the second axis
  3192. * @param axis3 defines the third axis
  3193. * @param ref defines the Vector3 where to store the result
  3194. */
  3195. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3196. }
  3197. /**
  3198. * Vector4 class created for EulerAngle class conversion to Quaternion
  3199. */
  3200. export class Vector4 {
  3201. /** x value of the vector */
  3202. x: number;
  3203. /** y value of the vector */
  3204. y: number;
  3205. /** z value of the vector */
  3206. z: number;
  3207. /** w value of the vector */
  3208. w: number;
  3209. /**
  3210. * Creates a Vector4 object from the given floats.
  3211. * @param x x value of the vector
  3212. * @param y y value of the vector
  3213. * @param z z value of the vector
  3214. * @param w w value of the vector
  3215. */
  3216. constructor(
  3217. /** x value of the vector */
  3218. x: number,
  3219. /** y value of the vector */
  3220. y: number,
  3221. /** z value of the vector */
  3222. z: number,
  3223. /** w value of the vector */
  3224. w: number);
  3225. /**
  3226. * Returns the string with the Vector4 coordinates.
  3227. * @returns a string containing all the vector values
  3228. */
  3229. toString(): string;
  3230. /**
  3231. * Returns the string "Vector4".
  3232. * @returns "Vector4"
  3233. */
  3234. getClassName(): string;
  3235. /**
  3236. * Returns the Vector4 hash code.
  3237. * @returns a unique hash code
  3238. */
  3239. getHashCode(): number;
  3240. /**
  3241. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3242. * @returns the resulting array
  3243. */
  3244. asArray(): number[];
  3245. /**
  3246. * Populates the given array from the given index with the Vector4 coordinates.
  3247. * @param array array to populate
  3248. * @param index index of the array to start at (default: 0)
  3249. * @returns the Vector4.
  3250. */
  3251. toArray(array: FloatArray, index?: number): Vector4;
  3252. /**
  3253. * Adds the given vector to the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the updated Vector4.
  3256. */
  3257. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3260. * @param otherVector the vector to add
  3261. * @returns the resulting vector
  3262. */
  3263. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3266. * @param otherVector the vector to add
  3267. * @param result the vector to store the result
  3268. * @returns the current Vector4.
  3269. */
  3270. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3271. /**
  3272. * Subtract in place the given vector from the current Vector4.
  3273. * @param otherVector the vector to subtract
  3274. * @returns the updated Vector4.
  3275. */
  3276. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3279. * @param otherVector the vector to add
  3280. * @returns the new vector with the result
  3281. */
  3282. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3285. * @param otherVector the vector to subtract
  3286. * @param result the vector to store the result
  3287. * @returns the current Vector4.
  3288. */
  3289. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3290. /**
  3291. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3292. */
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. * @param x value to subtract
  3296. * @param y value to subtract
  3297. * @param z value to subtract
  3298. * @param w value to subtract
  3299. * @returns new vector containing the result
  3300. */
  3301. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3302. /**
  3303. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3304. * @param x value to subtract
  3305. * @param y value to subtract
  3306. * @param z value to subtract
  3307. * @param w value to subtract
  3308. * @param result the vector to store the result in
  3309. * @returns the current Vector4.
  3310. */
  3311. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3312. /**
  3313. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3314. * @returns a new vector with the negated values
  3315. */
  3316. negate(): Vector4;
  3317. /**
  3318. * Negate this vector in place
  3319. * @returns this
  3320. */
  3321. negateInPlace(): Vector4;
  3322. /**
  3323. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3324. * @param result defines the Vector3 object where to store the result
  3325. * @returns the current Vector4
  3326. */
  3327. negateToRef(result: Vector4): Vector4;
  3328. /**
  3329. * Multiplies the current Vector4 coordinates by scale (float).
  3330. * @param scale the number to scale with
  3331. * @returns the updated Vector4.
  3332. */
  3333. scaleInPlace(scale: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3336. * @param scale the number to scale with
  3337. * @returns a new vector with the result
  3338. */
  3339. scale(scale: number): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3342. * @param scale the number to scale with
  3343. * @param result a vector to store the result in
  3344. * @returns the current Vector4.
  3345. */
  3346. scaleToRef(scale: number, result: Vector4): Vector4;
  3347. /**
  3348. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3349. * @param scale defines the scale factor
  3350. * @param result defines the Vector4 object where to store the result
  3351. * @returns the unmodified current Vector4
  3352. */
  3353. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3354. /**
  3355. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3356. * @param otherVector the vector to compare against
  3357. * @returns true if they are equal
  3358. */
  3359. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3360. /**
  3361. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3362. * @param otherVector vector to compare against
  3363. * @param epsilon (Default: very small number)
  3364. * @returns true if they are equal
  3365. */
  3366. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3367. /**
  3368. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3369. * @param x x value to compare against
  3370. * @param y y value to compare against
  3371. * @param z z value to compare against
  3372. * @param w w value to compare against
  3373. * @returns true if equal
  3374. */
  3375. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3376. /**
  3377. * Multiplies in place the current Vector4 by the given one.
  3378. * @param otherVector vector to multiple with
  3379. * @returns the updated Vector4.
  3380. */
  3381. multiplyInPlace(otherVector: Vector4): Vector4;
  3382. /**
  3383. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3384. * @param otherVector vector to multiple with
  3385. * @returns resulting new vector
  3386. */
  3387. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3388. /**
  3389. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3390. * @param otherVector vector to multiple with
  3391. * @param result vector to store the result
  3392. * @returns the current Vector4.
  3393. */
  3394. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3395. /**
  3396. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3397. * @param x x value multiply with
  3398. * @param y y value multiply with
  3399. * @param z z value multiply with
  3400. * @param w w value multiply with
  3401. * @returns resulting new vector
  3402. */
  3403. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3404. /**
  3405. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3406. * @param otherVector vector to devide with
  3407. * @returns resulting new vector
  3408. */
  3409. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3412. * @param otherVector vector to devide with
  3413. * @param result vector to store the result
  3414. * @returns the current Vector4.
  3415. */
  3416. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3417. /**
  3418. * Divides the current Vector3 coordinates by the given ones.
  3419. * @param otherVector vector to devide with
  3420. * @returns the updated Vector3.
  3421. */
  3422. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3423. /**
  3424. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3425. * @param other defines the second operand
  3426. * @returns the current updated Vector4
  3427. */
  3428. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3429. /**
  3430. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3431. * @param other defines the second operand
  3432. * @returns the current updated Vector4
  3433. */
  3434. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3435. /**
  3436. * Gets a new Vector4 from current Vector4 floored values
  3437. * @returns a new Vector4
  3438. */
  3439. floor(): Vector4;
  3440. /**
  3441. * Gets a new Vector4 from current Vector3 floored values
  3442. * @returns a new Vector4
  3443. */
  3444. fract(): Vector4;
  3445. /**
  3446. * Returns the Vector4 length (float).
  3447. * @returns the length
  3448. */
  3449. length(): number;
  3450. /**
  3451. * Returns the Vector4 squared length (float).
  3452. * @returns the length squared
  3453. */
  3454. lengthSquared(): number;
  3455. /**
  3456. * Normalizes in place the Vector4.
  3457. * @returns the updated Vector4.
  3458. */
  3459. normalize(): Vector4;
  3460. /**
  3461. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3462. * @returns this converted to a new vector3
  3463. */
  3464. toVector3(): Vector3;
  3465. /**
  3466. * Returns a new Vector4 copied from the current one.
  3467. * @returns the new cloned vector
  3468. */
  3469. clone(): Vector4;
  3470. /**
  3471. * Updates the current Vector4 with the given one coordinates.
  3472. * @param source the source vector to copy from
  3473. * @returns the updated Vector4.
  3474. */
  3475. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3476. /**
  3477. * Updates the current Vector4 coordinates with the given floats.
  3478. * @param x float to copy from
  3479. * @param y float to copy from
  3480. * @param z float to copy from
  3481. * @param w float to copy from
  3482. * @returns the updated Vector4.
  3483. */
  3484. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3485. /**
  3486. * Updates the current Vector4 coordinates with the given floats.
  3487. * @param x float to set from
  3488. * @param y float to set from
  3489. * @param z float to set from
  3490. * @param w float to set from
  3491. * @returns the updated Vector4.
  3492. */
  3493. set(x: number, y: number, z: number, w: number): Vector4;
  3494. /**
  3495. * Copies the given float to the current Vector3 coordinates
  3496. * @param v defines the x, y, z and w coordinates of the operand
  3497. * @returns the current updated Vector3
  3498. */
  3499. setAll(v: number): Vector4;
  3500. /**
  3501. * Returns a new Vector4 set from the starting index of the given array.
  3502. * @param array the array to pull values from
  3503. * @param offset the offset into the array to start at
  3504. * @returns the new vector
  3505. */
  3506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3507. /**
  3508. * Updates the given vector "result" from the starting index of the given array.
  3509. * @param array the array to pull values from
  3510. * @param offset the offset into the array to start at
  3511. * @param result the vector to store the result in
  3512. */
  3513. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3514. /**
  3515. * Updates the given vector "result" from the starting index of the given Float32Array.
  3516. * @param array the array to pull values from
  3517. * @param offset the offset into the array to start at
  3518. * @param result the vector to store the result in
  3519. */
  3520. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3521. /**
  3522. * Updates the given vector "result" coordinates from the given floats.
  3523. * @param x float to set from
  3524. * @param y float to set from
  3525. * @param z float to set from
  3526. * @param w float to set from
  3527. * @param result the vector to the floats in
  3528. */
  3529. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3530. /**
  3531. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3532. * @returns the new vector
  3533. */
  3534. static Zero(): Vector4;
  3535. /**
  3536. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3537. * @returns the new vector
  3538. */
  3539. static One(): Vector4;
  3540. /**
  3541. * Returns a new normalized Vector4 from the given one.
  3542. * @param vector the vector to normalize
  3543. * @returns the vector
  3544. */
  3545. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3546. /**
  3547. * Updates the given vector "result" from the normalization of the given one.
  3548. * @param vector the vector to normalize
  3549. * @param result the vector to store the result in
  3550. */
  3551. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3552. /**
  3553. * Returns a vector with the minimum values from the left and right vectors
  3554. * @param left left vector to minimize
  3555. * @param right right vector to minimize
  3556. * @returns a new vector with the minimum of the left and right vector values
  3557. */
  3558. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3559. /**
  3560. * Returns a vector with the maximum values from the left and right vectors
  3561. * @param left left vector to maximize
  3562. * @param right right vector to maximize
  3563. * @returns a new vector with the maximum of the left and right vector values
  3564. */
  3565. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3566. /**
  3567. * Returns the distance (float) between the vectors "value1" and "value2".
  3568. * @param value1 value to calulate the distance between
  3569. * @param value2 value to calulate the distance between
  3570. * @return the distance between the two vectors
  3571. */
  3572. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3573. /**
  3574. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3575. * @param value1 value to calulate the distance between
  3576. * @param value2 value to calulate the distance between
  3577. * @return the distance between the two vectors squared
  3578. */
  3579. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3580. /**
  3581. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3582. * @param value1 value to calulate the center between
  3583. * @param value2 value to calulate the center between
  3584. * @return the center between the two vectors
  3585. */
  3586. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3589. * This methods computes transformed normalized direction vectors only.
  3590. * @param vector the vector to transform
  3591. * @param transformation the transformation matrix to apply
  3592. * @returns the new vector
  3593. */
  3594. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3595. /**
  3596. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3597. * This methods computes transformed normalized direction vectors only.
  3598. * @param vector the vector to transform
  3599. * @param transformation the transformation matrix to apply
  3600. * @param result the vector to store the result in
  3601. */
  3602. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3603. /**
  3604. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3605. * This methods computes transformed normalized direction vectors only.
  3606. * @param x value to transform
  3607. * @param y value to transform
  3608. * @param z value to transform
  3609. * @param w value to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the results in
  3612. */
  3613. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Creates a new Vector4 from a Vector3
  3616. * @param source defines the source data
  3617. * @param w defines the 4th component (default is 0)
  3618. * @returns a new Vector4
  3619. */
  3620. static FromVector3(source: Vector3, w?: number): Vector4;
  3621. }
  3622. /**
  3623. * Class used to store quaternion data
  3624. * @see https://en.wikipedia.org/wiki/Quaternion
  3625. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3626. */
  3627. export class Quaternion {
  3628. /** @hidden */
  3629. _x: number;
  3630. /** @hidden */
  3631. _y: number;
  3632. /** @hidden */
  3633. _z: number;
  3634. /** @hidden */
  3635. _w: number;
  3636. /** @hidden */
  3637. _isDirty: boolean;
  3638. /** Gets or sets the x coordinate */
  3639. get x(): number;
  3640. set x(value: number);
  3641. /** Gets or sets the y coordinate */
  3642. get y(): number;
  3643. set y(value: number);
  3644. /** Gets or sets the z coordinate */
  3645. get z(): number;
  3646. set z(value: number);
  3647. /** Gets or sets the w coordinate */
  3648. get w(): number;
  3649. set w(value: number);
  3650. /**
  3651. * Creates a new Quaternion from the given floats
  3652. * @param x defines the first component (0 by default)
  3653. * @param y defines the second component (0 by default)
  3654. * @param z defines the third component (0 by default)
  3655. * @param w defines the fourth component (1.0 by default)
  3656. */
  3657. constructor(x?: number, y?: number, z?: number, w?: number);
  3658. /**
  3659. * Gets a string representation for the current quaternion
  3660. * @returns a string with the Quaternion coordinates
  3661. */
  3662. toString(): string;
  3663. /**
  3664. * Gets the class name of the quaternion
  3665. * @returns the string "Quaternion"
  3666. */
  3667. getClassName(): string;
  3668. /**
  3669. * Gets a hash code for this quaternion
  3670. * @returns the quaternion hash code
  3671. */
  3672. getHashCode(): number;
  3673. /**
  3674. * Copy the quaternion to an array
  3675. * @returns a new array populated with 4 elements from the quaternion coordinates
  3676. */
  3677. asArray(): number[];
  3678. /**
  3679. * Check if two quaternions are equals
  3680. * @param otherQuaternion defines the second operand
  3681. * @return true if the current quaternion and the given one coordinates are strictly equals
  3682. */
  3683. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3684. /**
  3685. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3686. * @param otherQuaternion defines the other quaternion
  3687. * @param epsilon defines the minimal distance to consider equality
  3688. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3689. */
  3690. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3691. /**
  3692. * Clone the current quaternion
  3693. * @returns a new quaternion copied from the current one
  3694. */
  3695. clone(): Quaternion;
  3696. /**
  3697. * Copy a quaternion to the current one
  3698. * @param other defines the other quaternion
  3699. * @returns the updated current quaternion
  3700. */
  3701. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3702. /**
  3703. * Updates the current quaternion with the given float coordinates
  3704. * @param x defines the x coordinate
  3705. * @param y defines the y coordinate
  3706. * @param z defines the z coordinate
  3707. * @param w defines the w coordinate
  3708. * @returns the updated current quaternion
  3709. */
  3710. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3711. /**
  3712. * Updates the current quaternion from the given float coordinates
  3713. * @param x defines the x coordinate
  3714. * @param y defines the y coordinate
  3715. * @param z defines the z coordinate
  3716. * @param w defines the w coordinate
  3717. * @returns the updated current quaternion
  3718. */
  3719. set(x: number, y: number, z: number, w: number): Quaternion;
  3720. /**
  3721. * Adds two quaternions
  3722. * @param other defines the second operand
  3723. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3724. */
  3725. add(other: DeepImmutable<Quaternion>): Quaternion;
  3726. /**
  3727. * Add a quaternion to the current one
  3728. * @param other defines the quaternion to add
  3729. * @returns the current quaternion
  3730. */
  3731. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Subtract two quaternions
  3734. * @param other defines the second operand
  3735. * @returns a new quaternion as the subtraction result of the given one from the current one
  3736. */
  3737. subtract(other: Quaternion): Quaternion;
  3738. /**
  3739. * Multiplies the current quaternion by a scale factor
  3740. * @param value defines the scale factor
  3741. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3742. */
  3743. scale(value: number): Quaternion;
  3744. /**
  3745. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3746. * @param scale defines the scale factor
  3747. * @param result defines the Quaternion object where to store the result
  3748. * @returns the unmodified current quaternion
  3749. */
  3750. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3751. /**
  3752. * Multiplies in place the current quaternion by a scale factor
  3753. * @param value defines the scale factor
  3754. * @returns the current modified quaternion
  3755. */
  3756. scaleInPlace(value: number): Quaternion;
  3757. /**
  3758. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3759. * @param scale defines the scale factor
  3760. * @param result defines the Quaternion object where to store the result
  3761. * @returns the unmodified current quaternion
  3762. */
  3763. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3764. /**
  3765. * Multiplies two quaternions
  3766. * @param q1 defines the second operand
  3767. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3768. */
  3769. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3770. /**
  3771. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3772. * @param q1 defines the second operand
  3773. * @param result defines the target quaternion
  3774. * @returns the current quaternion
  3775. */
  3776. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3777. /**
  3778. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3779. * @param q1 defines the second operand
  3780. * @returns the currentupdated quaternion
  3781. */
  3782. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3785. * @param ref defines the target quaternion
  3786. * @returns the current quaternion
  3787. */
  3788. conjugateToRef(ref: Quaternion): Quaternion;
  3789. /**
  3790. * Conjugates in place (1-q) the current quaternion
  3791. * @returns the current updated quaternion
  3792. */
  3793. conjugateInPlace(): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns a new quaternion
  3797. */
  3798. conjugate(): Quaternion;
  3799. /**
  3800. * Gets length of current quaternion
  3801. * @returns the quaternion length (float)
  3802. */
  3803. length(): number;
  3804. /**
  3805. * Normalize in place the current quaternion
  3806. * @returns the current updated quaternion
  3807. */
  3808. normalize(): Quaternion;
  3809. /**
  3810. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3811. * @param order is a reserved parameter and is ignore for now
  3812. * @returns a new Vector3 containing the Euler angles
  3813. */
  3814. toEulerAngles(order?: string): Vector3;
  3815. /**
  3816. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3817. * @param result defines the vector which will be filled with the Euler angles
  3818. * @param order is a reserved parameter and is ignore for now
  3819. * @returns the current unchanged quaternion
  3820. */
  3821. toEulerAnglesToRef(result: Vector3): Quaternion;
  3822. /**
  3823. * Updates the given rotation matrix with the current quaternion values
  3824. * @param result defines the target matrix
  3825. * @returns the current unchanged quaternion
  3826. */
  3827. toRotationMatrix(result: Matrix): Quaternion;
  3828. /**
  3829. * Updates the current quaternion from the given rotation matrix values
  3830. * @param matrix defines the source matrix
  3831. * @returns the current updated quaternion
  3832. */
  3833. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3834. /**
  3835. * Creates a new quaternion from a rotation matrix
  3836. * @param matrix defines the source matrix
  3837. * @returns a new quaternion created from the given rotation matrix values
  3838. */
  3839. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3840. /**
  3841. * Updates the given quaternion with the given rotation matrix values
  3842. * @param matrix defines the source matrix
  3843. * @param result defines the target quaternion
  3844. */
  3845. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3846. /**
  3847. * Returns the dot product (float) between the quaternions "left" and "right"
  3848. * @param left defines the left operand
  3849. * @param right defines the right operand
  3850. * @returns the dot product
  3851. */
  3852. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3853. /**
  3854. * Checks if the two quaternions are close to each other
  3855. * @param quat0 defines the first quaternion to check
  3856. * @param quat1 defines the second quaternion to check
  3857. * @returns true if the two quaternions are close to each other
  3858. */
  3859. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3860. /**
  3861. * Creates an empty quaternion
  3862. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3863. */
  3864. static Zero(): Quaternion;
  3865. /**
  3866. * Inverse a given quaternion
  3867. * @param q defines the source quaternion
  3868. * @returns a new quaternion as the inverted current quaternion
  3869. */
  3870. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3871. /**
  3872. * Inverse a given quaternion
  3873. * @param q defines the source quaternion
  3874. * @param result the quaternion the result will be stored in
  3875. * @returns the result quaternion
  3876. */
  3877. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3878. /**
  3879. * Creates an identity quaternion
  3880. * @returns the identity quaternion
  3881. */
  3882. static Identity(): Quaternion;
  3883. /**
  3884. * Gets a boolean indicating if the given quaternion is identity
  3885. * @param quaternion defines the quaternion to check
  3886. * @returns true if the quaternion is identity
  3887. */
  3888. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3889. /**
  3890. * Creates a quaternion from a rotation around an axis
  3891. * @param axis defines the axis to use
  3892. * @param angle defines the angle to use
  3893. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3894. */
  3895. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3896. /**
  3897. * Creates a rotation around an axis and stores it into the given quaternion
  3898. * @param axis defines the axis to use
  3899. * @param angle defines the angle to use
  3900. * @param result defines the target quaternion
  3901. * @returns the target quaternion
  3902. */
  3903. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Creates a new quaternion from data stored into an array
  3906. * @param array defines the data source
  3907. * @param offset defines the offset in the source array where the data starts
  3908. * @returns a new quaternion
  3909. */
  3910. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3911. /**
  3912. * Updates the given quaternion "result" from the starting index of the given array.
  3913. * @param array the array to pull values from
  3914. * @param offset the offset into the array to start at
  3915. * @param result the quaternion to store the result in
  3916. */
  3917. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3918. /**
  3919. * Create a quaternion from Euler rotation angles
  3920. * @param x Pitch
  3921. * @param y Yaw
  3922. * @param z Roll
  3923. * @returns the new Quaternion
  3924. */
  3925. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3926. /**
  3927. * Updates a quaternion from Euler rotation angles
  3928. * @param x Pitch
  3929. * @param y Yaw
  3930. * @param z Roll
  3931. * @param result the quaternion to store the result
  3932. * @returns the updated quaternion
  3933. */
  3934. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3935. /**
  3936. * Create a quaternion from Euler rotation vector
  3937. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3938. * @returns the new Quaternion
  3939. */
  3940. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3941. /**
  3942. * Updates a quaternion from Euler rotation vector
  3943. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3944. * @param result the quaternion to store the result
  3945. * @returns the updated quaternion
  3946. */
  3947. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3948. /**
  3949. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3950. * @param yaw defines the rotation around Y axis
  3951. * @param pitch defines the rotation around X axis
  3952. * @param roll defines the rotation around Z axis
  3953. * @returns the new quaternion
  3954. */
  3955. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3956. /**
  3957. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3958. * @param yaw defines the rotation around Y axis
  3959. * @param pitch defines the rotation around X axis
  3960. * @param roll defines the rotation around Z axis
  3961. * @param result defines the target quaternion
  3962. */
  3963. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3964. /**
  3965. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3966. * @param alpha defines the rotation around first axis
  3967. * @param beta defines the rotation around second axis
  3968. * @param gamma defines the rotation around third axis
  3969. * @returns the new quaternion
  3970. */
  3971. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3972. /**
  3973. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3974. * @param alpha defines the rotation around first axis
  3975. * @param beta defines the rotation around second axis
  3976. * @param gamma defines the rotation around third axis
  3977. * @param result defines the target quaternion
  3978. */
  3979. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3980. /**
  3981. * 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)
  3982. * @param axis1 defines the first axis
  3983. * @param axis2 defines the second axis
  3984. * @param axis3 defines the third axis
  3985. * @returns the new quaternion
  3986. */
  3987. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3988. /**
  3989. * 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
  3990. * @param axis1 defines the first axis
  3991. * @param axis2 defines the second axis
  3992. * @param axis3 defines the third axis
  3993. * @param ref defines the target quaternion
  3994. */
  3995. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3996. /**
  3997. * Interpolates between two quaternions
  3998. * @param left defines first quaternion
  3999. * @param right defines second quaternion
  4000. * @param amount defines the gradient to use
  4001. * @returns the new interpolated quaternion
  4002. */
  4003. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4004. /**
  4005. * Interpolates between two quaternions and stores it into a target quaternion
  4006. * @param left defines first quaternion
  4007. * @param right defines second quaternion
  4008. * @param amount defines the gradient to use
  4009. * @param result defines the target quaternion
  4010. */
  4011. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4012. /**
  4013. * Interpolate between two quaternions using Hermite interpolation
  4014. * @param value1 defines first quaternion
  4015. * @param tangent1 defines the incoming tangent
  4016. * @param value2 defines second quaternion
  4017. * @param tangent2 defines the outgoing tangent
  4018. * @param amount defines the target quaternion
  4019. * @returns the new interpolated quaternion
  4020. */
  4021. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4022. }
  4023. /**
  4024. * Class used to store matrix data (4x4)
  4025. */
  4026. export class Matrix {
  4027. /**
  4028. * Gets the precision of matrix computations
  4029. */
  4030. static get Use64Bits(): boolean;
  4031. private static _updateFlagSeed;
  4032. private static _identityReadOnly;
  4033. private _isIdentity;
  4034. private _isIdentityDirty;
  4035. private _isIdentity3x2;
  4036. private _isIdentity3x2Dirty;
  4037. /**
  4038. * Gets the update flag of the matrix which is an unique number for the matrix.
  4039. * It will be incremented every time the matrix data change.
  4040. * You can use it to speed the comparison between two versions of the same matrix.
  4041. */
  4042. updateFlag: number;
  4043. private readonly _m;
  4044. /**
  4045. * Gets the internal data of the matrix
  4046. */
  4047. get m(): DeepImmutable<Float32Array | Array<number>>;
  4048. /** @hidden */
  4049. _markAsUpdated(): void;
  4050. /** @hidden */
  4051. private _updateIdentityStatus;
  4052. /**
  4053. * Creates an empty matrix (filled with zeros)
  4054. */
  4055. constructor();
  4056. /**
  4057. * Check if the current matrix is identity
  4058. * @returns true is the matrix is the identity matrix
  4059. */
  4060. isIdentity(): boolean;
  4061. /**
  4062. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4063. * @returns true is the matrix is the identity matrix
  4064. */
  4065. isIdentityAs3x2(): boolean;
  4066. /**
  4067. * Gets the determinant of the matrix
  4068. * @returns the matrix determinant
  4069. */
  4070. determinant(): number;
  4071. /**
  4072. * Returns the matrix as a Float32Array or Array<number>
  4073. * @returns the matrix underlying array
  4074. */
  4075. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4076. /**
  4077. * Returns the matrix as a Float32Array or Array<number>
  4078. * @returns the matrix underlying array.
  4079. */
  4080. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4081. /**
  4082. * Inverts the current matrix in place
  4083. * @returns the current inverted matrix
  4084. */
  4085. invert(): Matrix;
  4086. /**
  4087. * Sets all the matrix elements to zero
  4088. * @returns the current matrix
  4089. */
  4090. reset(): Matrix;
  4091. /**
  4092. * Adds the current matrix with a second one
  4093. * @param other defines the matrix to add
  4094. * @returns a new matrix as the addition of the current matrix and the given one
  4095. */
  4096. add(other: DeepImmutable<Matrix>): Matrix;
  4097. /**
  4098. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4099. * @param other defines the matrix to add
  4100. * @param result defines the target matrix
  4101. * @returns the current matrix
  4102. */
  4103. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4104. /**
  4105. * Adds in place the given matrix to the current matrix
  4106. * @param other defines the second operand
  4107. * @returns the current updated matrix
  4108. */
  4109. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4110. /**
  4111. * Sets the given matrix to the current inverted Matrix
  4112. * @param other defines the target matrix
  4113. * @returns the unmodified current matrix
  4114. */
  4115. invertToRef(other: Matrix): Matrix;
  4116. /**
  4117. * add a value at the specified position in the current Matrix
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. addAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * mutiply the specified position in the current Matrix by a value
  4125. * @param index the index of the value within the matrix. between 0 and 15.
  4126. * @param value the value to be added
  4127. * @returns the current updated matrix
  4128. */
  4129. multiplyAtIndex(index: number, value: number): Matrix;
  4130. /**
  4131. * Inserts the translation vector (using 3 floats) in the current matrix
  4132. * @param x defines the 1st component of the translation
  4133. * @param y defines the 2nd component of the translation
  4134. * @param z defines the 3rd component of the translation
  4135. * @returns the current updated matrix
  4136. */
  4137. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4138. /**
  4139. * Adds the translation vector (using 3 floats) in the current matrix
  4140. * @param x defines the 1st component of the translation
  4141. * @param y defines the 2nd component of the translation
  4142. * @param z defines the 3rd component of the translation
  4143. * @returns the current updated matrix
  4144. */
  4145. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4146. /**
  4147. * Inserts the translation vector in the current matrix
  4148. * @param vector3 defines the translation to insert
  4149. * @returns the current updated matrix
  4150. */
  4151. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4152. /**
  4153. * Gets the translation value of the current matrix
  4154. * @returns a new Vector3 as the extracted translation from the matrix
  4155. */
  4156. getTranslation(): Vector3;
  4157. /**
  4158. * Fill a Vector3 with the extracted translation from the matrix
  4159. * @param result defines the Vector3 where to store the translation
  4160. * @returns the current matrix
  4161. */
  4162. getTranslationToRef(result: Vector3): Matrix;
  4163. /**
  4164. * Remove rotation and scaling part from the matrix
  4165. * @returns the updated matrix
  4166. */
  4167. removeRotationAndScaling(): Matrix;
  4168. /**
  4169. * Multiply two matrices
  4170. * @param other defines the second operand
  4171. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4172. */
  4173. multiply(other: DeepImmutable<Matrix>): Matrix;
  4174. /**
  4175. * Copy the current matrix from the given one
  4176. * @param other defines the source matrix
  4177. * @returns the current updated matrix
  4178. */
  4179. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4180. /**
  4181. * Populates the given array from the starting index with the current matrix values
  4182. * @param array defines the target array
  4183. * @param offset defines the offset in the target array where to start storing values
  4184. * @returns the current matrix
  4185. */
  4186. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4187. /**
  4188. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the matrix where to store the multiplication
  4191. * @returns the current matrix
  4192. */
  4193. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4194. /**
  4195. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4196. * @param other defines the second operand
  4197. * @param result defines the array where to store the multiplication
  4198. * @param offset defines the offset in the target array where to start storing values
  4199. * @returns the current matrix
  4200. */
  4201. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4202. /**
  4203. * Check equality between this matrix and a second one
  4204. * @param value defines the second matrix to compare
  4205. * @returns true is the current matrix and the given one values are strictly equal
  4206. */
  4207. equals(value: DeepImmutable<Matrix>): boolean;
  4208. /**
  4209. * Clone the current matrix
  4210. * @returns a new matrix from the current matrix
  4211. */
  4212. clone(): Matrix;
  4213. /**
  4214. * Returns the name of the current matrix class
  4215. * @returns the string "Matrix"
  4216. */
  4217. getClassName(): string;
  4218. /**
  4219. * Gets the hash code of the current matrix
  4220. * @returns the hash code
  4221. */
  4222. getHashCode(): number;
  4223. /**
  4224. * Decomposes the current Matrix into a translation, rotation and scaling components
  4225. * @param scale defines the scale vector3 given as a reference to update
  4226. * @param rotation defines the rotation quaternion given as a reference to update
  4227. * @param translation defines the translation vector3 given as a reference to update
  4228. * @returns true if operation was successful
  4229. */
  4230. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4231. /**
  4232. * Gets specific row of the matrix
  4233. * @param index defines the number of the row to get
  4234. * @returns the index-th row of the current matrix as a new Vector4
  4235. */
  4236. getRow(index: number): Nullable<Vector4>;
  4237. /**
  4238. * Sets the index-th row of the current matrix to the vector4 values
  4239. * @param index defines the number of the row to set
  4240. * @param row defines the target vector4
  4241. * @returns the updated current matrix
  4242. */
  4243. setRow(index: number, row: Vector4): Matrix;
  4244. /**
  4245. * Compute the transpose of the matrix
  4246. * @returns the new transposed matrix
  4247. */
  4248. transpose(): Matrix;
  4249. /**
  4250. * Compute the transpose of the matrix and store it in a given matrix
  4251. * @param result defines the target matrix
  4252. * @returns the current matrix
  4253. */
  4254. transposeToRef(result: Matrix): Matrix;
  4255. /**
  4256. * Sets the index-th row of the current matrix with the given 4 x float values
  4257. * @param index defines the row index
  4258. * @param x defines the x component to set
  4259. * @param y defines the y component to set
  4260. * @param z defines the z component to set
  4261. * @param w defines the w component to set
  4262. * @returns the updated current matrix
  4263. */
  4264. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4265. /**
  4266. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4267. * @param scale defines the scale factor
  4268. * @returns a new matrix
  4269. */
  4270. scale(scale: number): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor to a given result matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Scale the current matrix values by a factor and add the result to a given matrix
  4280. * @param scale defines the scale factor
  4281. * @param result defines the Matrix to store the result
  4282. * @returns the current matrix
  4283. */
  4284. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4285. /**
  4286. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4287. * @param ref matrix to store the result
  4288. */
  4289. toNormalMatrix(ref: Matrix): void;
  4290. /**
  4291. * Gets only rotation part of the current matrix
  4292. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4293. */
  4294. getRotationMatrix(): Matrix;
  4295. /**
  4296. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4297. * @param result defines the target matrix to store data to
  4298. * @returns the current matrix
  4299. */
  4300. getRotationMatrixToRef(result: Matrix): Matrix;
  4301. /**
  4302. * Toggles model matrix from being right handed to left handed in place and vice versa
  4303. */
  4304. toggleModelMatrixHandInPlace(): void;
  4305. /**
  4306. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4307. */
  4308. toggleProjectionMatrixHandInPlace(): void;
  4309. /**
  4310. * Creates a matrix from an array
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @returns a new Matrix set from the starting index of the given array
  4314. */
  4315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4316. /**
  4317. * Copy the content of an array into a given matrix
  4318. * @param array defines the source array
  4319. * @param offset defines an offset in the source array
  4320. * @param result defines the target matrix
  4321. */
  4322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4323. /**
  4324. * Stores an array into a matrix after having multiplied each component by a given factor
  4325. * @param array defines the source array
  4326. * @param offset defines the offset in the source array
  4327. * @param scale defines the scaling factor
  4328. * @param result defines the target matrix
  4329. */
  4330. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4331. /**
  4332. * Gets an identity matrix that must not be updated
  4333. */
  4334. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4335. /**
  4336. * Stores a list of values (16) inside a given matrix
  4337. * @param initialM11 defines 1st value of 1st row
  4338. * @param initialM12 defines 2nd value of 1st row
  4339. * @param initialM13 defines 3rd value of 1st row
  4340. * @param initialM14 defines 4th value of 1st row
  4341. * @param initialM21 defines 1st value of 2nd row
  4342. * @param initialM22 defines 2nd value of 2nd row
  4343. * @param initialM23 defines 3rd value of 2nd row
  4344. * @param initialM24 defines 4th value of 2nd row
  4345. * @param initialM31 defines 1st value of 3rd row
  4346. * @param initialM32 defines 2nd value of 3rd row
  4347. * @param initialM33 defines 3rd value of 3rd row
  4348. * @param initialM34 defines 4th value of 3rd row
  4349. * @param initialM41 defines 1st value of 4th row
  4350. * @param initialM42 defines 2nd value of 4th row
  4351. * @param initialM43 defines 3rd value of 4th row
  4352. * @param initialM44 defines 4th value of 4th row
  4353. * @param result defines the target matrix
  4354. */
  4355. 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;
  4356. /**
  4357. * Creates new matrix from a list of values (16)
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @returns the new matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4379. * @param scale defines the scale vector3
  4380. * @param rotation defines the rotation quaternion
  4381. * @param translation defines the translation vector3
  4382. * @returns a new matrix
  4383. */
  4384. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4385. /**
  4386. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4387. * @param scale defines the scale vector3
  4388. * @param rotation defines the rotation quaternion
  4389. * @param translation defines the translation vector3
  4390. * @param result defines the target matrix
  4391. */
  4392. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4393. /**
  4394. * Creates a new identity matrix
  4395. * @returns a new identity matrix
  4396. */
  4397. static Identity(): Matrix;
  4398. /**
  4399. * Creates a new identity matrix and stores the result in a given matrix
  4400. * @param result defines the target matrix
  4401. */
  4402. static IdentityToRef(result: Matrix): void;
  4403. /**
  4404. * Creates a new zero matrix
  4405. * @returns a new zero matrix
  4406. */
  4407. static Zero(): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the X axis
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationX(angle: number): Matrix;
  4414. /**
  4415. * Creates a new matrix as the invert of a given matrix
  4416. * @param source defines the source matrix
  4417. * @returns the new matrix
  4418. */
  4419. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4420. /**
  4421. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4422. * @param angle defines the angle (in radians) to use
  4423. * @param result defines the target matrix
  4424. */
  4425. static RotationXToRef(angle: number, result: Matrix): void;
  4426. /**
  4427. * Creates a new rotation matrix for "angle" radians around the Y axis
  4428. * @param angle defines the angle (in radians) to use
  4429. * @return the new matrix
  4430. */
  4431. static RotationY(angle: number): Matrix;
  4432. /**
  4433. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4434. * @param angle defines the angle (in radians) to use
  4435. * @param result defines the target matrix
  4436. */
  4437. static RotationYToRef(angle: number, result: Matrix): void;
  4438. /**
  4439. * Creates a new rotation matrix for "angle" radians around the Z axis
  4440. * @param angle defines the angle (in radians) to use
  4441. * @return the new matrix
  4442. */
  4443. static RotationZ(angle: number): Matrix;
  4444. /**
  4445. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4446. * @param angle defines the angle (in radians) to use
  4447. * @param result defines the target matrix
  4448. */
  4449. static RotationZToRef(angle: number, result: Matrix): void;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @return the new matrix
  4455. */
  4456. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4457. /**
  4458. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4459. * @param axis defines the axis to use
  4460. * @param angle defines the angle (in radians) to use
  4461. * @param result defines the target matrix
  4462. */
  4463. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4464. /**
  4465. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4466. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4467. * @param from defines the vector to align
  4468. * @param to defines the vector to align to
  4469. * @param result defines the target matrix
  4470. */
  4471. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a rotation matrix
  4474. * @param yaw defines the yaw angle in radians (Y axis)
  4475. * @param pitch defines the pitch angle in radians (X axis)
  4476. * @param roll defines the roll angle in radians (Z axis)
  4477. * @returns the new rotation matrix
  4478. */
  4479. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4480. /**
  4481. * Creates a rotation matrix and stores it in a given matrix
  4482. * @param yaw defines the yaw angle in radians (Y axis)
  4483. * @param pitch defines the pitch angle in radians (X axis)
  4484. * @param roll defines the roll angle in radians (Z axis)
  4485. * @param result defines the target matrix
  4486. */
  4487. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4488. /**
  4489. * Creates a scaling matrix
  4490. * @param x defines the scale factor on X axis
  4491. * @param y defines the scale factor on Y axis
  4492. * @param z defines the scale factor on Z axis
  4493. * @returns the new matrix
  4494. */
  4495. static Scaling(x: number, y: number, z: number): Matrix;
  4496. /**
  4497. * Creates a scaling matrix and stores it in a given matrix
  4498. * @param x defines the scale factor on X axis
  4499. * @param y defines the scale factor on Y axis
  4500. * @param z defines the scale factor on Z axis
  4501. * @param result defines the target matrix
  4502. */
  4503. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4504. /**
  4505. * Creates a translation matrix
  4506. * @param x defines the translation on X axis
  4507. * @param y defines the translation on Y axis
  4508. * @param z defines the translationon Z axis
  4509. * @returns the new matrix
  4510. */
  4511. static Translation(x: number, y: number, z: number): Matrix;
  4512. /**
  4513. * Creates a translation matrix and stores it in a given matrix
  4514. * @param x defines the translation on X axis
  4515. * @param y defines the translation on Y axis
  4516. * @param z defines the translationon Z axis
  4517. * @param result defines the target matrix
  4518. */
  4519. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4520. /**
  4521. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4522. * @param startValue defines the start value
  4523. * @param endValue defines the end value
  4524. * @param gradient defines the gradient factor
  4525. * @returns the new matrix
  4526. */
  4527. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4528. /**
  4529. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4530. * @param startValue defines the start value
  4531. * @param endValue defines the end value
  4532. * @param gradient defines the gradient factor
  4533. * @param result defines the Matrix object where to store data
  4534. */
  4535. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4536. /**
  4537. * Builds a new matrix whose values are computed by:
  4538. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4539. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4540. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4541. * @param startValue defines the first matrix
  4542. * @param endValue defines the second matrix
  4543. * @param gradient defines the gradient between the two matrices
  4544. * @returns the new matrix
  4545. */
  4546. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4547. /**
  4548. * Update a matrix to values which are computed by:
  4549. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4550. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4551. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4552. * @param startValue defines the first matrix
  4553. * @param endValue defines the second matrix
  4554. * @param gradient defines the gradient between the two matrices
  4555. * @param result defines the target matrix
  4556. */
  4557. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4558. /**
  4559. * 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"
  4560. * This function works in left handed mode
  4561. * @param eye defines the final position of the entity
  4562. * @param target defines where the entity should look at
  4563. * @param up defines the up vector for the entity
  4564. * @returns the new matrix
  4565. */
  4566. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4567. /**
  4568. * 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".
  4569. * This function works in left handed mode
  4570. * @param eye defines the final position of the entity
  4571. * @param target defines where the entity should look at
  4572. * @param up defines the up vector for the entity
  4573. * @param result defines the target matrix
  4574. */
  4575. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4576. /**
  4577. * 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"
  4578. * This function works in right handed mode
  4579. * @param eye defines the final position of the entity
  4580. * @param target defines where the entity should look at
  4581. * @param up defines the up vector for the entity
  4582. * @returns the new matrix
  4583. */
  4584. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4585. /**
  4586. * 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".
  4587. * This function works in right handed mode
  4588. * @param eye defines the final position of the entity
  4589. * @param target defines where the entity should look at
  4590. * @param up defines the up vector for the entity
  4591. * @param result defines the target matrix
  4592. */
  4593. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4594. /**
  4595. * Create a left-handed orthographic projection matrix
  4596. * @param width defines the viewport width
  4597. * @param height defines the viewport height
  4598. * @param znear defines the near clip plane
  4599. * @param zfar defines the far clip plane
  4600. * @returns a new matrix as a left-handed orthographic projection matrix
  4601. */
  4602. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4603. /**
  4604. * Store a left-handed orthographic projection to a given matrix
  4605. * @param width defines the viewport width
  4606. * @param height defines the viewport height
  4607. * @param znear defines the near clip plane
  4608. * @param zfar defines the far clip plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4612. /**
  4613. * Create a left-handed orthographic projection matrix
  4614. * @param left defines the viewport left coordinate
  4615. * @param right defines the viewport right coordinate
  4616. * @param bottom defines the viewport bottom coordinate
  4617. * @param top defines the viewport top coordinate
  4618. * @param znear defines the near clip plane
  4619. * @param zfar defines the far clip plane
  4620. * @returns a new matrix as a left-handed orthographic projection matrix
  4621. */
  4622. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4623. /**
  4624. * Stores a left-handed orthographic projection into a given matrix
  4625. * @param left defines the viewport left coordinate
  4626. * @param right defines the viewport right coordinate
  4627. * @param bottom defines the viewport bottom coordinate
  4628. * @param top defines the viewport top coordinate
  4629. * @param znear defines the near clip plane
  4630. * @param zfar defines the far clip plane
  4631. * @param result defines the target matrix
  4632. */
  4633. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4634. /**
  4635. * Creates a right-handed orthographic projection matrix
  4636. * @param left defines the viewport left coordinate
  4637. * @param right defines the viewport right coordinate
  4638. * @param bottom defines the viewport bottom coordinate
  4639. * @param top defines the viewport top coordinate
  4640. * @param znear defines the near clip plane
  4641. * @param zfar defines the far clip plane
  4642. * @returns a new matrix as a right-handed orthographic projection matrix
  4643. */
  4644. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4645. /**
  4646. * Stores a right-handed orthographic projection into a given matrix
  4647. * @param left defines the viewport left coordinate
  4648. * @param right defines the viewport right coordinate
  4649. * @param bottom defines the viewport bottom coordinate
  4650. * @param top defines the viewport top coordinate
  4651. * @param znear defines the near clip plane
  4652. * @param zfar defines the far clip plane
  4653. * @param result defines the target matrix
  4654. */
  4655. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4656. /**
  4657. * Creates a left-handed perspective projection matrix
  4658. * @param width defines the viewport width
  4659. * @param height defines the viewport height
  4660. * @param znear defines the near clip plane
  4661. * @param zfar defines the far clip plane
  4662. * @returns a new matrix as a left-handed perspective projection matrix
  4663. */
  4664. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4665. /**
  4666. * Creates a left-handed perspective projection matrix
  4667. * @param fov defines the horizontal field of view
  4668. * @param aspect defines the aspect ratio
  4669. * @param znear defines the near clip plane
  4670. * @param zfar defines the far clip plane
  4671. * @returns a new matrix as a left-handed perspective projection matrix
  4672. */
  4673. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4674. /**
  4675. * Stores a left-handed perspective projection into a given matrix
  4676. * @param fov defines the horizontal field of view
  4677. * @param aspect defines the aspect ratio
  4678. * @param znear defines the near clip plane
  4679. * @param zfar defines the far clip plane
  4680. * @param result defines the target matrix
  4681. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4682. */
  4683. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4684. /**
  4685. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4686. * @param fov defines the horizontal field of view
  4687. * @param aspect defines the aspect ratio
  4688. * @param znear defines the near clip plane
  4689. * @param zfar not used as infinity is used as far clip
  4690. * @param result defines the target matrix
  4691. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4692. */
  4693. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4694. /**
  4695. * Creates a right-handed perspective projection matrix
  4696. * @param fov defines the horizontal field of view
  4697. * @param aspect defines the aspect ratio
  4698. * @param znear defines the near clip plane
  4699. * @param zfar defines the far clip plane
  4700. * @returns a new matrix as a right-handed perspective projection matrix
  4701. */
  4702. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4703. /**
  4704. * Stores a right-handed perspective projection into a given matrix
  4705. * @param fov defines the horizontal field of view
  4706. * @param aspect defines the aspect ratio
  4707. * @param znear defines the near clip plane
  4708. * @param zfar defines the far clip plane
  4709. * @param result defines the target matrix
  4710. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4711. */
  4712. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4713. /**
  4714. * Stores a right-handed perspective projection into a given matrix
  4715. * @param fov defines the horizontal field of view
  4716. * @param aspect defines the aspect ratio
  4717. * @param znear defines the near clip plane
  4718. * @param zfar not used as infinity is used as far clip
  4719. * @param result defines the target matrix
  4720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4721. */
  4722. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4723. /**
  4724. * Stores a perspective projection for WebVR info a given matrix
  4725. * @param fov defines the field of view
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4730. */
  4731. static PerspectiveFovWebVRToRef(fov: {
  4732. upDegrees: number;
  4733. downDegrees: number;
  4734. leftDegrees: number;
  4735. rightDegrees: number;
  4736. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4737. /**
  4738. * Computes a complete transformation matrix
  4739. * @param viewport defines the viewport to use
  4740. * @param world defines the world matrix
  4741. * @param view defines the view matrix
  4742. * @param projection defines the projection matrix
  4743. * @param zmin defines the near clip plane
  4744. * @param zmax defines the far clip plane
  4745. * @returns the transformation matrix
  4746. */
  4747. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4748. /**
  4749. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4750. * @param matrix defines the matrix to use
  4751. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4752. */
  4753. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4754. /**
  4755. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4756. * @param matrix defines the matrix to use
  4757. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4758. */
  4759. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4760. /**
  4761. * Compute the transpose of a given matrix
  4762. * @param matrix defines the matrix to transpose
  4763. * @returns the new matrix
  4764. */
  4765. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4766. /**
  4767. * Compute the transpose of a matrix and store it in a target matrix
  4768. * @param matrix defines the matrix to transpose
  4769. * @param result defines the target matrix
  4770. */
  4771. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4772. /**
  4773. * Computes a reflection matrix from a plane
  4774. * @param plane defines the reflection plane
  4775. * @returns a new matrix
  4776. */
  4777. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4778. /**
  4779. * Computes a reflection matrix from a plane
  4780. * @param plane defines the reflection plane
  4781. * @param result defines the target matrix
  4782. */
  4783. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4784. /**
  4785. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4786. * @param xaxis defines the value of the 1st axis
  4787. * @param yaxis defines the value of the 2nd axis
  4788. * @param zaxis defines the value of the 3rd axis
  4789. * @param result defines the target matrix
  4790. */
  4791. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4792. /**
  4793. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4794. * @param quat defines the quaternion to use
  4795. * @param result defines the target matrix
  4796. */
  4797. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4798. }
  4799. /**
  4800. * @hidden
  4801. */
  4802. export class TmpVectors {
  4803. static Vector2: Vector2[];
  4804. static Vector3: Vector3[];
  4805. static Vector4: Vector4[];
  4806. static Quaternion: Quaternion[];
  4807. static Matrix: Matrix[];
  4808. }
  4809. }
  4810. declare module BABYLON {
  4811. /**
  4812. * Defines potential orientation for back face culling
  4813. */
  4814. export enum Orientation {
  4815. /**
  4816. * Clockwise
  4817. */
  4818. CW = 0,
  4819. /** Counter clockwise */
  4820. CCW = 1
  4821. }
  4822. /** Class used to represent a Bezier curve */
  4823. export class BezierCurve {
  4824. /**
  4825. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4826. * @param t defines the time
  4827. * @param x1 defines the left coordinate on X axis
  4828. * @param y1 defines the left coordinate on Y axis
  4829. * @param x2 defines the right coordinate on X axis
  4830. * @param y2 defines the right coordinate on Y axis
  4831. * @returns the interpolated value
  4832. */
  4833. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4834. }
  4835. /**
  4836. * Defines angle representation
  4837. */
  4838. export class Angle {
  4839. private _radians;
  4840. /**
  4841. * Creates an Angle object of "radians" radians (float).
  4842. * @param radians the angle in radians
  4843. */
  4844. constructor(radians: number);
  4845. /**
  4846. * Get value in degrees
  4847. * @returns the Angle value in degrees (float)
  4848. */
  4849. degrees(): number;
  4850. /**
  4851. * Get value in radians
  4852. * @returns the Angle value in radians (float)
  4853. */
  4854. radians(): number;
  4855. /**
  4856. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4857. * @param a defines first point as the origin
  4858. * @param b defines point
  4859. * @returns a new Angle
  4860. */
  4861. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4862. /**
  4863. * Gets a new Angle object from the given float in radians
  4864. * @param radians defines the angle value in radians
  4865. * @returns a new Angle
  4866. */
  4867. static FromRadians(radians: number): Angle;
  4868. /**
  4869. * Gets a new Angle object from the given float in degrees
  4870. * @param degrees defines the angle value in degrees
  4871. * @returns a new Angle
  4872. */
  4873. static FromDegrees(degrees: number): Angle;
  4874. }
  4875. /**
  4876. * This represents an arc in a 2d space.
  4877. */
  4878. export class Arc2 {
  4879. /** Defines the start point of the arc */
  4880. startPoint: Vector2;
  4881. /** Defines the mid point of the arc */
  4882. midPoint: Vector2;
  4883. /** Defines the end point of the arc */
  4884. endPoint: Vector2;
  4885. /**
  4886. * Defines the center point of the arc.
  4887. */
  4888. centerPoint: Vector2;
  4889. /**
  4890. * Defines the radius of the arc.
  4891. */
  4892. radius: number;
  4893. /**
  4894. * Defines the angle of the arc (from mid point to end point).
  4895. */
  4896. angle: Angle;
  4897. /**
  4898. * Defines the start angle of the arc (from start point to middle point).
  4899. */
  4900. startAngle: Angle;
  4901. /**
  4902. * Defines the orientation of the arc (clock wise/counter clock wise).
  4903. */
  4904. orientation: Orientation;
  4905. /**
  4906. * Creates an Arc object from the three given points : start, middle and end.
  4907. * @param startPoint Defines the start point of the arc
  4908. * @param midPoint Defines the midlle point of the arc
  4909. * @param endPoint Defines the end point of the arc
  4910. */
  4911. constructor(
  4912. /** Defines the start point of the arc */
  4913. startPoint: Vector2,
  4914. /** Defines the mid point of the arc */
  4915. midPoint: Vector2,
  4916. /** Defines the end point of the arc */
  4917. endPoint: Vector2);
  4918. }
  4919. /**
  4920. * Represents a 2D path made up of multiple 2D points
  4921. */
  4922. export class Path2 {
  4923. private _points;
  4924. private _length;
  4925. /**
  4926. * If the path start and end point are the same
  4927. */
  4928. closed: boolean;
  4929. /**
  4930. * Creates a Path2 object from the starting 2D coordinates x and y.
  4931. * @param x the starting points x value
  4932. * @param y the starting points y value
  4933. */
  4934. constructor(x: number, y: number);
  4935. /**
  4936. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4937. * @param x the added points x value
  4938. * @param y the added points y value
  4939. * @returns the updated Path2.
  4940. */
  4941. addLineTo(x: number, y: number): Path2;
  4942. /**
  4943. * 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.
  4944. * @param midX middle point x value
  4945. * @param midY middle point y value
  4946. * @param endX end point x value
  4947. * @param endY end point y value
  4948. * @param numberOfSegments (default: 36)
  4949. * @returns the updated Path2.
  4950. */
  4951. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4952. /**
  4953. * Closes the Path2.
  4954. * @returns the Path2.
  4955. */
  4956. close(): Path2;
  4957. /**
  4958. * Gets the sum of the distance between each sequential point in the path
  4959. * @returns the Path2 total length (float).
  4960. */
  4961. length(): number;
  4962. /**
  4963. * Gets the points which construct the path
  4964. * @returns the Path2 internal array of points.
  4965. */
  4966. getPoints(): Vector2[];
  4967. /**
  4968. * Retreives the point at the distance aways from the starting point
  4969. * @param normalizedLengthPosition the length along the path to retreive the point from
  4970. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4971. */
  4972. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4973. /**
  4974. * Creates a new path starting from an x and y position
  4975. * @param x starting x value
  4976. * @param y starting y value
  4977. * @returns a new Path2 starting at the coordinates (x, y).
  4978. */
  4979. static StartingAt(x: number, y: number): Path2;
  4980. }
  4981. /**
  4982. * Represents a 3D path made up of multiple 3D points
  4983. */
  4984. export class Path3D {
  4985. /**
  4986. * an array of Vector3, the curve axis of the Path3D
  4987. */
  4988. path: Vector3[];
  4989. private _curve;
  4990. private _distances;
  4991. private _tangents;
  4992. private _normals;
  4993. private _binormals;
  4994. private _raw;
  4995. private _alignTangentsWithPath;
  4996. private readonly _pointAtData;
  4997. /**
  4998. * new Path3D(path, normal, raw)
  4999. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5000. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5001. * @param path an array of Vector3, the curve axis of the Path3D
  5002. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5003. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5004. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5005. */
  5006. constructor(
  5007. /**
  5008. * an array of Vector3, the curve axis of the Path3D
  5009. */
  5010. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getCurve(): Vector3[];
  5016. /**
  5017. * Returns the Path3D array of successive Vector3 designing its curve.
  5018. * @returns the Path3D array of successive Vector3 designing its curve.
  5019. */
  5020. getPoints(): Vector3[];
  5021. /**
  5022. * @returns the computed length (float) of the path.
  5023. */
  5024. length(): number;
  5025. /**
  5026. * Returns an array populated with tangent vectors on each Path3D curve point.
  5027. * @returns an array populated with tangent vectors on each Path3D curve point.
  5028. */
  5029. getTangents(): Vector3[];
  5030. /**
  5031. * Returns an array populated with normal vectors on each Path3D curve point.
  5032. * @returns an array populated with normal vectors on each Path3D curve point.
  5033. */
  5034. getNormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with binormal vectors on each Path3D curve point.
  5037. * @returns an array populated with binormal vectors on each Path3D curve point.
  5038. */
  5039. getBinormals(): Vector3[];
  5040. /**
  5041. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5042. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5043. */
  5044. getDistances(): number[];
  5045. /**
  5046. * Returns an interpolated point along this path
  5047. * @param position the position of the point along this path, from 0.0 to 1.0
  5048. * @returns a new Vector3 as the point
  5049. */
  5050. getPointAt(position: number): Vector3;
  5051. /**
  5052. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5053. * @param position the position of the point along this path, from 0.0 to 1.0
  5054. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5055. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5056. */
  5057. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5058. /**
  5059. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5060. * @param position the position of the point along this path, from 0.0 to 1.0
  5061. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5062. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5063. */
  5064. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5065. /**
  5066. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5067. * @param position the position of the point along this path, from 0.0 to 1.0
  5068. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5069. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5070. */
  5071. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5072. /**
  5073. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5076. */
  5077. getDistanceAt(position: number): number;
  5078. /**
  5079. * Returns the array index of the previous point of an interpolated point along this path
  5080. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5081. * @returns the array index
  5082. */
  5083. getPreviousPointIndexAt(position: number): number;
  5084. /**
  5085. * 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)
  5086. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5087. * @returns the sub position
  5088. */
  5089. getSubPositionAt(position: number): number;
  5090. /**
  5091. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5092. * @param target the vector of which to get the closest position to
  5093. * @returns the position of the closest virtual point on this path to the target vector
  5094. */
  5095. getClosestPositionTo(target: Vector3): number;
  5096. /**
  5097. * Returns a sub path (slice) of this path
  5098. * @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
  5099. * @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
  5100. * @returns a sub path (slice) of this path
  5101. */
  5102. slice(start?: number, end?: number): Path3D;
  5103. /**
  5104. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5105. * @param path path which all values are copied into the curves points
  5106. * @param firstNormal which should be projected onto the curve
  5107. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5108. * @returns the same object updated.
  5109. */
  5110. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5111. private _compute;
  5112. private _getFirstNonNullVector;
  5113. private _getLastNonNullVector;
  5114. private _normalVector;
  5115. /**
  5116. * Updates the point at data for an interpolated point along this curve
  5117. * @param position the position of the point along this curve, from 0.0 to 1.0
  5118. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5119. * @returns the (updated) point at data
  5120. */
  5121. private _updatePointAtData;
  5122. /**
  5123. * Updates the point at data from the specified parameters
  5124. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5125. * @param point the interpolated point
  5126. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5127. */
  5128. private _setPointAtData;
  5129. /**
  5130. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5131. */
  5132. private _updateInterpolationMatrix;
  5133. }
  5134. /**
  5135. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5136. * A Curve3 is designed from a series of successive Vector3.
  5137. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5138. */
  5139. export class Curve3 {
  5140. private _points;
  5141. private _length;
  5142. /**
  5143. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5144. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5145. * @param v1 (Vector3) the control point
  5146. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5147. * @param nbPoints (integer) the wanted number of points in the curve
  5148. * @returns the created Curve3
  5149. */
  5150. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5151. /**
  5152. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5153. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5154. * @param v1 (Vector3) the first control point
  5155. * @param v2 (Vector3) the second control point
  5156. * @param v3 (Vector3) the end point of the Cubic Bezier
  5157. * @param nbPoints (integer) the wanted number of points in the curve
  5158. * @returns the created Curve3
  5159. */
  5160. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5161. /**
  5162. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5163. * @param p1 (Vector3) the origin point of the Hermite Spline
  5164. * @param t1 (Vector3) the tangent vector at the origin point
  5165. * @param p2 (Vector3) the end point of the Hermite Spline
  5166. * @param t2 (Vector3) the tangent vector at the end point
  5167. * @param nbPoints (integer) the wanted number of points in the curve
  5168. * @returns the created Curve3
  5169. */
  5170. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5171. /**
  5172. * Returns a Curve3 object along a CatmullRom Spline curve :
  5173. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5174. * @param nbPoints (integer) the wanted number of points between each curve control points
  5175. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5176. * @returns the created Curve3
  5177. */
  5178. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5179. /**
  5180. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5181. * A Curve3 is designed from a series of successive Vector3.
  5182. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5183. * @param points points which make up the curve
  5184. */
  5185. constructor(points: Vector3[]);
  5186. /**
  5187. * @returns the Curve3 stored array of successive Vector3
  5188. */
  5189. getPoints(): Vector3[];
  5190. /**
  5191. * @returns the computed length (float) of the curve.
  5192. */
  5193. length(): number;
  5194. /**
  5195. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5196. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5197. * curveA and curveB keep unchanged.
  5198. * @param curve the curve to continue from this curve
  5199. * @returns the newly constructed curve
  5200. */
  5201. continue(curve: DeepImmutable<Curve3>): Curve3;
  5202. private _computeLength;
  5203. }
  5204. }
  5205. declare module BABYLON {
  5206. /**
  5207. * This represents the main contract an easing function should follow.
  5208. * Easing functions are used throughout the animation system.
  5209. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export interface IEasingFunction {
  5212. /**
  5213. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5214. * of the easing function.
  5215. * The link below provides some of the most common examples of easing functions.
  5216. * @see https://easings.net/
  5217. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5218. * @returns the corresponding value on the curve defined by the easing function
  5219. */
  5220. ease(gradient: number): number;
  5221. }
  5222. /**
  5223. * Base class used for every default easing function.
  5224. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5225. */
  5226. export class EasingFunction implements IEasingFunction {
  5227. /**
  5228. * Interpolation follows the mathematical formula associated with the easing function.
  5229. */
  5230. static readonly EASINGMODE_EASEIN: number;
  5231. /**
  5232. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5233. */
  5234. static readonly EASINGMODE_EASEOUT: number;
  5235. /**
  5236. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5237. */
  5238. static readonly EASINGMODE_EASEINOUT: number;
  5239. private _easingMode;
  5240. /**
  5241. * Sets the easing mode of the current function.
  5242. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5243. */
  5244. setEasingMode(easingMode: number): void;
  5245. /**
  5246. * Gets the current easing mode.
  5247. * @returns the easing mode
  5248. */
  5249. getEasingMode(): number;
  5250. /**
  5251. * @hidden
  5252. */
  5253. easeInCore(gradient: number): number;
  5254. /**
  5255. * Given an input gradient between 0 and 1, this returns the corresponding value
  5256. * of the easing function.
  5257. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5258. * @returns the corresponding value on the curve defined by the easing function
  5259. */
  5260. ease(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a circle shape (see link below).
  5264. * @see https://easings.net/#easeInCirc
  5265. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class CircleEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a ease back shape (see link below).
  5273. * @see https://easings.net/#easeInBack
  5274. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class BackEase extends EasingFunction implements IEasingFunction {
  5277. /** Defines the amplitude of the function */
  5278. amplitude: number;
  5279. /**
  5280. * Instantiates a back ease easing
  5281. * @see https://easings.net/#easeInBack
  5282. * @param amplitude Defines the amplitude of the function
  5283. */
  5284. constructor(
  5285. /** Defines the amplitude of the function */
  5286. amplitude?: number);
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. /**
  5291. * Easing function with a bouncing shape (see link below).
  5292. * @see https://easings.net/#easeInBounce
  5293. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5294. */
  5295. export class BounceEase extends EasingFunction implements IEasingFunction {
  5296. /** Defines the number of bounces */
  5297. bounces: number;
  5298. /** Defines the amplitude of the bounce */
  5299. bounciness: number;
  5300. /**
  5301. * Instantiates a bounce easing
  5302. * @see https://easings.net/#easeInBounce
  5303. * @param bounces Defines the number of bounces
  5304. * @param bounciness Defines the amplitude of the bounce
  5305. */
  5306. constructor(
  5307. /** Defines the number of bounces */
  5308. bounces?: number,
  5309. /** Defines the amplitude of the bounce */
  5310. bounciness?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. /**
  5315. * Easing function with a power of 3 shape (see link below).
  5316. * @see https://easings.net/#easeInCubic
  5317. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5318. */
  5319. export class CubicEase extends EasingFunction implements IEasingFunction {
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with an elastic shape (see link below).
  5325. * @see https://easings.net/#easeInElastic
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the number of oscillations*/
  5330. oscillations: number;
  5331. /** Defines the amplitude of the oscillations*/
  5332. springiness: number;
  5333. /**
  5334. * Instantiates an elastic easing function
  5335. * @see https://easings.net/#easeInElastic
  5336. * @param oscillations Defines the number of oscillations
  5337. * @param springiness Defines the amplitude of the oscillations
  5338. */
  5339. constructor(
  5340. /** Defines the number of oscillations*/
  5341. oscillations?: number,
  5342. /** Defines the amplitude of the oscillations*/
  5343. springiness?: number);
  5344. /** @hidden */
  5345. easeInCore(gradient: number): number;
  5346. }
  5347. /**
  5348. * Easing function with an exponential shape (see link below).
  5349. * @see https://easings.net/#easeInExpo
  5350. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5351. */
  5352. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5353. /** Defines the exponent of the function */
  5354. exponent: number;
  5355. /**
  5356. * Instantiates an exponential easing function
  5357. * @see https://easings.net/#easeInExpo
  5358. * @param exponent Defines the exponent of the function
  5359. */
  5360. constructor(
  5361. /** Defines the exponent of the function */
  5362. exponent?: number);
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with a power shape (see link below).
  5368. * @see https://easings.net/#easeInQuad
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class PowerEase extends EasingFunction implements IEasingFunction {
  5372. /** Defines the power of the function */
  5373. power: number;
  5374. /**
  5375. * Instantiates an power base easing function
  5376. * @see https://easings.net/#easeInQuad
  5377. * @param power Defines the power of the function
  5378. */
  5379. constructor(
  5380. /** Defines the power of the function */
  5381. power?: number);
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a power of 2 shape (see link below).
  5387. * @see https://easings.net/#easeInQuad
  5388. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5391. /** @hidden */
  5392. easeInCore(gradient: number): number;
  5393. }
  5394. /**
  5395. * Easing function with a power of 4 shape (see link below).
  5396. * @see https://easings.net/#easeInQuart
  5397. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5398. */
  5399. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5400. /** @hidden */
  5401. easeInCore(gradient: number): number;
  5402. }
  5403. /**
  5404. * Easing function with a power of 5 shape (see link below).
  5405. * @see https://easings.net/#easeInQuint
  5406. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5407. */
  5408. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. /**
  5413. * Easing function with a sin shape (see link below).
  5414. * @see https://easings.net/#easeInSine
  5415. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5416. */
  5417. export class SineEase extends EasingFunction implements IEasingFunction {
  5418. /** @hidden */
  5419. easeInCore(gradient: number): number;
  5420. }
  5421. /**
  5422. * Easing function with a bezier shape (see link below).
  5423. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5424. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5425. */
  5426. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5427. /** Defines the x component of the start tangent in the bezier curve */
  5428. x1: number;
  5429. /** Defines the y component of the start tangent in the bezier curve */
  5430. y1: number;
  5431. /** Defines the x component of the end tangent in the bezier curve */
  5432. x2: number;
  5433. /** Defines the y component of the end tangent in the bezier curve */
  5434. y2: number;
  5435. /**
  5436. * Instantiates a bezier function
  5437. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5438. * @param x1 Defines the x component of the start tangent in the bezier curve
  5439. * @param y1 Defines the y component of the start tangent in the bezier curve
  5440. * @param x2 Defines the x component of the end tangent in the bezier curve
  5441. * @param y2 Defines the y component of the end tangent in the bezier curve
  5442. */
  5443. constructor(
  5444. /** Defines the x component of the start tangent in the bezier curve */
  5445. x1?: number,
  5446. /** Defines the y component of the start tangent in the bezier curve */
  5447. y1?: number,
  5448. /** Defines the x component of the end tangent in the bezier curve */
  5449. x2?: number,
  5450. /** Defines the y component of the end tangent in the bezier curve */
  5451. y2?: number);
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. }
  5456. declare module BABYLON {
  5457. /**
  5458. * Class used to hold a RBG color
  5459. */
  5460. export class Color3 {
  5461. /**
  5462. * Defines the red component (between 0 and 1, default is 0)
  5463. */
  5464. r: number;
  5465. /**
  5466. * Defines the green component (between 0 and 1, default is 0)
  5467. */
  5468. g: number;
  5469. /**
  5470. * Defines the blue component (between 0 and 1, default is 0)
  5471. */
  5472. b: number;
  5473. /**
  5474. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5475. * @param r defines the red component (between 0 and 1, default is 0)
  5476. * @param g defines the green component (between 0 and 1, default is 0)
  5477. * @param b defines the blue component (between 0 and 1, default is 0)
  5478. */
  5479. constructor(
  5480. /**
  5481. * Defines the red component (between 0 and 1, default is 0)
  5482. */
  5483. r?: number,
  5484. /**
  5485. * Defines the green component (between 0 and 1, default is 0)
  5486. */
  5487. g?: number,
  5488. /**
  5489. * Defines the blue component (between 0 and 1, default is 0)
  5490. */
  5491. b?: number);
  5492. /**
  5493. * Creates a string with the Color3 current values
  5494. * @returns the string representation of the Color3 object
  5495. */
  5496. toString(): string;
  5497. /**
  5498. * Returns the string "Color3"
  5499. * @returns "Color3"
  5500. */
  5501. getClassName(): string;
  5502. /**
  5503. * Compute the Color3 hash code
  5504. * @returns an unique number that can be used to hash Color3 objects
  5505. */
  5506. getHashCode(): number;
  5507. /**
  5508. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5509. * @param array defines the array where to store the r,g,b components
  5510. * @param index defines an optional index in the target array to define where to start storing values
  5511. * @returns the current Color3 object
  5512. */
  5513. toArray(array: FloatArray, index?: number): Color3;
  5514. /**
  5515. * Returns a new Color4 object from the current Color3 and the given alpha
  5516. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5517. * @returns a new Color4 object
  5518. */
  5519. toColor4(alpha?: number): Color4;
  5520. /**
  5521. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5522. * @returns the new array
  5523. */
  5524. asArray(): number[];
  5525. /**
  5526. * Returns the luminance value
  5527. * @returns a float value
  5528. */
  5529. toLuminance(): number;
  5530. /**
  5531. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5532. * @param otherColor defines the second operand
  5533. * @returns the new Color3 object
  5534. */
  5535. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5536. /**
  5537. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5538. * @param otherColor defines the second operand
  5539. * @param result defines the Color3 object where to store the result
  5540. * @returns the current Color3
  5541. */
  5542. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5543. /**
  5544. * Determines equality between Color3 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgb values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color3>): boolean;
  5549. /**
  5550. * Determines equality between the current Color3 object and a set of r,b,g values
  5551. * @param r defines the red component to check
  5552. * @param g defines the green component to check
  5553. * @param b defines the blue component to check
  5554. * @returns true if the rgb values are equal to the given ones
  5555. */
  5556. equalsFloats(r: number, g: number, b: number): boolean;
  5557. /**
  5558. * Multiplies in place each rgb value by scale
  5559. * @param scale defines the scaling factor
  5560. * @returns the updated Color3
  5561. */
  5562. scale(scale: number): Color3;
  5563. /**
  5564. * Multiplies the rgb values by scale and stores the result into "result"
  5565. * @param scale defines the scaling factor
  5566. * @param result defines the Color3 object where to store the result
  5567. * @returns the unmodified current Color3
  5568. */
  5569. scaleToRef(scale: number, result: Color3): Color3;
  5570. /**
  5571. * Scale the current Color3 values by a factor and add the result to a given Color3
  5572. * @param scale defines the scale factor
  5573. * @param result defines color to store the result into
  5574. * @returns the unmodified current Color3
  5575. */
  5576. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5577. /**
  5578. * Clamps the rgb values by the min and max values and stores the result into "result"
  5579. * @param min defines minimum clamping value (default is 0)
  5580. * @param max defines maximum clamping value (default is 1)
  5581. * @param result defines color to store the result into
  5582. * @returns the original Color3
  5583. */
  5584. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5585. /**
  5586. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5587. * @param otherColor defines the second operand
  5588. * @returns the new Color3
  5589. */
  5590. add(otherColor: DeepImmutable<Color3>): Color3;
  5591. /**
  5592. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5593. * @param otherColor defines the second operand
  5594. * @param result defines Color3 object to store the result into
  5595. * @returns the unmodified current Color3
  5596. */
  5597. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5598. /**
  5599. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3
  5602. */
  5603. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines Color3 object to store the result into
  5608. * @returns the unmodified current Color3
  5609. */
  5610. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Copy the current object
  5613. * @returns a new Color3 copied the current one
  5614. */
  5615. clone(): Color3;
  5616. /**
  5617. * Copies the rgb values from the source in the current Color3
  5618. * @param source defines the source Color3 object
  5619. * @returns the updated Color3 object
  5620. */
  5621. copyFrom(source: DeepImmutable<Color3>): Color3;
  5622. /**
  5623. * Updates the Color3 rgb values from the given floats
  5624. * @param r defines the red component to read from
  5625. * @param g defines the green component to read from
  5626. * @param b defines the blue component to read from
  5627. * @returns the current Color3 object
  5628. */
  5629. copyFromFloats(r: number, g: number, b: number): Color3;
  5630. /**
  5631. * Updates the Color3 rgb values from the given floats
  5632. * @param r defines the red component to read from
  5633. * @param g defines the green component to read from
  5634. * @param b defines the blue component to read from
  5635. * @returns the current Color3 object
  5636. */
  5637. set(r: number, g: number, b: number): Color3;
  5638. /**
  5639. * Compute the Color3 hexadecimal code as a string
  5640. * @returns a string containing the hexadecimal representation of the Color3 object
  5641. */
  5642. toHexString(): string;
  5643. /**
  5644. * Computes a new Color3 converted from the current one to linear space
  5645. * @returns a new Color3 object
  5646. */
  5647. toLinearSpace(): Color3;
  5648. /**
  5649. * Converts current color in rgb space to HSV values
  5650. * @returns a new color3 representing the HSV values
  5651. */
  5652. toHSV(): Color3;
  5653. /**
  5654. * Converts current color in rgb space to HSV values
  5655. * @param result defines the Color3 where to store the HSV values
  5656. */
  5657. toHSVToRef(result: Color3): void;
  5658. /**
  5659. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5660. * @param convertedColor defines the Color3 object where to store the linear space version
  5661. * @returns the unmodified Color3
  5662. */
  5663. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5664. /**
  5665. * Computes a new Color3 converted from the current one to gamma space
  5666. * @returns a new Color3 object
  5667. */
  5668. toGammaSpace(): Color3;
  5669. /**
  5670. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5671. * @param convertedColor defines the Color3 object where to store the gamma space version
  5672. * @returns the unmodified Color3
  5673. */
  5674. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5675. private static _BlackReadOnly;
  5676. /**
  5677. * Convert Hue, saturation and value to a Color3 (RGB)
  5678. * @param hue defines the hue
  5679. * @param saturation defines the saturation
  5680. * @param value defines the value
  5681. * @param result defines the Color3 where to store the RGB values
  5682. */
  5683. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5684. /**
  5685. * Creates a new Color3 from the string containing valid hexadecimal values
  5686. * @param hex defines a string containing valid hexadecimal values
  5687. * @returns a new Color3 object
  5688. */
  5689. static FromHexString(hex: string): Color3;
  5690. /**
  5691. * Creates a new Color3 from the starting index of the given array
  5692. * @param array defines the source array
  5693. * @param offset defines an offset in the source array
  5694. * @returns a new Color3 object
  5695. */
  5696. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5697. /**
  5698. * Creates a new Color3 from integer values (< 256)
  5699. * @param r defines the red component to read from (value between 0 and 255)
  5700. * @param g defines the green component to read from (value between 0 and 255)
  5701. * @param b defines the blue component to read from (value between 0 and 255)
  5702. * @returns a new Color3 object
  5703. */
  5704. static FromInts(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5707. * @param start defines the start Color3 value
  5708. * @param end defines the end Color3 value
  5709. * @param amount defines the gradient value between start and end
  5710. * @returns a new Color3 object
  5711. */
  5712. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5713. /**
  5714. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5715. * @param left defines the start value
  5716. * @param right defines the end value
  5717. * @param amount defines the gradient factor
  5718. * @param result defines the Color3 object where to store the result
  5719. */
  5720. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5721. /**
  5722. * Returns a Color3 value containing a red color
  5723. * @returns a new Color3 object
  5724. */
  5725. static Red(): Color3;
  5726. /**
  5727. * Returns a Color3 value containing a green color
  5728. * @returns a new Color3 object
  5729. */
  5730. static Green(): Color3;
  5731. /**
  5732. * Returns a Color3 value containing a blue color
  5733. * @returns a new Color3 object
  5734. */
  5735. static Blue(): Color3;
  5736. /**
  5737. * Returns a Color3 value containing a black color
  5738. * @returns a new Color3 object
  5739. */
  5740. static Black(): Color3;
  5741. /**
  5742. * Gets a Color3 value containing a black color that must not be updated
  5743. */
  5744. static get BlackReadOnly(): DeepImmutable<Color3>;
  5745. /**
  5746. * Returns a Color3 value containing a white color
  5747. * @returns a new Color3 object
  5748. */
  5749. static White(): Color3;
  5750. /**
  5751. * Returns a Color3 value containing a purple color
  5752. * @returns a new Color3 object
  5753. */
  5754. static Purple(): Color3;
  5755. /**
  5756. * Returns a Color3 value containing a magenta color
  5757. * @returns a new Color3 object
  5758. */
  5759. static Magenta(): Color3;
  5760. /**
  5761. * Returns a Color3 value containing a yellow color
  5762. * @returns a new Color3 object
  5763. */
  5764. static Yellow(): Color3;
  5765. /**
  5766. * Returns a Color3 value containing a gray color
  5767. * @returns a new Color3 object
  5768. */
  5769. static Gray(): Color3;
  5770. /**
  5771. * Returns a Color3 value containing a teal color
  5772. * @returns a new Color3 object
  5773. */
  5774. static Teal(): Color3;
  5775. /**
  5776. * Returns a Color3 value containing a random color
  5777. * @returns a new Color3 object
  5778. */
  5779. static Random(): Color3;
  5780. }
  5781. /**
  5782. * Class used to hold a RBGA color
  5783. */
  5784. export class Color4 {
  5785. /**
  5786. * Defines the red component (between 0 and 1, default is 0)
  5787. */
  5788. r: number;
  5789. /**
  5790. * Defines the green component (between 0 and 1, default is 0)
  5791. */
  5792. g: number;
  5793. /**
  5794. * Defines the blue component (between 0 and 1, default is 0)
  5795. */
  5796. b: number;
  5797. /**
  5798. * Defines the alpha component (between 0 and 1, default is 1)
  5799. */
  5800. a: number;
  5801. /**
  5802. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5803. * @param r defines the red component (between 0 and 1, default is 0)
  5804. * @param g defines the green component (between 0 and 1, default is 0)
  5805. * @param b defines the blue component (between 0 and 1, default is 0)
  5806. * @param a defines the alpha component (between 0 and 1, default is 1)
  5807. */
  5808. constructor(
  5809. /**
  5810. * Defines the red component (between 0 and 1, default is 0)
  5811. */
  5812. r?: number,
  5813. /**
  5814. * Defines the green component (between 0 and 1, default is 0)
  5815. */
  5816. g?: number,
  5817. /**
  5818. * Defines the blue component (between 0 and 1, default is 0)
  5819. */
  5820. b?: number,
  5821. /**
  5822. * Defines the alpha component (between 0 and 1, default is 1)
  5823. */
  5824. a?: number);
  5825. /**
  5826. * Adds in place the given Color4 values to the current Color4 object
  5827. * @param right defines the second operand
  5828. * @returns the current updated Color4 object
  5829. */
  5830. addInPlace(right: DeepImmutable<Color4>): Color4;
  5831. /**
  5832. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5833. * @returns the new array
  5834. */
  5835. asArray(): number[];
  5836. /**
  5837. * Stores from the starting index in the given array the Color4 successive values
  5838. * @param array defines the array where to store the r,g,b components
  5839. * @param index defines an optional index in the target array to define where to start storing values
  5840. * @returns the current Color4 object
  5841. */
  5842. toArray(array: number[], index?: number): Color4;
  5843. /**
  5844. * Determines equality between Color4 objects
  5845. * @param otherColor defines the second operand
  5846. * @returns true if the rgba values are equal to the given ones
  5847. */
  5848. equals(otherColor: DeepImmutable<Color4>): boolean;
  5849. /**
  5850. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5851. * @param right defines the second operand
  5852. * @returns a new Color4 object
  5853. */
  5854. add(right: DeepImmutable<Color4>): Color4;
  5855. /**
  5856. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5857. * @param right defines the second operand
  5858. * @returns a new Color4 object
  5859. */
  5860. subtract(right: DeepImmutable<Color4>): Color4;
  5861. /**
  5862. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5863. * @param right defines the second operand
  5864. * @param result defines the Color4 object where to store the result
  5865. * @returns the current Color4 object
  5866. */
  5867. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5868. /**
  5869. * Creates a new Color4 with the current Color4 values multiplied by scale
  5870. * @param scale defines the scaling factor to apply
  5871. * @returns a new Color4 object
  5872. */
  5873. scale(scale: number): Color4;
  5874. /**
  5875. * Multiplies the current Color4 values by scale and stores the result in "result"
  5876. * @param scale defines the scaling factor to apply
  5877. * @param result defines the Color4 object where to store the result
  5878. * @returns the current unmodified Color4
  5879. */
  5880. scaleToRef(scale: number, result: Color4): Color4;
  5881. /**
  5882. * Scale the current Color4 values by a factor and add the result to a given Color4
  5883. * @param scale defines the scale factor
  5884. * @param result defines the Color4 object where to store the result
  5885. * @returns the unmodified current Color4
  5886. */
  5887. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5888. /**
  5889. * Clamps the rgb values by the min and max values and stores the result into "result"
  5890. * @param min defines minimum clamping value (default is 0)
  5891. * @param max defines maximum clamping value (default is 1)
  5892. * @param result defines color to store the result into.
  5893. * @returns the cuurent Color4
  5894. */
  5895. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5896. /**
  5897. * Multipy an Color4 value by another and return a new Color4 object
  5898. * @param color defines the Color4 value to multiply by
  5899. * @returns a new Color4 object
  5900. */
  5901. multiply(color: Color4): Color4;
  5902. /**
  5903. * Multipy a Color4 value by another and push the result in a reference value
  5904. * @param color defines the Color4 value to multiply by
  5905. * @param result defines the Color4 to fill the result in
  5906. * @returns the result Color4
  5907. */
  5908. multiplyToRef(color: Color4, result: Color4): Color4;
  5909. /**
  5910. * Creates a string with the Color4 current values
  5911. * @returns the string representation of the Color4 object
  5912. */
  5913. toString(): string;
  5914. /**
  5915. * Returns the string "Color4"
  5916. * @returns "Color4"
  5917. */
  5918. getClassName(): string;
  5919. /**
  5920. * Compute the Color4 hash code
  5921. * @returns an unique number that can be used to hash Color4 objects
  5922. */
  5923. getHashCode(): number;
  5924. /**
  5925. * Creates a new Color4 copied from the current one
  5926. * @returns a new Color4 object
  5927. */
  5928. clone(): Color4;
  5929. /**
  5930. * Copies the given Color4 values into the current one
  5931. * @param source defines the source Color4 object
  5932. * @returns the current updated Color4 object
  5933. */
  5934. copyFrom(source: Color4): Color4;
  5935. /**
  5936. * Copies the given float values into the current one
  5937. * @param r defines the red component to read from
  5938. * @param g defines the green component to read from
  5939. * @param b defines the blue component to read from
  5940. * @param a defines the alpha component to read from
  5941. * @returns the current updated Color4 object
  5942. */
  5943. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5944. /**
  5945. * Copies the given float values into the current one
  5946. * @param r defines the red component to read from
  5947. * @param g defines the green component to read from
  5948. * @param b defines the blue component to read from
  5949. * @param a defines the alpha component to read from
  5950. * @returns the current updated Color4 object
  5951. */
  5952. set(r: number, g: number, b: number, a: number): Color4;
  5953. /**
  5954. * Compute the Color4 hexadecimal code as a string
  5955. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5956. * @returns a string containing the hexadecimal representation of the Color4 object
  5957. */
  5958. toHexString(returnAsColor3?: boolean): string;
  5959. /**
  5960. * Computes a new Color4 converted from the current one to linear space
  5961. * @returns a new Color4 object
  5962. */
  5963. toLinearSpace(): Color4;
  5964. /**
  5965. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5966. * @param convertedColor defines the Color4 object where to store the linear space version
  5967. * @returns the unmodified Color4
  5968. */
  5969. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5970. /**
  5971. * Computes a new Color4 converted from the current one to gamma space
  5972. * @returns a new Color4 object
  5973. */
  5974. toGammaSpace(): Color4;
  5975. /**
  5976. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5977. * @param convertedColor defines the Color4 object where to store the gamma space version
  5978. * @returns the unmodified Color4
  5979. */
  5980. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5981. /**
  5982. * Creates a new Color4 from the string containing valid hexadecimal values
  5983. * @param hex defines a string containing valid hexadecimal values
  5984. * @returns a new Color4 object
  5985. */
  5986. static FromHexString(hex: string): Color4;
  5987. /**
  5988. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5989. * @param left defines the start value
  5990. * @param right defines the end value
  5991. * @param amount defines the gradient factor
  5992. * @returns a new Color4 object
  5993. */
  5994. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5995. /**
  5996. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5997. * @param left defines the start value
  5998. * @param right defines the end value
  5999. * @param amount defines the gradient factor
  6000. * @param result defines the Color4 object where to store data
  6001. */
  6002. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6003. /**
  6004. * Creates a new Color4 from a Color3 and an alpha value
  6005. * @param color3 defines the source Color3 to read from
  6006. * @param alpha defines the alpha component (1.0 by default)
  6007. * @returns a new Color4 object
  6008. */
  6009. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6010. /**
  6011. * Creates a new Color4 from the starting index element of the given array
  6012. * @param array defines the source array to read from
  6013. * @param offset defines the offset in the source array
  6014. * @returns a new Color4 object
  6015. */
  6016. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6017. /**
  6018. * Creates a new Color3 from integer values (< 256)
  6019. * @param r defines the red component to read from (value between 0 and 255)
  6020. * @param g defines the green component to read from (value between 0 and 255)
  6021. * @param b defines the blue component to read from (value between 0 and 255)
  6022. * @param a defines the alpha component to read from (value between 0 and 255)
  6023. * @returns a new Color3 object
  6024. */
  6025. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Check the content of a given array and convert it to an array containing RGBA data
  6028. * If the original array was already containing count * 4 values then it is returned directly
  6029. * @param colors defines the array to check
  6030. * @param count defines the number of RGBA data to expect
  6031. * @returns an array containing count * 4 values (RGBA)
  6032. */
  6033. static CheckColors4(colors: number[], count: number): number[];
  6034. }
  6035. /**
  6036. * @hidden
  6037. */
  6038. export class TmpColors {
  6039. static Color3: Color3[];
  6040. static Color4: Color4[];
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * Defines an interface which represents an animation key frame
  6046. */
  6047. export interface IAnimationKey {
  6048. /**
  6049. * Frame of the key frame
  6050. */
  6051. frame: number;
  6052. /**
  6053. * Value at the specifies key frame
  6054. */
  6055. value: any;
  6056. /**
  6057. * The input tangent for the cubic hermite spline
  6058. */
  6059. inTangent?: any;
  6060. /**
  6061. * The output tangent for the cubic hermite spline
  6062. */
  6063. outTangent?: any;
  6064. /**
  6065. * The animation interpolation type
  6066. */
  6067. interpolation?: AnimationKeyInterpolation;
  6068. }
  6069. /**
  6070. * Enum for the animation key frame interpolation type
  6071. */
  6072. export enum AnimationKeyInterpolation {
  6073. /**
  6074. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6075. */
  6076. STEP = 1
  6077. }
  6078. }
  6079. declare module BABYLON {
  6080. /**
  6081. * Represents the range of an animation
  6082. */
  6083. export class AnimationRange {
  6084. /**The name of the animation range**/
  6085. name: string;
  6086. /**The starting frame of the animation */
  6087. from: number;
  6088. /**The ending frame of the animation*/
  6089. to: number;
  6090. /**
  6091. * Initializes the range of an animation
  6092. * @param name The name of the animation range
  6093. * @param from The starting frame of the animation
  6094. * @param to The ending frame of the animation
  6095. */
  6096. constructor(
  6097. /**The name of the animation range**/
  6098. name: string,
  6099. /**The starting frame of the animation */
  6100. from: number,
  6101. /**The ending frame of the animation*/
  6102. to: number);
  6103. /**
  6104. * Makes a copy of the animation range
  6105. * @returns A copy of the animation range
  6106. */
  6107. clone(): AnimationRange;
  6108. }
  6109. }
  6110. declare module BABYLON {
  6111. /**
  6112. * Composed of a frame, and an action function
  6113. */
  6114. export class AnimationEvent {
  6115. /** The frame for which the event is triggered **/
  6116. frame: number;
  6117. /** The event to perform when triggered **/
  6118. action: (currentFrame: number) => void;
  6119. /** Specifies if the event should be triggered only once**/
  6120. onlyOnce?: boolean | undefined;
  6121. /**
  6122. * Specifies if the animation event is done
  6123. */
  6124. isDone: boolean;
  6125. /**
  6126. * Initializes the animation event
  6127. * @param frame The frame for which the event is triggered
  6128. * @param action The event to perform when triggered
  6129. * @param onlyOnce Specifies if the event should be triggered only once
  6130. */
  6131. constructor(
  6132. /** The frame for which the event is triggered **/
  6133. frame: number,
  6134. /** The event to perform when triggered **/
  6135. action: (currentFrame: number) => void,
  6136. /** Specifies if the event should be triggered only once**/
  6137. onlyOnce?: boolean | undefined);
  6138. /** @hidden */
  6139. _clone(): AnimationEvent;
  6140. }
  6141. }
  6142. declare module BABYLON {
  6143. /**
  6144. * Interface used to define a behavior
  6145. */
  6146. export interface Behavior<T> {
  6147. /** gets or sets behavior's name */
  6148. name: string;
  6149. /**
  6150. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6151. */
  6152. init(): void;
  6153. /**
  6154. * Called when the behavior is attached to a target
  6155. * @param target defines the target where the behavior is attached to
  6156. */
  6157. attach(target: T): void;
  6158. /**
  6159. * Called when the behavior is detached from its target
  6160. */
  6161. detach(): void;
  6162. }
  6163. /**
  6164. * Interface implemented by classes supporting behaviors
  6165. */
  6166. export interface IBehaviorAware<T> {
  6167. /**
  6168. * Attach a behavior
  6169. * @param behavior defines the behavior to attach
  6170. * @returns the current host
  6171. */
  6172. addBehavior(behavior: Behavior<T>): T;
  6173. /**
  6174. * Remove a behavior from the current object
  6175. * @param behavior defines the behavior to detach
  6176. * @returns the current host
  6177. */
  6178. removeBehavior(behavior: Behavior<T>): T;
  6179. /**
  6180. * Gets a behavior using its name to search
  6181. * @param name defines the name to search
  6182. * @returns the behavior or null if not found
  6183. */
  6184. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Defines an array and its length.
  6190. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6191. */
  6192. export interface ISmartArrayLike<T> {
  6193. /**
  6194. * The data of the array.
  6195. */
  6196. data: Array<T>;
  6197. /**
  6198. * The active length of the array.
  6199. */
  6200. length: number;
  6201. }
  6202. /**
  6203. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6204. */
  6205. export class SmartArray<T> implements ISmartArrayLike<T> {
  6206. /**
  6207. * The full set of data from the array.
  6208. */
  6209. data: Array<T>;
  6210. /**
  6211. * The active length of the array.
  6212. */
  6213. length: number;
  6214. protected _id: number;
  6215. /**
  6216. * Instantiates a Smart Array.
  6217. * @param capacity defines the default capacity of the array.
  6218. */
  6219. constructor(capacity: number);
  6220. /**
  6221. * Pushes a value at the end of the active data.
  6222. * @param value defines the object to push in the array.
  6223. */
  6224. push(value: T): void;
  6225. /**
  6226. * Iterates over the active data and apply the lambda to them.
  6227. * @param func defines the action to apply on each value.
  6228. */
  6229. forEach(func: (content: T) => void): void;
  6230. /**
  6231. * Sorts the full sets of data.
  6232. * @param compareFn defines the comparison function to apply.
  6233. */
  6234. sort(compareFn: (a: T, b: T) => number): void;
  6235. /**
  6236. * Resets the active data to an empty array.
  6237. */
  6238. reset(): void;
  6239. /**
  6240. * Releases all the data from the array as well as the array.
  6241. */
  6242. dispose(): void;
  6243. /**
  6244. * Concats the active data with a given array.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concat(array: any): void;
  6248. /**
  6249. * Returns the position of a value in the active data.
  6250. * @param value defines the value to find the index for
  6251. * @returns the index if found in the active data otherwise -1
  6252. */
  6253. indexOf(value: T): number;
  6254. /**
  6255. * Returns whether an element is part of the active data.
  6256. * @param value defines the value to look for
  6257. * @returns true if found in the active data otherwise false
  6258. */
  6259. contains(value: T): boolean;
  6260. private static _GlobalId;
  6261. }
  6262. /**
  6263. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6264. * The data in this array can only be present once
  6265. */
  6266. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6267. private _duplicateId;
  6268. /**
  6269. * Pushes a value at the end of the active data.
  6270. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Pushes a value at the end of the active data.
  6276. * If the data is already present, it won t be added again
  6277. * @param value defines the object to push in the array.
  6278. * @returns true if added false if it was already present
  6279. */
  6280. pushNoDuplicate(value: T): boolean;
  6281. /**
  6282. * Resets the active data to an empty array.
  6283. */
  6284. reset(): void;
  6285. /**
  6286. * Concats the active data with a given array.
  6287. * This ensures no dupplicate will be present in the result.
  6288. * @param array defines the data to concatenate with.
  6289. */
  6290. concatWithNoDuplicate(array: any): void;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. /**
  6295. * @ignore
  6296. * This is a list of all the different input types that are available in the application.
  6297. * Fo instance: ArcRotateCameraGamepadInput...
  6298. */
  6299. export var CameraInputTypes: {};
  6300. /**
  6301. * This is the contract to implement in order to create a new input class.
  6302. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6303. */
  6304. export interface ICameraInput<TCamera extends Camera> {
  6305. /**
  6306. * Defines the camera the input is attached to.
  6307. */
  6308. camera: Nullable<TCamera>;
  6309. /**
  6310. * Gets the class name of the current intput.
  6311. * @returns the class name
  6312. */
  6313. getClassName(): string;
  6314. /**
  6315. * Get the friendly name associated with the input class.
  6316. * @returns the input friendly name
  6317. */
  6318. getSimpleName(): string;
  6319. /**
  6320. * Attach the input controls to a specific dom element to get the input from.
  6321. * @param element Defines the element the controls should be listened from
  6322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6325. /**
  6326. * Detach the current controls from the specified dom element.
  6327. * @param element Defines the element to stop listening the inputs from
  6328. */
  6329. detachControl(element: Nullable<HTMLElement>): void;
  6330. /**
  6331. * Update the current camera state depending on the inputs that have been used this frame.
  6332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6333. */
  6334. checkInputs?: () => void;
  6335. }
  6336. /**
  6337. * Represents a map of input types to input instance or input index to input instance.
  6338. */
  6339. export interface CameraInputsMap<TCamera extends Camera> {
  6340. /**
  6341. * Accessor to the input by input type.
  6342. */
  6343. [name: string]: ICameraInput<TCamera>;
  6344. /**
  6345. * Accessor to the input by input index.
  6346. */
  6347. [idx: number]: ICameraInput<TCamera>;
  6348. }
  6349. /**
  6350. * This represents the input manager used within a camera.
  6351. * It helps dealing with all the different kind of input attached to a camera.
  6352. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6353. */
  6354. export class CameraInputsManager<TCamera extends Camera> {
  6355. /**
  6356. * Defines the list of inputs attahed to the camera.
  6357. */
  6358. attached: CameraInputsMap<TCamera>;
  6359. /**
  6360. * Defines the dom element the camera is collecting inputs from.
  6361. * This is null if the controls have not been attached.
  6362. */
  6363. attachedElement: Nullable<HTMLElement>;
  6364. /**
  6365. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6366. */
  6367. noPreventDefault: boolean;
  6368. /**
  6369. * Defined the camera the input manager belongs to.
  6370. */
  6371. camera: TCamera;
  6372. /**
  6373. * Update the current camera state depending on the inputs that have been used this frame.
  6374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6375. */
  6376. checkInputs: () => void;
  6377. /**
  6378. * Instantiate a new Camera Input Manager.
  6379. * @param camera Defines the camera the input manager blongs to
  6380. */
  6381. constructor(camera: TCamera);
  6382. /**
  6383. * Add an input method to a camera
  6384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6385. * @param input camera input method
  6386. */
  6387. add(input: ICameraInput<TCamera>): void;
  6388. /**
  6389. * Remove a specific input method from a camera
  6390. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6391. * @param inputToRemove camera input method
  6392. */
  6393. remove(inputToRemove: ICameraInput<TCamera>): void;
  6394. /**
  6395. * Remove a specific input type from a camera
  6396. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6397. * @param inputType the type of the input to remove
  6398. */
  6399. removeByType(inputType: string): void;
  6400. private _addCheckInputs;
  6401. /**
  6402. * Attach the input controls to the currently attached dom element to listen the events from.
  6403. * @param input Defines the input to attach
  6404. */
  6405. attachInput(input: ICameraInput<TCamera>): void;
  6406. /**
  6407. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6408. * @param element Defines the dom element to collect the events 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. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6412. /**
  6413. * Detach the current manager inputs controls from a specific dom element.
  6414. * @param element Defines the dom element to collect the events from
  6415. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6416. */
  6417. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6418. /**
  6419. * Rebuild the dynamic inputCheck function from the current list of
  6420. * defined inputs in the manager.
  6421. */
  6422. rebuildInputCheck(): void;
  6423. /**
  6424. * Remove all attached input methods from a camera
  6425. */
  6426. clear(): void;
  6427. /**
  6428. * Serialize the current input manager attached to a camera.
  6429. * This ensures than once parsed,
  6430. * the input associated to the camera will be identical to the current ones
  6431. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6432. */
  6433. serialize(serializedCamera: any): void;
  6434. /**
  6435. * Parses an input manager serialized JSON to restore the previous list of inputs
  6436. * and states associated to a camera.
  6437. * @param parsedCamera Defines the JSON to parse
  6438. */
  6439. parse(parsedCamera: any): void;
  6440. }
  6441. }
  6442. declare module BABYLON {
  6443. /**
  6444. * Class used to store data that will be store in GPU memory
  6445. */
  6446. export class Buffer {
  6447. private _engine;
  6448. private _buffer;
  6449. /** @hidden */
  6450. _data: Nullable<DataArray>;
  6451. private _updatable;
  6452. private _instanced;
  6453. private _divisor;
  6454. /**
  6455. * Gets the byte stride.
  6456. */
  6457. readonly byteStride: number;
  6458. /**
  6459. * Constructor
  6460. * @param engine the engine
  6461. * @param data the data to use for this buffer
  6462. * @param updatable whether the data is updatable
  6463. * @param stride the stride (optional)
  6464. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6465. * @param instanced whether the buffer is instanced (optional)
  6466. * @param useBytes set to true if the stride in in bytes (optional)
  6467. * @param divisor sets an optional divisor for instances (1 by default)
  6468. */
  6469. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6470. /**
  6471. * Create a new VertexBuffer based on the current buffer
  6472. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6473. * @param offset defines offset in the buffer (0 by default)
  6474. * @param size defines the size in floats of attributes (position is 3 for instance)
  6475. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6476. * @param instanced defines if the vertex buffer contains indexed data
  6477. * @param useBytes defines if the offset and stride are in bytes *
  6478. * @param divisor sets an optional divisor for instances (1 by default)
  6479. * @returns the new vertex buffer
  6480. */
  6481. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6482. /**
  6483. * Gets a boolean indicating if the Buffer is updatable?
  6484. * @returns true if the buffer is updatable
  6485. */
  6486. isUpdatable(): boolean;
  6487. /**
  6488. * Gets current buffer's data
  6489. * @returns a DataArray or null
  6490. */
  6491. getData(): Nullable<DataArray>;
  6492. /**
  6493. * Gets underlying native buffer
  6494. * @returns underlying native buffer
  6495. */
  6496. getBuffer(): Nullable<DataBuffer>;
  6497. /**
  6498. * Gets the stride in float32 units (i.e. byte stride / 4).
  6499. * May not be an integer if the byte stride is not divisible by 4.
  6500. * @returns the stride in float32 units
  6501. * @deprecated Please use byteStride instead.
  6502. */
  6503. getStrideSize(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: Nullable<DataArray>): void;
  6509. /** @hidden */
  6510. _rebuild(): void;
  6511. /**
  6512. * Update current buffer data
  6513. * @param data defines the data to store
  6514. */
  6515. update(data: DataArray): void;
  6516. /**
  6517. * Updates the data directly.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param vertexCount the vertex count (optional)
  6521. * @param useBytes set to true if the offset is in bytes
  6522. */
  6523. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6524. /**
  6525. * Release all resources
  6526. */
  6527. dispose(): void;
  6528. }
  6529. /**
  6530. * Specialized buffer used to store vertex data
  6531. */
  6532. export class VertexBuffer {
  6533. /** @hidden */
  6534. _buffer: Buffer;
  6535. private _kind;
  6536. private _size;
  6537. private _ownsBuffer;
  6538. private _instanced;
  6539. private _instanceDivisor;
  6540. /**
  6541. * The byte type.
  6542. */
  6543. static readonly BYTE: number;
  6544. /**
  6545. * The unsigned byte type.
  6546. */
  6547. static readonly UNSIGNED_BYTE: number;
  6548. /**
  6549. * The short type.
  6550. */
  6551. static readonly SHORT: number;
  6552. /**
  6553. * The unsigned short type.
  6554. */
  6555. static readonly UNSIGNED_SHORT: number;
  6556. /**
  6557. * The integer type.
  6558. */
  6559. static readonly INT: number;
  6560. /**
  6561. * The unsigned integer type.
  6562. */
  6563. static readonly UNSIGNED_INT: number;
  6564. /**
  6565. * The float type.
  6566. */
  6567. static readonly FLOAT: number;
  6568. /**
  6569. * Gets or sets the instance divisor when in instanced mode
  6570. */
  6571. get instanceDivisor(): number;
  6572. set instanceDivisor(value: number);
  6573. /**
  6574. * Gets the byte stride.
  6575. */
  6576. readonly byteStride: number;
  6577. /**
  6578. * Gets the byte offset.
  6579. */
  6580. readonly byteOffset: number;
  6581. /**
  6582. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6583. */
  6584. readonly normalized: boolean;
  6585. /**
  6586. * Gets the data type of each component in the array.
  6587. */
  6588. readonly type: number;
  6589. /**
  6590. * Constructor
  6591. * @param engine the engine
  6592. * @param data the data to use for this vertex buffer
  6593. * @param kind the vertex buffer kind
  6594. * @param updatable whether the data is updatable
  6595. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6596. * @param stride the stride (optional)
  6597. * @param instanced whether the buffer is instanced (optional)
  6598. * @param offset the offset of the data (optional)
  6599. * @param size the number of components (optional)
  6600. * @param type the type of the component (optional)
  6601. * @param normalized whether the data contains normalized data (optional)
  6602. * @param useBytes set to true if stride and offset are in bytes (optional)
  6603. * @param divisor defines the instance divisor to use (1 by default)
  6604. */
  6605. 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);
  6606. /** @hidden */
  6607. _rebuild(): void;
  6608. /**
  6609. * Returns the kind of the VertexBuffer (string)
  6610. * @returns a string
  6611. */
  6612. getKind(): string;
  6613. /**
  6614. * Gets a boolean indicating if the VertexBuffer is updatable?
  6615. * @returns true if the buffer is updatable
  6616. */
  6617. isUpdatable(): boolean;
  6618. /**
  6619. * Gets current buffer's data
  6620. * @returns a DataArray or null
  6621. */
  6622. getData(): Nullable<DataArray>;
  6623. /**
  6624. * Gets underlying native buffer
  6625. * @returns underlying native buffer
  6626. */
  6627. getBuffer(): Nullable<DataBuffer>;
  6628. /**
  6629. * Gets the stride in float32 units (i.e. byte stride / 4).
  6630. * May not be an integer if the byte stride is not divisible by 4.
  6631. * @returns the stride in float32 units
  6632. * @deprecated Please use byteStride instead.
  6633. */
  6634. getStrideSize(): number;
  6635. /**
  6636. * Returns the offset as a multiple of the type byte length.
  6637. * @returns the offset in bytes
  6638. * @deprecated Please use byteOffset instead.
  6639. */
  6640. getOffset(): number;
  6641. /**
  6642. * Returns the number of components per vertex attribute (integer)
  6643. * @returns the size in float
  6644. */
  6645. getSize(): number;
  6646. /**
  6647. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6648. * @returns true if this buffer is instanced
  6649. */
  6650. getIsInstanced(): boolean;
  6651. /**
  6652. * Returns the instancing divisor, zero for non-instanced (integer).
  6653. * @returns a number
  6654. */
  6655. getInstanceDivisor(): number;
  6656. /**
  6657. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6658. * @param data defines the data to store
  6659. */
  6660. create(data?: DataArray): void;
  6661. /**
  6662. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6663. * This function will create a new buffer if the current one is not updatable
  6664. * @param data defines the data to store
  6665. */
  6666. update(data: DataArray): void;
  6667. /**
  6668. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6669. * Returns the directly updated WebGLBuffer.
  6670. * @param data the new data
  6671. * @param offset the new offset
  6672. * @param useBytes set to true if the offset is in bytes
  6673. */
  6674. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6675. /**
  6676. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6677. */
  6678. dispose(): void;
  6679. /**
  6680. * Enumerates each value of this vertex buffer as numbers.
  6681. * @param count the number of values to enumerate
  6682. * @param callback the callback function called for each value
  6683. */
  6684. forEach(count: number, callback: (value: number, index: number) => void): void;
  6685. /**
  6686. * Positions
  6687. */
  6688. static readonly PositionKind: string;
  6689. /**
  6690. * Normals
  6691. */
  6692. static readonly NormalKind: string;
  6693. /**
  6694. * Tangents
  6695. */
  6696. static readonly TangentKind: string;
  6697. /**
  6698. * Texture coordinates
  6699. */
  6700. static readonly UVKind: string;
  6701. /**
  6702. * Texture coordinates 2
  6703. */
  6704. static readonly UV2Kind: string;
  6705. /**
  6706. * Texture coordinates 3
  6707. */
  6708. static readonly UV3Kind: string;
  6709. /**
  6710. * Texture coordinates 4
  6711. */
  6712. static readonly UV4Kind: string;
  6713. /**
  6714. * Texture coordinates 5
  6715. */
  6716. static readonly UV5Kind: string;
  6717. /**
  6718. * Texture coordinates 6
  6719. */
  6720. static readonly UV6Kind: string;
  6721. /**
  6722. * Colors
  6723. */
  6724. static readonly ColorKind: string;
  6725. /**
  6726. * Matrix indices (for bones)
  6727. */
  6728. static readonly MatricesIndicesKind: string;
  6729. /**
  6730. * Matrix weights (for bones)
  6731. */
  6732. static readonly MatricesWeightsKind: string;
  6733. /**
  6734. * Additional matrix indices (for bones)
  6735. */
  6736. static readonly MatricesIndicesExtraKind: string;
  6737. /**
  6738. * Additional matrix weights (for bones)
  6739. */
  6740. static readonly MatricesWeightsExtraKind: string;
  6741. /**
  6742. * Deduces the stride given a kind.
  6743. * @param kind The kind string to deduce
  6744. * @returns The deduced stride
  6745. */
  6746. static DeduceStride(kind: string): number;
  6747. /**
  6748. * Gets the byte length of the given type.
  6749. * @param type the type
  6750. * @returns the number of bytes
  6751. */
  6752. static GetTypeByteLength(type: number): number;
  6753. /**
  6754. * Enumerates each value of the given parameters as numbers.
  6755. * @param data the data to enumerate
  6756. * @param byteOffset the byte offset of the data
  6757. * @param byteStride the byte stride of the data
  6758. * @param componentCount the number of components per element
  6759. * @param componentType the type of the component
  6760. * @param count the number of values to enumerate
  6761. * @param normalized whether the data is normalized
  6762. * @param callback the callback function called for each value
  6763. */
  6764. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6765. private static _GetFloatValue;
  6766. }
  6767. }
  6768. declare module BABYLON {
  6769. /**
  6770. * @hidden
  6771. */
  6772. export class IntersectionInfo {
  6773. bu: Nullable<number>;
  6774. bv: Nullable<number>;
  6775. distance: number;
  6776. faceId: number;
  6777. subMeshId: number;
  6778. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6779. }
  6780. }
  6781. declare module BABYLON {
  6782. /**
  6783. * Class used to store bounding sphere information
  6784. */
  6785. export class BoundingSphere {
  6786. /**
  6787. * Gets the center of the bounding sphere in local space
  6788. */
  6789. readonly center: Vector3;
  6790. /**
  6791. * Radius of the bounding sphere in local space
  6792. */
  6793. radius: number;
  6794. /**
  6795. * Gets the center of the bounding sphere in world space
  6796. */
  6797. readonly centerWorld: Vector3;
  6798. /**
  6799. * Radius of the bounding sphere in world space
  6800. */
  6801. radiusWorld: number;
  6802. /**
  6803. * Gets the minimum vector in local space
  6804. */
  6805. readonly minimum: Vector3;
  6806. /**
  6807. * Gets the maximum vector in local space
  6808. */
  6809. readonly maximum: Vector3;
  6810. private _worldMatrix;
  6811. private static readonly TmpVector3;
  6812. /**
  6813. * Creates a new bounding sphere
  6814. * @param min defines the minimum vector (in local space)
  6815. * @param max defines the maximum vector (in local space)
  6816. * @param worldMatrix defines the new world matrix
  6817. */
  6818. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6819. /**
  6820. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6821. * @param min defines the new minimum vector (in local space)
  6822. * @param max defines the new maximum vector (in local space)
  6823. * @param worldMatrix defines the new world matrix
  6824. */
  6825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6826. /**
  6827. * Scale the current bounding sphere by applying a scale factor
  6828. * @param factor defines the scale factor to apply
  6829. * @returns the current bounding box
  6830. */
  6831. scale(factor: number): BoundingSphere;
  6832. /**
  6833. * Gets the world matrix of the bounding box
  6834. * @returns a matrix
  6835. */
  6836. getWorldMatrix(): DeepImmutable<Matrix>;
  6837. /** @hidden */
  6838. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Tests if the bounding sphere is intersecting the frustum planes
  6841. * @param frustumPlanes defines the frustum planes to test
  6842. * @returns true if there is an intersection
  6843. */
  6844. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6845. /**
  6846. * Tests if the bounding sphere center is in between the frustum planes.
  6847. * Used for optimistic fast inclusion.
  6848. * @param frustumPlanes defines the frustum planes to test
  6849. * @returns true if the sphere center is in between the frustum planes
  6850. */
  6851. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6852. /**
  6853. * Tests if a point is inside the bounding sphere
  6854. * @param point defines the point to test
  6855. * @returns true if the point is inside the bounding sphere
  6856. */
  6857. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6858. /**
  6859. * Checks if two sphere intersct
  6860. * @param sphere0 sphere 0
  6861. * @param sphere1 sphere 1
  6862. * @returns true if the speres intersect
  6863. */
  6864. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6865. }
  6866. }
  6867. declare module BABYLON {
  6868. /**
  6869. * Class used to store bounding box information
  6870. */
  6871. export class BoundingBox implements ICullable {
  6872. /**
  6873. * Gets the 8 vectors representing the bounding box in local space
  6874. */
  6875. readonly vectors: Vector3[];
  6876. /**
  6877. * Gets the center of the bounding box in local space
  6878. */
  6879. readonly center: Vector3;
  6880. /**
  6881. * Gets the center of the bounding box in world space
  6882. */
  6883. readonly centerWorld: Vector3;
  6884. /**
  6885. * Gets the extend size in local space
  6886. */
  6887. readonly extendSize: Vector3;
  6888. /**
  6889. * Gets the extend size in world space
  6890. */
  6891. readonly extendSizeWorld: Vector3;
  6892. /**
  6893. * Gets the OBB (object bounding box) directions
  6894. */
  6895. readonly directions: Vector3[];
  6896. /**
  6897. * Gets the 8 vectors representing the bounding box in world space
  6898. */
  6899. readonly vectorsWorld: Vector3[];
  6900. /**
  6901. * Gets the minimum vector in world space
  6902. */
  6903. readonly minimumWorld: Vector3;
  6904. /**
  6905. * Gets the maximum vector in world space
  6906. */
  6907. readonly maximumWorld: Vector3;
  6908. /**
  6909. * Gets the minimum vector in local space
  6910. */
  6911. readonly minimum: Vector3;
  6912. /**
  6913. * Gets the maximum vector in local space
  6914. */
  6915. readonly maximum: Vector3;
  6916. private _worldMatrix;
  6917. private static readonly TmpVector3;
  6918. /**
  6919. * @hidden
  6920. */
  6921. _tag: number;
  6922. /**
  6923. * Creates a new bounding box
  6924. * @param min defines the minimum vector (in local space)
  6925. * @param max defines the maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6929. /**
  6930. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6931. * @param min defines the new minimum vector (in local space)
  6932. * @param max defines the new maximum vector (in local space)
  6933. * @param worldMatrix defines the new world matrix
  6934. */
  6935. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Scale the current bounding box by applying a scale factor
  6938. * @param factor defines the scale factor to apply
  6939. * @returns the current bounding box
  6940. */
  6941. scale(factor: number): BoundingBox;
  6942. /**
  6943. * Gets the world matrix of the bounding box
  6944. * @returns a matrix
  6945. */
  6946. getWorldMatrix(): DeepImmutable<Matrix>;
  6947. /** @hidden */
  6948. _update(world: DeepImmutable<Matrix>): void;
  6949. /**
  6950. * Tests if the bounding box is intersecting the frustum planes
  6951. * @param frustumPlanes defines the frustum planes to test
  6952. * @returns true if there is an intersection
  6953. */
  6954. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6955. /**
  6956. * Tests if the bounding box is entirely inside the frustum planes
  6957. * @param frustumPlanes defines the frustum planes to test
  6958. * @returns true if there is an inclusion
  6959. */
  6960. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6961. /**
  6962. * Tests if a point is inside the bounding box
  6963. * @param point defines the point to test
  6964. * @returns true if the point is inside the bounding box
  6965. */
  6966. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6967. /**
  6968. * Tests if the bounding box intersects with a bounding sphere
  6969. * @param sphere defines the sphere to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6973. /**
  6974. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6975. * @param min defines the min vector to use
  6976. * @param max defines the max vector to use
  6977. * @returns true if there is an intersection
  6978. */
  6979. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6980. /**
  6981. * Tests if two bounding boxes are intersections
  6982. * @param box0 defines the first box to test
  6983. * @param box1 defines the second box to test
  6984. * @returns true if there is an intersection
  6985. */
  6986. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6987. /**
  6988. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6989. * @param minPoint defines the minimum vector of the bounding box
  6990. * @param maxPoint defines the maximum vector of the bounding box
  6991. * @param sphereCenter defines the sphere center
  6992. * @param sphereRadius defines the sphere radius
  6993. * @returns true if there is an intersection
  6994. */
  6995. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an inclusion
  7001. */
  7002. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7005. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @return true if there is an intersection
  7008. */
  7009. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. }
  7011. }
  7012. declare module BABYLON {
  7013. /** @hidden */
  7014. export class Collider {
  7015. /** Define if a collision was found */
  7016. collisionFound: boolean;
  7017. /**
  7018. * Define last intersection point in local space
  7019. */
  7020. intersectionPoint: Vector3;
  7021. /**
  7022. * Define last collided mesh
  7023. */
  7024. collidedMesh: Nullable<AbstractMesh>;
  7025. private _collisionPoint;
  7026. private _planeIntersectionPoint;
  7027. private _tempVector;
  7028. private _tempVector2;
  7029. private _tempVector3;
  7030. private _tempVector4;
  7031. private _edge;
  7032. private _baseToVertex;
  7033. private _destinationPoint;
  7034. private _slidePlaneNormal;
  7035. private _displacementVector;
  7036. /** @hidden */
  7037. _radius: Vector3;
  7038. /** @hidden */
  7039. _retry: number;
  7040. private _velocity;
  7041. private _basePoint;
  7042. private _epsilon;
  7043. /** @hidden */
  7044. _velocityWorldLength: number;
  7045. /** @hidden */
  7046. _basePointWorld: Vector3;
  7047. private _velocityWorld;
  7048. private _normalizedVelocity;
  7049. /** @hidden */
  7050. _initialVelocity: Vector3;
  7051. /** @hidden */
  7052. _initialPosition: Vector3;
  7053. private _nearestDistance;
  7054. private _collisionMask;
  7055. get collisionMask(): number;
  7056. set collisionMask(mask: number);
  7057. /**
  7058. * Gets the plane normal used to compute the sliding response (in local space)
  7059. */
  7060. get slidePlaneNormal(): Vector3;
  7061. /** @hidden */
  7062. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7063. /** @hidden */
  7064. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7065. /** @hidden */
  7066. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7067. /** @hidden */
  7068. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7069. /** @hidden */
  7070. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7071. /** @hidden */
  7072. _getResponse(pos: Vector3, vel: Vector3): void;
  7073. }
  7074. }
  7075. declare module BABYLON {
  7076. /**
  7077. * Interface for cullable objects
  7078. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7079. */
  7080. export interface ICullable {
  7081. /**
  7082. * Checks if the object or part of the object is in the frustum
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isInFrustum(frustumPlanes: Plane[]): boolean;
  7087. /**
  7088. * Checks if a cullable object (mesh...) is in the camera frustum
  7089. * Unlike isInFrustum this cheks the full bounding box
  7090. * @param frustumPlanes Camera near/planes
  7091. * @returns true if the object is in frustum otherwise false
  7092. */
  7093. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7094. }
  7095. /**
  7096. * Info for a bounding data of a mesh
  7097. */
  7098. export class BoundingInfo implements ICullable {
  7099. /**
  7100. * Bounding box for the mesh
  7101. */
  7102. readonly boundingBox: BoundingBox;
  7103. /**
  7104. * Bounding sphere for the mesh
  7105. */
  7106. readonly boundingSphere: BoundingSphere;
  7107. private _isLocked;
  7108. private static readonly TmpVector3;
  7109. /**
  7110. * Constructs bounding info
  7111. * @param minimum min vector of the bounding box/sphere
  7112. * @param maximum max vector of the bounding box/sphere
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7116. /**
  7117. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7118. * @param min defines the new minimum vector (in local space)
  7119. * @param max defines the new maximum vector (in local space)
  7120. * @param worldMatrix defines the new world matrix
  7121. */
  7122. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7123. /**
  7124. * min vector of the bounding box/sphere
  7125. */
  7126. get minimum(): Vector3;
  7127. /**
  7128. * max vector of the bounding box/sphere
  7129. */
  7130. get maximum(): Vector3;
  7131. /**
  7132. * If the info is locked and won't be updated to avoid perf overhead
  7133. */
  7134. get isLocked(): boolean;
  7135. set isLocked(value: boolean);
  7136. /**
  7137. * Updates the bounding sphere and box
  7138. * @param world world matrix to be used to update
  7139. */
  7140. update(world: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7143. * @param center New center of the bounding info
  7144. * @param extend New extend of the bounding info
  7145. * @returns the current bounding info
  7146. */
  7147. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7148. /**
  7149. * Scale the current bounding info by applying a scale factor
  7150. * @param factor defines the scale factor to apply
  7151. * @returns the current bounding info
  7152. */
  7153. scale(factor: number): BoundingInfo;
  7154. /**
  7155. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7156. * @param frustumPlanes defines the frustum to test
  7157. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7158. * @returns true if the bounding info is in the frustum planes
  7159. */
  7160. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7161. /**
  7162. * Gets the world distance between the min and max points of the bounding box
  7163. */
  7164. get diagonalLength(): number;
  7165. /**
  7166. * Checks if a cullable object (mesh...) is in the camera frustum
  7167. * Unlike isInFrustum this cheks the full bounding box
  7168. * @param frustumPlanes Camera near/planes
  7169. * @returns true if the object is in frustum otherwise false
  7170. */
  7171. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. /** @hidden */
  7173. _checkCollision(collider: Collider): boolean;
  7174. /**
  7175. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param point the point to check intersection with
  7178. * @returns if the point intersects
  7179. */
  7180. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7181. /**
  7182. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7183. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7184. * @param boundingInfo the bounding info to check intersection with
  7185. * @param precise if the intersection should be done using OBB
  7186. * @returns if the bounding info intersects
  7187. */
  7188. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /**
  7193. * Extracts minimum and maximum values from a list of indexed positions
  7194. * @param positions defines the positions to use
  7195. * @param indices defines the indices to the positions
  7196. * @param indexStart defines the start index
  7197. * @param indexCount defines the end index
  7198. * @param bias defines bias value to add to the result
  7199. * @return minimum and maximum values
  7200. */
  7201. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7202. minimum: Vector3;
  7203. maximum: Vector3;
  7204. };
  7205. /**
  7206. * Extracts minimum and maximum values from a list of positions
  7207. * @param positions defines the positions to use
  7208. * @param start defines the start index in the positions array
  7209. * @param count defines the number of positions to handle
  7210. * @param bias defines bias value to add to the result
  7211. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7212. * @return minimum and maximum values
  7213. */
  7214. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7215. minimum: Vector3;
  7216. maximum: Vector3;
  7217. };
  7218. }
  7219. declare module BABYLON {
  7220. /** @hidden */
  7221. export class WebGLDataBuffer extends DataBuffer {
  7222. private _buffer;
  7223. constructor(resource: WebGLBuffer);
  7224. get underlyingResource(): any;
  7225. }
  7226. }
  7227. declare module BABYLON {
  7228. /** @hidden */
  7229. export class WebGLPipelineContext implements IPipelineContext {
  7230. engine: ThinEngine;
  7231. program: Nullable<WebGLProgram>;
  7232. context?: WebGLRenderingContext;
  7233. vertexShader?: WebGLShader;
  7234. fragmentShader?: WebGLShader;
  7235. isParallelCompiled: boolean;
  7236. onCompiled?: () => void;
  7237. transformFeedback?: WebGLTransformFeedback | null;
  7238. vertexCompilationError: Nullable<string>;
  7239. fragmentCompilationError: Nullable<string>;
  7240. programLinkError: Nullable<string>;
  7241. programValidationError: Nullable<string>;
  7242. get isAsync(): boolean;
  7243. get isReady(): boolean;
  7244. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7245. _getVertexShaderCode(): string | null;
  7246. _getFragmentShaderCode(): string | null;
  7247. }
  7248. }
  7249. declare module BABYLON {
  7250. interface ThinEngine {
  7251. /**
  7252. * Create an uniform buffer
  7253. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7254. * @param elements defines the content of the uniform buffer
  7255. * @returns the webGL uniform buffer
  7256. */
  7257. createUniformBuffer(elements: FloatArray): DataBuffer;
  7258. /**
  7259. * Create a dynamic uniform buffer
  7260. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7261. * @param elements defines the content of the uniform buffer
  7262. * @returns the webGL uniform buffer
  7263. */
  7264. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7265. /**
  7266. * Update an existing uniform buffer
  7267. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7268. * @param uniformBuffer defines the target uniform buffer
  7269. * @param elements defines the content to update
  7270. * @param offset defines the offset in the uniform buffer where update should start
  7271. * @param count defines the size of the data to update
  7272. */
  7273. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7274. /**
  7275. * Bind an uniform buffer to the current webGL context
  7276. * @param buffer defines the buffer to bind
  7277. */
  7278. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7279. /**
  7280. * Bind a buffer to the current webGL context at a given location
  7281. * @param buffer defines the buffer to bind
  7282. * @param location defines the index where to bind the buffer
  7283. */
  7284. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7285. /**
  7286. * Bind a specific block at a given index in a specific shader program
  7287. * @param pipelineContext defines the pipeline context to use
  7288. * @param blockName defines the block name
  7289. * @param index defines the index where to bind the block
  7290. */
  7291. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Uniform buffer objects.
  7297. *
  7298. * Handles blocks of uniform on the GPU.
  7299. *
  7300. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7301. *
  7302. * For more information, please refer to :
  7303. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7304. */
  7305. export class UniformBuffer {
  7306. private _engine;
  7307. private _buffer;
  7308. private _data;
  7309. private _bufferData;
  7310. private _dynamic?;
  7311. private _uniformLocations;
  7312. private _uniformSizes;
  7313. private _uniformLocationPointer;
  7314. private _needSync;
  7315. private _noUBO;
  7316. private _currentEffect;
  7317. /** @hidden */
  7318. _alreadyBound: boolean;
  7319. private static _MAX_UNIFORM_SIZE;
  7320. private static _tempBuffer;
  7321. /**
  7322. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7333. /**
  7334. * Lambda to Update a single float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat: (name: string, x: number) => void;
  7339. /**
  7340. * Lambda to Update a vec2 of float in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec3 of float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a vec4 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateMatrix: (name: string, mat: Matrix) => void;
  7363. /**
  7364. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateVector3: (name: string, vector: Vector3) => void;
  7369. /**
  7370. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateVector4: (name: string, vector: Vector4) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7387. /**
  7388. * Instantiates a new Uniform buffer objects.
  7389. *
  7390. * Handles blocks of uniform on the GPU.
  7391. *
  7392. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7393. *
  7394. * For more information, please refer to :
  7395. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7396. * @param engine Define the engine the buffer is associated with
  7397. * @param data Define the data contained in the buffer
  7398. * @param dynamic Define if the buffer is updatable
  7399. */
  7400. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7401. /**
  7402. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7403. * or just falling back on setUniformXXX calls.
  7404. */
  7405. get useUbo(): boolean;
  7406. /**
  7407. * Indicates if the WebGL underlying uniform buffer is in sync
  7408. * with the javascript cache data.
  7409. */
  7410. get isSync(): boolean;
  7411. /**
  7412. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7413. * Also, a dynamic UniformBuffer will disable cache verification and always
  7414. * update the underlying WebGL uniform buffer to the GPU.
  7415. * @returns if Dynamic, otherwise false
  7416. */
  7417. isDynamic(): boolean;
  7418. /**
  7419. * The data cache on JS side.
  7420. * @returns the underlying data as a float array
  7421. */
  7422. getData(): Float32Array;
  7423. /**
  7424. * The underlying WebGL Uniform buffer.
  7425. * @returns the webgl buffer
  7426. */
  7427. getBuffer(): Nullable<DataBuffer>;
  7428. /**
  7429. * std140 layout specifies how to align data within an UBO structure.
  7430. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7431. * for specs.
  7432. */
  7433. private _fillAlignment;
  7434. /**
  7435. * Adds an uniform in the buffer.
  7436. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7437. * for the layout to be correct !
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param size Data size, or data directly.
  7440. */
  7441. addUniform(name: string, size: number | number[]): void;
  7442. /**
  7443. * Adds a Matrix 4x4 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param mat A 4x4 matrix.
  7446. */
  7447. addMatrix(name: string, mat: Matrix): void;
  7448. /**
  7449. * Adds a vec2 to the uniform buffer.
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param x Define the x component value of the vec2
  7452. * @param y Define the y component value of the vec2
  7453. */
  7454. addFloat2(name: string, x: number, y: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param x Define the x component value of the vec3
  7459. * @param y Define the y component value of the vec3
  7460. * @param z Define the z component value of the vec3
  7461. */
  7462. addFloat3(name: string, x: number, y: number, z: number): void;
  7463. /**
  7464. * Adds a vec3 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the vec3 from a Color
  7467. */
  7468. addColor3(name: string, color: Color3): void;
  7469. /**
  7470. * Adds a vec4 to the uniform buffer.
  7471. * @param name Name of the uniform, as used in the uniform block in the shader.
  7472. * @param color Define the rgb components from a Color
  7473. * @param alpha Define the a component of the vec4
  7474. */
  7475. addColor4(name: string, color: Color3, alpha: number): void;
  7476. /**
  7477. * Adds a vec3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. * @param vector Define the vec3 components from a Vector
  7480. */
  7481. addVector3(name: string, vector: Vector3): void;
  7482. /**
  7483. * Adds a Matrix 3x3 to the uniform buffer.
  7484. * @param name Name of the uniform, as used in the uniform block in the shader.
  7485. */
  7486. addMatrix3x3(name: string): void;
  7487. /**
  7488. * Adds a Matrix 2x2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. */
  7491. addMatrix2x2(name: string): void;
  7492. /**
  7493. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7494. */
  7495. create(): void;
  7496. /** @hidden */
  7497. _rebuild(): void;
  7498. /**
  7499. * Updates the WebGL Uniform Buffer on the GPU.
  7500. * If the `dynamic` flag is set to true, no cache comparison is done.
  7501. * Otherwise, the buffer will be updated only if the cache differs.
  7502. */
  7503. update(): void;
  7504. /**
  7505. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7506. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7507. * @param data Define the flattened data
  7508. * @param size Define the size of the data.
  7509. */
  7510. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7511. private _valueCache;
  7512. private _cacheMatrix;
  7513. private _updateMatrix3x3ForUniform;
  7514. private _updateMatrix3x3ForEffect;
  7515. private _updateMatrix2x2ForEffect;
  7516. private _updateMatrix2x2ForUniform;
  7517. private _updateFloatForEffect;
  7518. private _updateFloatForUniform;
  7519. private _updateFloat2ForEffect;
  7520. private _updateFloat2ForUniform;
  7521. private _updateFloat3ForEffect;
  7522. private _updateFloat3ForUniform;
  7523. private _updateFloat4ForEffect;
  7524. private _updateFloat4ForUniform;
  7525. private _updateMatrixForEffect;
  7526. private _updateMatrixForUniform;
  7527. private _updateVector3ForEffect;
  7528. private _updateVector3ForUniform;
  7529. private _updateVector4ForEffect;
  7530. private _updateVector4ForUniform;
  7531. private _updateColor3ForEffect;
  7532. private _updateColor3ForUniform;
  7533. private _updateColor4ForEffect;
  7534. private _updateColor4ForUniform;
  7535. /**
  7536. * Sets a sampler uniform on the effect.
  7537. * @param name Define the name of the sampler.
  7538. * @param texture Define the texture to set in the sampler
  7539. */
  7540. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7541. /**
  7542. * Directly updates the value of the uniform in the cache AND on the GPU.
  7543. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7544. * @param data Define the flattened data
  7545. */
  7546. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7547. /**
  7548. * Binds this uniform buffer to an effect.
  7549. * @param effect Define the effect to bind the buffer to
  7550. * @param name Name of the uniform block in the shader.
  7551. */
  7552. bindToEffect(effect: Effect, name: string): void;
  7553. /**
  7554. * Disposes the uniform buffer.
  7555. */
  7556. dispose(): void;
  7557. }
  7558. }
  7559. declare module BABYLON {
  7560. /**
  7561. * Enum that determines the text-wrapping mode to use.
  7562. */
  7563. export enum InspectableType {
  7564. /**
  7565. * Checkbox for booleans
  7566. */
  7567. Checkbox = 0,
  7568. /**
  7569. * Sliders for numbers
  7570. */
  7571. Slider = 1,
  7572. /**
  7573. * Vector3
  7574. */
  7575. Vector3 = 2,
  7576. /**
  7577. * Quaternions
  7578. */
  7579. Quaternion = 3,
  7580. /**
  7581. * Color3
  7582. */
  7583. Color3 = 4,
  7584. /**
  7585. * String
  7586. */
  7587. String = 5
  7588. }
  7589. /**
  7590. * Interface used to define custom inspectable properties.
  7591. * This interface is used by the inspector to display custom property grids
  7592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7593. */
  7594. export interface IInspectable {
  7595. /**
  7596. * Gets the label to display
  7597. */
  7598. label: string;
  7599. /**
  7600. * Gets the name of the property to edit
  7601. */
  7602. propertyName: string;
  7603. /**
  7604. * Gets the type of the editor to use
  7605. */
  7606. type: InspectableType;
  7607. /**
  7608. * Gets the minimum value of the property when using in "slider" mode
  7609. */
  7610. min?: number;
  7611. /**
  7612. * Gets the maximum value of the property when using in "slider" mode
  7613. */
  7614. max?: number;
  7615. /**
  7616. * Gets the setp to use when using in "slider" mode
  7617. */
  7618. step?: number;
  7619. }
  7620. }
  7621. declare module BABYLON {
  7622. /**
  7623. * Class used to provide helper for timing
  7624. */
  7625. export class TimingTools {
  7626. /**
  7627. * Polyfill for setImmediate
  7628. * @param action defines the action to execute after the current execution block
  7629. */
  7630. static SetImmediate(action: () => void): void;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. /**
  7635. * Class used to enable instatition of objects by class name
  7636. */
  7637. export class InstantiationTools {
  7638. /**
  7639. * Use this object to register external classes like custom textures or material
  7640. * to allow the laoders to instantiate them
  7641. */
  7642. static RegisteredExternalClasses: {
  7643. [key: string]: Object;
  7644. };
  7645. /**
  7646. * Tries to instantiate a new object from a given class name
  7647. * @param className defines the class name to instantiate
  7648. * @returns the new object or null if the system was not able to do the instantiation
  7649. */
  7650. static Instantiate(className: string): any;
  7651. }
  7652. }
  7653. declare module BABYLON {
  7654. /**
  7655. * Define options used to create a depth texture
  7656. */
  7657. export class DepthTextureCreationOptions {
  7658. /** Specifies whether or not a stencil should be allocated in the texture */
  7659. generateStencil?: boolean;
  7660. /** Specifies whether or not bilinear filtering is enable on the texture */
  7661. bilinearFiltering?: boolean;
  7662. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7663. comparisonFunction?: number;
  7664. /** Specifies if the created texture is a cube texture */
  7665. isCube?: boolean;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @returns the cube texture as an InternalTexture
  7693. */
  7694. 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;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @returns the cube texture as an InternalTexture
  7706. */
  7707. 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;
  7708. /**
  7709. * Creates a cube texture
  7710. * @param rootUrl defines the url where the files to load is located
  7711. * @param scene defines the current scene
  7712. * @param files defines the list of files to load (1 per face)
  7713. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7714. * @param onLoad defines an optional callback raised when the texture is loaded
  7715. * @param onError defines an optional callback raised if there is an issue to load the texture
  7716. * @param format defines the format of the data
  7717. * @param forcedExtension defines the extension to use to pick the right loader
  7718. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7719. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7720. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7721. * @returns the cube texture as an InternalTexture
  7722. */
  7723. 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;
  7724. /** @hidden */
  7725. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7726. /** @hidden */
  7727. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /** @hidden */
  7729. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7730. /** @hidden */
  7731. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7732. /**
  7733. * @hidden
  7734. */
  7735. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7736. }
  7737. }
  7738. declare module BABYLON {
  7739. /**
  7740. * Class for creating a cube texture
  7741. */
  7742. export class CubeTexture extends BaseTexture {
  7743. private _delayedOnLoad;
  7744. /**
  7745. * Observable triggered once the texture has been loaded.
  7746. */
  7747. onLoadObservable: Observable<CubeTexture>;
  7748. /**
  7749. * The url of the texture
  7750. */
  7751. url: string;
  7752. /**
  7753. * Gets or sets the center of the bounding box associated with the cube texture.
  7754. * It must define where the camera used to render the texture was set
  7755. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7756. */
  7757. boundingBoxPosition: Vector3;
  7758. private _boundingBoxSize;
  7759. /**
  7760. * Gets or sets the size of the bounding box associated with the cube texture
  7761. * When defined, the cubemap will switch to local mode
  7762. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7763. * @example https://www.babylonjs-playground.com/#RNASML
  7764. */
  7765. set boundingBoxSize(value: Vector3);
  7766. /**
  7767. * Returns the bounding box size
  7768. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7769. */
  7770. get boundingBoxSize(): Vector3;
  7771. protected _rotationY: number;
  7772. /**
  7773. * Sets texture matrix rotation angle around Y axis in radians.
  7774. */
  7775. set rotationY(value: number);
  7776. /**
  7777. * Gets texture matrix rotation angle around Y axis radians.
  7778. */
  7779. get rotationY(): number;
  7780. /**
  7781. * Are mip maps generated for this texture or not.
  7782. */
  7783. get noMipmap(): boolean;
  7784. private _noMipmap;
  7785. private _files;
  7786. protected _forcedExtension: Nullable<string>;
  7787. private _extensions;
  7788. private _textureMatrix;
  7789. private _format;
  7790. private _createPolynomials;
  7791. /**
  7792. * Creates a cube texture from an array of image urls
  7793. * @param files defines an array of image urls
  7794. * @param scene defines the hosting scene
  7795. * @param noMipmap specifies if mip maps are not used
  7796. * @returns a cube texture
  7797. */
  7798. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7799. /**
  7800. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7801. * @param url defines the url of the prefiltered texture
  7802. * @param scene defines the scene the texture is attached to
  7803. * @param forcedExtension defines the extension of the file if different from the url
  7804. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7805. * @return the prefiltered texture
  7806. */
  7807. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7808. /**
  7809. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7810. * as prefiltered data.
  7811. * @param rootUrl defines the url of the texture or the root name of the six images
  7812. * @param null defines the scene or engine the texture is attached to
  7813. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7814. * @param noMipmap defines if mipmaps should be created or not
  7815. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7816. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7817. * @param onError defines a callback triggered in case of error during load
  7818. * @param format defines the internal format to use for the texture once loaded
  7819. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7820. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7821. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7822. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7823. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7824. * @return the cube texture
  7825. */
  7826. 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);
  7827. /**
  7828. * Get the current class name of the texture useful for serialization or dynamic coding.
  7829. * @returns "CubeTexture"
  7830. */
  7831. getClassName(): string;
  7832. /**
  7833. * Update the url (and optional buffer) of this texture if url was null during construction.
  7834. * @param url the url of the texture
  7835. * @param forcedExtension defines the extension to use
  7836. * @param onLoad callback called when the texture is loaded (defaults to null)
  7837. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7838. */
  7839. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7840. /**
  7841. * Delays loading of the cube texture
  7842. * @param forcedExtension defines the extension to use
  7843. */
  7844. delayLoad(forcedExtension?: string): void;
  7845. /**
  7846. * Returns the reflection texture matrix
  7847. * @returns the reflection texture matrix
  7848. */
  7849. getReflectionTextureMatrix(): Matrix;
  7850. /**
  7851. * Sets the reflection texture matrix
  7852. * @param value Reflection texture matrix
  7853. */
  7854. setReflectionTextureMatrix(value: Matrix): void;
  7855. /**
  7856. * Parses text to create a cube texture
  7857. * @param parsedTexture define the serialized text to read from
  7858. * @param scene defines the hosting scene
  7859. * @param rootUrl defines the root url of the cube texture
  7860. * @returns a cube texture
  7861. */
  7862. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7863. /**
  7864. * Makes a clone, or deep copy, of the cube texture
  7865. * @returns a new cube texture
  7866. */
  7867. clone(): CubeTexture;
  7868. }
  7869. }
  7870. declare module BABYLON {
  7871. /**
  7872. * Manages the defines for the Material
  7873. */
  7874. export class MaterialDefines {
  7875. /** @hidden */
  7876. protected _keys: string[];
  7877. private _isDirty;
  7878. /** @hidden */
  7879. _renderId: number;
  7880. /** @hidden */
  7881. _areLightsDirty: boolean;
  7882. /** @hidden */
  7883. _areLightsDisposed: boolean;
  7884. /** @hidden */
  7885. _areAttributesDirty: boolean;
  7886. /** @hidden */
  7887. _areTexturesDirty: boolean;
  7888. /** @hidden */
  7889. _areFresnelDirty: boolean;
  7890. /** @hidden */
  7891. _areMiscDirty: boolean;
  7892. /** @hidden */
  7893. _areImageProcessingDirty: boolean;
  7894. /** @hidden */
  7895. _normals: boolean;
  7896. /** @hidden */
  7897. _uvs: boolean;
  7898. /** @hidden */
  7899. _needNormals: boolean;
  7900. /** @hidden */
  7901. _needUVs: boolean;
  7902. [id: string]: any;
  7903. /**
  7904. * Specifies if the material needs to be re-calculated
  7905. */
  7906. get isDirty(): boolean;
  7907. /**
  7908. * Marks the material to indicate that it has been re-calculated
  7909. */
  7910. markAsProcessed(): void;
  7911. /**
  7912. * Marks the material to indicate that it needs to be re-calculated
  7913. */
  7914. markAsUnprocessed(): void;
  7915. /**
  7916. * Marks the material to indicate all of its defines need to be re-calculated
  7917. */
  7918. markAllAsDirty(): void;
  7919. /**
  7920. * Marks the material to indicate that image processing needs to be re-calculated
  7921. */
  7922. markAsImageProcessingDirty(): void;
  7923. /**
  7924. * Marks the material to indicate the lights need to be re-calculated
  7925. * @param disposed Defines whether the light is dirty due to dispose or not
  7926. */
  7927. markAsLightDirty(disposed?: boolean): void;
  7928. /**
  7929. * Marks the attribute state as changed
  7930. */
  7931. markAsAttributesDirty(): void;
  7932. /**
  7933. * Marks the texture state as changed
  7934. */
  7935. markAsTexturesDirty(): void;
  7936. /**
  7937. * Marks the fresnel state as changed
  7938. */
  7939. markAsFresnelDirty(): void;
  7940. /**
  7941. * Marks the misc state as changed
  7942. */
  7943. markAsMiscDirty(): void;
  7944. /**
  7945. * Rebuilds the material defines
  7946. */
  7947. rebuild(): void;
  7948. /**
  7949. * Specifies if two material defines are equal
  7950. * @param other - A material define instance to compare to
  7951. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7952. */
  7953. isEqual(other: MaterialDefines): boolean;
  7954. /**
  7955. * Clones this instance's defines to another instance
  7956. * @param other - material defines to clone values to
  7957. */
  7958. cloneTo(other: MaterialDefines): void;
  7959. /**
  7960. * Resets the material define values
  7961. */
  7962. reset(): void;
  7963. /**
  7964. * Converts the material define values to a string
  7965. * @returns - String of material define information
  7966. */
  7967. toString(): string;
  7968. }
  7969. }
  7970. declare module BABYLON {
  7971. /**
  7972. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7973. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7974. * 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;
  7975. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7976. */
  7977. export class ColorCurves {
  7978. private _dirty;
  7979. private _tempColor;
  7980. private _globalCurve;
  7981. private _highlightsCurve;
  7982. private _midtonesCurve;
  7983. private _shadowsCurve;
  7984. private _positiveCurve;
  7985. private _negativeCurve;
  7986. private _globalHue;
  7987. private _globalDensity;
  7988. private _globalSaturation;
  7989. private _globalExposure;
  7990. /**
  7991. * Gets the global Hue value.
  7992. * 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).
  7993. */
  7994. get globalHue(): number;
  7995. /**
  7996. * Sets the global Hue value.
  7997. * 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).
  7998. */
  7999. set globalHue(value: number);
  8000. /**
  8001. * Gets the global Density value.
  8002. * 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.
  8003. * Values less than zero provide a filter of opposite hue.
  8004. */
  8005. get globalDensity(): number;
  8006. /**
  8007. * Sets the global Density value.
  8008. * 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.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. set globalDensity(value: number);
  8012. /**
  8013. * Gets the global Saturation value.
  8014. * 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.
  8015. */
  8016. get globalSaturation(): number;
  8017. /**
  8018. * Sets the global Saturation value.
  8019. * 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.
  8020. */
  8021. set globalSaturation(value: number);
  8022. /**
  8023. * Gets the global Exposure value.
  8024. * 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.
  8025. */
  8026. get globalExposure(): number;
  8027. /**
  8028. * Sets the global Exposure value.
  8029. * 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.
  8030. */
  8031. set globalExposure(value: number);
  8032. private _highlightsHue;
  8033. private _highlightsDensity;
  8034. private _highlightsSaturation;
  8035. private _highlightsExposure;
  8036. /**
  8037. * Gets the highlights Hue value.
  8038. * 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).
  8039. */
  8040. get highlightsHue(): number;
  8041. /**
  8042. * Sets the highlights Hue value.
  8043. * 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).
  8044. */
  8045. set highlightsHue(value: number);
  8046. /**
  8047. * Gets the highlights Density value.
  8048. * 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.
  8049. * Values less than zero provide a filter of opposite hue.
  8050. */
  8051. get highlightsDensity(): number;
  8052. /**
  8053. * Sets the highlights Density value.
  8054. * 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.
  8055. * Values less than zero provide a filter of opposite hue.
  8056. */
  8057. set highlightsDensity(value: number);
  8058. /**
  8059. * Gets the highlights Saturation value.
  8060. * 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.
  8061. */
  8062. get highlightsSaturation(): number;
  8063. /**
  8064. * Sets the highlights Saturation value.
  8065. * 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.
  8066. */
  8067. set highlightsSaturation(value: number);
  8068. /**
  8069. * Gets the highlights Exposure value.
  8070. * 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.
  8071. */
  8072. get highlightsExposure(): number;
  8073. /**
  8074. * Sets the highlights Exposure value.
  8075. * 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.
  8076. */
  8077. set highlightsExposure(value: number);
  8078. private _midtonesHue;
  8079. private _midtonesDensity;
  8080. private _midtonesSaturation;
  8081. private _midtonesExposure;
  8082. /**
  8083. * Gets the midtones Hue value.
  8084. * 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).
  8085. */
  8086. get midtonesHue(): number;
  8087. /**
  8088. * Sets the midtones Hue value.
  8089. * 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).
  8090. */
  8091. set midtonesHue(value: number);
  8092. /**
  8093. * Gets the midtones Density value.
  8094. * 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.
  8095. * Values less than zero provide a filter of opposite hue.
  8096. */
  8097. get midtonesDensity(): number;
  8098. /**
  8099. * Sets the midtones Density value.
  8100. * 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.
  8101. * Values less than zero provide a filter of opposite hue.
  8102. */
  8103. set midtonesDensity(value: number);
  8104. /**
  8105. * Gets the midtones Saturation value.
  8106. * 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.
  8107. */
  8108. get midtonesSaturation(): number;
  8109. /**
  8110. * Sets the midtones Saturation value.
  8111. * 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.
  8112. */
  8113. set midtonesSaturation(value: number);
  8114. /**
  8115. * Gets the midtones Exposure value.
  8116. * 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.
  8117. */
  8118. get midtonesExposure(): number;
  8119. /**
  8120. * Sets the midtones Exposure value.
  8121. * 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.
  8122. */
  8123. set midtonesExposure(value: number);
  8124. private _shadowsHue;
  8125. private _shadowsDensity;
  8126. private _shadowsSaturation;
  8127. private _shadowsExposure;
  8128. /**
  8129. * Gets the shadows Hue value.
  8130. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8131. */
  8132. get shadowsHue(): number;
  8133. /**
  8134. * Sets the shadows Hue value.
  8135. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8136. */
  8137. set shadowsHue(value: number);
  8138. /**
  8139. * Gets the shadows Density value.
  8140. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8141. * Values less than zero provide a filter of opposite hue.
  8142. */
  8143. get shadowsDensity(): number;
  8144. /**
  8145. * Sets the shadows Density value.
  8146. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8147. * Values less than zero provide a filter of opposite hue.
  8148. */
  8149. set shadowsDensity(value: number);
  8150. /**
  8151. * Gets the shadows Saturation value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8153. */
  8154. get shadowsSaturation(): number;
  8155. /**
  8156. * Sets the shadows Saturation value.
  8157. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8158. */
  8159. set shadowsSaturation(value: number);
  8160. /**
  8161. * Gets the shadows Exposure value.
  8162. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8163. */
  8164. get shadowsExposure(): number;
  8165. /**
  8166. * Sets the shadows Exposure value.
  8167. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8168. */
  8169. set shadowsExposure(value: number);
  8170. /**
  8171. * Returns the class name
  8172. * @returns The class name
  8173. */
  8174. getClassName(): string;
  8175. /**
  8176. * Binds the color curves to the shader.
  8177. * @param colorCurves The color curve to bind
  8178. * @param effect The effect to bind to
  8179. * @param positiveUniform The positive uniform shader parameter
  8180. * @param neutralUniform The neutral uniform shader parameter
  8181. * @param negativeUniform The negative uniform shader parameter
  8182. */
  8183. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8184. /**
  8185. * Prepare the list of uniforms associated with the ColorCurves effects.
  8186. * @param uniformsList The list of uniforms used in the effect
  8187. */
  8188. static PrepareUniforms(uniformsList: string[]): void;
  8189. /**
  8190. * Returns color grading data based on a hue, density, saturation and exposure value.
  8191. * @param filterHue The hue of the color filter.
  8192. * @param filterDensity The density of the color filter.
  8193. * @param saturation The saturation.
  8194. * @param exposure The exposure.
  8195. * @param result The result data container.
  8196. */
  8197. private getColorGradingDataToRef;
  8198. /**
  8199. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8200. * @param value The input slider value in range [-100,100].
  8201. * @returns Adjusted value.
  8202. */
  8203. private static applyColorGradingSliderNonlinear;
  8204. /**
  8205. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8206. * @param hue The hue (H) input.
  8207. * @param saturation The saturation (S) input.
  8208. * @param brightness The brightness (B) input.
  8209. * @result An RGBA color represented as Vector4.
  8210. */
  8211. private static fromHSBToRef;
  8212. /**
  8213. * Returns a value clamped between min and max
  8214. * @param value The value to clamp
  8215. * @param min The minimum of value
  8216. * @param max The maximum of value
  8217. * @returns The clamped value.
  8218. */
  8219. private static clamp;
  8220. /**
  8221. * Clones the current color curve instance.
  8222. * @return The cloned curves
  8223. */
  8224. clone(): ColorCurves;
  8225. /**
  8226. * Serializes the current color curve instance to a json representation.
  8227. * @return a JSON representation
  8228. */
  8229. serialize(): any;
  8230. /**
  8231. * Parses the color curve from a json representation.
  8232. * @param source the JSON source to parse
  8233. * @return The parsed curves
  8234. */
  8235. static Parse(source: any): ColorCurves;
  8236. }
  8237. }
  8238. declare module BABYLON {
  8239. /**
  8240. * Interface to follow in your material defines to integrate easily the
  8241. * Image proccessing functions.
  8242. * @hidden
  8243. */
  8244. export interface IImageProcessingConfigurationDefines {
  8245. IMAGEPROCESSING: boolean;
  8246. VIGNETTE: boolean;
  8247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8248. VIGNETTEBLENDMODEOPAQUE: boolean;
  8249. TONEMAPPING: boolean;
  8250. TONEMAPPING_ACES: boolean;
  8251. CONTRAST: boolean;
  8252. EXPOSURE: boolean;
  8253. COLORCURVES: boolean;
  8254. COLORGRADING: boolean;
  8255. COLORGRADING3D: boolean;
  8256. SAMPLER3DGREENDEPTH: boolean;
  8257. SAMPLER3DBGRMAP: boolean;
  8258. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8259. }
  8260. /**
  8261. * @hidden
  8262. */
  8263. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8264. IMAGEPROCESSING: boolean;
  8265. VIGNETTE: boolean;
  8266. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8267. VIGNETTEBLENDMODEOPAQUE: boolean;
  8268. TONEMAPPING: boolean;
  8269. TONEMAPPING_ACES: boolean;
  8270. CONTRAST: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. EXPOSURE: boolean;
  8278. constructor();
  8279. }
  8280. /**
  8281. * This groups together the common properties used for image processing either in direct forward pass
  8282. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8283. * or not.
  8284. */
  8285. export class ImageProcessingConfiguration {
  8286. /**
  8287. * Default tone mapping applied in BabylonJS.
  8288. */
  8289. static readonly TONEMAPPING_STANDARD: number;
  8290. /**
  8291. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8292. * to other engines rendering to increase portability.
  8293. */
  8294. static readonly TONEMAPPING_ACES: number;
  8295. /**
  8296. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8297. */
  8298. colorCurves: Nullable<ColorCurves>;
  8299. private _colorCurvesEnabled;
  8300. /**
  8301. * Gets wether the color curves effect is enabled.
  8302. */
  8303. get colorCurvesEnabled(): boolean;
  8304. /**
  8305. * Sets wether the color curves effect is enabled.
  8306. */
  8307. set colorCurvesEnabled(value: boolean);
  8308. private _colorGradingTexture;
  8309. /**
  8310. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8311. */
  8312. get colorGradingTexture(): Nullable<BaseTexture>;
  8313. /**
  8314. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8315. */
  8316. set colorGradingTexture(value: Nullable<BaseTexture>);
  8317. private _colorGradingEnabled;
  8318. /**
  8319. * Gets wether the color grading effect is enabled.
  8320. */
  8321. get colorGradingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color grading effect is enabled.
  8324. */
  8325. set colorGradingEnabled(value: boolean);
  8326. private _colorGradingWithGreenDepth;
  8327. /**
  8328. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8329. */
  8330. get colorGradingWithGreenDepth(): boolean;
  8331. /**
  8332. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8333. */
  8334. set colorGradingWithGreenDepth(value: boolean);
  8335. private _colorGradingBGR;
  8336. /**
  8337. * Gets wether the color grading texture contains BGR values.
  8338. */
  8339. get colorGradingBGR(): boolean;
  8340. /**
  8341. * Sets wether the color grading texture contains BGR values.
  8342. */
  8343. set colorGradingBGR(value: boolean);
  8344. /** @hidden */
  8345. _exposure: number;
  8346. /**
  8347. * Gets the Exposure used in the effect.
  8348. */
  8349. get exposure(): number;
  8350. /**
  8351. * Sets the Exposure used in the effect.
  8352. */
  8353. set exposure(value: number);
  8354. private _toneMappingEnabled;
  8355. /**
  8356. * Gets wether the tone mapping effect is enabled.
  8357. */
  8358. get toneMappingEnabled(): boolean;
  8359. /**
  8360. * Sets wether the tone mapping effect is enabled.
  8361. */
  8362. set toneMappingEnabled(value: boolean);
  8363. private _toneMappingType;
  8364. /**
  8365. * Gets the type of tone mapping effect.
  8366. */
  8367. get toneMappingType(): number;
  8368. /**
  8369. * Sets the type of tone mapping effect used in BabylonJS.
  8370. */
  8371. set toneMappingType(value: number);
  8372. protected _contrast: number;
  8373. /**
  8374. * Gets the contrast used in the effect.
  8375. */
  8376. get contrast(): number;
  8377. /**
  8378. * Sets the contrast used in the effect.
  8379. */
  8380. set contrast(value: number);
  8381. /**
  8382. * Vignette stretch size.
  8383. */
  8384. vignetteStretch: number;
  8385. /**
  8386. * Vignette centre X Offset.
  8387. */
  8388. vignetteCentreX: number;
  8389. /**
  8390. * Vignette centre Y Offset.
  8391. */
  8392. vignetteCentreY: number;
  8393. /**
  8394. * Vignette weight or intensity of the vignette effect.
  8395. */
  8396. vignetteWeight: number;
  8397. /**
  8398. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8399. * if vignetteEnabled is set to true.
  8400. */
  8401. vignetteColor: Color4;
  8402. /**
  8403. * Camera field of view used by the Vignette effect.
  8404. */
  8405. vignetteCameraFov: number;
  8406. private _vignetteBlendMode;
  8407. /**
  8408. * Gets the vignette blend mode allowing different kind of effect.
  8409. */
  8410. get vignetteBlendMode(): number;
  8411. /**
  8412. * Sets the vignette blend mode allowing different kind of effect.
  8413. */
  8414. set vignetteBlendMode(value: number);
  8415. private _vignetteEnabled;
  8416. /**
  8417. * Gets wether the vignette effect is enabled.
  8418. */
  8419. get vignetteEnabled(): boolean;
  8420. /**
  8421. * Sets wether the vignette effect is enabled.
  8422. */
  8423. set vignetteEnabled(value: boolean);
  8424. private _applyByPostProcess;
  8425. /**
  8426. * Gets wether the image processing is applied through a post process or not.
  8427. */
  8428. get applyByPostProcess(): boolean;
  8429. /**
  8430. * Sets wether the image processing is applied through a post process or not.
  8431. */
  8432. set applyByPostProcess(value: boolean);
  8433. private _isEnabled;
  8434. /**
  8435. * Gets wether the image processing is enabled or not.
  8436. */
  8437. get isEnabled(): boolean;
  8438. /**
  8439. * Sets wether the image processing is enabled or not.
  8440. */
  8441. set isEnabled(value: boolean);
  8442. /**
  8443. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8444. */
  8445. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8446. /**
  8447. * Method called each time the image processing information changes requires to recompile the effect.
  8448. */
  8449. protected _updateParameters(): void;
  8450. /**
  8451. * Gets the current class name.
  8452. * @return "ImageProcessingConfiguration"
  8453. */
  8454. getClassName(): string;
  8455. /**
  8456. * Prepare the list of uniforms associated with the Image Processing effects.
  8457. * @param uniforms The list of uniforms used in the effect
  8458. * @param defines the list of defines currently in use
  8459. */
  8460. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8461. /**
  8462. * Prepare the list of samplers associated with the Image Processing effects.
  8463. * @param samplersList The list of uniforms used in the effect
  8464. * @param defines the list of defines currently in use
  8465. */
  8466. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8467. /**
  8468. * Prepare the list of defines associated to the shader.
  8469. * @param defines the list of defines to complete
  8470. * @param forPostProcess Define if we are currently in post process mode or not
  8471. */
  8472. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8473. /**
  8474. * Returns true if all the image processing information are ready.
  8475. * @returns True if ready, otherwise, false
  8476. */
  8477. isReady(): boolean;
  8478. /**
  8479. * Binds the image processing to the shader.
  8480. * @param effect The effect to bind to
  8481. * @param overrideAspectRatio Override the aspect ratio of the effect
  8482. */
  8483. bind(effect: Effect, overrideAspectRatio?: number): void;
  8484. /**
  8485. * Clones the current image processing instance.
  8486. * @return The cloned image processing
  8487. */
  8488. clone(): ImageProcessingConfiguration;
  8489. /**
  8490. * Serializes the current image processing instance to a json representation.
  8491. * @return a JSON representation
  8492. */
  8493. serialize(): any;
  8494. /**
  8495. * Parses the image processing from a json representation.
  8496. * @param source the JSON source to parse
  8497. * @return The parsed image processing
  8498. */
  8499. static Parse(source: any): ImageProcessingConfiguration;
  8500. private static _VIGNETTEMODE_MULTIPLY;
  8501. private static _VIGNETTEMODE_OPAQUE;
  8502. /**
  8503. * Used to apply the vignette as a mix with the pixel color.
  8504. */
  8505. static get VIGNETTEMODE_MULTIPLY(): number;
  8506. /**
  8507. * Used to apply the vignette as a replacement of the pixel color.
  8508. */
  8509. static get VIGNETTEMODE_OPAQUE(): number;
  8510. }
  8511. }
  8512. declare module BABYLON {
  8513. /** @hidden */
  8514. export var postprocessVertexShader: {
  8515. name: string;
  8516. shader: string;
  8517. };
  8518. }
  8519. declare module BABYLON {
  8520. interface ThinEngine {
  8521. /**
  8522. * Creates a new render target texture
  8523. * @param size defines the size of the texture
  8524. * @param options defines the options used to create the texture
  8525. * @returns a new render target texture stored in an InternalTexture
  8526. */
  8527. createRenderTargetTexture(size: number | {
  8528. width: number;
  8529. height: number;
  8530. layers?: number;
  8531. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8532. /**
  8533. * Creates a depth stencil texture.
  8534. * This is only available in WebGL 2 or with the depth texture extension available.
  8535. * @param size The size of face edge in the texture.
  8536. * @param options The options defining the texture.
  8537. * @returns The texture
  8538. */
  8539. createDepthStencilTexture(size: number | {
  8540. width: number;
  8541. height: number;
  8542. layers?: number;
  8543. }, options: DepthTextureCreationOptions): InternalTexture;
  8544. /** @hidden */
  8545. _createDepthStencilTexture(size: number | {
  8546. width: number;
  8547. height: number;
  8548. layers?: number;
  8549. }, options: DepthTextureCreationOptions): InternalTexture;
  8550. }
  8551. }
  8552. declare module BABYLON {
  8553. /**
  8554. * Defines the kind of connection point for node based material
  8555. */
  8556. export enum NodeMaterialBlockConnectionPointTypes {
  8557. /** Float */
  8558. Float = 1,
  8559. /** Int */
  8560. Int = 2,
  8561. /** Vector2 */
  8562. Vector2 = 4,
  8563. /** Vector3 */
  8564. Vector3 = 8,
  8565. /** Vector4 */
  8566. Vector4 = 16,
  8567. /** Color3 */
  8568. Color3 = 32,
  8569. /** Color4 */
  8570. Color4 = 64,
  8571. /** Matrix */
  8572. Matrix = 128,
  8573. /** Custom object */
  8574. Object = 256,
  8575. /** Detect type based on connection */
  8576. AutoDetect = 1024,
  8577. /** Output type that will be defined by input type */
  8578. BasedOnInput = 2048
  8579. }
  8580. }
  8581. declare module BABYLON {
  8582. /**
  8583. * Enum used to define the target of a block
  8584. */
  8585. export enum NodeMaterialBlockTargets {
  8586. /** Vertex shader */
  8587. Vertex = 1,
  8588. /** Fragment shader */
  8589. Fragment = 2,
  8590. /** Neutral */
  8591. Neutral = 4,
  8592. /** Vertex and Fragment */
  8593. VertexAndFragment = 3
  8594. }
  8595. }
  8596. declare module BABYLON {
  8597. /**
  8598. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8599. */
  8600. export enum NodeMaterialBlockConnectionPointMode {
  8601. /** Value is an uniform */
  8602. Uniform = 0,
  8603. /** Value is a mesh attribute */
  8604. Attribute = 1,
  8605. /** Value is a varying between vertex and fragment shaders */
  8606. Varying = 2,
  8607. /** Mode is undefined */
  8608. Undefined = 3
  8609. }
  8610. }
  8611. declare module BABYLON {
  8612. /**
  8613. * Enum used to define system values e.g. values automatically provided by the system
  8614. */
  8615. export enum NodeMaterialSystemValues {
  8616. /** World */
  8617. World = 1,
  8618. /** View */
  8619. View = 2,
  8620. /** Projection */
  8621. Projection = 3,
  8622. /** ViewProjection */
  8623. ViewProjection = 4,
  8624. /** WorldView */
  8625. WorldView = 5,
  8626. /** WorldViewProjection */
  8627. WorldViewProjection = 6,
  8628. /** CameraPosition */
  8629. CameraPosition = 7,
  8630. /** Fog Color */
  8631. FogColor = 8,
  8632. /** Delta time */
  8633. DeltaTime = 9
  8634. }
  8635. }
  8636. declare module BABYLON {
  8637. /** Defines supported spaces */
  8638. export enum Space {
  8639. /** Local (object) space */
  8640. LOCAL = 0,
  8641. /** World space */
  8642. WORLD = 1,
  8643. /** Bone space */
  8644. BONE = 2
  8645. }
  8646. /** Defines the 3 main axes */
  8647. export class Axis {
  8648. /** X axis */
  8649. static X: Vector3;
  8650. /** Y axis */
  8651. static Y: Vector3;
  8652. /** Z axis */
  8653. static Z: Vector3;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Represents a camera frustum
  8659. */
  8660. export class Frustum {
  8661. /**
  8662. * Gets the planes representing the frustum
  8663. * @param transform matrix to be applied to the returned planes
  8664. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8665. */
  8666. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8667. /**
  8668. * Gets the near frustum plane transformed by the transform matrix
  8669. * @param transform transformation matrix to be applied to the resulting frustum plane
  8670. * @param frustumPlane the resuling frustum plane
  8671. */
  8672. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8673. /**
  8674. * Gets the far frustum plane transformed by the transform matrix
  8675. * @param transform transformation matrix to be applied to the resulting frustum plane
  8676. * @param frustumPlane the resuling frustum plane
  8677. */
  8678. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8679. /**
  8680. * Gets the left frustum plane transformed by the transform matrix
  8681. * @param transform transformation matrix to be applied to the resulting frustum plane
  8682. * @param frustumPlane the resuling frustum plane
  8683. */
  8684. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8685. /**
  8686. * Gets the right frustum plane transformed by the transform matrix
  8687. * @param transform transformation matrix to be applied to the resulting frustum plane
  8688. * @param frustumPlane the resuling frustum plane
  8689. */
  8690. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8691. /**
  8692. * Gets the top frustum plane transformed by the transform matrix
  8693. * @param transform transformation matrix to be applied to the resulting frustum plane
  8694. * @param frustumPlane the resuling frustum plane
  8695. */
  8696. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8697. /**
  8698. * Gets the bottom frustum plane transformed by the transform matrix
  8699. * @param transform transformation matrix to be applied to the resulting frustum plane
  8700. * @param frustumPlane the resuling frustum plane
  8701. */
  8702. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8703. /**
  8704. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8705. * @param transform transformation matrix to be applied to the resulting frustum planes
  8706. * @param frustumPlanes the resuling frustum planes
  8707. */
  8708. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8709. }
  8710. }
  8711. declare module BABYLON {
  8712. /**
  8713. * Interface for the size containing width and height
  8714. */
  8715. export interface ISize {
  8716. /**
  8717. * Width
  8718. */
  8719. width: number;
  8720. /**
  8721. * Heighht
  8722. */
  8723. height: number;
  8724. }
  8725. /**
  8726. * Size containing widht and height
  8727. */
  8728. export class Size implements ISize {
  8729. /**
  8730. * Width
  8731. */
  8732. width: number;
  8733. /**
  8734. * Height
  8735. */
  8736. height: number;
  8737. /**
  8738. * Creates a Size object from the given width and height (floats).
  8739. * @param width width of the new size
  8740. * @param height height of the new size
  8741. */
  8742. constructor(width: number, height: number);
  8743. /**
  8744. * Returns a string with the Size width and height
  8745. * @returns a string with the Size width and height
  8746. */
  8747. toString(): string;
  8748. /**
  8749. * "Size"
  8750. * @returns the string "Size"
  8751. */
  8752. getClassName(): string;
  8753. /**
  8754. * Returns the Size hash code.
  8755. * @returns a hash code for a unique width and height
  8756. */
  8757. getHashCode(): number;
  8758. /**
  8759. * Updates the current size from the given one.
  8760. * @param src the given size
  8761. */
  8762. copyFrom(src: Size): void;
  8763. /**
  8764. * Updates in place the current Size from the given floats.
  8765. * @param width width of the new size
  8766. * @param height height of the new size
  8767. * @returns the updated Size.
  8768. */
  8769. copyFromFloats(width: number, height: number): Size;
  8770. /**
  8771. * Updates in place the current Size from the given floats.
  8772. * @param width width to set
  8773. * @param height height to set
  8774. * @returns the updated Size.
  8775. */
  8776. set(width: number, height: number): Size;
  8777. /**
  8778. * Multiplies the width and height by numbers
  8779. * @param w factor to multiple the width by
  8780. * @param h factor to multiple the height by
  8781. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8782. */
  8783. multiplyByFloats(w: number, h: number): Size;
  8784. /**
  8785. * Clones the size
  8786. * @returns a new Size copied from the given one.
  8787. */
  8788. clone(): Size;
  8789. /**
  8790. * True if the current Size and the given one width and height are strictly equal.
  8791. * @param other the other size to compare against
  8792. * @returns True if the current Size and the given one width and height are strictly equal.
  8793. */
  8794. equals(other: Size): boolean;
  8795. /**
  8796. * The surface of the Size : width * height (float).
  8797. */
  8798. get surface(): number;
  8799. /**
  8800. * Create a new size of zero
  8801. * @returns a new Size set to (0.0, 0.0)
  8802. */
  8803. static Zero(): Size;
  8804. /**
  8805. * Sums the width and height of two sizes
  8806. * @param otherSize size to add to this size
  8807. * @returns a new Size set as the addition result of the current Size and the given one.
  8808. */
  8809. add(otherSize: Size): Size;
  8810. /**
  8811. * Subtracts the width and height of two
  8812. * @param otherSize size to subtract to this size
  8813. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8814. */
  8815. subtract(otherSize: Size): Size;
  8816. /**
  8817. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8818. * @param start starting size to lerp between
  8819. * @param end end size to lerp between
  8820. * @param amount amount to lerp between the start and end values
  8821. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8822. */
  8823. static Lerp(start: Size, end: Size, amount: number): Size;
  8824. }
  8825. }
  8826. declare module BABYLON {
  8827. /**
  8828. * Contains position and normal vectors for a vertex
  8829. */
  8830. export class PositionNormalVertex {
  8831. /** the position of the vertex (defaut: 0,0,0) */
  8832. position: Vector3;
  8833. /** the normal of the vertex (defaut: 0,1,0) */
  8834. normal: Vector3;
  8835. /**
  8836. * Creates a PositionNormalVertex
  8837. * @param position the position of the vertex (defaut: 0,0,0)
  8838. * @param normal the normal of the vertex (defaut: 0,1,0)
  8839. */
  8840. constructor(
  8841. /** the position of the vertex (defaut: 0,0,0) */
  8842. position?: Vector3,
  8843. /** the normal of the vertex (defaut: 0,1,0) */
  8844. normal?: Vector3);
  8845. /**
  8846. * Clones the PositionNormalVertex
  8847. * @returns the cloned PositionNormalVertex
  8848. */
  8849. clone(): PositionNormalVertex;
  8850. }
  8851. /**
  8852. * Contains position, normal and uv vectors for a vertex
  8853. */
  8854. export class PositionNormalTextureVertex {
  8855. /** the position of the vertex (defaut: 0,0,0) */
  8856. position: Vector3;
  8857. /** the normal of the vertex (defaut: 0,1,0) */
  8858. normal: Vector3;
  8859. /** the uv of the vertex (default: 0,0) */
  8860. uv: Vector2;
  8861. /**
  8862. * Creates a PositionNormalTextureVertex
  8863. * @param position the position of the vertex (defaut: 0,0,0)
  8864. * @param normal the normal of the vertex (defaut: 0,1,0)
  8865. * @param uv the uv of the vertex (default: 0,0)
  8866. */
  8867. constructor(
  8868. /** the position of the vertex (defaut: 0,0,0) */
  8869. position?: Vector3,
  8870. /** the normal of the vertex (defaut: 0,1,0) */
  8871. normal?: Vector3,
  8872. /** the uv of the vertex (default: 0,0) */
  8873. uv?: Vector2);
  8874. /**
  8875. * Clones the PositionNormalTextureVertex
  8876. * @returns the cloned PositionNormalTextureVertex
  8877. */
  8878. clone(): PositionNormalTextureVertex;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. /**
  8883. * Enum defining the type of animations supported by InputBlock
  8884. */
  8885. export enum AnimatedInputBlockTypes {
  8886. /** No animation */
  8887. None = 0,
  8888. /** Time based animation. Will only work for floats */
  8889. Time = 1
  8890. }
  8891. }
  8892. declare module BABYLON {
  8893. /**
  8894. * Interface describing all the common properties and methods a shadow light needs to implement.
  8895. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8896. * as well as binding the different shadow properties to the effects.
  8897. */
  8898. export interface IShadowLight extends Light {
  8899. /**
  8900. * The light id in the scene (used in scene.findLighById for instance)
  8901. */
  8902. id: string;
  8903. /**
  8904. * The position the shdow will be casted from.
  8905. */
  8906. position: Vector3;
  8907. /**
  8908. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8909. */
  8910. direction: Vector3;
  8911. /**
  8912. * The transformed position. Position of the light in world space taking parenting in account.
  8913. */
  8914. transformedPosition: Vector3;
  8915. /**
  8916. * The transformed direction. Direction of the light in world space taking parenting in account.
  8917. */
  8918. transformedDirection: Vector3;
  8919. /**
  8920. * The friendly name of the light in the scene.
  8921. */
  8922. name: string;
  8923. /**
  8924. * Defines the shadow projection clipping minimum z value.
  8925. */
  8926. shadowMinZ: number;
  8927. /**
  8928. * Defines the shadow projection clipping maximum z value.
  8929. */
  8930. shadowMaxZ: number;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Gets the scene the light belongs to.
  8938. * @returns The scene
  8939. */
  8940. getScene(): Scene;
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8948. * @param matrix The materix to updated with the projection information
  8949. * @param viewMatrix The transform matrix of the light
  8950. * @param renderList The list of mesh to render in the map
  8951. * @returns The current light
  8952. */
  8953. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8954. /**
  8955. * Gets the current depth scale used in ESM.
  8956. * @returns The scale
  8957. */
  8958. getDepthScale(): number;
  8959. /**
  8960. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8961. * @returns true if a cube texture needs to be use
  8962. */
  8963. needCube(): boolean;
  8964. /**
  8965. * Detects if the projection matrix requires to be recomputed this frame.
  8966. * @returns true if it requires to be recomputed otherwise, false.
  8967. */
  8968. needProjectionMatrixCompute(): boolean;
  8969. /**
  8970. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8971. */
  8972. forceProjectionMatrixCompute(): void;
  8973. /**
  8974. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8975. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8976. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8977. */
  8978. getShadowDirection(faceIndex?: number): Vector3;
  8979. /**
  8980. * Gets the minZ used for shadow according to both the scene and the light.
  8981. * @param activeCamera The camera we are returning the min for
  8982. * @returns the depth min z
  8983. */
  8984. getDepthMinZ(activeCamera: Camera): number;
  8985. /**
  8986. * Gets the maxZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the max for
  8988. * @returns the depth max z
  8989. */
  8990. getDepthMaxZ(activeCamera: Camera): number;
  8991. }
  8992. /**
  8993. * Base implementation IShadowLight
  8994. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8995. */
  8996. export abstract class ShadowLight extends Light implements IShadowLight {
  8997. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8998. protected _position: Vector3;
  8999. protected _setPosition(value: Vector3): void;
  9000. /**
  9001. * Sets the position the shadow will be casted from. Also use as the light position for both
  9002. * point and spot lights.
  9003. */
  9004. get position(): Vector3;
  9005. /**
  9006. * Sets the position the shadow will be casted from. Also use as the light position for both
  9007. * point and spot lights.
  9008. */
  9009. set position(value: Vector3);
  9010. protected _direction: Vector3;
  9011. protected _setDirection(value: Vector3): void;
  9012. /**
  9013. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9014. * Also use as the light direction on spot and directional lights.
  9015. */
  9016. get direction(): Vector3;
  9017. /**
  9018. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. set direction(value: Vector3);
  9022. protected _shadowMinZ: number;
  9023. /**
  9024. * Gets the shadow projection clipping minimum z value.
  9025. */
  9026. get shadowMinZ(): number;
  9027. /**
  9028. * Sets the shadow projection clipping minimum z value.
  9029. */
  9030. set shadowMinZ(value: number);
  9031. protected _shadowMaxZ: number;
  9032. /**
  9033. * Sets the shadow projection clipping maximum z value.
  9034. */
  9035. get shadowMaxZ(): number;
  9036. /**
  9037. * Gets the shadow projection clipping maximum z value.
  9038. */
  9039. set shadowMaxZ(value: number);
  9040. /**
  9041. * Callback defining a custom Projection Matrix Builder.
  9042. * This can be used to override the default projection matrix computation.
  9043. */
  9044. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. private _needProjectionMatrixCompute;
  9054. /**
  9055. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9056. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9057. */
  9058. computeTransformedInformation(): boolean;
  9059. /**
  9060. * Return the depth scale used for the shadow map.
  9061. * @returns the depth scale.
  9062. */
  9063. getDepthScale(): number;
  9064. /**
  9065. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9068. */
  9069. getShadowDirection(faceIndex?: number): Vector3;
  9070. /**
  9071. * Returns the ShadowLight absolute position in the World.
  9072. * @returns the position vector in world space
  9073. */
  9074. getAbsolutePosition(): Vector3;
  9075. /**
  9076. * Sets the ShadowLight direction toward the passed target.
  9077. * @param target The point to target in local space
  9078. * @returns the updated ShadowLight direction
  9079. */
  9080. setDirectionToTarget(target: Vector3): Vector3;
  9081. /**
  9082. * Returns the light rotation in euler definition.
  9083. * @returns the x y z rotation in local space.
  9084. */
  9085. getRotation(): Vector3;
  9086. /**
  9087. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9088. * @returns true if a cube texture needs to be use
  9089. */
  9090. needCube(): boolean;
  9091. /**
  9092. * Detects if the projection matrix requires to be recomputed this frame.
  9093. * @returns true if it requires to be recomputed otherwise, false.
  9094. */
  9095. needProjectionMatrixCompute(): boolean;
  9096. /**
  9097. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9098. */
  9099. forceProjectionMatrixCompute(): void;
  9100. /** @hidden */
  9101. _initCache(): void;
  9102. /** @hidden */
  9103. _isSynchronized(): boolean;
  9104. /**
  9105. * Computes the world matrix of the node
  9106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9107. * @returns the world matrix
  9108. */
  9109. computeWorldMatrix(force?: boolean): Matrix;
  9110. /**
  9111. * Gets the minZ used for shadow according to both the scene and the light.
  9112. * @param activeCamera The camera we are returning the min for
  9113. * @returns the depth min z
  9114. */
  9115. getDepthMinZ(activeCamera: Camera): number;
  9116. /**
  9117. * Gets the maxZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the max for
  9119. * @returns the depth max z
  9120. */
  9121. getDepthMaxZ(activeCamera: Camera): number;
  9122. /**
  9123. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9124. * @param matrix The materix to updated with the projection information
  9125. * @param viewMatrix The transform matrix of the light
  9126. * @param renderList The list of mesh to render in the map
  9127. * @returns The current light
  9128. */
  9129. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9130. }
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var packingFunctions: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var bayerDitherFunctions: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var shadowMapFragmentDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var clipPlaneFragmentDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var clipPlaneFragment: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var shadowMapFragment: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var shadowMapPixelShader: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var bonesDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var morphTargetsVertexGlobalDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertexDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var helperFunctions: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexDeclaration: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var clipPlaneVertexDeclaration: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var morphTargetsVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var instancesVertex: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var bonesVertex: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapVertexNormalBias: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var shadowMapVertexMetric: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var clipPlaneVertex: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var shadowMapVertexShader: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var depthBoxBlurPixelShader: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var shadowMapFragmentSoftTransparentShadow: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /**
  9295. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9296. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9297. */
  9298. export class EffectFallbacks implements IEffectFallbacks {
  9299. private _defines;
  9300. private _currentRank;
  9301. private _maxRank;
  9302. private _mesh;
  9303. /**
  9304. * Removes the fallback from the bound mesh.
  9305. */
  9306. unBindMesh(): void;
  9307. /**
  9308. * Adds a fallback on the specified property.
  9309. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9310. * @param define The name of the define in the shader
  9311. */
  9312. addFallback(rank: number, define: string): void;
  9313. /**
  9314. * Sets the mesh to use CPU skinning when needing to fallback.
  9315. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9316. * @param mesh The mesh to use the fallbacks.
  9317. */
  9318. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9319. /**
  9320. * Checks to see if more fallbacks are still availible.
  9321. */
  9322. get hasMoreFallbacks(): boolean;
  9323. /**
  9324. * Removes the defines that should be removed when falling back.
  9325. * @param currentDefines defines the current define statements for the shader.
  9326. * @param effect defines the current effect we try to compile
  9327. * @returns The resulting defines with defines of the current rank removed.
  9328. */
  9329. reduce(currentDefines: string, effect: Effect): string;
  9330. }
  9331. }
  9332. declare module BABYLON {
  9333. /**
  9334. * Interface used to define Action
  9335. */
  9336. export interface IAction {
  9337. /**
  9338. * Trigger for the action
  9339. */
  9340. trigger: number;
  9341. /** Options of the trigger */
  9342. triggerOptions: any;
  9343. /**
  9344. * Gets the trigger parameters
  9345. * @returns the trigger parameters
  9346. */
  9347. getTriggerParameter(): any;
  9348. /**
  9349. * Internal only - executes current action event
  9350. * @hidden
  9351. */
  9352. _executeCurrent(evt?: ActionEvent): void;
  9353. /**
  9354. * Serialize placeholder for child classes
  9355. * @param parent of child
  9356. * @returns the serialized object
  9357. */
  9358. serialize(parent: any): any;
  9359. /**
  9360. * Internal only
  9361. * @hidden
  9362. */
  9363. _prepare(): void;
  9364. /**
  9365. * Internal only - manager for action
  9366. * @hidden
  9367. */
  9368. _actionManager: AbstractActionManager;
  9369. /**
  9370. * Adds action to chain of actions, may be a DoNothingAction
  9371. * @param action defines the next action to execute
  9372. * @returns The action passed in
  9373. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9374. */
  9375. then(action: IAction): IAction;
  9376. }
  9377. /**
  9378. * The action to be carried out following a trigger
  9379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9380. */
  9381. export class Action implements IAction {
  9382. /** the trigger, with or without parameters, for the action */
  9383. triggerOptions: any;
  9384. /**
  9385. * Trigger for the action
  9386. */
  9387. trigger: number;
  9388. /**
  9389. * Internal only - manager for action
  9390. * @hidden
  9391. */
  9392. _actionManager: ActionManager;
  9393. private _nextActiveAction;
  9394. private _child;
  9395. private _condition?;
  9396. private _triggerParameter;
  9397. /**
  9398. * An event triggered prior to action being executed.
  9399. */
  9400. onBeforeExecuteObservable: Observable<Action>;
  9401. /**
  9402. * Creates a new Action
  9403. * @param triggerOptions the trigger, with or without parameters, for the action
  9404. * @param condition an optional determinant of action
  9405. */
  9406. constructor(
  9407. /** the trigger, with or without parameters, for the action */
  9408. triggerOptions: any, condition?: Condition);
  9409. /**
  9410. * Internal only
  9411. * @hidden
  9412. */
  9413. _prepare(): void;
  9414. /**
  9415. * Gets the trigger parameters
  9416. * @returns the trigger parameters
  9417. */
  9418. getTriggerParameter(): any;
  9419. /**
  9420. * Internal only - executes current action event
  9421. * @hidden
  9422. */
  9423. _executeCurrent(evt?: ActionEvent): void;
  9424. /**
  9425. * Execute placeholder for child classes
  9426. * @param evt optional action event
  9427. */
  9428. execute(evt?: ActionEvent): void;
  9429. /**
  9430. * Skips to next active action
  9431. */
  9432. skipToNextActiveAction(): void;
  9433. /**
  9434. * Adds action to chain of actions, may be a DoNothingAction
  9435. * @param action defines the next action to execute
  9436. * @returns The action passed in
  9437. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9438. */
  9439. then(action: Action): Action;
  9440. /**
  9441. * Internal only
  9442. * @hidden
  9443. */
  9444. _getProperty(propertyPath: string): string;
  9445. /**
  9446. * Internal only
  9447. * @hidden
  9448. */
  9449. _getEffectiveTarget(target: any, propertyPath: string): any;
  9450. /**
  9451. * Serialize placeholder for child classes
  9452. * @param parent of child
  9453. * @returns the serialized object
  9454. */
  9455. serialize(parent: any): any;
  9456. /**
  9457. * Internal only called by serialize
  9458. * @hidden
  9459. */
  9460. protected _serialize(serializedAction: any, parent?: any): any;
  9461. /**
  9462. * Internal only
  9463. * @hidden
  9464. */
  9465. static _SerializeValueAsString: (value: any) => string;
  9466. /**
  9467. * Internal only
  9468. * @hidden
  9469. */
  9470. static _GetTargetProperty: (target: Scene | Node) => {
  9471. name: string;
  9472. targetType: string;
  9473. value: string;
  9474. };
  9475. }
  9476. }
  9477. declare module BABYLON {
  9478. /**
  9479. * A Condition applied to an Action
  9480. */
  9481. export class Condition {
  9482. /**
  9483. * Internal only - manager for action
  9484. * @hidden
  9485. */
  9486. _actionManager: ActionManager;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. _evaluationId: number;
  9492. /**
  9493. * Internal only
  9494. * @hidden
  9495. */
  9496. _currentResult: boolean;
  9497. /**
  9498. * Creates a new Condition
  9499. * @param actionManager the manager of the action the condition is applied to
  9500. */
  9501. constructor(actionManager: ActionManager);
  9502. /**
  9503. * Check if the current condition is valid
  9504. * @returns a boolean
  9505. */
  9506. isValid(): boolean;
  9507. /**
  9508. * Internal only
  9509. * @hidden
  9510. */
  9511. _getProperty(propertyPath: string): string;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. _getEffectiveTarget(target: any, propertyPath: string): any;
  9517. /**
  9518. * Serialize placeholder for child classes
  9519. * @returns the serialized object
  9520. */
  9521. serialize(): any;
  9522. /**
  9523. * Internal only
  9524. * @hidden
  9525. */
  9526. protected _serialize(serializedCondition: any): any;
  9527. }
  9528. /**
  9529. * Defines specific conditional operators as extensions of Condition
  9530. */
  9531. export class ValueCondition extends Condition {
  9532. /** path to specify the property of the target the conditional operator uses */
  9533. propertyPath: string;
  9534. /** the value compared by the conditional operator against the current value of the property */
  9535. value: any;
  9536. /** the conditional operator, default ValueCondition.IsEqual */
  9537. operator: number;
  9538. /**
  9539. * Internal only
  9540. * @hidden
  9541. */
  9542. private static _IsEqual;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. private static _IsDifferent;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. private static _IsGreater;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. private static _IsLesser;
  9558. /**
  9559. * returns the number for IsEqual
  9560. */
  9561. static get IsEqual(): number;
  9562. /**
  9563. * Returns the number for IsDifferent
  9564. */
  9565. static get IsDifferent(): number;
  9566. /**
  9567. * Returns the number for IsGreater
  9568. */
  9569. static get IsGreater(): number;
  9570. /**
  9571. * Returns the number for IsLesser
  9572. */
  9573. static get IsLesser(): number;
  9574. /**
  9575. * Internal only The action manager for the condition
  9576. * @hidden
  9577. */
  9578. _actionManager: ActionManager;
  9579. /**
  9580. * Internal only
  9581. * @hidden
  9582. */
  9583. private _target;
  9584. /**
  9585. * Internal only
  9586. * @hidden
  9587. */
  9588. private _effectiveTarget;
  9589. /**
  9590. * Internal only
  9591. * @hidden
  9592. */
  9593. private _property;
  9594. /**
  9595. * Creates a new ValueCondition
  9596. * @param actionManager manager for the action the condition applies to
  9597. * @param target for the action
  9598. * @param propertyPath path to specify the property of the target the conditional operator uses
  9599. * @param value the value compared by the conditional operator against the current value of the property
  9600. * @param operator the conditional operator, default ValueCondition.IsEqual
  9601. */
  9602. constructor(actionManager: ActionManager, target: any,
  9603. /** path to specify the property of the target the conditional operator uses */
  9604. propertyPath: string,
  9605. /** the value compared by the conditional operator against the current value of the property */
  9606. value: any,
  9607. /** the conditional operator, default ValueCondition.IsEqual */
  9608. operator?: number);
  9609. /**
  9610. * Compares the given value with the property value for the specified conditional operator
  9611. * @returns the result of the comparison
  9612. */
  9613. isValid(): boolean;
  9614. /**
  9615. * Serialize the ValueCondition into a JSON compatible object
  9616. * @returns serialization object
  9617. */
  9618. serialize(): any;
  9619. /**
  9620. * Gets the name of the conditional operator for the ValueCondition
  9621. * @param operator the conditional operator
  9622. * @returns the name
  9623. */
  9624. static GetOperatorName(operator: number): string;
  9625. }
  9626. /**
  9627. * Defines a predicate condition as an extension of Condition
  9628. */
  9629. export class PredicateCondition extends Condition {
  9630. /** defines the predicate function used to validate the condition */
  9631. predicate: () => boolean;
  9632. /**
  9633. * Internal only - manager for action
  9634. * @hidden
  9635. */
  9636. _actionManager: ActionManager;
  9637. /**
  9638. * Creates a new PredicateCondition
  9639. * @param actionManager manager for the action the condition applies to
  9640. * @param predicate defines the predicate function used to validate the condition
  9641. */
  9642. constructor(actionManager: ActionManager,
  9643. /** defines the predicate function used to validate the condition */
  9644. predicate: () => boolean);
  9645. /**
  9646. * @returns the validity of the predicate condition
  9647. */
  9648. isValid(): boolean;
  9649. }
  9650. /**
  9651. * Defines a state condition as an extension of Condition
  9652. */
  9653. export class StateCondition extends Condition {
  9654. /** Value to compare with target state */
  9655. value: string;
  9656. /**
  9657. * Internal only - manager for action
  9658. * @hidden
  9659. */
  9660. _actionManager: ActionManager;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private _target;
  9666. /**
  9667. * Creates a new StateCondition
  9668. * @param actionManager manager for the action the condition applies to
  9669. * @param target of the condition
  9670. * @param value to compare with target state
  9671. */
  9672. constructor(actionManager: ActionManager, target: any,
  9673. /** Value to compare with target state */
  9674. value: string);
  9675. /**
  9676. * Gets a boolean indicating if the current condition is met
  9677. * @returns the validity of the state
  9678. */
  9679. isValid(): boolean;
  9680. /**
  9681. * Serialize the StateCondition into a JSON compatible object
  9682. * @returns serialization object
  9683. */
  9684. serialize(): any;
  9685. }
  9686. }
  9687. declare module BABYLON {
  9688. /**
  9689. * This defines an action responsible to toggle a boolean once triggered.
  9690. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9691. */
  9692. export class SwitchBooleanAction extends Action {
  9693. /**
  9694. * The path to the boolean property in the target object
  9695. */
  9696. propertyPath: string;
  9697. private _target;
  9698. private _effectiveTarget;
  9699. private _property;
  9700. /**
  9701. * Instantiate the action
  9702. * @param triggerOptions defines the trigger options
  9703. * @param target defines the object containing the boolean
  9704. * @param propertyPath defines the path to the boolean property in the target object
  9705. * @param condition defines the trigger related conditions
  9706. */
  9707. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9708. /** @hidden */
  9709. _prepare(): void;
  9710. /**
  9711. * Execute the action toggle the boolean value.
  9712. */
  9713. execute(): void;
  9714. /**
  9715. * Serializes the actions and its related information.
  9716. * @param parent defines the object to serialize in
  9717. * @returns the serialized object
  9718. */
  9719. serialize(parent: any): any;
  9720. }
  9721. /**
  9722. * This defines an action responsible to set a the state field of the target
  9723. * to a desired value once triggered.
  9724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9725. */
  9726. export class SetStateAction extends Action {
  9727. /**
  9728. * The value to store in the state field.
  9729. */
  9730. value: string;
  9731. private _target;
  9732. /**
  9733. * Instantiate the action
  9734. * @param triggerOptions defines the trigger options
  9735. * @param target defines the object containing the state property
  9736. * @param value defines the value to store in the state field
  9737. * @param condition defines the trigger related conditions
  9738. */
  9739. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9740. /**
  9741. * Execute the action and store the value on the target state property.
  9742. */
  9743. execute(): void;
  9744. /**
  9745. * Serializes the actions and its related information.
  9746. * @param parent defines the object to serialize in
  9747. * @returns the serialized object
  9748. */
  9749. serialize(parent: any): any;
  9750. }
  9751. /**
  9752. * This defines an action responsible to set a property of the target
  9753. * to a desired value once triggered.
  9754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9755. */
  9756. export class SetValueAction extends Action {
  9757. /**
  9758. * The path of the property to set in the target.
  9759. */
  9760. propertyPath: string;
  9761. /**
  9762. * The value to set in the property
  9763. */
  9764. value: any;
  9765. private _target;
  9766. private _effectiveTarget;
  9767. private _property;
  9768. /**
  9769. * Instantiate the action
  9770. * @param triggerOptions defines the trigger options
  9771. * @param target defines the object containing the property
  9772. * @param propertyPath defines the path of the property to set in the target
  9773. * @param value defines the value to set in the property
  9774. * @param condition defines the trigger related conditions
  9775. */
  9776. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9777. /** @hidden */
  9778. _prepare(): void;
  9779. /**
  9780. * Execute the action and set the targetted property to the desired value.
  9781. */
  9782. execute(): void;
  9783. /**
  9784. * Serializes the actions and its related information.
  9785. * @param parent defines the object to serialize in
  9786. * @returns the serialized object
  9787. */
  9788. serialize(parent: any): any;
  9789. }
  9790. /**
  9791. * This defines an action responsible to increment the target value
  9792. * to a desired value once triggered.
  9793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9794. */
  9795. export class IncrementValueAction extends Action {
  9796. /**
  9797. * The path of the property to increment in the target.
  9798. */
  9799. propertyPath: string;
  9800. /**
  9801. * The value we should increment the property by.
  9802. */
  9803. value: any;
  9804. private _target;
  9805. private _effectiveTarget;
  9806. private _property;
  9807. /**
  9808. * Instantiate the action
  9809. * @param triggerOptions defines the trigger options
  9810. * @param target defines the object containing the property
  9811. * @param propertyPath defines the path of the property to increment in the target
  9812. * @param value defines the value value we should increment the property by
  9813. * @param condition defines the trigger related conditions
  9814. */
  9815. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9816. /** @hidden */
  9817. _prepare(): void;
  9818. /**
  9819. * Execute the action and increment the target of the value amount.
  9820. */
  9821. execute(): void;
  9822. /**
  9823. * Serializes the actions and its related information.
  9824. * @param parent defines the object to serialize in
  9825. * @returns the serialized object
  9826. */
  9827. serialize(parent: any): any;
  9828. }
  9829. /**
  9830. * This defines an action responsible to start an animation once triggered.
  9831. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9832. */
  9833. export class PlayAnimationAction extends Action {
  9834. /**
  9835. * Where the animation should start (animation frame)
  9836. */
  9837. from: number;
  9838. /**
  9839. * Where the animation should stop (animation frame)
  9840. */
  9841. to: number;
  9842. /**
  9843. * Define if the animation should loop or stop after the first play.
  9844. */
  9845. loop?: boolean;
  9846. private _target;
  9847. /**
  9848. * Instantiate the action
  9849. * @param triggerOptions defines the trigger options
  9850. * @param target defines the target animation or animation name
  9851. * @param from defines from where the animation should start (animation frame)
  9852. * @param end defines where the animation should stop (animation frame)
  9853. * @param loop defines if the animation should loop or stop after the first play
  9854. * @param condition defines the trigger related conditions
  9855. */
  9856. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9857. /** @hidden */
  9858. _prepare(): void;
  9859. /**
  9860. * Execute the action and play the animation.
  9861. */
  9862. execute(): void;
  9863. /**
  9864. * Serializes the actions and its related information.
  9865. * @param parent defines the object to serialize in
  9866. * @returns the serialized object
  9867. */
  9868. serialize(parent: any): any;
  9869. }
  9870. /**
  9871. * This defines an action responsible to stop an animation once triggered.
  9872. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9873. */
  9874. export class StopAnimationAction extends Action {
  9875. private _target;
  9876. /**
  9877. * Instantiate the action
  9878. * @param triggerOptions defines the trigger options
  9879. * @param target defines the target animation or animation name
  9880. * @param condition defines the trigger related conditions
  9881. */
  9882. constructor(triggerOptions: any, target: any, condition?: Condition);
  9883. /** @hidden */
  9884. _prepare(): void;
  9885. /**
  9886. * Execute the action and stop the animation.
  9887. */
  9888. execute(): void;
  9889. /**
  9890. * Serializes the actions and its related information.
  9891. * @param parent defines the object to serialize in
  9892. * @returns the serialized object
  9893. */
  9894. serialize(parent: any): any;
  9895. }
  9896. /**
  9897. * This defines an action responsible that does nothing once triggered.
  9898. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9899. */
  9900. export class DoNothingAction extends Action {
  9901. /**
  9902. * Instantiate the action
  9903. * @param triggerOptions defines the trigger options
  9904. * @param condition defines the trigger related conditions
  9905. */
  9906. constructor(triggerOptions?: any, condition?: Condition);
  9907. /**
  9908. * Execute the action and do nothing.
  9909. */
  9910. execute(): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to trigger several actions once triggered.
  9920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9921. */
  9922. export class CombineAction extends Action {
  9923. /**
  9924. * The list of aggregated animations to run.
  9925. */
  9926. children: Action[];
  9927. /**
  9928. * Instantiate the action
  9929. * @param triggerOptions defines the trigger options
  9930. * @param children defines the list of aggregated animations to run
  9931. * @param condition defines the trigger related conditions
  9932. */
  9933. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9934. /** @hidden */
  9935. _prepare(): void;
  9936. /**
  9937. * Execute the action and executes all the aggregated actions.
  9938. */
  9939. execute(evt: ActionEvent): void;
  9940. /**
  9941. * Serializes the actions and its related information.
  9942. * @param parent defines the object to serialize in
  9943. * @returns the serialized object
  9944. */
  9945. serialize(parent: any): any;
  9946. }
  9947. /**
  9948. * This defines an action responsible to run code (external event) once triggered.
  9949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9950. */
  9951. export class ExecuteCodeAction extends Action {
  9952. /**
  9953. * The callback function to run.
  9954. */
  9955. func: (evt: ActionEvent) => void;
  9956. /**
  9957. * Instantiate the action
  9958. * @param triggerOptions defines the trigger options
  9959. * @param func defines the callback function to run
  9960. * @param condition defines the trigger related conditions
  9961. */
  9962. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9963. /**
  9964. * Execute the action and run the attached code.
  9965. */
  9966. execute(evt: ActionEvent): void;
  9967. }
  9968. /**
  9969. * This defines an action responsible to set the parent property of the target once triggered.
  9970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9971. */
  9972. export class SetParentAction extends Action {
  9973. private _parent;
  9974. private _target;
  9975. /**
  9976. * Instantiate the action
  9977. * @param triggerOptions defines the trigger options
  9978. * @param target defines the target containing the parent property
  9979. * @param parent defines from where the animation should start (animation frame)
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and set the parent property.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. }
  9997. declare module BABYLON {
  9998. /**
  9999. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10000. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class ActionManager extends AbstractActionManager {
  10004. /**
  10005. * Nothing
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly NothingTrigger: number;
  10009. /**
  10010. * On pick
  10011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10012. */
  10013. static readonly OnPickTrigger: number;
  10014. /**
  10015. * On left pick
  10016. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10017. */
  10018. static readonly OnLeftPickTrigger: number;
  10019. /**
  10020. * On right pick
  10021. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10022. */
  10023. static readonly OnRightPickTrigger: number;
  10024. /**
  10025. * On center pick
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10027. */
  10028. static readonly OnCenterPickTrigger: number;
  10029. /**
  10030. * On pick down
  10031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10032. */
  10033. static readonly OnPickDownTrigger: number;
  10034. /**
  10035. * On double pick
  10036. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10037. */
  10038. static readonly OnDoublePickTrigger: number;
  10039. /**
  10040. * On pick up
  10041. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10042. */
  10043. static readonly OnPickUpTrigger: number;
  10044. /**
  10045. * On pick out.
  10046. * This trigger will only be raised if you also declared a OnPickDown
  10047. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnPickOutTrigger: number;
  10050. /**
  10051. * On long press
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnLongPressTrigger: number;
  10055. /**
  10056. * On pointer over
  10057. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10058. */
  10059. static readonly OnPointerOverTrigger: number;
  10060. /**
  10061. * On pointer out
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10063. */
  10064. static readonly OnPointerOutTrigger: number;
  10065. /**
  10066. * On every frame
  10067. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10068. */
  10069. static readonly OnEveryFrameTrigger: number;
  10070. /**
  10071. * On intersection enter
  10072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10073. */
  10074. static readonly OnIntersectionEnterTrigger: number;
  10075. /**
  10076. * On intersection exit
  10077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10078. */
  10079. static readonly OnIntersectionExitTrigger: number;
  10080. /**
  10081. * On key down
  10082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10083. */
  10084. static readonly OnKeyDownTrigger: number;
  10085. /**
  10086. * On key up
  10087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10088. */
  10089. static readonly OnKeyUpTrigger: number;
  10090. private _scene;
  10091. /**
  10092. * Creates a new action manager
  10093. * @param scene defines the hosting scene
  10094. */
  10095. constructor(scene: Scene);
  10096. /**
  10097. * Releases all associated resources
  10098. */
  10099. dispose(): void;
  10100. /**
  10101. * Gets hosting scene
  10102. * @returns the hosting scene
  10103. */
  10104. getScene(): Scene;
  10105. /**
  10106. * Does this action manager handles actions of any of the given triggers
  10107. * @param triggers defines the triggers to be tested
  10108. * @return a boolean indicating whether one (or more) of the triggers is handled
  10109. */
  10110. hasSpecificTriggers(triggers: number[]): boolean;
  10111. /**
  10112. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10113. * speed.
  10114. * @param triggerA defines the trigger to be tested
  10115. * @param triggerB defines the trigger to be tested
  10116. * @return a boolean indicating whether one (or more) of the triggers is handled
  10117. */
  10118. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10119. /**
  10120. * Does this action manager handles actions of a given trigger
  10121. * @param trigger defines the trigger to be tested
  10122. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10123. * @return whether the trigger is handled
  10124. */
  10125. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10126. /**
  10127. * Does this action manager has pointer triggers
  10128. */
  10129. get hasPointerTriggers(): boolean;
  10130. /**
  10131. * Does this action manager has pick triggers
  10132. */
  10133. get hasPickTriggers(): boolean;
  10134. /**
  10135. * Registers an action to this action manager
  10136. * @param action defines the action to be registered
  10137. * @return the action amended (prepared) after registration
  10138. */
  10139. registerAction(action: IAction): Nullable<IAction>;
  10140. /**
  10141. * Unregisters an action to this action manager
  10142. * @param action defines the action to be unregistered
  10143. * @return a boolean indicating whether the action has been unregistered
  10144. */
  10145. unregisterAction(action: IAction): Boolean;
  10146. /**
  10147. * Process a specific trigger
  10148. * @param trigger defines the trigger to process
  10149. * @param evt defines the event details to be processed
  10150. */
  10151. processTrigger(trigger: number, evt?: IActionEvent): void;
  10152. /** @hidden */
  10153. _getEffectiveTarget(target: any, propertyPath: string): any;
  10154. /** @hidden */
  10155. _getProperty(propertyPath: string): string;
  10156. /**
  10157. * Serialize this manager to a JSON object
  10158. * @param name defines the property name to store this manager
  10159. * @returns a JSON representation of this manager
  10160. */
  10161. serialize(name: string): any;
  10162. /**
  10163. * Creates a new ActionManager from a JSON data
  10164. * @param parsedActions defines the JSON data to read from
  10165. * @param object defines the hosting mesh
  10166. * @param scene defines the hosting scene
  10167. */
  10168. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10169. /**
  10170. * Get a trigger name by index
  10171. * @param trigger defines the trigger index
  10172. * @returns a trigger name
  10173. */
  10174. static GetTriggerName(trigger: number): string;
  10175. }
  10176. }
  10177. declare module BABYLON {
  10178. /**
  10179. * Class used to represent a sprite
  10180. * @see https://doc.babylonjs.com/babylon101/sprites
  10181. */
  10182. export class Sprite implements IAnimatable {
  10183. /** defines the name */
  10184. name: string;
  10185. /** Gets or sets the current world position */
  10186. position: Vector3;
  10187. /** Gets or sets the main color */
  10188. color: Color4;
  10189. /** Gets or sets the width */
  10190. width: number;
  10191. /** Gets or sets the height */
  10192. height: number;
  10193. /** Gets or sets rotation angle */
  10194. angle: number;
  10195. /** Gets or sets the cell index in the sprite sheet */
  10196. cellIndex: number;
  10197. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10198. cellRef: string;
  10199. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10200. invertU: boolean;
  10201. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10202. invertV: boolean;
  10203. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10204. disposeWhenFinishedAnimating: boolean;
  10205. /** Gets the list of attached animations */
  10206. animations: Nullable<Array<Animation>>;
  10207. /** Gets or sets a boolean indicating if the sprite can be picked */
  10208. isPickable: boolean;
  10209. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10210. useAlphaForPicking: boolean;
  10211. /** @hidden */
  10212. _xOffset: number;
  10213. /** @hidden */
  10214. _yOffset: number;
  10215. /** @hidden */
  10216. _xSize: number;
  10217. /** @hidden */
  10218. _ySize: number;
  10219. /**
  10220. * Gets or sets the associated action manager
  10221. */
  10222. actionManager: Nullable<ActionManager>;
  10223. /**
  10224. * An event triggered when the control has been disposed
  10225. */
  10226. onDisposeObservable: Observable<Sprite>;
  10227. private _animationStarted;
  10228. private _loopAnimation;
  10229. private _fromIndex;
  10230. private _toIndex;
  10231. private _delay;
  10232. private _direction;
  10233. private _manager;
  10234. private _time;
  10235. private _onAnimationEnd;
  10236. /**
  10237. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10238. */
  10239. isVisible: boolean;
  10240. /**
  10241. * Gets or sets the sprite size
  10242. */
  10243. get size(): number;
  10244. set size(value: number);
  10245. /**
  10246. * Returns a boolean indicating if the animation is started
  10247. */
  10248. get animationStarted(): boolean;
  10249. /**
  10250. * Gets or sets the unique id of the sprite
  10251. */
  10252. uniqueId: number;
  10253. /**
  10254. * Gets the manager of this sprite
  10255. */
  10256. get manager(): ISpriteManager;
  10257. /**
  10258. * Creates a new Sprite
  10259. * @param name defines the name
  10260. * @param manager defines the manager
  10261. */
  10262. constructor(
  10263. /** defines the name */
  10264. name: string, manager: ISpriteManager);
  10265. /**
  10266. * Returns the string "Sprite"
  10267. * @returns "Sprite"
  10268. */
  10269. getClassName(): string;
  10270. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10271. get fromIndex(): number;
  10272. set fromIndex(value: number);
  10273. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10274. get toIndex(): number;
  10275. set toIndex(value: number);
  10276. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10277. get loopAnimation(): boolean;
  10278. set loopAnimation(value: boolean);
  10279. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10280. get delay(): number;
  10281. set delay(value: number);
  10282. /**
  10283. * Starts an animation
  10284. * @param from defines the initial key
  10285. * @param to defines the end key
  10286. * @param loop defines if the animation must loop
  10287. * @param delay defines the start delay (in ms)
  10288. * @param onAnimationEnd defines a callback to call when animation ends
  10289. */
  10290. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10291. /** Stops current animation (if any) */
  10292. stopAnimation(): void;
  10293. /** @hidden */
  10294. _animate(deltaTime: number): void;
  10295. /** Release associated resources */
  10296. dispose(): void;
  10297. /**
  10298. * Serializes the sprite to a JSON object
  10299. * @returns the JSON object
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Parses a JSON object to create a new sprite
  10304. * @param parsedSprite The JSON object to parse
  10305. * @param manager defines the hosting manager
  10306. * @returns the new sprite
  10307. */
  10308. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Information about the result of picking within a scene
  10314. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10315. */
  10316. export class PickingInfo {
  10317. /** @hidden */
  10318. _pickingUnavailable: boolean;
  10319. /**
  10320. * If the pick collided with an object
  10321. */
  10322. hit: boolean;
  10323. /**
  10324. * Distance away where the pick collided
  10325. */
  10326. distance: number;
  10327. /**
  10328. * The location of pick collision
  10329. */
  10330. pickedPoint: Nullable<Vector3>;
  10331. /**
  10332. * The mesh corresponding the the pick collision
  10333. */
  10334. pickedMesh: Nullable<AbstractMesh>;
  10335. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10336. bu: number;
  10337. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10338. bv: number;
  10339. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10340. faceId: number;
  10341. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10342. subMeshFaceId: number;
  10343. /** Id of the the submesh that was picked */
  10344. subMeshId: number;
  10345. /** If a sprite was picked, this will be the sprite the pick collided with */
  10346. pickedSprite: Nullable<Sprite>;
  10347. /**
  10348. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10349. */
  10350. originMesh: Nullable<AbstractMesh>;
  10351. /**
  10352. * The ray that was used to perform the picking.
  10353. */
  10354. ray: Nullable<Ray>;
  10355. /**
  10356. * Gets the normal correspodning to the face the pick collided with
  10357. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10358. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10359. * @returns The normal correspodning to the face the pick collided with
  10360. */
  10361. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10362. /**
  10363. * Gets the texture coordinates of where the pick occured
  10364. * @returns the vector containing the coordnates of the texture
  10365. */
  10366. getTextureCoordinates(): Nullable<Vector2>;
  10367. }
  10368. }
  10369. declare module BABYLON {
  10370. /**
  10371. * Class representing a ray with position and direction
  10372. */
  10373. export class Ray {
  10374. /** origin point */
  10375. origin: Vector3;
  10376. /** direction */
  10377. direction: Vector3;
  10378. /** length of the ray */
  10379. length: number;
  10380. private static readonly TmpVector3;
  10381. private _tmpRay;
  10382. /**
  10383. * Creates a new ray
  10384. * @param origin origin point
  10385. * @param direction direction
  10386. * @param length length of the ray
  10387. */
  10388. constructor(
  10389. /** origin point */
  10390. origin: Vector3,
  10391. /** direction */
  10392. direction: Vector3,
  10393. /** length of the ray */
  10394. length?: number);
  10395. /**
  10396. * Checks if the ray intersects a box
  10397. * This does not account for the ray lenght by design to improve perfs.
  10398. * @param minimum bound of the box
  10399. * @param maximum bound of the box
  10400. * @param intersectionTreshold extra extend to be added to the box in all direction
  10401. * @returns if the box was hit
  10402. */
  10403. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10404. /**
  10405. * Checks if the ray intersects a box
  10406. * This does not account for the ray lenght by design to improve perfs.
  10407. * @param box the bounding box to check
  10408. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10409. * @returns if the box was hit
  10410. */
  10411. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10412. /**
  10413. * If the ray hits a sphere
  10414. * @param sphere the bounding sphere to check
  10415. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10416. * @returns true if it hits the sphere
  10417. */
  10418. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10419. /**
  10420. * If the ray hits a triange
  10421. * @param vertex0 triangle vertex
  10422. * @param vertex1 triangle vertex
  10423. * @param vertex2 triangle vertex
  10424. * @returns intersection information if hit
  10425. */
  10426. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10427. /**
  10428. * Checks if ray intersects a plane
  10429. * @param plane the plane to check
  10430. * @returns the distance away it was hit
  10431. */
  10432. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10433. /**
  10434. * Calculate the intercept of a ray on a given axis
  10435. * @param axis to check 'x' | 'y' | 'z'
  10436. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10437. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10438. */
  10439. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10440. /**
  10441. * Checks if ray intersects a mesh
  10442. * @param mesh the mesh to check
  10443. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10444. * @returns picking info of the intersecton
  10445. */
  10446. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10447. /**
  10448. * Checks if ray intersects a mesh
  10449. * @param meshes the meshes to check
  10450. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10451. * @param results array to store result in
  10452. * @returns Array of picking infos
  10453. */
  10454. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10455. private _comparePickingInfo;
  10456. private static smallnum;
  10457. private static rayl;
  10458. /**
  10459. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10460. * @param sega the first point of the segment to test the intersection against
  10461. * @param segb the second point of the segment to test the intersection against
  10462. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10463. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10464. */
  10465. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10466. /**
  10467. * Update the ray from viewport position
  10468. * @param x position
  10469. * @param y y position
  10470. * @param viewportWidth viewport width
  10471. * @param viewportHeight viewport height
  10472. * @param world world matrix
  10473. * @param view view matrix
  10474. * @param projection projection matrix
  10475. * @returns this ray updated
  10476. */
  10477. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10478. /**
  10479. * Creates a ray with origin and direction of 0,0,0
  10480. * @returns the new ray
  10481. */
  10482. static Zero(): Ray;
  10483. /**
  10484. * Creates a new ray from screen space and viewport
  10485. * @param x position
  10486. * @param y y position
  10487. * @param viewportWidth viewport width
  10488. * @param viewportHeight viewport height
  10489. * @param world world matrix
  10490. * @param view view matrix
  10491. * @param projection projection matrix
  10492. * @returns new ray
  10493. */
  10494. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10495. /**
  10496. * 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
  10497. * transformed to the given world matrix.
  10498. * @param origin The origin point
  10499. * @param end The end point
  10500. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10501. * @returns the new ray
  10502. */
  10503. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10504. /**
  10505. * Transforms a ray by a matrix
  10506. * @param ray ray to transform
  10507. * @param matrix matrix to apply
  10508. * @returns the resulting new ray
  10509. */
  10510. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10511. /**
  10512. * Transforms a ray by a matrix
  10513. * @param ray ray to transform
  10514. * @param matrix matrix to apply
  10515. * @param result ray to store result in
  10516. */
  10517. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10518. /**
  10519. * Unproject a ray from screen space to object space
  10520. * @param sourceX defines the screen space x coordinate to use
  10521. * @param sourceY defines the screen space y coordinate to use
  10522. * @param viewportWidth defines the current width of the viewport
  10523. * @param viewportHeight defines the current height of the viewport
  10524. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10525. * @param view defines the view matrix to use
  10526. * @param projection defines the projection matrix to use
  10527. */
  10528. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10529. }
  10530. /**
  10531. * Type used to define predicate used to select faces when a mesh intersection is detected
  10532. */
  10533. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10534. interface Scene {
  10535. /** @hidden */
  10536. _tempPickingRay: Nullable<Ray>;
  10537. /** @hidden */
  10538. _cachedRayForTransform: Ray;
  10539. /** @hidden */
  10540. _pickWithRayInverseMatrix: Matrix;
  10541. /** @hidden */
  10542. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10543. /** @hidden */
  10544. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10545. }
  10546. }
  10547. declare module BABYLON {
  10548. /**
  10549. * Groups all the scene component constants in one place to ease maintenance.
  10550. * @hidden
  10551. */
  10552. export class SceneComponentConstants {
  10553. static readonly NAME_EFFECTLAYER: string;
  10554. static readonly NAME_LAYER: string;
  10555. static readonly NAME_LENSFLARESYSTEM: string;
  10556. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10557. static readonly NAME_PARTICLESYSTEM: string;
  10558. static readonly NAME_GAMEPAD: string;
  10559. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10560. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10561. static readonly NAME_PREPASSRENDERER: string;
  10562. static readonly NAME_DEPTHRENDERER: string;
  10563. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10564. static readonly NAME_SPRITE: string;
  10565. static readonly NAME_OUTLINERENDERER: string;
  10566. static readonly NAME_PROCEDURALTEXTURE: string;
  10567. static readonly NAME_SHADOWGENERATOR: string;
  10568. static readonly NAME_OCTREE: string;
  10569. static readonly NAME_PHYSICSENGINE: string;
  10570. static readonly NAME_AUDIO: string;
  10571. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10572. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10573. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10574. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10575. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10576. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10577. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10578. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10579. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10580. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10581. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10582. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10583. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10584. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10585. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10586. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10587. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10588. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10589. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10590. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10591. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10592. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10593. static readonly STEP_AFTERRENDER_AUDIO: number;
  10594. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10595. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10596. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10597. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10598. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10599. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10600. static readonly STEP_POINTERMOVE_SPRITE: number;
  10601. static readonly STEP_POINTERDOWN_SPRITE: number;
  10602. static readonly STEP_POINTERUP_SPRITE: number;
  10603. }
  10604. /**
  10605. * This represents a scene component.
  10606. *
  10607. * This is used to decouple the dependency the scene is having on the different workloads like
  10608. * layers, post processes...
  10609. */
  10610. export interface ISceneComponent {
  10611. /**
  10612. * The name of the component. Each component must have a unique name.
  10613. */
  10614. name: string;
  10615. /**
  10616. * The scene the component belongs to.
  10617. */
  10618. scene: Scene;
  10619. /**
  10620. * Register the component to one instance of a scene.
  10621. */
  10622. register(): void;
  10623. /**
  10624. * Rebuilds the elements related to this component in case of
  10625. * context lost for instance.
  10626. */
  10627. rebuild(): void;
  10628. /**
  10629. * Disposes the component and the associated ressources.
  10630. */
  10631. dispose(): void;
  10632. }
  10633. /**
  10634. * This represents a SERIALIZABLE scene component.
  10635. *
  10636. * This extends Scene Component to add Serialization methods on top.
  10637. */
  10638. export interface ISceneSerializableComponent extends ISceneComponent {
  10639. /**
  10640. * Adds all the elements from the container to the scene
  10641. * @param container the container holding the elements
  10642. */
  10643. addFromContainer(container: AbstractScene): void;
  10644. /**
  10645. * Removes all the elements in the container from the scene
  10646. * @param container contains the elements to remove
  10647. * @param dispose if the removed element should be disposed (default: false)
  10648. */
  10649. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10650. /**
  10651. * Serializes the component data to the specified json object
  10652. * @param serializationObject The object to serialize to
  10653. */
  10654. serialize(serializationObject: any): void;
  10655. }
  10656. /**
  10657. * Strong typing of a Mesh related stage step action
  10658. */
  10659. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10660. /**
  10661. * Strong typing of a Evaluate Sub Mesh related stage step action
  10662. */
  10663. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10664. /**
  10665. * Strong typing of a Active Mesh related stage step action
  10666. */
  10667. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10668. /**
  10669. * Strong typing of a Camera related stage step action
  10670. */
  10671. export type CameraStageAction = (camera: Camera) => void;
  10672. /**
  10673. * Strong typing of a Camera Frame buffer related stage step action
  10674. */
  10675. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10676. /**
  10677. * Strong typing of a Render Target related stage step action
  10678. */
  10679. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10680. /**
  10681. * Strong typing of a RenderingGroup related stage step action
  10682. */
  10683. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10684. /**
  10685. * Strong typing of a Mesh Render related stage step action
  10686. */
  10687. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10688. /**
  10689. * Strong typing of a simple stage step action
  10690. */
  10691. export type SimpleStageAction = () => void;
  10692. /**
  10693. * Strong typing of a render target action.
  10694. */
  10695. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10696. /**
  10697. * Strong typing of a pointer move action.
  10698. */
  10699. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10700. /**
  10701. * Strong typing of a pointer up/down action.
  10702. */
  10703. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10704. /**
  10705. * Representation of a stage in the scene (Basically a list of ordered steps)
  10706. * @hidden
  10707. */
  10708. export class Stage<T extends Function> extends Array<{
  10709. index: number;
  10710. component: ISceneComponent;
  10711. action: T;
  10712. }> {
  10713. /**
  10714. * Hide ctor from the rest of the world.
  10715. * @param items The items to add.
  10716. */
  10717. private constructor();
  10718. /**
  10719. * Creates a new Stage.
  10720. * @returns A new instance of a Stage
  10721. */
  10722. static Create<T extends Function>(): Stage<T>;
  10723. /**
  10724. * Registers a step in an ordered way in the targeted stage.
  10725. * @param index Defines the position to register the step in
  10726. * @param component Defines the component attached to the step
  10727. * @param action Defines the action to launch during the step
  10728. */
  10729. registerStep(index: number, component: ISceneComponent, action: T): void;
  10730. /**
  10731. * Clears all the steps from the stage.
  10732. */
  10733. clear(): void;
  10734. }
  10735. }
  10736. declare module BABYLON {
  10737. interface Scene {
  10738. /** @hidden */
  10739. _pointerOverSprite: Nullable<Sprite>;
  10740. /** @hidden */
  10741. _pickedDownSprite: Nullable<Sprite>;
  10742. /** @hidden */
  10743. _tempSpritePickingRay: Nullable<Ray>;
  10744. /**
  10745. * All of the sprite managers added to this scene
  10746. * @see https://doc.babylonjs.com/babylon101/sprites
  10747. */
  10748. spriteManagers: Array<ISpriteManager>;
  10749. /**
  10750. * An event triggered when sprites rendering is about to start
  10751. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10752. */
  10753. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10754. /**
  10755. * An event triggered when sprites rendering is done
  10756. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10757. */
  10758. onAfterSpritesRenderingObservable: Observable<Scene>;
  10759. /** @hidden */
  10760. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10761. /** Launch a ray to try to pick a sprite in the scene
  10762. * @param x position on screen
  10763. * @param y position on screen
  10764. * @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
  10765. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10767. * @returns a PickingInfo
  10768. */
  10769. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10770. /** Use the given ray to pick a sprite in the scene
  10771. * @param ray The ray (in world space) to use to pick meshes
  10772. * @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
  10773. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10775. * @returns a PickingInfo
  10776. */
  10777. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10778. /** @hidden */
  10779. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10780. /** Launch a ray to try to pick sprites in the scene
  10781. * @param x position on screen
  10782. * @param y position on screen
  10783. * @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
  10784. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10785. * @returns a PickingInfo array
  10786. */
  10787. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10788. /** Use the given ray to pick sprites in the scene
  10789. * @param ray The ray (in world space) to use to pick meshes
  10790. * @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
  10791. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10792. * @returns a PickingInfo array
  10793. */
  10794. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10795. /**
  10796. * Force the sprite under the pointer
  10797. * @param sprite defines the sprite to use
  10798. */
  10799. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10800. /**
  10801. * Gets the sprite under the pointer
  10802. * @returns a Sprite or null if no sprite is under the pointer
  10803. */
  10804. getPointerOverSprite(): Nullable<Sprite>;
  10805. }
  10806. /**
  10807. * Defines the sprite scene component responsible to manage sprites
  10808. * in a given scene.
  10809. */
  10810. export class SpriteSceneComponent implements ISceneComponent {
  10811. /**
  10812. * The component name helpfull to identify the component in the list of scene components.
  10813. */
  10814. readonly name: string;
  10815. /**
  10816. * The scene the component belongs to.
  10817. */
  10818. scene: Scene;
  10819. /** @hidden */
  10820. private _spritePredicate;
  10821. /**
  10822. * Creates a new instance of the component for the given scene
  10823. * @param scene Defines the scene to register the component in
  10824. */
  10825. constructor(scene: Scene);
  10826. /**
  10827. * Registers the component in a given scene
  10828. */
  10829. register(): void;
  10830. /**
  10831. * Rebuilds the elements related to this component in case of
  10832. * context lost for instance.
  10833. */
  10834. rebuild(): void;
  10835. /**
  10836. * Disposes the component and the associated ressources.
  10837. */
  10838. dispose(): void;
  10839. private _pickSpriteButKeepRay;
  10840. private _pointerMove;
  10841. private _pointerDown;
  10842. private _pointerUp;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. /** @hidden */
  10847. export var fogFragmentDeclaration: {
  10848. name: string;
  10849. shader: string;
  10850. };
  10851. }
  10852. declare module BABYLON {
  10853. /** @hidden */
  10854. export var fogFragment: {
  10855. name: string;
  10856. shader: string;
  10857. };
  10858. }
  10859. declare module BABYLON {
  10860. /** @hidden */
  10861. export var spritesPixelShader: {
  10862. name: string;
  10863. shader: string;
  10864. };
  10865. }
  10866. declare module BABYLON {
  10867. /** @hidden */
  10868. export var fogVertexDeclaration: {
  10869. name: string;
  10870. shader: string;
  10871. };
  10872. }
  10873. declare module BABYLON {
  10874. /** @hidden */
  10875. export var spritesVertexShader: {
  10876. name: string;
  10877. shader: string;
  10878. };
  10879. }
  10880. declare module BABYLON {
  10881. /**
  10882. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10883. */
  10884. export interface ISpriteManager extends IDisposable {
  10885. /**
  10886. * Gets manager's name
  10887. */
  10888. name: string;
  10889. /**
  10890. * Restricts the camera to viewing objects with the same layerMask.
  10891. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10892. */
  10893. layerMask: number;
  10894. /**
  10895. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10896. */
  10897. isPickable: boolean;
  10898. /**
  10899. * Gets the hosting scene
  10900. */
  10901. scene: Scene;
  10902. /**
  10903. * Specifies the rendering group id for this mesh (0 by default)
  10904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10905. */
  10906. renderingGroupId: number;
  10907. /**
  10908. * Defines the list of sprites managed by the manager.
  10909. */
  10910. sprites: Array<Sprite>;
  10911. /**
  10912. * Gets or sets the spritesheet texture
  10913. */
  10914. texture: Texture;
  10915. /** Defines the default width of a cell in the spritesheet */
  10916. cellWidth: number;
  10917. /** Defines the default height of a cell in the spritesheet */
  10918. cellHeight: number;
  10919. /**
  10920. * Tests the intersection of a sprite with a specific ray.
  10921. * @param ray The ray we are sending to test the collision
  10922. * @param camera The camera space we are sending rays in
  10923. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10924. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10925. * @returns picking info or null.
  10926. */
  10927. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10928. /**
  10929. * Intersects the sprites with a ray
  10930. * @param ray defines the ray to intersect with
  10931. * @param camera defines the current active camera
  10932. * @param predicate defines a predicate used to select candidate sprites
  10933. * @returns null if no hit or a PickingInfo array
  10934. */
  10935. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10936. /**
  10937. * Renders the list of sprites on screen.
  10938. */
  10939. render(): void;
  10940. }
  10941. /**
  10942. * Class used to manage multiple sprites on the same spritesheet
  10943. * @see https://doc.babylonjs.com/babylon101/sprites
  10944. */
  10945. export class SpriteManager implements ISpriteManager {
  10946. /** defines the manager's name */
  10947. name: string;
  10948. /** Define the Url to load snippets */
  10949. static SnippetUrl: string;
  10950. /** Snippet ID if the manager was created from the snippet server */
  10951. snippetId: string;
  10952. /** Gets the list of sprites */
  10953. sprites: Sprite[];
  10954. /** Gets or sets the rendering group id (0 by default) */
  10955. renderingGroupId: number;
  10956. /** Gets or sets camera layer mask */
  10957. layerMask: number;
  10958. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10959. fogEnabled: boolean;
  10960. /** Gets or sets a boolean indicating if the sprites are pickable */
  10961. isPickable: boolean;
  10962. /** Defines the default width of a cell in the spritesheet */
  10963. cellWidth: number;
  10964. /** Defines the default height of a cell in the spritesheet */
  10965. cellHeight: number;
  10966. /** Associative array from JSON sprite data file */
  10967. private _cellData;
  10968. /** Array of sprite names from JSON sprite data file */
  10969. private _spriteMap;
  10970. /** True when packed cell data from JSON file is ready*/
  10971. private _packedAndReady;
  10972. private _textureContent;
  10973. /**
  10974. * An event triggered when the manager is disposed.
  10975. */
  10976. onDisposeObservable: Observable<SpriteManager>;
  10977. private _onDisposeObserver;
  10978. /**
  10979. * Callback called when the manager is disposed
  10980. */
  10981. set onDispose(callback: () => void);
  10982. private _capacity;
  10983. private _fromPacked;
  10984. private _spriteTexture;
  10985. private _epsilon;
  10986. private _scene;
  10987. private _vertexData;
  10988. private _buffer;
  10989. private _vertexBuffers;
  10990. private _indexBuffer;
  10991. private _effectBase;
  10992. private _effectFog;
  10993. /**
  10994. * Gets or sets the unique id of the sprite
  10995. */
  10996. uniqueId: number;
  10997. /**
  10998. * Gets the array of sprites
  10999. */
  11000. get children(): Sprite[];
  11001. /**
  11002. * Gets the hosting scene
  11003. */
  11004. get scene(): Scene;
  11005. /**
  11006. * Gets the capacity of the manager
  11007. */
  11008. get capacity(): number;
  11009. /**
  11010. * Gets or sets the spritesheet texture
  11011. */
  11012. get texture(): Texture;
  11013. set texture(value: Texture);
  11014. private _blendMode;
  11015. /**
  11016. * Blend mode use to render the particle, it can be any of
  11017. * the static Constants.ALPHA_x properties provided in this class.
  11018. * Default value is Constants.ALPHA_COMBINE
  11019. */
  11020. get blendMode(): number;
  11021. set blendMode(blendMode: number);
  11022. /** Disables writing to the depth buffer when rendering the sprites.
  11023. * It can be handy to disable depth writing when using textures without alpha channel
  11024. * and setting some specific blend modes.
  11025. */
  11026. disableDepthWrite: boolean;
  11027. /**
  11028. * Creates a new sprite manager
  11029. * @param name defines the manager's name
  11030. * @param imgUrl defines the sprite sheet url
  11031. * @param capacity defines the maximum allowed number of sprites
  11032. * @param cellSize defines the size of a sprite cell
  11033. * @param scene defines the hosting scene
  11034. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11035. * @param samplingMode defines the smapling mode to use with spritesheet
  11036. * @param fromPacked set to false; do not alter
  11037. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11038. */
  11039. constructor(
  11040. /** defines the manager's name */
  11041. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11042. /**
  11043. * Returns the string "SpriteManager"
  11044. * @returns "SpriteManager"
  11045. */
  11046. getClassName(): string;
  11047. private _makePacked;
  11048. private _appendSpriteVertex;
  11049. private _checkTextureAlpha;
  11050. /**
  11051. * Intersects the sprites with a ray
  11052. * @param ray defines the ray to intersect with
  11053. * @param camera defines the current active camera
  11054. * @param predicate defines a predicate used to select candidate sprites
  11055. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11056. * @returns null if no hit or a PickingInfo
  11057. */
  11058. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11059. /**
  11060. * Intersects the sprites with a ray
  11061. * @param ray defines the ray to intersect with
  11062. * @param camera defines the current active camera
  11063. * @param predicate defines a predicate used to select candidate sprites
  11064. * @returns null if no hit or a PickingInfo array
  11065. */
  11066. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11067. /**
  11068. * Render all child sprites
  11069. */
  11070. render(): void;
  11071. /**
  11072. * Release associated resources
  11073. */
  11074. dispose(): void;
  11075. /**
  11076. * Serializes the sprite manager to a JSON object
  11077. * @param serializeTexture defines if the texture must be serialized as well
  11078. * @returns the JSON object
  11079. */
  11080. serialize(serializeTexture?: boolean): any;
  11081. /**
  11082. * Parses a JSON object to create a new sprite manager.
  11083. * @param parsedManager The JSON object to parse
  11084. * @param scene The scene to create the sprite managerin
  11085. * @param rootUrl The root url to use to load external dependencies like texture
  11086. * @returns the new sprite manager
  11087. */
  11088. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11089. /**
  11090. * Creates a sprite manager from a snippet saved in a remote file
  11091. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11092. * @param url defines the url to load from
  11093. * @param scene defines the hosting scene
  11094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11095. * @returns a promise that will resolve to the new sprite manager
  11096. */
  11097. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11098. /**
  11099. * Creates a sprite manager from a snippet saved by the sprite editor
  11100. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11101. * @param scene defines the hosting scene
  11102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11103. * @returns a promise that will resolve to the new sprite manager
  11104. */
  11105. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11106. }
  11107. }
  11108. declare module BABYLON {
  11109. /** Interface used by value gradients (color, factor, ...) */
  11110. export interface IValueGradient {
  11111. /**
  11112. * Gets or sets the gradient value (between 0 and 1)
  11113. */
  11114. gradient: number;
  11115. }
  11116. /** Class used to store color4 gradient */
  11117. export class ColorGradient implements IValueGradient {
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number;
  11122. /**
  11123. * Gets or sets first associated color
  11124. */
  11125. color1: Color4;
  11126. /**
  11127. * Gets or sets second associated color
  11128. */
  11129. color2?: Color4 | undefined;
  11130. /**
  11131. * Creates a new color4 gradient
  11132. * @param gradient gets or sets the gradient value (between 0 and 1)
  11133. * @param color1 gets or sets first associated color
  11134. * @param color2 gets or sets first second color
  11135. */
  11136. constructor(
  11137. /**
  11138. * Gets or sets the gradient value (between 0 and 1)
  11139. */
  11140. gradient: number,
  11141. /**
  11142. * Gets or sets first associated color
  11143. */
  11144. color1: Color4,
  11145. /**
  11146. * Gets or sets second associated color
  11147. */
  11148. color2?: Color4 | undefined);
  11149. /**
  11150. * Will get a color picked randomly between color1 and color2.
  11151. * If color2 is undefined then color1 will be used
  11152. * @param result defines the target Color4 to store the result in
  11153. */
  11154. getColorToRef(result: Color4): void;
  11155. }
  11156. /** Class used to store color 3 gradient */
  11157. export class Color3Gradient implements IValueGradient {
  11158. /**
  11159. * Gets or sets the gradient value (between 0 and 1)
  11160. */
  11161. gradient: number;
  11162. /**
  11163. * Gets or sets the associated color
  11164. */
  11165. color: Color3;
  11166. /**
  11167. * Creates a new color3 gradient
  11168. * @param gradient gets or sets the gradient value (between 0 and 1)
  11169. * @param color gets or sets associated color
  11170. */
  11171. constructor(
  11172. /**
  11173. * Gets or sets the gradient value (between 0 and 1)
  11174. */
  11175. gradient: number,
  11176. /**
  11177. * Gets or sets the associated color
  11178. */
  11179. color: Color3);
  11180. }
  11181. /** Class used to store factor gradient */
  11182. export class FactorGradient implements IValueGradient {
  11183. /**
  11184. * Gets or sets the gradient value (between 0 and 1)
  11185. */
  11186. gradient: number;
  11187. /**
  11188. * Gets or sets first associated factor
  11189. */
  11190. factor1: number;
  11191. /**
  11192. * Gets or sets second associated factor
  11193. */
  11194. factor2?: number | undefined;
  11195. /**
  11196. * Creates a new factor gradient
  11197. * @param gradient gets or sets the gradient value (between 0 and 1)
  11198. * @param factor1 gets or sets first associated factor
  11199. * @param factor2 gets or sets second associated factor
  11200. */
  11201. constructor(
  11202. /**
  11203. * Gets or sets the gradient value (between 0 and 1)
  11204. */
  11205. gradient: number,
  11206. /**
  11207. * Gets or sets first associated factor
  11208. */
  11209. factor1: number,
  11210. /**
  11211. * Gets or sets second associated factor
  11212. */
  11213. factor2?: number | undefined);
  11214. /**
  11215. * Will get a number picked randomly between factor1 and factor2.
  11216. * If factor2 is undefined then factor1 will be used
  11217. * @returns the picked number
  11218. */
  11219. getFactor(): number;
  11220. }
  11221. /**
  11222. * Helper used to simplify some generic gradient tasks
  11223. */
  11224. export class GradientHelper {
  11225. /**
  11226. * Gets the current gradient from an array of IValueGradient
  11227. * @param ratio defines the current ratio to get
  11228. * @param gradients defines the array of IValueGradient
  11229. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11230. */
  11231. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11232. }
  11233. }
  11234. declare module BABYLON {
  11235. interface ThinEngine {
  11236. /**
  11237. * Creates a raw texture
  11238. * @param data defines the data to store in the texture
  11239. * @param width defines the width of the texture
  11240. * @param height defines the height of the texture
  11241. * @param format defines the format of the data
  11242. * @param generateMipMaps defines if the engine should generate the mip levels
  11243. * @param invertY defines if data must be stored with Y axis inverted
  11244. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11245. * @param compression defines the compression used (null by default)
  11246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11247. * @returns the raw texture inside an InternalTexture
  11248. */
  11249. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11250. /**
  11251. * Update a raw texture
  11252. * @param texture defines the texture to update
  11253. * @param data defines the data to store in the texture
  11254. * @param format defines the format of the data
  11255. * @param invertY defines if data must be stored with Y axis inverted
  11256. */
  11257. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11258. /**
  11259. * Update a raw texture
  11260. * @param texture defines the texture to update
  11261. * @param data defines the data to store in the texture
  11262. * @param format defines the format of the data
  11263. * @param invertY defines if data must be stored with Y axis inverted
  11264. * @param compression defines the compression used (null by default)
  11265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11266. */
  11267. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11268. /**
  11269. * Creates a new raw cube texture
  11270. * @param data defines the array of data to use to create each face
  11271. * @param size defines the size of the textures
  11272. * @param format defines the format of the data
  11273. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11274. * @param generateMipMaps defines if the engine should generate the mip levels
  11275. * @param invertY defines if data must be stored with Y axis inverted
  11276. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11277. * @param compression defines the compression used (null by default)
  11278. * @returns the cube texture as an InternalTexture
  11279. */
  11280. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11281. /**
  11282. * Update a raw cube texture
  11283. * @param texture defines the texture to udpdate
  11284. * @param data defines the data to store
  11285. * @param format defines the data format
  11286. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11287. * @param invertY defines if data must be stored with Y axis inverted
  11288. */
  11289. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11290. /**
  11291. * Update a raw cube texture
  11292. * @param texture defines the texture to udpdate
  11293. * @param data defines the data to store
  11294. * @param format defines the data format
  11295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11296. * @param invertY defines if data must be stored with Y axis inverted
  11297. * @param compression defines the compression used (null by default)
  11298. */
  11299. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11300. /**
  11301. * Update a raw cube texture
  11302. * @param texture defines the texture to udpdate
  11303. * @param data defines the data to store
  11304. * @param format defines the data format
  11305. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11306. * @param invertY defines if data must be stored with Y axis inverted
  11307. * @param compression defines the compression used (null by default)
  11308. * @param level defines which level of the texture to update
  11309. */
  11310. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11311. /**
  11312. * Creates a new raw cube texture from a specified url
  11313. * @param url defines the url where the data is located
  11314. * @param scene defines the current scene
  11315. * @param size defines the size of the textures
  11316. * @param format defines the format of the data
  11317. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11318. * @param noMipmap defines if the engine should avoid generating the mip levels
  11319. * @param callback defines a callback used to extract texture data from loaded data
  11320. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11321. * @param onLoad defines a callback called when texture is loaded
  11322. * @param onError defines a callback called if there is an error
  11323. * @returns the cube texture as an InternalTexture
  11324. */
  11325. 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;
  11326. /**
  11327. * Creates a new raw cube texture from a specified url
  11328. * @param url defines the url where the data is located
  11329. * @param scene defines the current scene
  11330. * @param size defines the size of the textures
  11331. * @param format defines the format of the data
  11332. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11333. * @param noMipmap defines if the engine should avoid generating the mip levels
  11334. * @param callback defines a callback used to extract texture data from loaded data
  11335. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11336. * @param onLoad defines a callback called when texture is loaded
  11337. * @param onError defines a callback called if there is an error
  11338. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11339. * @param invertY defines if data must be stored with Y axis inverted
  11340. * @returns the cube texture as an InternalTexture
  11341. */
  11342. 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;
  11343. /**
  11344. * Creates a new raw 3D texture
  11345. * @param data defines the data used to create the texture
  11346. * @param width defines the width of the texture
  11347. * @param height defines the height of the texture
  11348. * @param depth defines the depth of the texture
  11349. * @param format defines the format of the texture
  11350. * @param generateMipMaps defines if the engine must generate mip levels
  11351. * @param invertY defines if data must be stored with Y axis inverted
  11352. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11353. * @param compression defines the compressed used (can be null)
  11354. * @param textureType defines the compressed used (can be null)
  11355. * @returns a new raw 3D texture (stored in an InternalTexture)
  11356. */
  11357. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11358. /**
  11359. * Update a raw 3D texture
  11360. * @param texture defines the texture to update
  11361. * @param data defines the data to store
  11362. * @param format defines the data format
  11363. * @param invertY defines if data must be stored with Y axis inverted
  11364. */
  11365. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11366. /**
  11367. * Update a raw 3D texture
  11368. * @param texture defines the texture to update
  11369. * @param data defines the data to store
  11370. * @param format defines the data format
  11371. * @param invertY defines if data must be stored with Y axis inverted
  11372. * @param compression defines the used compression (can be null)
  11373. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11374. */
  11375. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11376. /**
  11377. * Creates a new raw 2D array texture
  11378. * @param data defines the data used to create the texture
  11379. * @param width defines the width of the texture
  11380. * @param height defines the height of the texture
  11381. * @param depth defines the number of layers of the texture
  11382. * @param format defines the format of the texture
  11383. * @param generateMipMaps defines if the engine must generate mip levels
  11384. * @param invertY defines if data must be stored with Y axis inverted
  11385. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11386. * @param compression defines the compressed used (can be null)
  11387. * @param textureType defines the compressed used (can be null)
  11388. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11389. */
  11390. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11391. /**
  11392. * Update a raw 2D array texture
  11393. * @param texture defines the texture to update
  11394. * @param data defines the data to store
  11395. * @param format defines the data format
  11396. * @param invertY defines if data must be stored with Y axis inverted
  11397. */
  11398. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11399. /**
  11400. * Update a raw 2D array texture
  11401. * @param texture defines the texture to update
  11402. * @param data defines the data to store
  11403. * @param format defines the data format
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. * @param compression defines the used compression (can be null)
  11406. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11407. */
  11408. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11409. }
  11410. }
  11411. declare module BABYLON {
  11412. /**
  11413. * Raw texture can help creating a texture directly from an array of data.
  11414. * This can be super useful if you either get the data from an uncompressed source or
  11415. * if you wish to create your texture pixel by pixel.
  11416. */
  11417. export class RawTexture extends Texture {
  11418. /**
  11419. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11420. */
  11421. format: number;
  11422. /**
  11423. * Instantiates a new RawTexture.
  11424. * Raw texture can help creating a texture directly from an array of data.
  11425. * This can be super useful if you either get the data from an uncompressed source or
  11426. * if you wish to create your texture pixel by pixel.
  11427. * @param data define the array of data to use to create the texture
  11428. * @param width define the width of the texture
  11429. * @param height define the height of the texture
  11430. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11431. * @param scene define the scene the texture belongs to
  11432. * @param generateMipMaps define whether mip maps should be generated or not
  11433. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11434. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11435. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11436. */
  11437. constructor(data: ArrayBufferView, width: number, height: number,
  11438. /**
  11439. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11440. */
  11441. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11442. /**
  11443. * Updates the texture underlying data.
  11444. * @param data Define the new data of the texture
  11445. */
  11446. update(data: ArrayBufferView): void;
  11447. /**
  11448. * Creates a luminance texture from some data.
  11449. * @param data Define the texture data
  11450. * @param width Define the width of the texture
  11451. * @param height Define the height of the texture
  11452. * @param scene Define the scene the texture belongs to
  11453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11456. * @returns the luminance texture
  11457. */
  11458. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11459. /**
  11460. * Creates a luminance alpha texture from some data.
  11461. * @param data Define the texture data
  11462. * @param width Define the width of the texture
  11463. * @param height Define the height of the texture
  11464. * @param scene Define the scene the texture belongs to
  11465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11468. * @returns the luminance alpha texture
  11469. */
  11470. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11471. /**
  11472. * Creates an alpha texture from some data.
  11473. * @param data Define the texture data
  11474. * @param width Define the width of the texture
  11475. * @param height Define the height of the texture
  11476. * @param scene Define the scene the texture belongs to
  11477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11480. * @returns the alpha texture
  11481. */
  11482. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11483. /**
  11484. * Creates a RGB texture from some data.
  11485. * @param data Define the texture data
  11486. * @param width Define the width of the texture
  11487. * @param height Define the height of the texture
  11488. * @param scene Define the scene the texture belongs to
  11489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11492. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11493. * @returns the RGB alpha texture
  11494. */
  11495. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11496. /**
  11497. * Creates a RGBA texture from some data.
  11498. * @param data Define the texture data
  11499. * @param width Define the width of the texture
  11500. * @param height Define the height of the texture
  11501. * @param scene Define the scene the texture belongs to
  11502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11506. * @returns the RGBA texture
  11507. */
  11508. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11509. /**
  11510. * Creates a R texture from some data.
  11511. * @param data Define the texture data
  11512. * @param width Define the width of the texture
  11513. * @param height Define the height of the texture
  11514. * @param scene Define the scene the texture belongs to
  11515. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11518. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11519. * @returns the R texture
  11520. */
  11521. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11522. }
  11523. }
  11524. declare module BABYLON {
  11525. interface AbstractScene {
  11526. /**
  11527. * The list of procedural textures added to the scene
  11528. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11529. */
  11530. proceduralTextures: Array<ProceduralTexture>;
  11531. }
  11532. /**
  11533. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11534. * in a given scene.
  11535. */
  11536. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11537. /**
  11538. * The component name helpfull to identify the component in the list of scene components.
  11539. */
  11540. readonly name: string;
  11541. /**
  11542. * The scene the component belongs to.
  11543. */
  11544. scene: Scene;
  11545. /**
  11546. * Creates a new instance of the component for the given scene
  11547. * @param scene Defines the scene to register the component in
  11548. */
  11549. constructor(scene: Scene);
  11550. /**
  11551. * Registers the component in a given scene
  11552. */
  11553. register(): void;
  11554. /**
  11555. * Rebuilds the elements related to this component in case of
  11556. * context lost for instance.
  11557. */
  11558. rebuild(): void;
  11559. /**
  11560. * Disposes the component and the associated ressources.
  11561. */
  11562. dispose(): void;
  11563. private _beforeClear;
  11564. }
  11565. }
  11566. declare module BABYLON {
  11567. interface ThinEngine {
  11568. /**
  11569. * Creates a new render target cube texture
  11570. * @param size defines the size of the texture
  11571. * @param options defines the options used to create the texture
  11572. * @returns a new render target cube texture stored in an InternalTexture
  11573. */
  11574. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11575. }
  11576. }
  11577. declare module BABYLON {
  11578. /** @hidden */
  11579. export var proceduralVertexShader: {
  11580. name: string;
  11581. shader: string;
  11582. };
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * 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.
  11587. * This is the base class of any Procedural texture and contains most of the shareable code.
  11588. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11589. */
  11590. export class ProceduralTexture extends Texture {
  11591. isCube: boolean;
  11592. /**
  11593. * Define if the texture is enabled or not (disabled texture will not render)
  11594. */
  11595. isEnabled: boolean;
  11596. /**
  11597. * Define if the texture must be cleared before rendering (default is true)
  11598. */
  11599. autoClear: boolean;
  11600. /**
  11601. * Callback called when the texture is generated
  11602. */
  11603. onGenerated: () => void;
  11604. /**
  11605. * Event raised when the texture is generated
  11606. */
  11607. onGeneratedObservable: Observable<ProceduralTexture>;
  11608. /** @hidden */
  11609. _generateMipMaps: boolean;
  11610. /** @hidden **/
  11611. _effect: Effect;
  11612. /** @hidden */
  11613. _textures: {
  11614. [key: string]: Texture;
  11615. };
  11616. /** @hidden */
  11617. protected _fallbackTexture: Nullable<Texture>;
  11618. private _size;
  11619. private _currentRefreshId;
  11620. private _frameId;
  11621. private _refreshRate;
  11622. private _vertexBuffers;
  11623. private _indexBuffer;
  11624. private _uniforms;
  11625. private _samplers;
  11626. private _fragment;
  11627. private _floats;
  11628. private _ints;
  11629. private _floatsArrays;
  11630. private _colors3;
  11631. private _colors4;
  11632. private _vectors2;
  11633. private _vectors3;
  11634. private _matrices;
  11635. private _fallbackTextureUsed;
  11636. private _fullEngine;
  11637. private _cachedDefines;
  11638. private _contentUpdateId;
  11639. private _contentData;
  11640. /**
  11641. * Instantiates a new procedural texture.
  11642. * 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.
  11643. * This is the base class of any Procedural texture and contains most of the shareable code.
  11644. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11645. * @param name Define the name of the texture
  11646. * @param size Define the size of the texture to create
  11647. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11648. * @param scene Define the scene the texture belongs to
  11649. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11650. * @param generateMipMaps Define if the texture should creates mip maps or not
  11651. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11652. */
  11653. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11654. /**
  11655. * The effect that is created when initializing the post process.
  11656. * @returns The created effect corresponding the the postprocess.
  11657. */
  11658. getEffect(): Effect;
  11659. /**
  11660. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11661. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11662. */
  11663. getContent(): Nullable<ArrayBufferView>;
  11664. private _createIndexBuffer;
  11665. /** @hidden */
  11666. _rebuild(): void;
  11667. /**
  11668. * Resets the texture in order to recreate its associated resources.
  11669. * This can be called in case of context loss
  11670. */
  11671. reset(): void;
  11672. protected _getDefines(): string;
  11673. /**
  11674. * Is the texture ready to be used ? (rendered at least once)
  11675. * @returns true if ready, otherwise, false.
  11676. */
  11677. isReady(): boolean;
  11678. /**
  11679. * Resets the refresh counter of the texture and start bak from scratch.
  11680. * Could be useful to regenerate the texture if it is setup to render only once.
  11681. */
  11682. resetRefreshCounter(): void;
  11683. /**
  11684. * Set the fragment shader to use in order to render the texture.
  11685. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11686. */
  11687. setFragment(fragment: any): void;
  11688. /**
  11689. * Define the refresh rate of the texture or the rendering frequency.
  11690. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11691. */
  11692. get refreshRate(): number;
  11693. set refreshRate(value: number);
  11694. /** @hidden */
  11695. _shouldRender(): boolean;
  11696. /**
  11697. * Get the size the texture is rendering at.
  11698. * @returns the size (texture is always squared)
  11699. */
  11700. getRenderSize(): number;
  11701. /**
  11702. * Resize the texture to new value.
  11703. * @param size Define the new size the texture should have
  11704. * @param generateMipMaps Define whether the new texture should create mip maps
  11705. */
  11706. resize(size: number, generateMipMaps: boolean): void;
  11707. private _checkUniform;
  11708. /**
  11709. * Set a texture in the shader program used to render.
  11710. * @param name Define the name of the uniform samplers as defined in the shader
  11711. * @param texture Define the texture to bind to this sampler
  11712. * @return the texture itself allowing "fluent" like uniform updates
  11713. */
  11714. setTexture(name: string, texture: Texture): ProceduralTexture;
  11715. /**
  11716. * Set a float in the shader.
  11717. * @param name Define the name of the uniform as defined in the shader
  11718. * @param value Define the value to give to the uniform
  11719. * @return the texture itself allowing "fluent" like uniform updates
  11720. */
  11721. setFloat(name: string, value: number): ProceduralTexture;
  11722. /**
  11723. * Set a int in the shader.
  11724. * @param name Define the name of the uniform as defined in the shader
  11725. * @param value Define the value to give to the uniform
  11726. * @return the texture itself allowing "fluent" like uniform updates
  11727. */
  11728. setInt(name: string, value: number): ProceduralTexture;
  11729. /**
  11730. * Set an array of floats in the shader.
  11731. * @param name Define the name of the uniform as defined in the shader
  11732. * @param value Define the value to give to the uniform
  11733. * @return the texture itself allowing "fluent" like uniform updates
  11734. */
  11735. setFloats(name: string, value: number[]): ProceduralTexture;
  11736. /**
  11737. * Set a vec3 in the shader from a Color3.
  11738. * @param name Define the name of the uniform as defined in the shader
  11739. * @param value Define the value to give to the uniform
  11740. * @return the texture itself allowing "fluent" like uniform updates
  11741. */
  11742. setColor3(name: string, value: Color3): ProceduralTexture;
  11743. /**
  11744. * Set a vec4 in the shader from a Color4.
  11745. * @param name Define the name of the uniform as defined in the shader
  11746. * @param value Define the value to give to the uniform
  11747. * @return the texture itself allowing "fluent" like uniform updates
  11748. */
  11749. setColor4(name: string, value: Color4): ProceduralTexture;
  11750. /**
  11751. * Set a vec2 in the shader from a Vector2.
  11752. * @param name Define the name of the uniform as defined in the shader
  11753. * @param value Define the value to give to the uniform
  11754. * @return the texture itself allowing "fluent" like uniform updates
  11755. */
  11756. setVector2(name: string, value: Vector2): ProceduralTexture;
  11757. /**
  11758. * Set a vec3 in the shader from a Vector3.
  11759. * @param name Define the name of the uniform as defined in the shader
  11760. * @param value Define the value to give to the uniform
  11761. * @return the texture itself allowing "fluent" like uniform updates
  11762. */
  11763. setVector3(name: string, value: Vector3): ProceduralTexture;
  11764. /**
  11765. * Set a mat4 in the shader from a MAtrix.
  11766. * @param name Define the name of the uniform as defined in the shader
  11767. * @param value Define the value to give to the uniform
  11768. * @return the texture itself allowing "fluent" like uniform updates
  11769. */
  11770. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11771. /**
  11772. * Render the texture to its associated render target.
  11773. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11774. */
  11775. render(useCameraPostProcess?: boolean): void;
  11776. /**
  11777. * Clone the texture.
  11778. * @returns the cloned texture
  11779. */
  11780. clone(): ProceduralTexture;
  11781. /**
  11782. * Dispose the texture and release its asoociated resources.
  11783. */
  11784. dispose(): void;
  11785. }
  11786. }
  11787. declare module BABYLON {
  11788. /**
  11789. * This represents the base class for particle system in Babylon.
  11790. * 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.
  11791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11792. * @example https://doc.babylonjs.com/babylon101/particles
  11793. */
  11794. export class BaseParticleSystem {
  11795. /**
  11796. * Source color is added to the destination color without alpha affecting the result
  11797. */
  11798. static BLENDMODE_ONEONE: number;
  11799. /**
  11800. * Blend current color and particle color using particle’s alpha
  11801. */
  11802. static BLENDMODE_STANDARD: number;
  11803. /**
  11804. * Add current color and particle color multiplied by particle’s alpha
  11805. */
  11806. static BLENDMODE_ADD: number;
  11807. /**
  11808. * Multiply current color with particle color
  11809. */
  11810. static BLENDMODE_MULTIPLY: number;
  11811. /**
  11812. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11813. */
  11814. static BLENDMODE_MULTIPLYADD: number;
  11815. /**
  11816. * List of animations used by the particle system.
  11817. */
  11818. animations: Animation[];
  11819. /**
  11820. * Gets or sets the unique id of the particle system
  11821. */
  11822. uniqueId: number;
  11823. /**
  11824. * The id of the Particle system.
  11825. */
  11826. id: string;
  11827. /**
  11828. * The friendly name of the Particle system.
  11829. */
  11830. name: string;
  11831. /**
  11832. * Snippet ID if the particle system was created from the snippet server
  11833. */
  11834. snippetId: string;
  11835. /**
  11836. * The rendering group used by the Particle system to chose when to render.
  11837. */
  11838. renderingGroupId: number;
  11839. /**
  11840. * The emitter represents the Mesh or position we are attaching the particle system to.
  11841. */
  11842. emitter: Nullable<AbstractMesh | Vector3>;
  11843. /**
  11844. * The maximum number of particles to emit per frame
  11845. */
  11846. emitRate: number;
  11847. /**
  11848. * If you want to launch only a few particles at once, that can be done, as well.
  11849. */
  11850. manualEmitCount: number;
  11851. /**
  11852. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11853. */
  11854. updateSpeed: number;
  11855. /**
  11856. * The amount of time the particle system is running (depends of the overall update speed).
  11857. */
  11858. targetStopDuration: number;
  11859. /**
  11860. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11861. */
  11862. disposeOnStop: boolean;
  11863. /**
  11864. * Minimum power of emitting particles.
  11865. */
  11866. minEmitPower: number;
  11867. /**
  11868. * Maximum power of emitting particles.
  11869. */
  11870. maxEmitPower: number;
  11871. /**
  11872. * Minimum life time of emitting particles.
  11873. */
  11874. minLifeTime: number;
  11875. /**
  11876. * Maximum life time of emitting particles.
  11877. */
  11878. maxLifeTime: number;
  11879. /**
  11880. * Minimum Size of emitting particles.
  11881. */
  11882. minSize: number;
  11883. /**
  11884. * Maximum Size of emitting particles.
  11885. */
  11886. maxSize: number;
  11887. /**
  11888. * Minimum scale of emitting particles on X axis.
  11889. */
  11890. minScaleX: number;
  11891. /**
  11892. * Maximum scale of emitting particles on X axis.
  11893. */
  11894. maxScaleX: number;
  11895. /**
  11896. * Minimum scale of emitting particles on Y axis.
  11897. */
  11898. minScaleY: number;
  11899. /**
  11900. * Maximum scale of emitting particles on Y axis.
  11901. */
  11902. maxScaleY: number;
  11903. /**
  11904. * Gets or sets the minimal initial rotation in radians.
  11905. */
  11906. minInitialRotation: number;
  11907. /**
  11908. * Gets or sets the maximal initial rotation in radians.
  11909. */
  11910. maxInitialRotation: number;
  11911. /**
  11912. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11913. */
  11914. minAngularSpeed: number;
  11915. /**
  11916. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11917. */
  11918. maxAngularSpeed: number;
  11919. /**
  11920. * The texture used to render each particle. (this can be a spritesheet)
  11921. */
  11922. particleTexture: Nullable<Texture>;
  11923. /**
  11924. * The layer mask we are rendering the particles through.
  11925. */
  11926. layerMask: number;
  11927. /**
  11928. * This can help using your own shader to render the particle system.
  11929. * The according effect will be created
  11930. */
  11931. customShader: any;
  11932. /**
  11933. * By default particle system starts as soon as they are created. This prevents the
  11934. * automatic start to happen and let you decide when to start emitting particles.
  11935. */
  11936. preventAutoStart: boolean;
  11937. private _noiseTexture;
  11938. /**
  11939. * Gets or sets a texture used to add random noise to particle positions
  11940. */
  11941. get noiseTexture(): Nullable<ProceduralTexture>;
  11942. set noiseTexture(value: Nullable<ProceduralTexture>);
  11943. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11944. noiseStrength: Vector3;
  11945. /**
  11946. * Callback triggered when the particle animation is ending.
  11947. */
  11948. onAnimationEnd: Nullable<() => void>;
  11949. /**
  11950. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11951. */
  11952. blendMode: number;
  11953. /**
  11954. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11955. * to override the particles.
  11956. */
  11957. forceDepthWrite: boolean;
  11958. /** 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 */
  11959. preWarmCycles: number;
  11960. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11961. preWarmStepOffset: number;
  11962. /**
  11963. * 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)
  11964. */
  11965. spriteCellChangeSpeed: number;
  11966. /**
  11967. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11968. */
  11969. startSpriteCellID: number;
  11970. /**
  11971. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11972. */
  11973. endSpriteCellID: number;
  11974. /**
  11975. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11976. */
  11977. spriteCellWidth: number;
  11978. /**
  11979. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11980. */
  11981. spriteCellHeight: number;
  11982. /**
  11983. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11984. */
  11985. spriteRandomStartCell: boolean;
  11986. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11987. translationPivot: Vector2;
  11988. /** @hidden */
  11989. protected _isAnimationSheetEnabled: boolean;
  11990. /**
  11991. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11992. */
  11993. beginAnimationOnStart: boolean;
  11994. /**
  11995. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11996. */
  11997. beginAnimationFrom: number;
  11998. /**
  11999. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12000. */
  12001. beginAnimationTo: number;
  12002. /**
  12003. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12004. */
  12005. beginAnimationLoop: boolean;
  12006. /**
  12007. * Gets or sets a world offset applied to all particles
  12008. */
  12009. worldOffset: Vector3;
  12010. /**
  12011. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12012. */
  12013. get isAnimationSheetEnabled(): boolean;
  12014. set isAnimationSheetEnabled(value: boolean);
  12015. /**
  12016. * Get hosting scene
  12017. * @returns the scene
  12018. */
  12019. getScene(): Scene;
  12020. /**
  12021. * You can use gravity if you want to give an orientation to your particles.
  12022. */
  12023. gravity: Vector3;
  12024. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12025. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12026. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12027. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12028. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12029. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12030. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12031. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12032. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12033. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12034. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12035. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12036. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12037. /**
  12038. * Defines the delay in milliseconds before starting the system (0 by default)
  12039. */
  12040. startDelay: number;
  12041. /**
  12042. * Gets the current list of drag gradients.
  12043. * You must use addDragGradient and removeDragGradient to udpate this list
  12044. * @returns the list of drag gradients
  12045. */
  12046. getDragGradients(): Nullable<Array<FactorGradient>>;
  12047. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12048. limitVelocityDamping: number;
  12049. /**
  12050. * Gets the current list of limit velocity gradients.
  12051. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12052. * @returns the list of limit velocity gradients
  12053. */
  12054. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12055. /**
  12056. * Gets the current list of color gradients.
  12057. * You must use addColorGradient and removeColorGradient to udpate this list
  12058. * @returns the list of color gradients
  12059. */
  12060. getColorGradients(): Nullable<Array<ColorGradient>>;
  12061. /**
  12062. * Gets the current list of size gradients.
  12063. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12064. * @returns the list of size gradients
  12065. */
  12066. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12067. /**
  12068. * Gets the current list of color remap gradients.
  12069. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12070. * @returns the list of color remap gradients
  12071. */
  12072. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12073. /**
  12074. * Gets the current list of alpha remap gradients.
  12075. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12076. * @returns the list of alpha remap gradients
  12077. */
  12078. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12079. /**
  12080. * Gets the current list of life time gradients.
  12081. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12082. * @returns the list of life time gradients
  12083. */
  12084. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12085. /**
  12086. * Gets the current list of angular speed gradients.
  12087. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12088. * @returns the list of angular speed gradients
  12089. */
  12090. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12091. /**
  12092. * Gets the current list of velocity gradients.
  12093. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12094. * @returns the list of velocity gradients
  12095. */
  12096. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12097. /**
  12098. * Gets the current list of start size gradients.
  12099. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12100. * @returns the list of start size gradients
  12101. */
  12102. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12103. /**
  12104. * Gets the current list of emit rate gradients.
  12105. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12106. * @returns the list of emit rate gradients
  12107. */
  12108. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12109. /**
  12110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12112. */
  12113. get direction1(): Vector3;
  12114. set direction1(value: Vector3);
  12115. /**
  12116. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12117. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12118. */
  12119. get direction2(): Vector3;
  12120. set direction2(value: Vector3);
  12121. /**
  12122. * 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.
  12123. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12124. */
  12125. get minEmitBox(): Vector3;
  12126. set minEmitBox(value: Vector3);
  12127. /**
  12128. * 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.
  12129. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12130. */
  12131. get maxEmitBox(): Vector3;
  12132. set maxEmitBox(value: Vector3);
  12133. /**
  12134. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12135. */
  12136. color1: Color4;
  12137. /**
  12138. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12139. */
  12140. color2: Color4;
  12141. /**
  12142. * Color the particle will have at the end of its lifetime
  12143. */
  12144. colorDead: Color4;
  12145. /**
  12146. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12147. */
  12148. textureMask: Color4;
  12149. /**
  12150. * The particle emitter type defines the emitter used by the particle system.
  12151. * It can be for example box, sphere, or cone...
  12152. */
  12153. particleEmitterType: IParticleEmitterType;
  12154. /** @hidden */
  12155. _isSubEmitter: boolean;
  12156. /**
  12157. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12158. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12159. */
  12160. billboardMode: number;
  12161. protected _isBillboardBased: boolean;
  12162. /**
  12163. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12164. */
  12165. get isBillboardBased(): boolean;
  12166. set isBillboardBased(value: boolean);
  12167. /**
  12168. * The scene the particle system belongs to.
  12169. */
  12170. protected _scene: Scene;
  12171. /**
  12172. * Local cache of defines for image processing.
  12173. */
  12174. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12175. /**
  12176. * Default configuration related to image processing available in the standard Material.
  12177. */
  12178. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12179. /**
  12180. * Gets the image processing configuration used either in this material.
  12181. */
  12182. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12183. /**
  12184. * Sets the Default image processing configuration used either in the this material.
  12185. *
  12186. * If sets to null, the scene one is in use.
  12187. */
  12188. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12189. /**
  12190. * Attaches a new image processing configuration to the Standard Material.
  12191. * @param configuration
  12192. */
  12193. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12194. /** @hidden */
  12195. protected _reset(): void;
  12196. /** @hidden */
  12197. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12198. /**
  12199. * Instantiates a particle system.
  12200. * 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.
  12201. * @param name The name of the particle system
  12202. */
  12203. constructor(name: string);
  12204. /**
  12205. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12206. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12207. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12208. * @returns the emitter
  12209. */
  12210. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12211. /**
  12212. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12213. * @param radius The radius of the hemisphere to emit from
  12214. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12215. * @returns the emitter
  12216. */
  12217. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12218. /**
  12219. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12220. * @param radius The radius of the sphere to emit from
  12221. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12222. * @returns the emitter
  12223. */
  12224. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12225. /**
  12226. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12227. * @param radius The radius of the sphere to emit from
  12228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12230. * @returns the emitter
  12231. */
  12232. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12233. /**
  12234. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12235. * @param radius The radius of the emission cylinder
  12236. * @param height The height of the emission cylinder
  12237. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12238. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12239. * @returns the emitter
  12240. */
  12241. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12242. /**
  12243. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12244. * @param radius The radius of the cylinder to emit from
  12245. * @param height The height of the emission cylinder
  12246. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12247. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12248. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12249. * @returns the emitter
  12250. */
  12251. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12252. /**
  12253. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12254. * @param radius The radius of the cone to emit from
  12255. * @param angle The base angle of the cone
  12256. * @returns the emitter
  12257. */
  12258. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12259. /**
  12260. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12261. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12262. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12263. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12264. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12265. * @returns the emitter
  12266. */
  12267. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12268. }
  12269. }
  12270. declare module BABYLON {
  12271. /**
  12272. * Type of sub emitter
  12273. */
  12274. export enum SubEmitterType {
  12275. /**
  12276. * Attached to the particle over it's lifetime
  12277. */
  12278. ATTACHED = 0,
  12279. /**
  12280. * Created when the particle dies
  12281. */
  12282. END = 1
  12283. }
  12284. /**
  12285. * Sub emitter class used to emit particles from an existing particle
  12286. */
  12287. export class SubEmitter {
  12288. /**
  12289. * the particle system to be used by the sub emitter
  12290. */
  12291. particleSystem: ParticleSystem;
  12292. /**
  12293. * Type of the submitter (Default: END)
  12294. */
  12295. type: SubEmitterType;
  12296. /**
  12297. * 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)
  12298. * Note: This only is supported when using an emitter of type Mesh
  12299. */
  12300. inheritDirection: boolean;
  12301. /**
  12302. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12303. */
  12304. inheritedVelocityAmount: number;
  12305. /**
  12306. * Creates a sub emitter
  12307. * @param particleSystem the particle system to be used by the sub emitter
  12308. */
  12309. constructor(
  12310. /**
  12311. * the particle system to be used by the sub emitter
  12312. */
  12313. particleSystem: ParticleSystem);
  12314. /**
  12315. * Clones the sub emitter
  12316. * @returns the cloned sub emitter
  12317. */
  12318. clone(): SubEmitter;
  12319. /**
  12320. * Serialize current object to a JSON object
  12321. * @returns the serialized object
  12322. */
  12323. serialize(): any;
  12324. /** @hidden */
  12325. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12326. /**
  12327. * Creates a new SubEmitter from a serialized JSON version
  12328. * @param serializationObject defines the JSON object to read from
  12329. * @param scene defines the hosting scene
  12330. * @param rootUrl defines the rootUrl for data loading
  12331. * @returns a new SubEmitter
  12332. */
  12333. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12334. /** Release associated resources */
  12335. dispose(): void;
  12336. }
  12337. }
  12338. declare module BABYLON {
  12339. /** @hidden */
  12340. export var imageProcessingDeclaration: {
  12341. name: string;
  12342. shader: string;
  12343. };
  12344. }
  12345. declare module BABYLON {
  12346. /** @hidden */
  12347. export var imageProcessingFunctions: {
  12348. name: string;
  12349. shader: string;
  12350. };
  12351. }
  12352. declare module BABYLON {
  12353. /** @hidden */
  12354. export var particlesPixelShader: {
  12355. name: string;
  12356. shader: string;
  12357. };
  12358. }
  12359. declare module BABYLON {
  12360. /** @hidden */
  12361. export var particlesVertexShader: {
  12362. name: string;
  12363. shader: string;
  12364. };
  12365. }
  12366. declare module BABYLON {
  12367. /**
  12368. * This represents a particle system in Babylon.
  12369. * 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.
  12370. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12371. * @example https://doc.babylonjs.com/babylon101/particles
  12372. */
  12373. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12374. /**
  12375. * Billboard mode will only apply to Y axis
  12376. */
  12377. static readonly BILLBOARDMODE_Y: number;
  12378. /**
  12379. * Billboard mode will apply to all axes
  12380. */
  12381. static readonly BILLBOARDMODE_ALL: number;
  12382. /**
  12383. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12384. */
  12385. static readonly BILLBOARDMODE_STRETCHED: number;
  12386. /**
  12387. * This function can be defined to provide custom update for active particles.
  12388. * This function will be called instead of regular update (age, position, color, etc.).
  12389. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12390. */
  12391. updateFunction: (particles: Particle[]) => void;
  12392. private _emitterWorldMatrix;
  12393. /**
  12394. * This function can be defined to specify initial direction for every new particle.
  12395. * It by default use the emitterType defined function
  12396. */
  12397. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12398. /**
  12399. * This function can be defined to specify initial position for every new particle.
  12400. * It by default use the emitterType defined function
  12401. */
  12402. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12403. /**
  12404. * @hidden
  12405. */
  12406. _inheritedVelocityOffset: Vector3;
  12407. /**
  12408. * An event triggered when the system is disposed
  12409. */
  12410. onDisposeObservable: Observable<IParticleSystem>;
  12411. private _onDisposeObserver;
  12412. /**
  12413. * Sets a callback that will be triggered when the system is disposed
  12414. */
  12415. set onDispose(callback: () => void);
  12416. private _particles;
  12417. private _epsilon;
  12418. private _capacity;
  12419. private _stockParticles;
  12420. private _newPartsExcess;
  12421. private _vertexData;
  12422. private _vertexBuffer;
  12423. private _vertexBuffers;
  12424. private _spriteBuffer;
  12425. private _indexBuffer;
  12426. private _effect;
  12427. private _customEffect;
  12428. private _cachedDefines;
  12429. private _scaledColorStep;
  12430. private _colorDiff;
  12431. private _scaledDirection;
  12432. private _scaledGravity;
  12433. private _currentRenderId;
  12434. private _alive;
  12435. private _useInstancing;
  12436. private _started;
  12437. private _stopped;
  12438. private _actualFrame;
  12439. private _scaledUpdateSpeed;
  12440. private _vertexBufferSize;
  12441. /** @hidden */
  12442. _currentEmitRateGradient: Nullable<FactorGradient>;
  12443. /** @hidden */
  12444. _currentEmitRate1: number;
  12445. /** @hidden */
  12446. _currentEmitRate2: number;
  12447. /** @hidden */
  12448. _currentStartSizeGradient: Nullable<FactorGradient>;
  12449. /** @hidden */
  12450. _currentStartSize1: number;
  12451. /** @hidden */
  12452. _currentStartSize2: number;
  12453. private readonly _rawTextureWidth;
  12454. private _rampGradientsTexture;
  12455. private _useRampGradients;
  12456. /** Gets or sets a boolean indicating that ramp gradients must be used
  12457. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12458. */
  12459. get useRampGradients(): boolean;
  12460. set useRampGradients(value: boolean);
  12461. /**
  12462. * 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.
  12463. * 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: [])
  12464. */
  12465. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12466. private _subEmitters;
  12467. /**
  12468. * @hidden
  12469. * If the particle systems emitter should be disposed when the particle system is disposed
  12470. */
  12471. _disposeEmitterOnDispose: boolean;
  12472. /**
  12473. * The current active Sub-systems, this property is used by the root particle system only.
  12474. */
  12475. activeSubSystems: Array<ParticleSystem>;
  12476. /**
  12477. * Specifies if the particles are updated in emitter local space or world space
  12478. */
  12479. isLocal: boolean;
  12480. private _rootParticleSystem;
  12481. /**
  12482. * Gets the current list of active particles
  12483. */
  12484. get particles(): Particle[];
  12485. /**
  12486. * Gets the number of particles active at the same time.
  12487. * @returns The number of active particles.
  12488. */
  12489. getActiveCount(): number;
  12490. /**
  12491. * Returns the string "ParticleSystem"
  12492. * @returns a string containing the class name
  12493. */
  12494. getClassName(): string;
  12495. /**
  12496. * Gets a boolean indicating that the system is stopping
  12497. * @returns true if the system is currently stopping
  12498. */
  12499. isStopping(): boolean;
  12500. /**
  12501. * Gets the custom effect used to render the particles
  12502. * @param blendMode Blend mode for which the effect should be retrieved
  12503. * @returns The effect
  12504. */
  12505. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12506. /**
  12507. * Sets the custom effect used to render the particles
  12508. * @param effect The effect to set
  12509. * @param blendMode Blend mode for which the effect should be set
  12510. */
  12511. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12512. /** @hidden */
  12513. private _onBeforeDrawParticlesObservable;
  12514. /**
  12515. * Observable that will be called just before the particles are drawn
  12516. */
  12517. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12518. /**
  12519. * Gets the name of the particle vertex shader
  12520. */
  12521. get vertexShaderName(): string;
  12522. /**
  12523. * Instantiates a particle system.
  12524. * 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.
  12525. * @param name The name of the particle system
  12526. * @param capacity The max number of particles alive at the same time
  12527. * @param scene The scene the particle system belongs to
  12528. * @param customEffect a custom effect used to change the way particles are rendered by default
  12529. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12530. * @param epsilon Offset used to render the particles
  12531. */
  12532. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12533. private _addFactorGradient;
  12534. private _removeFactorGradient;
  12535. /**
  12536. * Adds a new life time gradient
  12537. * @param gradient defines the gradient to use (between 0 and 1)
  12538. * @param factor defines the life time factor to affect to the specified gradient
  12539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12540. * @returns the current particle system
  12541. */
  12542. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12543. /**
  12544. * Remove a specific life time gradient
  12545. * @param gradient defines the gradient to remove
  12546. * @returns the current particle system
  12547. */
  12548. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12549. /**
  12550. * Adds a new size gradient
  12551. * @param gradient defines the gradient to use (between 0 and 1)
  12552. * @param factor defines the size factor to affect to the specified gradient
  12553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12554. * @returns the current particle system
  12555. */
  12556. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12557. /**
  12558. * Remove a specific size gradient
  12559. * @param gradient defines the gradient to remove
  12560. * @returns the current particle system
  12561. */
  12562. removeSizeGradient(gradient: number): IParticleSystem;
  12563. /**
  12564. * Adds a new color remap gradient
  12565. * @param gradient defines the gradient to use (between 0 and 1)
  12566. * @param min defines the color remap minimal range
  12567. * @param max defines the color remap maximal range
  12568. * @returns the current particle system
  12569. */
  12570. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12571. /**
  12572. * Remove a specific color remap gradient
  12573. * @param gradient defines the gradient to remove
  12574. * @returns the current particle system
  12575. */
  12576. removeColorRemapGradient(gradient: number): IParticleSystem;
  12577. /**
  12578. * Adds a new alpha remap gradient
  12579. * @param gradient defines the gradient to use (between 0 and 1)
  12580. * @param min defines the alpha remap minimal range
  12581. * @param max defines the alpha remap maximal range
  12582. * @returns the current particle system
  12583. */
  12584. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12585. /**
  12586. * Remove a specific alpha remap gradient
  12587. * @param gradient defines the gradient to remove
  12588. * @returns the current particle system
  12589. */
  12590. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12591. /**
  12592. * Adds a new angular speed gradient
  12593. * @param gradient defines the gradient to use (between 0 and 1)
  12594. * @param factor defines the angular speed to affect to the specified gradient
  12595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12596. * @returns the current particle system
  12597. */
  12598. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12599. /**
  12600. * Remove a specific angular speed gradient
  12601. * @param gradient defines the gradient to remove
  12602. * @returns the current particle system
  12603. */
  12604. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12605. /**
  12606. * Adds a new velocity gradient
  12607. * @param gradient defines the gradient to use (between 0 and 1)
  12608. * @param factor defines the velocity to affect to the specified gradient
  12609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12610. * @returns the current particle system
  12611. */
  12612. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12613. /**
  12614. * Remove a specific velocity gradient
  12615. * @param gradient defines the gradient to remove
  12616. * @returns the current particle system
  12617. */
  12618. removeVelocityGradient(gradient: number): IParticleSystem;
  12619. /**
  12620. * Adds a new limit velocity gradient
  12621. * @param gradient defines the gradient to use (between 0 and 1)
  12622. * @param factor defines the limit velocity value to affect to the specified gradient
  12623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12624. * @returns the current particle system
  12625. */
  12626. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12627. /**
  12628. * Remove a specific limit velocity gradient
  12629. * @param gradient defines the gradient to remove
  12630. * @returns the current particle system
  12631. */
  12632. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12633. /**
  12634. * Adds a new drag gradient
  12635. * @param gradient defines the gradient to use (between 0 and 1)
  12636. * @param factor defines the drag value to affect to the specified gradient
  12637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12638. * @returns the current particle system
  12639. */
  12640. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12641. /**
  12642. * Remove a specific drag gradient
  12643. * @param gradient defines the gradient to remove
  12644. * @returns the current particle system
  12645. */
  12646. removeDragGradient(gradient: number): IParticleSystem;
  12647. /**
  12648. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12649. * @param gradient defines the gradient to use (between 0 and 1)
  12650. * @param factor defines the emit rate value to affect to the specified gradient
  12651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12652. * @returns the current particle system
  12653. */
  12654. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12655. /**
  12656. * Remove a specific emit rate gradient
  12657. * @param gradient defines the gradient to remove
  12658. * @returns the current particle system
  12659. */
  12660. removeEmitRateGradient(gradient: number): IParticleSystem;
  12661. /**
  12662. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12663. * @param gradient defines the gradient to use (between 0 and 1)
  12664. * @param factor defines the start size value to affect to the specified gradient
  12665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12666. * @returns the current particle system
  12667. */
  12668. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12669. /**
  12670. * Remove a specific start size gradient
  12671. * @param gradient defines the gradient to remove
  12672. * @returns the current particle system
  12673. */
  12674. removeStartSizeGradient(gradient: number): IParticleSystem;
  12675. private _createRampGradientTexture;
  12676. /**
  12677. * Gets the current list of ramp gradients.
  12678. * You must use addRampGradient and removeRampGradient to udpate this list
  12679. * @returns the list of ramp gradients
  12680. */
  12681. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12682. /** Force the system to rebuild all gradients that need to be resync */
  12683. forceRefreshGradients(): void;
  12684. private _syncRampGradientTexture;
  12685. /**
  12686. * Adds a new ramp gradient used to remap particle colors
  12687. * @param gradient defines the gradient to use (between 0 and 1)
  12688. * @param color defines the color to affect to the specified gradient
  12689. * @returns the current particle system
  12690. */
  12691. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12692. /**
  12693. * Remove a specific ramp gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeRampGradient(gradient: number): ParticleSystem;
  12698. /**
  12699. * Adds a new color gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param color1 defines the color to affect to the specified gradient
  12702. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12703. * @returns this particle system
  12704. */
  12705. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12706. /**
  12707. * Remove a specific color gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns this particle system
  12710. */
  12711. removeColorGradient(gradient: number): IParticleSystem;
  12712. private _fetchR;
  12713. protected _reset(): void;
  12714. private _resetEffect;
  12715. private _createVertexBuffers;
  12716. private _createIndexBuffer;
  12717. /**
  12718. * Gets the maximum number of particles active at the same time.
  12719. * @returns The max number of active particles.
  12720. */
  12721. getCapacity(): number;
  12722. /**
  12723. * Gets whether there are still active particles in the system.
  12724. * @returns True if it is alive, otherwise false.
  12725. */
  12726. isAlive(): boolean;
  12727. /**
  12728. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12729. * @returns True if it has been started, otherwise false.
  12730. */
  12731. isStarted(): boolean;
  12732. private _prepareSubEmitterInternalArray;
  12733. /**
  12734. * Starts the particle system and begins to emit
  12735. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12736. */
  12737. start(delay?: number): void;
  12738. /**
  12739. * Stops the particle system.
  12740. * @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.
  12741. */
  12742. stop(stopSubEmitters?: boolean): void;
  12743. /**
  12744. * Remove all active particles
  12745. */
  12746. reset(): void;
  12747. /**
  12748. * @hidden (for internal use only)
  12749. */
  12750. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12751. /**
  12752. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12753. * Its lifetime will start back at 0.
  12754. */
  12755. recycleParticle: (particle: Particle) => void;
  12756. private _stopSubEmitters;
  12757. private _createParticle;
  12758. private _removeFromRoot;
  12759. private _emitFromParticle;
  12760. private _update;
  12761. /** @hidden */
  12762. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12763. /** @hidden */
  12764. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12765. /**
  12766. * Fill the defines array according to the current settings of the particle system
  12767. * @param defines Array to be updated
  12768. * @param blendMode blend mode to take into account when updating the array
  12769. */
  12770. fillDefines(defines: Array<string>, blendMode: number): void;
  12771. /**
  12772. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12773. * @param uniforms Uniforms array to fill
  12774. * @param attributes Attributes array to fill
  12775. * @param samplers Samplers array to fill
  12776. */
  12777. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12778. /** @hidden */
  12779. private _getEffect;
  12780. /**
  12781. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12782. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12783. */
  12784. animate(preWarmOnly?: boolean): void;
  12785. private _appendParticleVertices;
  12786. /**
  12787. * Rebuilds the particle system.
  12788. */
  12789. rebuild(): void;
  12790. /**
  12791. * Is this system ready to be used/rendered
  12792. * @return true if the system is ready
  12793. */
  12794. isReady(): boolean;
  12795. private _render;
  12796. /**
  12797. * Renders the particle system in its current state.
  12798. * @returns the current number of particles
  12799. */
  12800. render(): number;
  12801. /**
  12802. * Disposes the particle system and free the associated resources
  12803. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12804. */
  12805. dispose(disposeTexture?: boolean): void;
  12806. /**
  12807. * Clones the particle system.
  12808. * @param name The name of the cloned object
  12809. * @param newEmitter The new emitter to use
  12810. * @returns the cloned particle system
  12811. */
  12812. clone(name: string, newEmitter: any): ParticleSystem;
  12813. /**
  12814. * Serializes the particle system to a JSON object
  12815. * @param serializeTexture defines if the texture must be serialized as well
  12816. * @returns the JSON object
  12817. */
  12818. serialize(serializeTexture?: boolean): any;
  12819. /** @hidden */
  12820. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12821. /** @hidden */
  12822. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12823. /**
  12824. * Parses a JSON object to create a particle system.
  12825. * @param parsedParticleSystem The JSON object to parse
  12826. * @param scene The scene to create the particle system in
  12827. * @param rootUrl The root url to use to load external dependencies like texture
  12828. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12829. * @returns the Parsed particle system
  12830. */
  12831. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12832. }
  12833. }
  12834. declare module BABYLON {
  12835. /**
  12836. * A particle represents one of the element emitted by a particle system.
  12837. * This is mainly define by its coordinates, direction, velocity and age.
  12838. */
  12839. export class Particle {
  12840. /**
  12841. * The particle system the particle belongs to.
  12842. */
  12843. particleSystem: ParticleSystem;
  12844. private static _Count;
  12845. /**
  12846. * Unique ID of the particle
  12847. */
  12848. id: number;
  12849. /**
  12850. * The world position of the particle in the scene.
  12851. */
  12852. position: Vector3;
  12853. /**
  12854. * The world direction of the particle in the scene.
  12855. */
  12856. direction: Vector3;
  12857. /**
  12858. * The color of the particle.
  12859. */
  12860. color: Color4;
  12861. /**
  12862. * The color change of the particle per step.
  12863. */
  12864. colorStep: Color4;
  12865. /**
  12866. * Defines how long will the life of the particle be.
  12867. */
  12868. lifeTime: number;
  12869. /**
  12870. * The current age of the particle.
  12871. */
  12872. age: number;
  12873. /**
  12874. * The current size of the particle.
  12875. */
  12876. size: number;
  12877. /**
  12878. * The current scale of the particle.
  12879. */
  12880. scale: Vector2;
  12881. /**
  12882. * The current angle of the particle.
  12883. */
  12884. angle: number;
  12885. /**
  12886. * Defines how fast is the angle changing.
  12887. */
  12888. angularSpeed: number;
  12889. /**
  12890. * Defines the cell index used by the particle to be rendered from a sprite.
  12891. */
  12892. cellIndex: number;
  12893. /**
  12894. * The information required to support color remapping
  12895. */
  12896. remapData: Vector4;
  12897. /** @hidden */
  12898. _randomCellOffset?: number;
  12899. /** @hidden */
  12900. _initialDirection: Nullable<Vector3>;
  12901. /** @hidden */
  12902. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12903. /** @hidden */
  12904. _initialStartSpriteCellID: number;
  12905. /** @hidden */
  12906. _initialEndSpriteCellID: number;
  12907. /** @hidden */
  12908. _currentColorGradient: Nullable<ColorGradient>;
  12909. /** @hidden */
  12910. _currentColor1: Color4;
  12911. /** @hidden */
  12912. _currentColor2: Color4;
  12913. /** @hidden */
  12914. _currentSizeGradient: Nullable<FactorGradient>;
  12915. /** @hidden */
  12916. _currentSize1: number;
  12917. /** @hidden */
  12918. _currentSize2: number;
  12919. /** @hidden */
  12920. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12921. /** @hidden */
  12922. _currentAngularSpeed1: number;
  12923. /** @hidden */
  12924. _currentAngularSpeed2: number;
  12925. /** @hidden */
  12926. _currentVelocityGradient: Nullable<FactorGradient>;
  12927. /** @hidden */
  12928. _currentVelocity1: number;
  12929. /** @hidden */
  12930. _currentVelocity2: number;
  12931. /** @hidden */
  12932. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12933. /** @hidden */
  12934. _currentLimitVelocity1: number;
  12935. /** @hidden */
  12936. _currentLimitVelocity2: number;
  12937. /** @hidden */
  12938. _currentDragGradient: Nullable<FactorGradient>;
  12939. /** @hidden */
  12940. _currentDrag1: number;
  12941. /** @hidden */
  12942. _currentDrag2: number;
  12943. /** @hidden */
  12944. _randomNoiseCoordinates1: Vector3;
  12945. /** @hidden */
  12946. _randomNoiseCoordinates2: Vector3;
  12947. /** @hidden */
  12948. _localPosition?: Vector3;
  12949. /**
  12950. * Creates a new instance Particle
  12951. * @param particleSystem the particle system the particle belongs to
  12952. */
  12953. constructor(
  12954. /**
  12955. * The particle system the particle belongs to.
  12956. */
  12957. particleSystem: ParticleSystem);
  12958. private updateCellInfoFromSystem;
  12959. /**
  12960. * Defines how the sprite cell index is updated for the particle
  12961. */
  12962. updateCellIndex(): void;
  12963. /** @hidden */
  12964. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12965. /** @hidden */
  12966. _inheritParticleInfoToSubEmitters(): void;
  12967. /** @hidden */
  12968. _reset(): void;
  12969. /**
  12970. * Copy the properties of particle to another one.
  12971. * @param other the particle to copy the information to.
  12972. */
  12973. copyTo(other: Particle): void;
  12974. }
  12975. }
  12976. declare module BABYLON {
  12977. /**
  12978. * Particle emitter represents a volume emitting particles.
  12979. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12980. */
  12981. export interface IParticleEmitterType {
  12982. /**
  12983. * Called by the particle System when the direction is computed for the created particle.
  12984. * @param worldMatrix is the world matrix of the particle system
  12985. * @param directionToUpdate is the direction vector to update with the result
  12986. * @param particle is the particle we are computed the direction for
  12987. * @param isLocal defines if the direction should be set in local space
  12988. */
  12989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12990. /**
  12991. * Called by the particle System when the position is computed for the created particle.
  12992. * @param worldMatrix is the world matrix of the particle system
  12993. * @param positionToUpdate is the position vector to update with the result
  12994. * @param particle is the particle we are computed the position for
  12995. * @param isLocal defines if the position should be set in local space
  12996. */
  12997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12998. /**
  12999. * Clones the current emitter and returns a copy of it
  13000. * @returns the new emitter
  13001. */
  13002. clone(): IParticleEmitterType;
  13003. /**
  13004. * Called by the GPUParticleSystem to setup the update shader
  13005. * @param effect defines the update shader
  13006. */
  13007. applyToShader(effect: Effect): void;
  13008. /**
  13009. * Returns a string to use to update the GPU particles update shader
  13010. * @returns the effect defines string
  13011. */
  13012. getEffectDefines(): string;
  13013. /**
  13014. * Returns a string representing the class name
  13015. * @returns a string containing the class name
  13016. */
  13017. getClassName(): string;
  13018. /**
  13019. * Serializes the particle system to a JSON object.
  13020. * @returns the JSON object
  13021. */
  13022. serialize(): any;
  13023. /**
  13024. * Parse properties from a JSON object
  13025. * @param serializationObject defines the JSON object
  13026. * @param scene defines the hosting scene
  13027. */
  13028. parse(serializationObject: any, scene: Scene): void;
  13029. }
  13030. }
  13031. declare module BABYLON {
  13032. /**
  13033. * Particle emitter emitting particles from the inside of a box.
  13034. * It emits the particles randomly between 2 given directions.
  13035. */
  13036. export class BoxParticleEmitter implements IParticleEmitterType {
  13037. /**
  13038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13039. */
  13040. direction1: Vector3;
  13041. /**
  13042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13043. */
  13044. direction2: Vector3;
  13045. /**
  13046. * 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.
  13047. */
  13048. minEmitBox: Vector3;
  13049. /**
  13050. * 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.
  13051. */
  13052. maxEmitBox: Vector3;
  13053. /**
  13054. * Creates a new instance BoxParticleEmitter
  13055. */
  13056. constructor();
  13057. /**
  13058. * Called by the particle System when the direction is computed for the created particle.
  13059. * @param worldMatrix is the world matrix of the particle system
  13060. * @param directionToUpdate is the direction vector to update with the result
  13061. * @param particle is the particle we are computed the direction for
  13062. * @param isLocal defines if the direction should be set in local space
  13063. */
  13064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13065. /**
  13066. * Called by the particle System when the position is computed for the created particle.
  13067. * @param worldMatrix is the world matrix of the particle system
  13068. * @param positionToUpdate is the position vector to update with the result
  13069. * @param particle is the particle we are computed the position for
  13070. * @param isLocal defines if the position should be set in local space
  13071. */
  13072. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13073. /**
  13074. * Clones the current emitter and returns a copy of it
  13075. * @returns the new emitter
  13076. */
  13077. clone(): BoxParticleEmitter;
  13078. /**
  13079. * Called by the GPUParticleSystem to setup the update shader
  13080. * @param effect defines the update shader
  13081. */
  13082. applyToShader(effect: Effect): void;
  13083. /**
  13084. * Returns a string to use to update the GPU particles update shader
  13085. * @returns a string containng the defines string
  13086. */
  13087. getEffectDefines(): string;
  13088. /**
  13089. * Returns the string "BoxParticleEmitter"
  13090. * @returns a string containing the class name
  13091. */
  13092. getClassName(): string;
  13093. /**
  13094. * Serializes the particle system to a JSON object.
  13095. * @returns the JSON object
  13096. */
  13097. serialize(): any;
  13098. /**
  13099. * Parse properties from a JSON object
  13100. * @param serializationObject defines the JSON object
  13101. */
  13102. parse(serializationObject: any): void;
  13103. }
  13104. }
  13105. declare module BABYLON {
  13106. /**
  13107. * Particle emitter emitting particles from the inside of a cone.
  13108. * It emits the particles alongside the cone volume from the base to the particle.
  13109. * The emission direction might be randomized.
  13110. */
  13111. export class ConeParticleEmitter implements IParticleEmitterType {
  13112. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13113. directionRandomizer: number;
  13114. private _radius;
  13115. private _angle;
  13116. private _height;
  13117. /**
  13118. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13119. */
  13120. radiusRange: number;
  13121. /**
  13122. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13123. */
  13124. heightRange: number;
  13125. /**
  13126. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13127. */
  13128. emitFromSpawnPointOnly: boolean;
  13129. /**
  13130. * Gets or sets the radius of the emission cone
  13131. */
  13132. get radius(): number;
  13133. set radius(value: number);
  13134. /**
  13135. * Gets or sets the angle of the emission cone
  13136. */
  13137. get angle(): number;
  13138. set angle(value: number);
  13139. private _buildHeight;
  13140. /**
  13141. * Creates a new instance ConeParticleEmitter
  13142. * @param radius the radius of the emission cone (1 by default)
  13143. * @param angle the cone base angle (PI by default)
  13144. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13145. */
  13146. constructor(radius?: number, angle?: number,
  13147. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13148. directionRandomizer?: number);
  13149. /**
  13150. * Called by the particle System when the direction is computed for the created particle.
  13151. * @param worldMatrix is the world matrix of the particle system
  13152. * @param directionToUpdate is the direction vector to update with the result
  13153. * @param particle is the particle we are computed the direction for
  13154. * @param isLocal defines if the direction should be set in local space
  13155. */
  13156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13157. /**
  13158. * Called by the particle System when the position is computed for the created particle.
  13159. * @param worldMatrix is the world matrix of the particle system
  13160. * @param positionToUpdate is the position vector to update with the result
  13161. * @param particle is the particle we are computed the position for
  13162. * @param isLocal defines if the position should be set in local space
  13163. */
  13164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13165. /**
  13166. * Clones the current emitter and returns a copy of it
  13167. * @returns the new emitter
  13168. */
  13169. clone(): ConeParticleEmitter;
  13170. /**
  13171. * Called by the GPUParticleSystem to setup the update shader
  13172. * @param effect defines the update shader
  13173. */
  13174. applyToShader(effect: Effect): void;
  13175. /**
  13176. * Returns a string to use to update the GPU particles update shader
  13177. * @returns a string containng the defines string
  13178. */
  13179. getEffectDefines(): string;
  13180. /**
  13181. * Returns the string "ConeParticleEmitter"
  13182. * @returns a string containing the class name
  13183. */
  13184. getClassName(): string;
  13185. /**
  13186. * Serializes the particle system to a JSON object.
  13187. * @returns the JSON object
  13188. */
  13189. serialize(): any;
  13190. /**
  13191. * Parse properties from a JSON object
  13192. * @param serializationObject defines the JSON object
  13193. */
  13194. parse(serializationObject: any): void;
  13195. }
  13196. }
  13197. declare module BABYLON {
  13198. /**
  13199. * Particle emitter emitting particles from the inside of a cylinder.
  13200. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13201. */
  13202. export class CylinderParticleEmitter implements IParticleEmitterType {
  13203. /**
  13204. * The radius of the emission cylinder.
  13205. */
  13206. radius: number;
  13207. /**
  13208. * The height of the emission cylinder.
  13209. */
  13210. height: number;
  13211. /**
  13212. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13213. */
  13214. radiusRange: number;
  13215. /**
  13216. * How much to randomize the particle direction [0-1].
  13217. */
  13218. directionRandomizer: number;
  13219. /**
  13220. * Creates a new instance CylinderParticleEmitter
  13221. * @param radius the radius of the emission cylinder (1 by default)
  13222. * @param height the height of the emission cylinder (1 by default)
  13223. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13224. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13225. */
  13226. constructor(
  13227. /**
  13228. * The radius of the emission cylinder.
  13229. */
  13230. radius?: number,
  13231. /**
  13232. * The height of the emission cylinder.
  13233. */
  13234. height?: number,
  13235. /**
  13236. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13237. */
  13238. radiusRange?: number,
  13239. /**
  13240. * How much to randomize the particle direction [0-1].
  13241. */
  13242. directionRandomizer?: number);
  13243. /**
  13244. * Called by the particle System when the direction is computed for the created particle.
  13245. * @param worldMatrix is the world matrix of the particle system
  13246. * @param directionToUpdate is the direction vector to update with the result
  13247. * @param particle is the particle we are computed the direction for
  13248. * @param isLocal defines if the direction should be set in local space
  13249. */
  13250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13251. /**
  13252. * Called by the particle System when the position is computed for the created particle.
  13253. * @param worldMatrix is the world matrix of the particle system
  13254. * @param positionToUpdate is the position vector to update with the result
  13255. * @param particle is the particle we are computed the position for
  13256. * @param isLocal defines if the position should be set in local space
  13257. */
  13258. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13259. /**
  13260. * Clones the current emitter and returns a copy of it
  13261. * @returns the new emitter
  13262. */
  13263. clone(): CylinderParticleEmitter;
  13264. /**
  13265. * Called by the GPUParticleSystem to setup the update shader
  13266. * @param effect defines the update shader
  13267. */
  13268. applyToShader(effect: Effect): void;
  13269. /**
  13270. * Returns a string to use to update the GPU particles update shader
  13271. * @returns a string containng the defines string
  13272. */
  13273. getEffectDefines(): string;
  13274. /**
  13275. * Returns the string "CylinderParticleEmitter"
  13276. * @returns a string containing the class name
  13277. */
  13278. getClassName(): string;
  13279. /**
  13280. * Serializes the particle system to a JSON object.
  13281. * @returns the JSON object
  13282. */
  13283. serialize(): any;
  13284. /**
  13285. * Parse properties from a JSON object
  13286. * @param serializationObject defines the JSON object
  13287. */
  13288. parse(serializationObject: any): void;
  13289. }
  13290. /**
  13291. * Particle emitter emitting particles from the inside of a cylinder.
  13292. * It emits the particles randomly between two vectors.
  13293. */
  13294. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13295. /**
  13296. * The min limit of the emission direction.
  13297. */
  13298. direction1: Vector3;
  13299. /**
  13300. * The max limit of the emission direction.
  13301. */
  13302. direction2: Vector3;
  13303. /**
  13304. * Creates a new instance CylinderDirectedParticleEmitter
  13305. * @param radius the radius of the emission cylinder (1 by default)
  13306. * @param height the height of the emission cylinder (1 by default)
  13307. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13308. * @param direction1 the min limit of the emission direction (up vector by default)
  13309. * @param direction2 the max limit of the emission direction (up vector by default)
  13310. */
  13311. constructor(radius?: number, height?: number, radiusRange?: number,
  13312. /**
  13313. * The min limit of the emission direction.
  13314. */
  13315. direction1?: Vector3,
  13316. /**
  13317. * The max limit of the emission direction.
  13318. */
  13319. direction2?: Vector3);
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. */
  13326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13327. /**
  13328. * Clones the current emitter and returns a copy of it
  13329. * @returns the new emitter
  13330. */
  13331. clone(): CylinderDirectedParticleEmitter;
  13332. /**
  13333. * Called by the GPUParticleSystem to setup the update shader
  13334. * @param effect defines the update shader
  13335. */
  13336. applyToShader(effect: Effect): void;
  13337. /**
  13338. * Returns a string to use to update the GPU particles update shader
  13339. * @returns a string containng the defines string
  13340. */
  13341. getEffectDefines(): string;
  13342. /**
  13343. * Returns the string "CylinderDirectedParticleEmitter"
  13344. * @returns a string containing the class name
  13345. */
  13346. getClassName(): string;
  13347. /**
  13348. * Serializes the particle system to a JSON object.
  13349. * @returns the JSON object
  13350. */
  13351. serialize(): any;
  13352. /**
  13353. * Parse properties from a JSON object
  13354. * @param serializationObject defines the JSON object
  13355. */
  13356. parse(serializationObject: any): void;
  13357. }
  13358. }
  13359. declare module BABYLON {
  13360. /**
  13361. * Particle emitter emitting particles from the inside of a hemisphere.
  13362. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13363. */
  13364. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13365. /**
  13366. * The radius of the emission hemisphere.
  13367. */
  13368. radius: number;
  13369. /**
  13370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13371. */
  13372. radiusRange: number;
  13373. /**
  13374. * How much to randomize the particle direction [0-1].
  13375. */
  13376. directionRandomizer: number;
  13377. /**
  13378. * Creates a new instance HemisphericParticleEmitter
  13379. * @param radius the radius of the emission hemisphere (1 by default)
  13380. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13381. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13382. */
  13383. constructor(
  13384. /**
  13385. * The radius of the emission hemisphere.
  13386. */
  13387. radius?: number,
  13388. /**
  13389. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13390. */
  13391. radiusRange?: number,
  13392. /**
  13393. * How much to randomize the particle direction [0-1].
  13394. */
  13395. directionRandomizer?: number);
  13396. /**
  13397. * Called by the particle System when the direction is computed for the created particle.
  13398. * @param worldMatrix is the world matrix of the particle system
  13399. * @param directionToUpdate is the direction vector to update with the result
  13400. * @param particle is the particle we are computed the direction for
  13401. * @param isLocal defines if the direction should be set in local space
  13402. */
  13403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13404. /**
  13405. * Called by the particle System when the position is computed for the created particle.
  13406. * @param worldMatrix is the world matrix of the particle system
  13407. * @param positionToUpdate is the position vector to update with the result
  13408. * @param particle is the particle we are computed the position for
  13409. * @param isLocal defines if the position should be set in local space
  13410. */
  13411. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13412. /**
  13413. * Clones the current emitter and returns a copy of it
  13414. * @returns the new emitter
  13415. */
  13416. clone(): HemisphericParticleEmitter;
  13417. /**
  13418. * Called by the GPUParticleSystem to setup the update shader
  13419. * @param effect defines the update shader
  13420. */
  13421. applyToShader(effect: Effect): void;
  13422. /**
  13423. * Returns a string to use to update the GPU particles update shader
  13424. * @returns a string containng the defines string
  13425. */
  13426. getEffectDefines(): string;
  13427. /**
  13428. * Returns the string "HemisphericParticleEmitter"
  13429. * @returns a string containing the class name
  13430. */
  13431. getClassName(): string;
  13432. /**
  13433. * Serializes the particle system to a JSON object.
  13434. * @returns the JSON object
  13435. */
  13436. serialize(): any;
  13437. /**
  13438. * Parse properties from a JSON object
  13439. * @param serializationObject defines the JSON object
  13440. */
  13441. parse(serializationObject: any): void;
  13442. }
  13443. }
  13444. declare module BABYLON {
  13445. /**
  13446. * Particle emitter emitting particles from a point.
  13447. * It emits the particles randomly between 2 given directions.
  13448. */
  13449. export class PointParticleEmitter implements IParticleEmitterType {
  13450. /**
  13451. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13452. */
  13453. direction1: Vector3;
  13454. /**
  13455. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13456. */
  13457. direction2: Vector3;
  13458. /**
  13459. * Creates a new instance PointParticleEmitter
  13460. */
  13461. constructor();
  13462. /**
  13463. * Called by the particle System when the direction is computed for the created particle.
  13464. * @param worldMatrix is the world matrix of the particle system
  13465. * @param directionToUpdate is the direction vector to update with the result
  13466. * @param particle is the particle we are computed the direction for
  13467. * @param isLocal defines if the direction should be set in local space
  13468. */
  13469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13470. /**
  13471. * Called by the particle System when the position is computed for the created particle.
  13472. * @param worldMatrix is the world matrix of the particle system
  13473. * @param positionToUpdate is the position vector to update with the result
  13474. * @param particle is the particle we are computed the position for
  13475. * @param isLocal defines if the position should be set in local space
  13476. */
  13477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13478. /**
  13479. * Clones the current emitter and returns a copy of it
  13480. * @returns the new emitter
  13481. */
  13482. clone(): PointParticleEmitter;
  13483. /**
  13484. * Called by the GPUParticleSystem to setup the update shader
  13485. * @param effect defines the update shader
  13486. */
  13487. applyToShader(effect: Effect): void;
  13488. /**
  13489. * Returns a string to use to update the GPU particles update shader
  13490. * @returns a string containng the defines string
  13491. */
  13492. getEffectDefines(): string;
  13493. /**
  13494. * Returns the string "PointParticleEmitter"
  13495. * @returns a string containing the class name
  13496. */
  13497. getClassName(): string;
  13498. /**
  13499. * Serializes the particle system to a JSON object.
  13500. * @returns the JSON object
  13501. */
  13502. serialize(): any;
  13503. /**
  13504. * Parse properties from a JSON object
  13505. * @param serializationObject defines the JSON object
  13506. */
  13507. parse(serializationObject: any): void;
  13508. }
  13509. }
  13510. declare module BABYLON {
  13511. /**
  13512. * Particle emitter emitting particles from the inside of a sphere.
  13513. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13514. */
  13515. export class SphereParticleEmitter implements IParticleEmitterType {
  13516. /**
  13517. * The radius of the emission sphere.
  13518. */
  13519. radius: number;
  13520. /**
  13521. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13522. */
  13523. radiusRange: number;
  13524. /**
  13525. * How much to randomize the particle direction [0-1].
  13526. */
  13527. directionRandomizer: number;
  13528. /**
  13529. * Creates a new instance SphereParticleEmitter
  13530. * @param radius the radius of the emission sphere (1 by default)
  13531. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13532. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13533. */
  13534. constructor(
  13535. /**
  13536. * The radius of the emission sphere.
  13537. */
  13538. radius?: number,
  13539. /**
  13540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13541. */
  13542. radiusRange?: number,
  13543. /**
  13544. * How much to randomize the particle direction [0-1].
  13545. */
  13546. directionRandomizer?: number);
  13547. /**
  13548. * Called by the particle System when the direction is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param directionToUpdate is the direction vector to update with the result
  13551. * @param particle is the particle we are computed the direction for
  13552. * @param isLocal defines if the direction should be set in local space
  13553. */
  13554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Called by the particle System when the position is computed for the created particle.
  13557. * @param worldMatrix is the world matrix of the particle system
  13558. * @param positionToUpdate is the position vector to update with the result
  13559. * @param particle is the particle we are computed the position for
  13560. * @param isLocal defines if the position should be set in local space
  13561. */
  13562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13563. /**
  13564. * Clones the current emitter and returns a copy of it
  13565. * @returns the new emitter
  13566. */
  13567. clone(): SphereParticleEmitter;
  13568. /**
  13569. * Called by the GPUParticleSystem to setup the update shader
  13570. * @param effect defines the update shader
  13571. */
  13572. applyToShader(effect: Effect): void;
  13573. /**
  13574. * Returns a string to use to update the GPU particles update shader
  13575. * @returns a string containng the defines string
  13576. */
  13577. getEffectDefines(): string;
  13578. /**
  13579. * Returns the string "SphereParticleEmitter"
  13580. * @returns a string containing the class name
  13581. */
  13582. getClassName(): string;
  13583. /**
  13584. * Serializes the particle system to a JSON object.
  13585. * @returns the JSON object
  13586. */
  13587. serialize(): any;
  13588. /**
  13589. * Parse properties from a JSON object
  13590. * @param serializationObject defines the JSON object
  13591. */
  13592. parse(serializationObject: any): void;
  13593. }
  13594. /**
  13595. * Particle emitter emitting particles from the inside of a sphere.
  13596. * It emits the particles randomly between two vectors.
  13597. */
  13598. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13599. /**
  13600. * The min limit of the emission direction.
  13601. */
  13602. direction1: Vector3;
  13603. /**
  13604. * The max limit of the emission direction.
  13605. */
  13606. direction2: Vector3;
  13607. /**
  13608. * Creates a new instance SphereDirectedParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param direction1 the min limit of the emission direction (up vector by default)
  13611. * @param direction2 the max limit of the emission direction (up vector by default)
  13612. */
  13613. constructor(radius?: number,
  13614. /**
  13615. * The min limit of the emission direction.
  13616. */
  13617. direction1?: Vector3,
  13618. /**
  13619. * The max limit of the emission direction.
  13620. */
  13621. direction2?: Vector3);
  13622. /**
  13623. * Called by the particle System when the direction is computed for the created particle.
  13624. * @param worldMatrix is the world matrix of the particle system
  13625. * @param directionToUpdate is the direction vector to update with the result
  13626. * @param particle is the particle we are computed the direction for
  13627. */
  13628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): SphereDirectedParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "SphereDirectedParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module BABYLON {
  13662. /**
  13663. * Particle emitter emitting particles from a custom list of positions.
  13664. */
  13665. export class CustomParticleEmitter implements IParticleEmitterType {
  13666. /**
  13667. * Gets or sets the position generator that will create the inital position of each particle.
  13668. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13669. */
  13670. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13671. /**
  13672. * Gets or sets the destination generator that will create the final destination of each particle.
  13673. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13674. */
  13675. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13676. /**
  13677. * Creates a new instance CustomParticleEmitter
  13678. */
  13679. constructor();
  13680. /**
  13681. * Called by the particle System when the direction is computed for the created particle.
  13682. * @param worldMatrix is the world matrix of the particle system
  13683. * @param directionToUpdate is the direction vector to update with the result
  13684. * @param particle is the particle we are computed the direction for
  13685. * @param isLocal defines if the direction should be set in local space
  13686. */
  13687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13688. /**
  13689. * Called by the particle System when the position is computed for the created particle.
  13690. * @param worldMatrix is the world matrix of the particle system
  13691. * @param positionToUpdate is the position vector to update with the result
  13692. * @param particle is the particle we are computed the position for
  13693. * @param isLocal defines if the position should be set in local space
  13694. */
  13695. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13696. /**
  13697. * Clones the current emitter and returns a copy of it
  13698. * @returns the new emitter
  13699. */
  13700. clone(): CustomParticleEmitter;
  13701. /**
  13702. * Called by the GPUParticleSystem to setup the update shader
  13703. * @param effect defines the update shader
  13704. */
  13705. applyToShader(effect: Effect): void;
  13706. /**
  13707. * Returns a string to use to update the GPU particles update shader
  13708. * @returns a string containng the defines string
  13709. */
  13710. getEffectDefines(): string;
  13711. /**
  13712. * Returns the string "PointParticleEmitter"
  13713. * @returns a string containing the class name
  13714. */
  13715. getClassName(): string;
  13716. /**
  13717. * Serializes the particle system to a JSON object.
  13718. * @returns the JSON object
  13719. */
  13720. serialize(): any;
  13721. /**
  13722. * Parse properties from a JSON object
  13723. * @param serializationObject defines the JSON object
  13724. */
  13725. parse(serializationObject: any): void;
  13726. }
  13727. }
  13728. declare module BABYLON {
  13729. /**
  13730. * Particle emitter emitting particles from the inside of a box.
  13731. * It emits the particles randomly between 2 given directions.
  13732. */
  13733. export class MeshParticleEmitter implements IParticleEmitterType {
  13734. private _indices;
  13735. private _positions;
  13736. private _normals;
  13737. private _storedNormal;
  13738. private _mesh;
  13739. /**
  13740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13741. */
  13742. direction1: Vector3;
  13743. /**
  13744. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13745. */
  13746. direction2: Vector3;
  13747. /**
  13748. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13749. */
  13750. useMeshNormalsForDirection: boolean;
  13751. /** Defines the mesh to use as source */
  13752. get mesh(): Nullable<AbstractMesh>;
  13753. set mesh(value: Nullable<AbstractMesh>);
  13754. /**
  13755. * Creates a new instance MeshParticleEmitter
  13756. * @param mesh defines the mesh to use as source
  13757. */
  13758. constructor(mesh?: Nullable<AbstractMesh>);
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): MeshParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "BoxParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. * @param scene defines the hosting scene
  13804. */
  13805. parse(serializationObject: any, scene: Scene): void;
  13806. }
  13807. }
  13808. declare module BABYLON {
  13809. /**
  13810. * Interface representing a particle system in Babylon.js.
  13811. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13812. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13813. */
  13814. export interface IParticleSystem {
  13815. /**
  13816. * List of animations used by the particle system.
  13817. */
  13818. animations: Animation[];
  13819. /**
  13820. * The id of the Particle system.
  13821. */
  13822. id: string;
  13823. /**
  13824. * The name of the Particle system.
  13825. */
  13826. name: string;
  13827. /**
  13828. * The emitter represents the Mesh or position we are attaching the particle system to.
  13829. */
  13830. emitter: Nullable<AbstractMesh | Vector3>;
  13831. /**
  13832. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13833. */
  13834. isBillboardBased: boolean;
  13835. /**
  13836. * The rendering group used by the Particle system to chose when to render.
  13837. */
  13838. renderingGroupId: number;
  13839. /**
  13840. * The layer mask we are rendering the particles through.
  13841. */
  13842. layerMask: number;
  13843. /**
  13844. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13845. */
  13846. updateSpeed: number;
  13847. /**
  13848. * The amount of time the particle system is running (depends of the overall update speed).
  13849. */
  13850. targetStopDuration: number;
  13851. /**
  13852. * The texture used to render each particle. (this can be a spritesheet)
  13853. */
  13854. particleTexture: Nullable<Texture>;
  13855. /**
  13856. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13857. */
  13858. blendMode: number;
  13859. /**
  13860. * Minimum life time of emitting particles.
  13861. */
  13862. minLifeTime: number;
  13863. /**
  13864. * Maximum life time of emitting particles.
  13865. */
  13866. maxLifeTime: number;
  13867. /**
  13868. * Minimum Size of emitting particles.
  13869. */
  13870. minSize: number;
  13871. /**
  13872. * Maximum Size of emitting particles.
  13873. */
  13874. maxSize: number;
  13875. /**
  13876. * Minimum scale of emitting particles on X axis.
  13877. */
  13878. minScaleX: number;
  13879. /**
  13880. * Maximum scale of emitting particles on X axis.
  13881. */
  13882. maxScaleX: number;
  13883. /**
  13884. * Minimum scale of emitting particles on Y axis.
  13885. */
  13886. minScaleY: number;
  13887. /**
  13888. * Maximum scale of emitting particles on Y axis.
  13889. */
  13890. maxScaleY: number;
  13891. /**
  13892. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13893. */
  13894. color1: Color4;
  13895. /**
  13896. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13897. */
  13898. color2: Color4;
  13899. /**
  13900. * Color the particle will have at the end of its lifetime.
  13901. */
  13902. colorDead: Color4;
  13903. /**
  13904. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13905. */
  13906. emitRate: number;
  13907. /**
  13908. * You can use gravity if you want to give an orientation to your particles.
  13909. */
  13910. gravity: Vector3;
  13911. /**
  13912. * Minimum power of emitting particles.
  13913. */
  13914. minEmitPower: number;
  13915. /**
  13916. * Maximum power of emitting particles.
  13917. */
  13918. maxEmitPower: number;
  13919. /**
  13920. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13921. */
  13922. minAngularSpeed: number;
  13923. /**
  13924. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13925. */
  13926. maxAngularSpeed: number;
  13927. /**
  13928. * Gets or sets the minimal initial rotation in radians.
  13929. */
  13930. minInitialRotation: number;
  13931. /**
  13932. * Gets or sets the maximal initial rotation in radians.
  13933. */
  13934. maxInitialRotation: number;
  13935. /**
  13936. * The particle emitter type defines the emitter used by the particle system.
  13937. * It can be for example box, sphere, or cone...
  13938. */
  13939. particleEmitterType: Nullable<IParticleEmitterType>;
  13940. /**
  13941. * Defines the delay in milliseconds before starting the system (0 by default)
  13942. */
  13943. startDelay: number;
  13944. /**
  13945. * 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
  13946. */
  13947. preWarmCycles: number;
  13948. /**
  13949. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13950. */
  13951. preWarmStepOffset: number;
  13952. /**
  13953. * 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)
  13954. */
  13955. spriteCellChangeSpeed: number;
  13956. /**
  13957. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13958. */
  13959. startSpriteCellID: number;
  13960. /**
  13961. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13962. */
  13963. endSpriteCellID: number;
  13964. /**
  13965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13966. */
  13967. spriteCellWidth: number;
  13968. /**
  13969. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13970. */
  13971. spriteCellHeight: number;
  13972. /**
  13973. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13974. */
  13975. spriteRandomStartCell: boolean;
  13976. /**
  13977. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13978. */
  13979. isAnimationSheetEnabled: boolean;
  13980. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13981. translationPivot: Vector2;
  13982. /**
  13983. * Gets or sets a texture used to add random noise to particle positions
  13984. */
  13985. noiseTexture: Nullable<BaseTexture>;
  13986. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13987. noiseStrength: Vector3;
  13988. /**
  13989. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13990. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13991. */
  13992. billboardMode: number;
  13993. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13994. limitVelocityDamping: number;
  13995. /**
  13996. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13997. */
  13998. beginAnimationOnStart: boolean;
  13999. /**
  14000. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14001. */
  14002. beginAnimationFrom: number;
  14003. /**
  14004. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14005. */
  14006. beginAnimationTo: number;
  14007. /**
  14008. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14009. */
  14010. beginAnimationLoop: boolean;
  14011. /**
  14012. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14013. */
  14014. disposeOnStop: boolean;
  14015. /**
  14016. * Specifies if the particles are updated in emitter local space or world space
  14017. */
  14018. isLocal: boolean;
  14019. /** Snippet ID if the particle system was created from the snippet server */
  14020. snippetId: string;
  14021. /**
  14022. * Gets the maximum number of particles active at the same time.
  14023. * @returns The max number of active particles.
  14024. */
  14025. getCapacity(): number;
  14026. /**
  14027. * Gets the number of particles active at the same time.
  14028. * @returns The number of active particles.
  14029. */
  14030. getActiveCount(): number;
  14031. /**
  14032. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14033. * @returns True if it has been started, otherwise false.
  14034. */
  14035. isStarted(): boolean;
  14036. /**
  14037. * Animates the particle system for this frame.
  14038. */
  14039. animate(): void;
  14040. /**
  14041. * Renders the particle system in its current state.
  14042. * @returns the current number of particles
  14043. */
  14044. render(): number;
  14045. /**
  14046. * Dispose the particle system and frees its associated resources.
  14047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14048. */
  14049. dispose(disposeTexture?: boolean): void;
  14050. /**
  14051. * An event triggered when the system is disposed
  14052. */
  14053. onDisposeObservable: Observable<IParticleSystem>;
  14054. /**
  14055. * Clones the particle system.
  14056. * @param name The name of the cloned object
  14057. * @param newEmitter The new emitter to use
  14058. * @returns the cloned particle system
  14059. */
  14060. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14061. /**
  14062. * Serializes the particle system to a JSON object
  14063. * @param serializeTexture defines if the texture must be serialized as well
  14064. * @returns the JSON object
  14065. */
  14066. serialize(serializeTexture: boolean): any;
  14067. /**
  14068. * Rebuild the particle system
  14069. */
  14070. rebuild(): void;
  14071. /** Force the system to rebuild all gradients that need to be resync */
  14072. forceRefreshGradients(): void;
  14073. /**
  14074. * Starts the particle system and begins to emit
  14075. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14076. */
  14077. start(delay?: number): void;
  14078. /**
  14079. * Stops the particle system.
  14080. */
  14081. stop(): void;
  14082. /**
  14083. * Remove all active particles
  14084. */
  14085. reset(): void;
  14086. /**
  14087. * Gets a boolean indicating that the system is stopping
  14088. * @returns true if the system is currently stopping
  14089. */
  14090. isStopping(): boolean;
  14091. /**
  14092. * Is this system ready to be used/rendered
  14093. * @return true if the system is ready
  14094. */
  14095. isReady(): boolean;
  14096. /**
  14097. * Returns the string "ParticleSystem"
  14098. * @returns a string containing the class name
  14099. */
  14100. getClassName(): string;
  14101. /**
  14102. * Gets the custom effect used to render the particles
  14103. * @param blendMode Blend mode for which the effect should be retrieved
  14104. * @returns The effect
  14105. */
  14106. getCustomEffect(blendMode: number): Nullable<Effect>;
  14107. /**
  14108. * Sets the custom effect used to render the particles
  14109. * @param effect The effect to set
  14110. * @param blendMode Blend mode for which the effect should be set
  14111. */
  14112. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14113. /**
  14114. * Fill the defines array according to the current settings of the particle system
  14115. * @param defines Array to be updated
  14116. * @param blendMode blend mode to take into account when updating the array
  14117. */
  14118. fillDefines(defines: Array<string>, blendMode: number): void;
  14119. /**
  14120. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14121. * @param uniforms Uniforms array to fill
  14122. * @param attributes Attributes array to fill
  14123. * @param samplers Samplers array to fill
  14124. */
  14125. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14126. /**
  14127. * Observable that will be called just before the particles are drawn
  14128. */
  14129. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14130. /**
  14131. * Gets the name of the particle vertex shader
  14132. */
  14133. vertexShaderName: string;
  14134. /**
  14135. * Adds a new color gradient
  14136. * @param gradient defines the gradient to use (between 0 and 1)
  14137. * @param color1 defines the color to affect to the specified gradient
  14138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14139. * @returns the current particle system
  14140. */
  14141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14142. /**
  14143. * Remove a specific color gradient
  14144. * @param gradient defines the gradient to remove
  14145. * @returns the current particle system
  14146. */
  14147. removeColorGradient(gradient: number): IParticleSystem;
  14148. /**
  14149. * Adds a new size gradient
  14150. * @param gradient defines the gradient to use (between 0 and 1)
  14151. * @param factor defines the size factor to affect to the specified gradient
  14152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14153. * @returns the current particle system
  14154. */
  14155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14156. /**
  14157. * Remove a specific size gradient
  14158. * @param gradient defines the gradient to remove
  14159. * @returns the current particle system
  14160. */
  14161. removeSizeGradient(gradient: number): IParticleSystem;
  14162. /**
  14163. * Gets the current list of color gradients.
  14164. * You must use addColorGradient and removeColorGradient to udpate this list
  14165. * @returns the list of color gradients
  14166. */
  14167. getColorGradients(): Nullable<Array<ColorGradient>>;
  14168. /**
  14169. * Gets the current list of size gradients.
  14170. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14171. * @returns the list of size gradients
  14172. */
  14173. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14174. /**
  14175. * Gets the current list of angular speed gradients.
  14176. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14177. * @returns the list of angular speed gradients
  14178. */
  14179. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14180. /**
  14181. * Adds a new angular speed gradient
  14182. * @param gradient defines the gradient to use (between 0 and 1)
  14183. * @param factor defines the angular speed to affect to the specified gradient
  14184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14185. * @returns the current particle system
  14186. */
  14187. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14188. /**
  14189. * Remove a specific angular speed gradient
  14190. * @param gradient defines the gradient to remove
  14191. * @returns the current particle system
  14192. */
  14193. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14194. /**
  14195. * Gets the current list of velocity gradients.
  14196. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14197. * @returns the list of velocity gradients
  14198. */
  14199. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14200. /**
  14201. * Adds a new velocity gradient
  14202. * @param gradient defines the gradient to use (between 0 and 1)
  14203. * @param factor defines the velocity to affect to the specified gradient
  14204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14205. * @returns the current particle system
  14206. */
  14207. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14208. /**
  14209. * Remove a specific velocity gradient
  14210. * @param gradient defines the gradient to remove
  14211. * @returns the current particle system
  14212. */
  14213. removeVelocityGradient(gradient: number): IParticleSystem;
  14214. /**
  14215. * Gets the current list of limit velocity gradients.
  14216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14217. * @returns the list of limit velocity gradients
  14218. */
  14219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14220. /**
  14221. * Adds a new limit velocity gradient
  14222. * @param gradient defines the gradient to use (between 0 and 1)
  14223. * @param factor defines the limit velocity to affect to the specified gradient
  14224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14225. * @returns the current particle system
  14226. */
  14227. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14228. /**
  14229. * Remove a specific limit velocity gradient
  14230. * @param gradient defines the gradient to remove
  14231. * @returns the current particle system
  14232. */
  14233. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14234. /**
  14235. * Adds a new drag gradient
  14236. * @param gradient defines the gradient to use (between 0 and 1)
  14237. * @param factor defines the drag to affect to the specified gradient
  14238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14239. * @returns the current particle system
  14240. */
  14241. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14242. /**
  14243. * Remove a specific drag gradient
  14244. * @param gradient defines the gradient to remove
  14245. * @returns the current particle system
  14246. */
  14247. removeDragGradient(gradient: number): IParticleSystem;
  14248. /**
  14249. * Gets the current list of drag gradients.
  14250. * You must use addDragGradient and removeDragGradient to udpate this list
  14251. * @returns the list of drag gradients
  14252. */
  14253. getDragGradients(): Nullable<Array<FactorGradient>>;
  14254. /**
  14255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14256. * @param gradient defines the gradient to use (between 0 and 1)
  14257. * @param factor defines the emit rate to affect to the specified gradient
  14258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14259. * @returns the current particle system
  14260. */
  14261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14262. /**
  14263. * Remove a specific emit rate gradient
  14264. * @param gradient defines the gradient to remove
  14265. * @returns the current particle system
  14266. */
  14267. removeEmitRateGradient(gradient: number): IParticleSystem;
  14268. /**
  14269. * Gets the current list of emit rate gradients.
  14270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14271. * @returns the list of emit rate gradients
  14272. */
  14273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14274. /**
  14275. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14276. * @param gradient defines the gradient to use (between 0 and 1)
  14277. * @param factor defines the start size to affect to the specified gradient
  14278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14279. * @returns the current particle system
  14280. */
  14281. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14282. /**
  14283. * Remove a specific start size gradient
  14284. * @param gradient defines the gradient to remove
  14285. * @returns the current particle system
  14286. */
  14287. removeStartSizeGradient(gradient: number): IParticleSystem;
  14288. /**
  14289. * Gets the current list of start size gradients.
  14290. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14291. * @returns the list of start size gradients
  14292. */
  14293. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14294. /**
  14295. * Adds a new life time gradient
  14296. * @param gradient defines the gradient to use (between 0 and 1)
  14297. * @param factor defines the life time factor to affect to the specified gradient
  14298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14299. * @returns the current particle system
  14300. */
  14301. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14302. /**
  14303. * Remove a specific life time gradient
  14304. * @param gradient defines the gradient to remove
  14305. * @returns the current particle system
  14306. */
  14307. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14308. /**
  14309. * Gets the current list of life time gradients.
  14310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14311. * @returns the list of life time gradients
  14312. */
  14313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14314. /**
  14315. * Gets the current list of color gradients.
  14316. * You must use addColorGradient and removeColorGradient to udpate this list
  14317. * @returns the list of color gradients
  14318. */
  14319. getColorGradients(): Nullable<Array<ColorGradient>>;
  14320. /**
  14321. * Adds a new ramp gradient used to remap particle colors
  14322. * @param gradient defines the gradient to use (between 0 and 1)
  14323. * @param color defines the color to affect to the specified gradient
  14324. * @returns the current particle system
  14325. */
  14326. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14327. /**
  14328. * Gets the current list of ramp gradients.
  14329. * You must use addRampGradient and removeRampGradient to udpate this list
  14330. * @returns the list of ramp gradients
  14331. */
  14332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14333. /** Gets or sets a boolean indicating that ramp gradients must be used
  14334. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14335. */
  14336. useRampGradients: boolean;
  14337. /**
  14338. * Adds a new color remap gradient
  14339. * @param gradient defines the gradient to use (between 0 and 1)
  14340. * @param min defines the color remap minimal range
  14341. * @param max defines the color remap maximal range
  14342. * @returns the current particle system
  14343. */
  14344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of color remap gradients.
  14347. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14348. * @returns the list of color remap gradients
  14349. */
  14350. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Adds a new alpha remap gradient
  14353. * @param gradient defines the gradient to use (between 0 and 1)
  14354. * @param min defines the alpha remap minimal range
  14355. * @param max defines the alpha remap maximal range
  14356. * @returns the current particle system
  14357. */
  14358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14359. /**
  14360. * Gets the current list of alpha remap gradients.
  14361. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14362. * @returns the list of alpha remap gradients
  14363. */
  14364. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14365. /**
  14366. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14367. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14368. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14369. * @returns the emitter
  14370. */
  14371. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14372. /**
  14373. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14374. * @param radius The radius of the hemisphere to emit from
  14375. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14376. * @returns the emitter
  14377. */
  14378. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14379. /**
  14380. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14381. * @param radius The radius of the sphere to emit from
  14382. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14383. * @returns the emitter
  14384. */
  14385. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14386. /**
  14387. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14388. * @param radius The radius of the sphere to emit from
  14389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14391. * @returns the emitter
  14392. */
  14393. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14394. /**
  14395. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14396. * @param radius The radius of the emission cylinder
  14397. * @param height The height of the emission cylinder
  14398. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14399. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14400. * @returns the emitter
  14401. */
  14402. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14403. /**
  14404. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14405. * @param radius The radius of the cylinder to emit from
  14406. * @param height The height of the emission cylinder
  14407. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14410. * @returns the emitter
  14411. */
  14412. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14413. /**
  14414. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14415. * @param radius The radius of the cone to emit from
  14416. * @param angle The base angle of the cone
  14417. * @returns the emitter
  14418. */
  14419. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14420. /**
  14421. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14424. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14425. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14426. * @returns the emitter
  14427. */
  14428. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14429. /**
  14430. * Get hosting scene
  14431. * @returns the scene
  14432. */
  14433. getScene(): Scene;
  14434. }
  14435. }
  14436. declare module BABYLON {
  14437. /**
  14438. * 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.
  14439. * @see https://doc.babylonjs.com/how_to/transformnode
  14440. */
  14441. export class TransformNode extends Node {
  14442. /**
  14443. * Object will not rotate to face the camera
  14444. */
  14445. static BILLBOARDMODE_NONE: number;
  14446. /**
  14447. * Object will rotate to face the camera but only on the x axis
  14448. */
  14449. static BILLBOARDMODE_X: number;
  14450. /**
  14451. * Object will rotate to face the camera but only on the y axis
  14452. */
  14453. static BILLBOARDMODE_Y: number;
  14454. /**
  14455. * Object will rotate to face the camera but only on the z axis
  14456. */
  14457. static BILLBOARDMODE_Z: number;
  14458. /**
  14459. * Object will rotate to face the camera
  14460. */
  14461. static BILLBOARDMODE_ALL: number;
  14462. /**
  14463. * Object will rotate to face the camera's position instead of orientation
  14464. */
  14465. static BILLBOARDMODE_USE_POSITION: number;
  14466. private static _TmpRotation;
  14467. private static _TmpScaling;
  14468. private static _TmpTranslation;
  14469. private _forward;
  14470. private _forwardInverted;
  14471. private _up;
  14472. private _right;
  14473. private _rightInverted;
  14474. private _position;
  14475. private _rotation;
  14476. private _rotationQuaternion;
  14477. protected _scaling: Vector3;
  14478. protected _isDirty: boolean;
  14479. private _transformToBoneReferal;
  14480. private _isAbsoluteSynced;
  14481. private _billboardMode;
  14482. /**
  14483. * Gets or sets the billboard mode. Default is 0.
  14484. *
  14485. * | Value | Type | Description |
  14486. * | --- | --- | --- |
  14487. * | 0 | BILLBOARDMODE_NONE | |
  14488. * | 1 | BILLBOARDMODE_X | |
  14489. * | 2 | BILLBOARDMODE_Y | |
  14490. * | 4 | BILLBOARDMODE_Z | |
  14491. * | 7 | BILLBOARDMODE_ALL | |
  14492. *
  14493. */
  14494. get billboardMode(): number;
  14495. set billboardMode(value: number);
  14496. private _preserveParentRotationForBillboard;
  14497. /**
  14498. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14499. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14500. */
  14501. get preserveParentRotationForBillboard(): boolean;
  14502. set preserveParentRotationForBillboard(value: boolean);
  14503. /**
  14504. * 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
  14505. */
  14506. scalingDeterminant: number;
  14507. private _infiniteDistance;
  14508. /**
  14509. * Gets or sets the distance of the object to max, often used by skybox
  14510. */
  14511. get infiniteDistance(): boolean;
  14512. set infiniteDistance(value: boolean);
  14513. /**
  14514. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14515. * By default the system will update normals to compensate
  14516. */
  14517. ignoreNonUniformScaling: boolean;
  14518. /**
  14519. * 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
  14520. */
  14521. reIntegrateRotationIntoRotationQuaternion: boolean;
  14522. /** @hidden */
  14523. _poseMatrix: Nullable<Matrix>;
  14524. /** @hidden */
  14525. _localMatrix: Matrix;
  14526. private _usePivotMatrix;
  14527. private _absolutePosition;
  14528. private _absoluteScaling;
  14529. private _absoluteRotationQuaternion;
  14530. private _pivotMatrix;
  14531. private _pivotMatrixInverse;
  14532. protected _postMultiplyPivotMatrix: boolean;
  14533. protected _isWorldMatrixFrozen: boolean;
  14534. /** @hidden */
  14535. _indexInSceneTransformNodesArray: number;
  14536. /**
  14537. * An event triggered after the world matrix is updated
  14538. */
  14539. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14540. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14541. /**
  14542. * Gets a string identifying the name of the class
  14543. * @returns "TransformNode" string
  14544. */
  14545. getClassName(): string;
  14546. /**
  14547. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14548. */
  14549. get position(): Vector3;
  14550. set position(newPosition: Vector3);
  14551. /**
  14552. * 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)).
  14553. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14554. */
  14555. get rotation(): Vector3;
  14556. set rotation(newRotation: Vector3);
  14557. /**
  14558. * 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)).
  14559. */
  14560. get scaling(): Vector3;
  14561. set scaling(newScaling: Vector3);
  14562. /**
  14563. * 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).
  14564. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14565. */
  14566. get rotationQuaternion(): Nullable<Quaternion>;
  14567. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14568. /**
  14569. * The forward direction of that transform in world space.
  14570. */
  14571. get forward(): Vector3;
  14572. /**
  14573. * The up direction of that transform in world space.
  14574. */
  14575. get up(): Vector3;
  14576. /**
  14577. * The right direction of that transform in world space.
  14578. */
  14579. get right(): Vector3;
  14580. /**
  14581. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14582. * @param matrix the matrix to copy the pose from
  14583. * @returns this TransformNode.
  14584. */
  14585. updatePoseMatrix(matrix: Matrix): TransformNode;
  14586. /**
  14587. * Returns the mesh Pose matrix.
  14588. * @returns the pose matrix
  14589. */
  14590. getPoseMatrix(): Matrix;
  14591. /** @hidden */
  14592. _isSynchronized(): boolean;
  14593. /** @hidden */
  14594. _initCache(): void;
  14595. /**
  14596. * Flag the transform node as dirty (Forcing it to update everything)
  14597. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14598. * @returns this transform node
  14599. */
  14600. markAsDirty(property: string): TransformNode;
  14601. /**
  14602. * Returns the current mesh absolute position.
  14603. * Returns a Vector3.
  14604. */
  14605. get absolutePosition(): Vector3;
  14606. /**
  14607. * Returns the current mesh absolute scaling.
  14608. * Returns a Vector3.
  14609. */
  14610. get absoluteScaling(): Vector3;
  14611. /**
  14612. * Returns the current mesh absolute rotation.
  14613. * Returns a Quaternion.
  14614. */
  14615. get absoluteRotationQuaternion(): Quaternion;
  14616. /**
  14617. * Sets a new matrix to apply before all other transformation
  14618. * @param matrix defines the transform matrix
  14619. * @returns the current TransformNode
  14620. */
  14621. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14622. /**
  14623. * Sets a new pivot matrix to the current node
  14624. * @param matrix defines the new pivot matrix to use
  14625. * @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
  14626. * @returns the current TransformNode
  14627. */
  14628. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14629. /**
  14630. * Returns the mesh pivot matrix.
  14631. * Default : Identity.
  14632. * @returns the matrix
  14633. */
  14634. getPivotMatrix(): Matrix;
  14635. /**
  14636. * Instantiate (when possible) or clone that node with its hierarchy
  14637. * @param newParent defines the new parent to use for the instance (or clone)
  14638. * @param options defines options to configure how copy is done
  14639. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14640. * @returns an instance (or a clone) of the current node with its hiearchy
  14641. */
  14642. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14643. doNotInstantiate: boolean;
  14644. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14645. /**
  14646. * Prevents the World matrix to be computed any longer
  14647. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14648. * @returns the TransformNode.
  14649. */
  14650. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14651. /**
  14652. * Allows back the World matrix computation.
  14653. * @returns the TransformNode.
  14654. */
  14655. unfreezeWorldMatrix(): this;
  14656. /**
  14657. * True if the World matrix has been frozen.
  14658. */
  14659. get isWorldMatrixFrozen(): boolean;
  14660. /**
  14661. * Retuns the mesh absolute position in the World.
  14662. * @returns a Vector3.
  14663. */
  14664. getAbsolutePosition(): Vector3;
  14665. /**
  14666. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14667. * @param absolutePosition the absolute position to set
  14668. * @returns the TransformNode.
  14669. */
  14670. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14671. /**
  14672. * Sets the mesh position in its local space.
  14673. * @param vector3 the position to set in localspace
  14674. * @returns the TransformNode.
  14675. */
  14676. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14677. /**
  14678. * Returns the mesh position in the local space from the current World matrix values.
  14679. * @returns a new Vector3.
  14680. */
  14681. getPositionExpressedInLocalSpace(): Vector3;
  14682. /**
  14683. * Translates the mesh along the passed Vector3 in its local space.
  14684. * @param vector3 the distance to translate in localspace
  14685. * @returns the TransformNode.
  14686. */
  14687. locallyTranslate(vector3: Vector3): TransformNode;
  14688. private static _lookAtVectorCache;
  14689. /**
  14690. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14691. * @param targetPoint the position (must be in same space as current mesh) to look at
  14692. * @param yawCor optional yaw (y-axis) correction in radians
  14693. * @param pitchCor optional pitch (x-axis) correction in radians
  14694. * @param rollCor optional roll (z-axis) correction in radians
  14695. * @param space the choosen space of the target
  14696. * @returns the TransformNode.
  14697. */
  14698. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14699. /**
  14700. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14701. * This Vector3 is expressed in the World space.
  14702. * @param localAxis axis to rotate
  14703. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14704. */
  14705. getDirection(localAxis: Vector3): Vector3;
  14706. /**
  14707. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14708. * localAxis is expressed in the mesh local space.
  14709. * result is computed in the Wordl space from the mesh World matrix.
  14710. * @param localAxis axis to rotate
  14711. * @param result the resulting transformnode
  14712. * @returns this TransformNode.
  14713. */
  14714. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14715. /**
  14716. * Sets this transform node rotation to the given local axis.
  14717. * @param localAxis the axis in local space
  14718. * @param yawCor optional yaw (y-axis) correction in radians
  14719. * @param pitchCor optional pitch (x-axis) correction in radians
  14720. * @param rollCor optional roll (z-axis) correction in radians
  14721. * @returns this TransformNode
  14722. */
  14723. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14724. /**
  14725. * Sets a new pivot point to the current node
  14726. * @param point defines the new pivot point to use
  14727. * @param space defines if the point is in world or local space (local by default)
  14728. * @returns the current TransformNode
  14729. */
  14730. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14731. /**
  14732. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14733. * @returns the pivot point
  14734. */
  14735. getPivotPoint(): Vector3;
  14736. /**
  14737. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14738. * @param result the vector3 to store the result
  14739. * @returns this TransformNode.
  14740. */
  14741. getPivotPointToRef(result: Vector3): TransformNode;
  14742. /**
  14743. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14744. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14745. */
  14746. getAbsolutePivotPoint(): Vector3;
  14747. /**
  14748. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14749. * @param result vector3 to store the result
  14750. * @returns this TransformNode.
  14751. */
  14752. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14753. /**
  14754. * Defines the passed node as the parent of the current node.
  14755. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14756. * @see https://doc.babylonjs.com/how_to/parenting
  14757. * @param node the node ot set as the parent
  14758. * @returns this TransformNode.
  14759. */
  14760. setParent(node: Nullable<Node>): TransformNode;
  14761. private _nonUniformScaling;
  14762. /**
  14763. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14764. */
  14765. get nonUniformScaling(): boolean;
  14766. /** @hidden */
  14767. _updateNonUniformScalingState(value: boolean): boolean;
  14768. /**
  14769. * Attach the current TransformNode to another TransformNode associated with a bone
  14770. * @param bone Bone affecting the TransformNode
  14771. * @param affectedTransformNode TransformNode associated with the bone
  14772. * @returns this object
  14773. */
  14774. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14775. /**
  14776. * Detach the transform node if its associated with a bone
  14777. * @returns this object
  14778. */
  14779. detachFromBone(): TransformNode;
  14780. private static _rotationAxisCache;
  14781. /**
  14782. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14783. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14784. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14785. * The passed axis is also normalized.
  14786. * @param axis the axis to rotate around
  14787. * @param amount the amount to rotate in radians
  14788. * @param space Space to rotate in (Default: local)
  14789. * @returns the TransformNode.
  14790. */
  14791. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14792. /**
  14793. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14794. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14795. * The passed axis is also normalized. .
  14796. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14797. * @param point the point to rotate around
  14798. * @param axis the axis to rotate around
  14799. * @param amount the amount to rotate in radians
  14800. * @returns the TransformNode
  14801. */
  14802. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14803. /**
  14804. * Translates the mesh along the axis vector for the passed distance in the given space.
  14805. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14806. * @param axis the axis to translate in
  14807. * @param distance the distance to translate
  14808. * @param space Space to rotate in (Default: local)
  14809. * @returns the TransformNode.
  14810. */
  14811. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14812. /**
  14813. * Adds a rotation step to the mesh current rotation.
  14814. * x, y, z are Euler angles expressed in radians.
  14815. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14816. * This means this rotation is made in the mesh local space only.
  14817. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14818. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14819. * ```javascript
  14820. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14821. * ```
  14822. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14823. * 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.
  14824. * @param x Rotation to add
  14825. * @param y Rotation to add
  14826. * @param z Rotation to add
  14827. * @returns the TransformNode.
  14828. */
  14829. addRotation(x: number, y: number, z: number): TransformNode;
  14830. /**
  14831. * @hidden
  14832. */
  14833. protected _getEffectiveParent(): Nullable<Node>;
  14834. /**
  14835. * Computes the world matrix of the node
  14836. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14837. * @returns the world matrix
  14838. */
  14839. computeWorldMatrix(force?: boolean): Matrix;
  14840. /**
  14841. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14842. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14843. */
  14844. resetLocalMatrix(independentOfChildren?: boolean): void;
  14845. protected _afterComputeWorldMatrix(): void;
  14846. /**
  14847. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14848. * @param func callback function to add
  14849. *
  14850. * @returns the TransformNode.
  14851. */
  14852. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14853. /**
  14854. * Removes a registered callback function.
  14855. * @param func callback function to remove
  14856. * @returns the TransformNode.
  14857. */
  14858. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14859. /**
  14860. * Gets the position of the current mesh in camera space
  14861. * @param camera defines the camera to use
  14862. * @returns a position
  14863. */
  14864. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14865. /**
  14866. * Returns the distance from the mesh to the active camera
  14867. * @param camera defines the camera to use
  14868. * @returns the distance
  14869. */
  14870. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14871. /**
  14872. * Clone the current transform node
  14873. * @param name Name of the new clone
  14874. * @param newParent New parent for the clone
  14875. * @param doNotCloneChildren Do not clone children hierarchy
  14876. * @returns the new transform node
  14877. */
  14878. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14879. /**
  14880. * Serializes the objects information.
  14881. * @param currentSerializationObject defines the object to serialize in
  14882. * @returns the serialized object
  14883. */
  14884. serialize(currentSerializationObject?: any): any;
  14885. /**
  14886. * Returns a new TransformNode object parsed from the source provided.
  14887. * @param parsedTransformNode is the source.
  14888. * @param scene the scne the object belongs to
  14889. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14890. * @returns a new TransformNode object parsed from the source provided.
  14891. */
  14892. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14893. /**
  14894. * Get all child-transformNodes of this node
  14895. * @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
  14896. * @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
  14897. * @returns an array of TransformNode
  14898. */
  14899. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14900. /**
  14901. * Releases resources associated with this transform node.
  14902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14904. */
  14905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14906. /**
  14907. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14908. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14909. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14910. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14911. * @returns the current mesh
  14912. */
  14913. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14914. private _syncAbsoluteScalingAndRotation;
  14915. }
  14916. }
  14917. declare module BABYLON {
  14918. /**
  14919. * Class used to override all child animations of a given target
  14920. */
  14921. export class AnimationPropertiesOverride {
  14922. /**
  14923. * Gets or sets a value indicating if animation blending must be used
  14924. */
  14925. enableBlending: boolean;
  14926. /**
  14927. * Gets or sets the blending speed to use when enableBlending is true
  14928. */
  14929. blendingSpeed: number;
  14930. /**
  14931. * Gets or sets the default loop mode to use
  14932. */
  14933. loopMode: number;
  14934. }
  14935. }
  14936. declare module BABYLON {
  14937. /**
  14938. * Class used to store bone information
  14939. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14940. */
  14941. export class Bone extends Node {
  14942. /**
  14943. * defines the bone name
  14944. */
  14945. name: string;
  14946. private static _tmpVecs;
  14947. private static _tmpQuat;
  14948. private static _tmpMats;
  14949. /**
  14950. * Gets the list of child bones
  14951. */
  14952. children: Bone[];
  14953. /** Gets the animations associated with this bone */
  14954. animations: Animation[];
  14955. /**
  14956. * Gets or sets bone length
  14957. */
  14958. length: number;
  14959. /**
  14960. * @hidden Internal only
  14961. * Set this value to map this bone to a different index in the transform matrices
  14962. * Set this value to -1 to exclude the bone from the transform matrices
  14963. */
  14964. _index: Nullable<number>;
  14965. private _skeleton;
  14966. private _localMatrix;
  14967. private _restPose;
  14968. private _baseMatrix;
  14969. private _absoluteTransform;
  14970. private _invertedAbsoluteTransform;
  14971. private _parent;
  14972. private _scalingDeterminant;
  14973. private _worldTransform;
  14974. private _localScaling;
  14975. private _localRotation;
  14976. private _localPosition;
  14977. private _needToDecompose;
  14978. private _needToCompose;
  14979. /** @hidden */
  14980. _linkedTransformNode: Nullable<TransformNode>;
  14981. /** @hidden */
  14982. _waitingTransformNodeId: Nullable<string>;
  14983. /** @hidden */
  14984. get _matrix(): Matrix;
  14985. /** @hidden */
  14986. set _matrix(value: Matrix);
  14987. /**
  14988. * Create a new bone
  14989. * @param name defines the bone name
  14990. * @param skeleton defines the parent skeleton
  14991. * @param parentBone defines the parent (can be null if the bone is the root)
  14992. * @param localMatrix defines the local matrix
  14993. * @param restPose defines the rest pose matrix
  14994. * @param baseMatrix defines the base matrix
  14995. * @param index defines index of the bone in the hiearchy
  14996. */
  14997. constructor(
  14998. /**
  14999. * defines the bone name
  15000. */
  15001. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15002. /**
  15003. * Gets the current object class name.
  15004. * @return the class name
  15005. */
  15006. getClassName(): string;
  15007. /**
  15008. * Gets the parent skeleton
  15009. * @returns a skeleton
  15010. */
  15011. getSkeleton(): Skeleton;
  15012. /**
  15013. * Gets parent bone
  15014. * @returns a bone or null if the bone is the root of the bone hierarchy
  15015. */
  15016. getParent(): Nullable<Bone>;
  15017. /**
  15018. * Returns an array containing the root bones
  15019. * @returns an array containing the root bones
  15020. */
  15021. getChildren(): Array<Bone>;
  15022. /**
  15023. * Gets the node index in matrix array generated for rendering
  15024. * @returns the node index
  15025. */
  15026. getIndex(): number;
  15027. /**
  15028. * Sets the parent bone
  15029. * @param parent defines the parent (can be null if the bone is the root)
  15030. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15031. */
  15032. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15033. /**
  15034. * Gets the local matrix
  15035. * @returns a matrix
  15036. */
  15037. getLocalMatrix(): Matrix;
  15038. /**
  15039. * Gets the base matrix (initial matrix which remains unchanged)
  15040. * @returns a matrix
  15041. */
  15042. getBaseMatrix(): Matrix;
  15043. /**
  15044. * Gets the rest pose matrix
  15045. * @returns a matrix
  15046. */
  15047. getRestPose(): Matrix;
  15048. /**
  15049. * Sets the rest pose matrix
  15050. * @param matrix the local-space rest pose to set for this bone
  15051. */
  15052. setRestPose(matrix: Matrix): void;
  15053. /**
  15054. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15055. */
  15056. getWorldMatrix(): Matrix;
  15057. /**
  15058. * Sets the local matrix to rest pose matrix
  15059. */
  15060. returnToRest(): void;
  15061. /**
  15062. * Gets the inverse of the absolute transform matrix.
  15063. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15064. * @returns a matrix
  15065. */
  15066. getInvertedAbsoluteTransform(): Matrix;
  15067. /**
  15068. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15069. * @returns a matrix
  15070. */
  15071. getAbsoluteTransform(): Matrix;
  15072. /**
  15073. * Links with the given transform node.
  15074. * The local matrix of this bone is copied from the transform node every frame.
  15075. * @param transformNode defines the transform node to link to
  15076. */
  15077. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15078. /**
  15079. * Gets the node used to drive the bone's transformation
  15080. * @returns a transform node or null
  15081. */
  15082. getTransformNode(): Nullable<TransformNode>;
  15083. /** Gets or sets current position (in local space) */
  15084. get position(): Vector3;
  15085. set position(newPosition: Vector3);
  15086. /** Gets or sets current rotation (in local space) */
  15087. get rotation(): Vector3;
  15088. set rotation(newRotation: Vector3);
  15089. /** Gets or sets current rotation quaternion (in local space) */
  15090. get rotationQuaternion(): Quaternion;
  15091. set rotationQuaternion(newRotation: Quaternion);
  15092. /** Gets or sets current scaling (in local space) */
  15093. get scaling(): Vector3;
  15094. set scaling(newScaling: Vector3);
  15095. /**
  15096. * Gets the animation properties override
  15097. */
  15098. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15099. private _decompose;
  15100. private _compose;
  15101. /**
  15102. * Update the base and local matrices
  15103. * @param matrix defines the new base or local matrix
  15104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15105. * @param updateLocalMatrix defines if the local matrix should be updated
  15106. */
  15107. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15108. /** @hidden */
  15109. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15110. /**
  15111. * Flag the bone as dirty (Forcing it to update everything)
  15112. */
  15113. markAsDirty(): void;
  15114. /** @hidden */
  15115. _markAsDirtyAndCompose(): void;
  15116. private _markAsDirtyAndDecompose;
  15117. /**
  15118. * Translate the bone in local or world space
  15119. * @param vec The amount to translate the bone
  15120. * @param space The space that the translation is in
  15121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15122. */
  15123. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15124. /**
  15125. * Set the postion of the bone in local or world space
  15126. * @param position The position to set the bone
  15127. * @param space The space that the position is in
  15128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15129. */
  15130. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15131. /**
  15132. * Set the absolute position of the bone (world space)
  15133. * @param position The position to set the bone
  15134. * @param mesh The mesh that this bone is attached to
  15135. */
  15136. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15137. /**
  15138. * Scale the bone on the x, y and z axes (in local space)
  15139. * @param x The amount to scale the bone on the x axis
  15140. * @param y The amount to scale the bone on the y axis
  15141. * @param z The amount to scale the bone on the z axis
  15142. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15143. */
  15144. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15145. /**
  15146. * Set the bone scaling in local space
  15147. * @param scale defines the scaling vector
  15148. */
  15149. setScale(scale: Vector3): void;
  15150. /**
  15151. * Gets the current scaling in local space
  15152. * @returns the current scaling vector
  15153. */
  15154. getScale(): Vector3;
  15155. /**
  15156. * Gets the current scaling in local space and stores it in a target vector
  15157. * @param result defines the target vector
  15158. */
  15159. getScaleToRef(result: Vector3): void;
  15160. /**
  15161. * Set the yaw, pitch, and roll of the bone in local or world space
  15162. * @param yaw The rotation of the bone on the y axis
  15163. * @param pitch The rotation of the bone on the x axis
  15164. * @param roll The rotation of the bone on the z axis
  15165. * @param space The space that the axes of rotation are in
  15166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15167. */
  15168. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15169. /**
  15170. * Add a rotation to the bone on an axis in local or world space
  15171. * @param axis The axis to rotate the bone on
  15172. * @param amount The amount to rotate the bone
  15173. * @param space The space that the axis is in
  15174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15175. */
  15176. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15177. /**
  15178. * Set the rotation of the bone to a particular axis angle in local or world space
  15179. * @param axis The axis to rotate the bone on
  15180. * @param angle The angle that the bone should be rotated to
  15181. * @param space The space that the axis is in
  15182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15183. */
  15184. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15185. /**
  15186. * Set the euler rotation of the bone in local of world space
  15187. * @param rotation The euler rotation that the bone should be set to
  15188. * @param space The space that the rotation is in
  15189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15190. */
  15191. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15192. /**
  15193. * Set the quaternion rotation of the bone in local of world space
  15194. * @param quat The quaternion rotation that the bone should be set to
  15195. * @param space The space that the rotation is in
  15196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15197. */
  15198. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15199. /**
  15200. * Set the rotation matrix of the bone in local of world space
  15201. * @param rotMat The rotation matrix that the bone should be set to
  15202. * @param space The space that the rotation is in
  15203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15204. */
  15205. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15206. private _rotateWithMatrix;
  15207. private _getNegativeRotationToRef;
  15208. /**
  15209. * Get the position of the bone in local or world space
  15210. * @param space The space that the returned position is in
  15211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15212. * @returns The position of the bone
  15213. */
  15214. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15215. /**
  15216. * Copy the position of the bone to a vector3 in local or world space
  15217. * @param space The space that the returned position is in
  15218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15219. * @param result The vector3 to copy the position to
  15220. */
  15221. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15222. /**
  15223. * Get the absolute position of the bone (world space)
  15224. * @param mesh The mesh that this bone is attached to
  15225. * @returns The absolute position of the bone
  15226. */
  15227. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15228. /**
  15229. * Copy the absolute position of the bone (world space) to the result param
  15230. * @param mesh The mesh that this bone is attached to
  15231. * @param result The vector3 to copy the absolute position to
  15232. */
  15233. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15234. /**
  15235. * Compute the absolute transforms of this bone and its children
  15236. */
  15237. computeAbsoluteTransforms(): void;
  15238. /**
  15239. * Get the world direction from an axis that is in the local space of the bone
  15240. * @param localAxis The local direction that is used to compute the world direction
  15241. * @param mesh The mesh that this bone is attached to
  15242. * @returns The world direction
  15243. */
  15244. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15245. /**
  15246. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15247. * @param localAxis The local direction that is used to compute the world direction
  15248. * @param mesh The mesh that this bone is attached to
  15249. * @param result The vector3 that the world direction will be copied to
  15250. */
  15251. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15252. /**
  15253. * Get the euler rotation of the bone in local or world space
  15254. * @param space The space that the rotation should be in
  15255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15256. * @returns The euler rotation
  15257. */
  15258. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15259. /**
  15260. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15261. * @param space The space that the rotation should be in
  15262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15263. * @param result The vector3 that the rotation should be copied to
  15264. */
  15265. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15266. /**
  15267. * Get the quaternion rotation of the bone in either local or world space
  15268. * @param space The space that the rotation should be in
  15269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15270. * @returns The quaternion rotation
  15271. */
  15272. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15273. /**
  15274. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15275. * @param space The space that the rotation should be in
  15276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15277. * @param result The quaternion that the rotation should be copied to
  15278. */
  15279. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15280. /**
  15281. * Get the rotation matrix of the bone in local or world space
  15282. * @param space The space that the rotation should be in
  15283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15284. * @returns The rotation matrix
  15285. */
  15286. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15287. /**
  15288. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15289. * @param space The space that the rotation should be in
  15290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15291. * @param result The quaternion that the rotation should be copied to
  15292. */
  15293. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15294. /**
  15295. * Get the world position of a point that is in the local space of the bone
  15296. * @param position The local position
  15297. * @param mesh The mesh that this bone is attached to
  15298. * @returns The world position
  15299. */
  15300. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15301. /**
  15302. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15303. * @param position The local position
  15304. * @param mesh The mesh that this bone is attached to
  15305. * @param result The vector3 that the world position should be copied to
  15306. */
  15307. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15308. /**
  15309. * Get the local position of a point that is in world space
  15310. * @param position The world position
  15311. * @param mesh The mesh that this bone is attached to
  15312. * @returns The local position
  15313. */
  15314. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15315. /**
  15316. * Get the local position of a point that is in world space and copy it to the result param
  15317. * @param position The world position
  15318. * @param mesh The mesh that this bone is attached to
  15319. * @param result The vector3 that the local position should be copied to
  15320. */
  15321. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15322. }
  15323. }
  15324. declare module BABYLON {
  15325. /**
  15326. * Defines a runtime animation
  15327. */
  15328. export class RuntimeAnimation {
  15329. private _events;
  15330. /**
  15331. * The current frame of the runtime animation
  15332. */
  15333. private _currentFrame;
  15334. /**
  15335. * The animation used by the runtime animation
  15336. */
  15337. private _animation;
  15338. /**
  15339. * The target of the runtime animation
  15340. */
  15341. private _target;
  15342. /**
  15343. * The initiating animatable
  15344. */
  15345. private _host;
  15346. /**
  15347. * The original value of the runtime animation
  15348. */
  15349. private _originalValue;
  15350. /**
  15351. * The original blend value of the runtime animation
  15352. */
  15353. private _originalBlendValue;
  15354. /**
  15355. * The offsets cache of the runtime animation
  15356. */
  15357. private _offsetsCache;
  15358. /**
  15359. * The high limits cache of the runtime animation
  15360. */
  15361. private _highLimitsCache;
  15362. /**
  15363. * Specifies if the runtime animation has been stopped
  15364. */
  15365. private _stopped;
  15366. /**
  15367. * The blending factor of the runtime animation
  15368. */
  15369. private _blendingFactor;
  15370. /**
  15371. * The BabylonJS scene
  15372. */
  15373. private _scene;
  15374. /**
  15375. * The current value of the runtime animation
  15376. */
  15377. private _currentValue;
  15378. /** @hidden */
  15379. _animationState: _IAnimationState;
  15380. /**
  15381. * The active target of the runtime animation
  15382. */
  15383. private _activeTargets;
  15384. private _currentActiveTarget;
  15385. private _directTarget;
  15386. /**
  15387. * The target path of the runtime animation
  15388. */
  15389. private _targetPath;
  15390. /**
  15391. * The weight of the runtime animation
  15392. */
  15393. private _weight;
  15394. /**
  15395. * The ratio offset of the runtime animation
  15396. */
  15397. private _ratioOffset;
  15398. /**
  15399. * The previous delay of the runtime animation
  15400. */
  15401. private _previousDelay;
  15402. /**
  15403. * The previous ratio of the runtime animation
  15404. */
  15405. private _previousRatio;
  15406. private _enableBlending;
  15407. private _keys;
  15408. private _minFrame;
  15409. private _maxFrame;
  15410. private _minValue;
  15411. private _maxValue;
  15412. private _targetIsArray;
  15413. /**
  15414. * Gets the current frame of the runtime animation
  15415. */
  15416. get currentFrame(): number;
  15417. /**
  15418. * Gets the weight of the runtime animation
  15419. */
  15420. get weight(): number;
  15421. /**
  15422. * Gets the current value of the runtime animation
  15423. */
  15424. get currentValue(): any;
  15425. /**
  15426. * Gets the target path of the runtime animation
  15427. */
  15428. get targetPath(): string;
  15429. /**
  15430. * Gets the actual target of the runtime animation
  15431. */
  15432. get target(): any;
  15433. /**
  15434. * Gets the additive state of the runtime animation
  15435. */
  15436. get isAdditive(): boolean;
  15437. /** @hidden */
  15438. _onLoop: () => void;
  15439. /**
  15440. * Create a new RuntimeAnimation object
  15441. * @param target defines the target of the animation
  15442. * @param animation defines the source animation object
  15443. * @param scene defines the hosting scene
  15444. * @param host defines the initiating Animatable
  15445. */
  15446. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15447. private _preparePath;
  15448. /**
  15449. * Gets the animation from the runtime animation
  15450. */
  15451. get animation(): Animation;
  15452. /**
  15453. * Resets the runtime animation to the beginning
  15454. * @param restoreOriginal defines whether to restore the target property to the original value
  15455. */
  15456. reset(restoreOriginal?: boolean): void;
  15457. /**
  15458. * Specifies if the runtime animation is stopped
  15459. * @returns Boolean specifying if the runtime animation is stopped
  15460. */
  15461. isStopped(): boolean;
  15462. /**
  15463. * Disposes of the runtime animation
  15464. */
  15465. dispose(): void;
  15466. /**
  15467. * Apply the interpolated value to the target
  15468. * @param currentValue defines the value computed by the animation
  15469. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15470. */
  15471. setValue(currentValue: any, weight: number): void;
  15472. private _getOriginalValues;
  15473. private _setValue;
  15474. /**
  15475. * Gets the loop pmode of the runtime animation
  15476. * @returns Loop Mode
  15477. */
  15478. private _getCorrectLoopMode;
  15479. /**
  15480. * Move the current animation to a given frame
  15481. * @param frame defines the frame to move to
  15482. */
  15483. goToFrame(frame: number): void;
  15484. /**
  15485. * @hidden Internal use only
  15486. */
  15487. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15488. /**
  15489. * Execute the current animation
  15490. * @param delay defines the delay to add to the current frame
  15491. * @param from defines the lower bound of the animation range
  15492. * @param to defines the upper bound of the animation range
  15493. * @param loop defines if the current animation must loop
  15494. * @param speedRatio defines the current speed ratio
  15495. * @param weight defines the weight of the animation (default is -1 so no weight)
  15496. * @param onLoop optional callback called when animation loops
  15497. * @returns a boolean indicating if the animation is running
  15498. */
  15499. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15500. }
  15501. }
  15502. declare module BABYLON {
  15503. /**
  15504. * Class used to store an actual running animation
  15505. */
  15506. export class Animatable {
  15507. /** defines the target object */
  15508. target: any;
  15509. /** defines the starting frame number (default is 0) */
  15510. fromFrame: number;
  15511. /** defines the ending frame number (default is 100) */
  15512. toFrame: number;
  15513. /** defines if the animation must loop (default is false) */
  15514. loopAnimation: boolean;
  15515. /** defines a callback to call when animation ends if it is not looping */
  15516. onAnimationEnd?: (() => void) | null | undefined;
  15517. /** defines a callback to call when animation loops */
  15518. onAnimationLoop?: (() => void) | null | undefined;
  15519. /** defines whether the animation should be evaluated additively */
  15520. isAdditive: boolean;
  15521. private _localDelayOffset;
  15522. private _pausedDelay;
  15523. private _runtimeAnimations;
  15524. private _paused;
  15525. private _scene;
  15526. private _speedRatio;
  15527. private _weight;
  15528. private _syncRoot;
  15529. /**
  15530. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15531. * This will only apply for non looping animation (default is true)
  15532. */
  15533. disposeOnEnd: boolean;
  15534. /**
  15535. * Gets a boolean indicating if the animation has started
  15536. */
  15537. animationStarted: boolean;
  15538. /**
  15539. * Observer raised when the animation ends
  15540. */
  15541. onAnimationEndObservable: Observable<Animatable>;
  15542. /**
  15543. * Observer raised when the animation loops
  15544. */
  15545. onAnimationLoopObservable: Observable<Animatable>;
  15546. /**
  15547. * Gets the root Animatable used to synchronize and normalize animations
  15548. */
  15549. get syncRoot(): Nullable<Animatable>;
  15550. /**
  15551. * Gets the current frame of the first RuntimeAnimation
  15552. * Used to synchronize Animatables
  15553. */
  15554. get masterFrame(): number;
  15555. /**
  15556. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15557. */
  15558. get weight(): number;
  15559. set weight(value: number);
  15560. /**
  15561. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15562. */
  15563. get speedRatio(): number;
  15564. set speedRatio(value: number);
  15565. /**
  15566. * Creates a new Animatable
  15567. * @param scene defines the hosting scene
  15568. * @param target defines the target object
  15569. * @param fromFrame defines the starting frame number (default is 0)
  15570. * @param toFrame defines the ending frame number (default is 100)
  15571. * @param loopAnimation defines if the animation must loop (default is false)
  15572. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15573. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15574. * @param animations defines a group of animation to add to the new Animatable
  15575. * @param onAnimationLoop defines a callback to call when animation loops
  15576. * @param isAdditive defines whether the animation should be evaluated additively
  15577. */
  15578. constructor(scene: Scene,
  15579. /** defines the target object */
  15580. target: any,
  15581. /** defines the starting frame number (default is 0) */
  15582. fromFrame?: number,
  15583. /** defines the ending frame number (default is 100) */
  15584. toFrame?: number,
  15585. /** defines if the animation must loop (default is false) */
  15586. loopAnimation?: boolean, speedRatio?: number,
  15587. /** defines a callback to call when animation ends if it is not looping */
  15588. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15589. /** defines a callback to call when animation loops */
  15590. onAnimationLoop?: (() => void) | null | undefined,
  15591. /** defines whether the animation should be evaluated additively */
  15592. isAdditive?: boolean);
  15593. /**
  15594. * Synchronize and normalize current Animatable with a source Animatable
  15595. * This is useful when using animation weights and when animations are not of the same length
  15596. * @param root defines the root Animatable to synchronize with
  15597. * @returns the current Animatable
  15598. */
  15599. syncWith(root: Animatable): Animatable;
  15600. /**
  15601. * Gets the list of runtime animations
  15602. * @returns an array of RuntimeAnimation
  15603. */
  15604. getAnimations(): RuntimeAnimation[];
  15605. /**
  15606. * Adds more animations to the current animatable
  15607. * @param target defines the target of the animations
  15608. * @param animations defines the new animations to add
  15609. */
  15610. appendAnimations(target: any, animations: Animation[]): void;
  15611. /**
  15612. * Gets the source animation for a specific property
  15613. * @param property defines the propertyu to look for
  15614. * @returns null or the source animation for the given property
  15615. */
  15616. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15617. /**
  15618. * Gets the runtime animation for a specific property
  15619. * @param property defines the propertyu to look for
  15620. * @returns null or the runtime animation for the given property
  15621. */
  15622. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15623. /**
  15624. * Resets the animatable to its original state
  15625. */
  15626. reset(): void;
  15627. /**
  15628. * Allows the animatable to blend with current running animations
  15629. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15630. * @param blendingSpeed defines the blending speed to use
  15631. */
  15632. enableBlending(blendingSpeed: number): void;
  15633. /**
  15634. * Disable animation blending
  15635. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15636. */
  15637. disableBlending(): void;
  15638. /**
  15639. * Jump directly to a given frame
  15640. * @param frame defines the frame to jump to
  15641. */
  15642. goToFrame(frame: number): void;
  15643. /**
  15644. * Pause the animation
  15645. */
  15646. pause(): void;
  15647. /**
  15648. * Restart the animation
  15649. */
  15650. restart(): void;
  15651. private _raiseOnAnimationEnd;
  15652. /**
  15653. * Stop and delete the current animation
  15654. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15655. * @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)
  15656. */
  15657. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15658. /**
  15659. * Wait asynchronously for the animation to end
  15660. * @returns a promise which will be fullfilled when the animation ends
  15661. */
  15662. waitAsync(): Promise<Animatable>;
  15663. /** @hidden */
  15664. _animate(delay: number): boolean;
  15665. }
  15666. interface Scene {
  15667. /** @hidden */
  15668. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15669. /** @hidden */
  15670. _processLateAnimationBindingsForMatrices(holder: {
  15671. totalWeight: number;
  15672. totalAdditiveWeight: number;
  15673. animations: RuntimeAnimation[];
  15674. additiveAnimations: RuntimeAnimation[];
  15675. originalValue: Matrix;
  15676. }): any;
  15677. /** @hidden */
  15678. _processLateAnimationBindingsForQuaternions(holder: {
  15679. totalWeight: number;
  15680. totalAdditiveWeight: number;
  15681. animations: RuntimeAnimation[];
  15682. additiveAnimations: RuntimeAnimation[];
  15683. originalValue: Quaternion;
  15684. }, refQuaternion: Quaternion): Quaternion;
  15685. /** @hidden */
  15686. _processLateAnimationBindings(): void;
  15687. /**
  15688. * Will start the animation sequence of a given target
  15689. * @param target defines the target
  15690. * @param from defines from which frame should animation start
  15691. * @param to defines until which frame should animation run.
  15692. * @param weight defines the weight to apply to the animation (1.0 by default)
  15693. * @param loop defines if the animation loops
  15694. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15695. * @param onAnimationEnd defines the function to be executed when the animation ends
  15696. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15697. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15698. * @param onAnimationLoop defines the callback to call when an animation loops
  15699. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15700. * @returns the animatable object created for this animation
  15701. */
  15702. 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;
  15703. /**
  15704. * Will start the animation sequence of a given target
  15705. * @param target defines the target
  15706. * @param from defines from which frame should animation start
  15707. * @param to defines until which frame should animation run.
  15708. * @param loop defines if the animation loops
  15709. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15710. * @param onAnimationEnd defines the function to be executed when the animation ends
  15711. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15712. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15713. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15714. * @param onAnimationLoop defines the callback to call when an animation loops
  15715. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15716. * @returns the animatable object created for this animation
  15717. */
  15718. 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;
  15719. /**
  15720. * Will start the animation sequence of a given target and its hierarchy
  15721. * @param target defines the target
  15722. * @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.
  15723. * @param from defines from which frame should animation start
  15724. * @param to defines until which frame should animation run.
  15725. * @param loop defines if the animation loops
  15726. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15727. * @param onAnimationEnd defines the function to be executed when the animation ends
  15728. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15729. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15730. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15731. * @param onAnimationLoop defines the callback to call when an animation loops
  15732. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15733. * @returns the list of created animatables
  15734. */
  15735. 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[];
  15736. /**
  15737. * Begin a new animation on a given node
  15738. * @param target defines the target where the animation will take place
  15739. * @param animations defines the list of animations to start
  15740. * @param from defines the initial value
  15741. * @param to defines the final value
  15742. * @param loop defines if you want animation to loop (off by default)
  15743. * @param speedRatio defines the speed ratio to apply to all animations
  15744. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15745. * @param onAnimationLoop defines the callback to call when an animation loops
  15746. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15747. * @returns the list of created animatables
  15748. */
  15749. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15750. /**
  15751. * Begin a new animation on a given node and its hierarchy
  15752. * @param target defines the root node where the animation will take place
  15753. * @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.
  15754. * @param animations defines the list of animations to start
  15755. * @param from defines the initial value
  15756. * @param to defines the final value
  15757. * @param loop defines if you want animation to loop (off by default)
  15758. * @param speedRatio defines the speed ratio to apply to all animations
  15759. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15760. * @param onAnimationLoop defines the callback to call when an animation loops
  15761. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15762. * @returns the list of animatables created for all nodes
  15763. */
  15764. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15765. /**
  15766. * Gets the animatable associated with a specific target
  15767. * @param target defines the target of the animatable
  15768. * @returns the required animatable if found
  15769. */
  15770. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15771. /**
  15772. * Gets all animatables associated with a given target
  15773. * @param target defines the target to look animatables for
  15774. * @returns an array of Animatables
  15775. */
  15776. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15777. /**
  15778. * Stops and removes all animations that have been applied to the scene
  15779. */
  15780. stopAllAnimations(): void;
  15781. /**
  15782. * Gets the current delta time used by animation engine
  15783. */
  15784. deltaTime: number;
  15785. }
  15786. interface Bone {
  15787. /**
  15788. * Copy an animation range from another bone
  15789. * @param source defines the source bone
  15790. * @param rangeName defines the range name to copy
  15791. * @param frameOffset defines the frame offset
  15792. * @param rescaleAsRequired defines if rescaling must be applied if required
  15793. * @param skelDimensionsRatio defines the scaling ratio
  15794. * @returns true if operation was successful
  15795. */
  15796. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15797. }
  15798. }
  15799. declare module BABYLON {
  15800. /**
  15801. * Class used to handle skinning animations
  15802. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15803. */
  15804. export class Skeleton implements IAnimatable {
  15805. /** defines the skeleton name */
  15806. name: string;
  15807. /** defines the skeleton Id */
  15808. id: string;
  15809. /**
  15810. * Defines the list of child bones
  15811. */
  15812. bones: Bone[];
  15813. /**
  15814. * Defines an estimate of the dimension of the skeleton at rest
  15815. */
  15816. dimensionsAtRest: Vector3;
  15817. /**
  15818. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15819. */
  15820. needInitialSkinMatrix: boolean;
  15821. /**
  15822. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15823. */
  15824. overrideMesh: Nullable<AbstractMesh>;
  15825. /**
  15826. * Gets the list of animations attached to this skeleton
  15827. */
  15828. animations: Array<Animation>;
  15829. private _scene;
  15830. private _isDirty;
  15831. private _transformMatrices;
  15832. private _transformMatrixTexture;
  15833. private _meshesWithPoseMatrix;
  15834. private _animatables;
  15835. private _identity;
  15836. private _synchronizedWithMesh;
  15837. private _ranges;
  15838. private _lastAbsoluteTransformsUpdateId;
  15839. private _canUseTextureForBones;
  15840. private _uniqueId;
  15841. /** @hidden */
  15842. _numBonesWithLinkedTransformNode: number;
  15843. /** @hidden */
  15844. _hasWaitingData: Nullable<boolean>;
  15845. /**
  15846. * Specifies if the skeleton should be serialized
  15847. */
  15848. doNotSerialize: boolean;
  15849. private _useTextureToStoreBoneMatrices;
  15850. /**
  15851. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15852. * Please note that this option is not available if the hardware does not support it
  15853. */
  15854. get useTextureToStoreBoneMatrices(): boolean;
  15855. set useTextureToStoreBoneMatrices(value: boolean);
  15856. private _animationPropertiesOverride;
  15857. /**
  15858. * Gets or sets the animation properties override
  15859. */
  15860. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15861. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15862. /**
  15863. * List of inspectable custom properties (used by the Inspector)
  15864. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15865. */
  15866. inspectableCustomProperties: IInspectable[];
  15867. /**
  15868. * An observable triggered before computing the skeleton's matrices
  15869. */
  15870. onBeforeComputeObservable: Observable<Skeleton>;
  15871. /**
  15872. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15873. */
  15874. get isUsingTextureForMatrices(): boolean;
  15875. /**
  15876. * Gets the unique ID of this skeleton
  15877. */
  15878. get uniqueId(): number;
  15879. /**
  15880. * Creates a new skeleton
  15881. * @param name defines the skeleton name
  15882. * @param id defines the skeleton Id
  15883. * @param scene defines the hosting scene
  15884. */
  15885. constructor(
  15886. /** defines the skeleton name */
  15887. name: string,
  15888. /** defines the skeleton Id */
  15889. id: string, scene: Scene);
  15890. /**
  15891. * Gets the current object class name.
  15892. * @return the class name
  15893. */
  15894. getClassName(): string;
  15895. /**
  15896. * Returns an array containing the root bones
  15897. * @returns an array containing the root bones
  15898. */
  15899. getChildren(): Array<Bone>;
  15900. /**
  15901. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15902. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15903. * @returns a Float32Array containing matrices data
  15904. */
  15905. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15906. /**
  15907. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15908. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15909. * @returns a raw texture containing the data
  15910. */
  15911. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15912. /**
  15913. * Gets the current hosting scene
  15914. * @returns a scene object
  15915. */
  15916. getScene(): Scene;
  15917. /**
  15918. * Gets a string representing the current skeleton data
  15919. * @param fullDetails defines a boolean indicating if we want a verbose version
  15920. * @returns a string representing the current skeleton data
  15921. */
  15922. toString(fullDetails?: boolean): string;
  15923. /**
  15924. * Get bone's index searching by name
  15925. * @param name defines bone's name to search for
  15926. * @return the indice of the bone. Returns -1 if not found
  15927. */
  15928. getBoneIndexByName(name: string): number;
  15929. /**
  15930. * Creater a new animation range
  15931. * @param name defines the name of the range
  15932. * @param from defines the start key
  15933. * @param to defines the end key
  15934. */
  15935. createAnimationRange(name: string, from: number, to: number): void;
  15936. /**
  15937. * Delete a specific animation range
  15938. * @param name defines the name of the range
  15939. * @param deleteFrames defines if frames must be removed as well
  15940. */
  15941. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15942. /**
  15943. * Gets a specific animation range
  15944. * @param name defines the name of the range to look for
  15945. * @returns the requested animation range or null if not found
  15946. */
  15947. getAnimationRange(name: string): Nullable<AnimationRange>;
  15948. /**
  15949. * Gets the list of all animation ranges defined on this skeleton
  15950. * @returns an array
  15951. */
  15952. getAnimationRanges(): Nullable<AnimationRange>[];
  15953. /**
  15954. * Copy animation range from a source skeleton.
  15955. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15956. * @param source defines the source skeleton
  15957. * @param name defines the name of the range to copy
  15958. * @param rescaleAsRequired defines if rescaling must be applied if required
  15959. * @returns true if operation was successful
  15960. */
  15961. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15962. /**
  15963. * Forces the skeleton to go to rest pose
  15964. */
  15965. returnToRest(): void;
  15966. private _getHighestAnimationFrame;
  15967. /**
  15968. * Begin a specific animation range
  15969. * @param name defines the name of the range to start
  15970. * @param loop defines if looping must be turned on (false by default)
  15971. * @param speedRatio defines the speed ratio to apply (1 by default)
  15972. * @param onAnimationEnd defines a callback which will be called when animation will end
  15973. * @returns a new animatable
  15974. */
  15975. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15976. /**
  15977. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15978. * @param skeleton defines the Skeleton containing the animation range to convert
  15979. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15980. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15981. * @returns the original skeleton
  15982. */
  15983. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15984. /** @hidden */
  15985. _markAsDirty(): void;
  15986. /** @hidden */
  15987. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15988. /** @hidden */
  15989. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15990. private _computeTransformMatrices;
  15991. /**
  15992. * Build all resources required to render a skeleton
  15993. */
  15994. prepare(): void;
  15995. /**
  15996. * Gets the list of animatables currently running for this skeleton
  15997. * @returns an array of animatables
  15998. */
  15999. getAnimatables(): IAnimatable[];
  16000. /**
  16001. * Clone the current skeleton
  16002. * @param name defines the name of the new skeleton
  16003. * @param id defines the id of the new skeleton
  16004. * @returns the new skeleton
  16005. */
  16006. clone(name: string, id?: string): Skeleton;
  16007. /**
  16008. * Enable animation blending for this skeleton
  16009. * @param blendingSpeed defines the blending speed to apply
  16010. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16011. */
  16012. enableBlending(blendingSpeed?: number): void;
  16013. /**
  16014. * Releases all resources associated with the current skeleton
  16015. */
  16016. dispose(): void;
  16017. /**
  16018. * Serialize the skeleton in a JSON object
  16019. * @returns a JSON object
  16020. */
  16021. serialize(): any;
  16022. /**
  16023. * Creates a new skeleton from serialized data
  16024. * @param parsedSkeleton defines the serialized data
  16025. * @param scene defines the hosting scene
  16026. * @returns a new skeleton
  16027. */
  16028. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16029. /**
  16030. * Compute all node absolute transforms
  16031. * @param forceUpdate defines if computation must be done even if cache is up to date
  16032. */
  16033. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16034. /**
  16035. * Gets the root pose matrix
  16036. * @returns a matrix
  16037. */
  16038. getPoseMatrix(): Nullable<Matrix>;
  16039. /**
  16040. * Sorts bones per internal index
  16041. */
  16042. sortBones(): void;
  16043. private _sortBones;
  16044. }
  16045. }
  16046. declare module BABYLON {
  16047. /**
  16048. * Creates an instance based on a source mesh.
  16049. */
  16050. export class InstancedMesh extends AbstractMesh {
  16051. private _sourceMesh;
  16052. private _currentLOD;
  16053. /** @hidden */
  16054. _indexInSourceMeshInstanceArray: number;
  16055. constructor(name: string, source: Mesh);
  16056. /**
  16057. * Returns the string "InstancedMesh".
  16058. */
  16059. getClassName(): string;
  16060. /** Gets the list of lights affecting that mesh */
  16061. get lightSources(): Light[];
  16062. _resyncLightSources(): void;
  16063. _resyncLightSource(light: Light): void;
  16064. _removeLightSource(light: Light, dispose: boolean): void;
  16065. /**
  16066. * If the source mesh receives shadows
  16067. */
  16068. get receiveShadows(): boolean;
  16069. /**
  16070. * The material of the source mesh
  16071. */
  16072. get material(): Nullable<Material>;
  16073. /**
  16074. * Visibility of the source mesh
  16075. */
  16076. get visibility(): number;
  16077. /**
  16078. * Skeleton of the source mesh
  16079. */
  16080. get skeleton(): Nullable<Skeleton>;
  16081. /**
  16082. * Rendering ground id of the source mesh
  16083. */
  16084. get renderingGroupId(): number;
  16085. set renderingGroupId(value: number);
  16086. /**
  16087. * Returns the total number of vertices (integer).
  16088. */
  16089. getTotalVertices(): number;
  16090. /**
  16091. * Returns a positive integer : the total number of indices in this mesh geometry.
  16092. * @returns the numner of indices or zero if the mesh has no geometry.
  16093. */
  16094. getTotalIndices(): number;
  16095. /**
  16096. * The source mesh of the instance
  16097. */
  16098. get sourceMesh(): Mesh;
  16099. /**
  16100. * Creates a new InstancedMesh object from the mesh model.
  16101. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16102. * @param name defines the name of the new instance
  16103. * @returns a new InstancedMesh
  16104. */
  16105. createInstance(name: string): InstancedMesh;
  16106. /**
  16107. * Is this node ready to be used/rendered
  16108. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16109. * @return {boolean} is it ready
  16110. */
  16111. isReady(completeCheck?: boolean): boolean;
  16112. /**
  16113. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16114. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16115. * @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.
  16116. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16117. */
  16118. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16119. /**
  16120. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16121. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16122. * The `data` are either a numeric array either a Float32Array.
  16123. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16124. * 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).
  16125. * Note that a new underlying VertexBuffer object is created each call.
  16126. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16127. *
  16128. * Possible `kind` values :
  16129. * - VertexBuffer.PositionKind
  16130. * - VertexBuffer.UVKind
  16131. * - VertexBuffer.UV2Kind
  16132. * - VertexBuffer.UV3Kind
  16133. * - VertexBuffer.UV4Kind
  16134. * - VertexBuffer.UV5Kind
  16135. * - VertexBuffer.UV6Kind
  16136. * - VertexBuffer.ColorKind
  16137. * - VertexBuffer.MatricesIndicesKind
  16138. * - VertexBuffer.MatricesIndicesExtraKind
  16139. * - VertexBuffer.MatricesWeightsKind
  16140. * - VertexBuffer.MatricesWeightsExtraKind
  16141. *
  16142. * Returns the Mesh.
  16143. */
  16144. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16145. /**
  16146. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16147. * If the mesh has no geometry, it is simply returned as it is.
  16148. * The `data` are either a numeric array either a Float32Array.
  16149. * No new underlying VertexBuffer object is created.
  16150. * 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.
  16151. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16152. *
  16153. * Possible `kind` values :
  16154. * - VertexBuffer.PositionKind
  16155. * - VertexBuffer.UVKind
  16156. * - VertexBuffer.UV2Kind
  16157. * - VertexBuffer.UV3Kind
  16158. * - VertexBuffer.UV4Kind
  16159. * - VertexBuffer.UV5Kind
  16160. * - VertexBuffer.UV6Kind
  16161. * - VertexBuffer.ColorKind
  16162. * - VertexBuffer.MatricesIndicesKind
  16163. * - VertexBuffer.MatricesIndicesExtraKind
  16164. * - VertexBuffer.MatricesWeightsKind
  16165. * - VertexBuffer.MatricesWeightsExtraKind
  16166. *
  16167. * Returns the Mesh.
  16168. */
  16169. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16170. /**
  16171. * Sets the mesh indices.
  16172. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16173. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16174. * This method creates a new index buffer each call.
  16175. * Returns the Mesh.
  16176. */
  16177. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16178. /**
  16179. * Boolean : True if the mesh owns the requested kind of data.
  16180. */
  16181. isVerticesDataPresent(kind: string): boolean;
  16182. /**
  16183. * Returns an array of indices (IndicesArray).
  16184. */
  16185. getIndices(): Nullable<IndicesArray>;
  16186. get _positions(): Nullable<Vector3[]>;
  16187. /**
  16188. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16189. * This means the mesh underlying bounding box and sphere are recomputed.
  16190. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16191. * @returns the current mesh
  16192. */
  16193. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16194. /** @hidden */
  16195. _preActivate(): InstancedMesh;
  16196. /** @hidden */
  16197. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16198. /** @hidden */
  16199. _postActivate(): void;
  16200. getWorldMatrix(): Matrix;
  16201. get isAnInstance(): boolean;
  16202. /**
  16203. * Returns the current associated LOD AbstractMesh.
  16204. */
  16205. getLOD(camera: Camera): AbstractMesh;
  16206. /** @hidden */
  16207. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16208. /** @hidden */
  16209. _syncSubMeshes(): InstancedMesh;
  16210. /** @hidden */
  16211. _generatePointsArray(): boolean;
  16212. /**
  16213. * Creates a new InstancedMesh from the current mesh.
  16214. * - name (string) : the cloned mesh name
  16215. * - newParent (optional Node) : the optional Node to parent the clone to.
  16216. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16217. *
  16218. * Returns the clone.
  16219. */
  16220. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16221. /**
  16222. * Disposes the InstancedMesh.
  16223. * Returns nothing.
  16224. */
  16225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16226. }
  16227. interface Mesh {
  16228. /**
  16229. * Register a custom buffer that will be instanced
  16230. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16231. * @param kind defines the buffer kind
  16232. * @param stride defines the stride in floats
  16233. */
  16234. registerInstancedBuffer(kind: string, stride: number): void;
  16235. /**
  16236. * true to use the edge renderer for all instances of this mesh
  16237. */
  16238. edgesShareWithInstances: boolean;
  16239. /** @hidden */
  16240. _userInstancedBuffersStorage: {
  16241. data: {
  16242. [key: string]: Float32Array;
  16243. };
  16244. sizes: {
  16245. [key: string]: number;
  16246. };
  16247. vertexBuffers: {
  16248. [key: string]: Nullable<VertexBuffer>;
  16249. };
  16250. strides: {
  16251. [key: string]: number;
  16252. };
  16253. };
  16254. }
  16255. interface AbstractMesh {
  16256. /**
  16257. * Object used to store instanced buffers defined by user
  16258. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16259. */
  16260. instancedBuffers: {
  16261. [key: string]: any;
  16262. };
  16263. }
  16264. }
  16265. declare module BABYLON {
  16266. /**
  16267. * Defines the options associated with the creation of a shader material.
  16268. */
  16269. export interface IShaderMaterialOptions {
  16270. /**
  16271. * Does the material work in alpha blend mode
  16272. */
  16273. needAlphaBlending: boolean;
  16274. /**
  16275. * Does the material work in alpha test mode
  16276. */
  16277. needAlphaTesting: boolean;
  16278. /**
  16279. * The list of attribute names used in the shader
  16280. */
  16281. attributes: string[];
  16282. /**
  16283. * The list of unifrom names used in the shader
  16284. */
  16285. uniforms: string[];
  16286. /**
  16287. * The list of UBO names used in the shader
  16288. */
  16289. uniformBuffers: string[];
  16290. /**
  16291. * The list of sampler names used in the shader
  16292. */
  16293. samplers: string[];
  16294. /**
  16295. * The list of defines used in the shader
  16296. */
  16297. defines: string[];
  16298. }
  16299. /**
  16300. * 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.
  16301. *
  16302. * This returned material effects how the mesh will look based on the code in the shaders.
  16303. *
  16304. * @see https://doc.babylonjs.com/how_to/shader_material
  16305. */
  16306. export class ShaderMaterial extends Material {
  16307. private _shaderPath;
  16308. private _options;
  16309. private _textures;
  16310. private _textureArrays;
  16311. private _floats;
  16312. private _ints;
  16313. private _floatsArrays;
  16314. private _colors3;
  16315. private _colors3Arrays;
  16316. private _colors4;
  16317. private _colors4Arrays;
  16318. private _vectors2;
  16319. private _vectors3;
  16320. private _vectors4;
  16321. private _matrices;
  16322. private _matrixArrays;
  16323. private _matrices3x3;
  16324. private _matrices2x2;
  16325. private _vectors2Arrays;
  16326. private _vectors3Arrays;
  16327. private _vectors4Arrays;
  16328. private _cachedWorldViewMatrix;
  16329. private _cachedWorldViewProjectionMatrix;
  16330. private _renderId;
  16331. private _multiview;
  16332. private _cachedDefines;
  16333. /** Define the Url to load snippets */
  16334. static SnippetUrl: string;
  16335. /** Snippet ID if the material was created from the snippet server */
  16336. snippetId: string;
  16337. /**
  16338. * Instantiate a new shader material.
  16339. * 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.
  16340. * This returned material effects how the mesh will look based on the code in the shaders.
  16341. * @see https://doc.babylonjs.com/how_to/shader_material
  16342. * @param name Define the name of the material in the scene
  16343. * @param scene Define the scene the material belongs to
  16344. * @param shaderPath Defines the route to the shader code in one of three ways:
  16345. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16346. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16347. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16348. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16349. * @param options Define the options used to create the shader
  16350. */
  16351. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16352. /**
  16353. * Gets the shader path used to define the shader code
  16354. * It can be modified to trigger a new compilation
  16355. */
  16356. get shaderPath(): any;
  16357. /**
  16358. * Sets the shader path used to define the shader code
  16359. * It can be modified to trigger a new compilation
  16360. */
  16361. set shaderPath(shaderPath: any);
  16362. /**
  16363. * Gets the options used to compile the shader.
  16364. * They can be modified to trigger a new compilation
  16365. */
  16366. get options(): IShaderMaterialOptions;
  16367. /**
  16368. * Gets the current class name of the material e.g. "ShaderMaterial"
  16369. * Mainly use in serialization.
  16370. * @returns the class name
  16371. */
  16372. getClassName(): string;
  16373. /**
  16374. * Specifies if the material will require alpha blending
  16375. * @returns a boolean specifying if alpha blending is needed
  16376. */
  16377. needAlphaBlending(): boolean;
  16378. /**
  16379. * Specifies if this material should be rendered in alpha test mode
  16380. * @returns a boolean specifying if an alpha test is needed.
  16381. */
  16382. needAlphaTesting(): boolean;
  16383. private _checkUniform;
  16384. /**
  16385. * Set a texture in the shader.
  16386. * @param name Define the name of the uniform samplers as defined in the shader
  16387. * @param texture Define the texture to bind to this sampler
  16388. * @return the material itself allowing "fluent" like uniform updates
  16389. */
  16390. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16391. /**
  16392. * Set a texture array in the shader.
  16393. * @param name Define the name of the uniform sampler array as defined in the shader
  16394. * @param textures Define the list of textures to bind to this sampler
  16395. * @return the material itself allowing "fluent" like uniform updates
  16396. */
  16397. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16398. /**
  16399. * Set a float in the shader.
  16400. * @param name Define the name of the uniform as defined in the shader
  16401. * @param value Define the value to give to the uniform
  16402. * @return the material itself allowing "fluent" like uniform updates
  16403. */
  16404. setFloat(name: string, value: number): ShaderMaterial;
  16405. /**
  16406. * Set a int in the shader.
  16407. * @param name Define the name of the uniform as defined in the shader
  16408. * @param value Define the value to give to the uniform
  16409. * @return the material itself allowing "fluent" like uniform updates
  16410. */
  16411. setInt(name: string, value: number): ShaderMaterial;
  16412. /**
  16413. * Set an array of floats in the shader.
  16414. * @param name Define the name of the uniform as defined in the shader
  16415. * @param value Define the value to give to the uniform
  16416. * @return the material itself allowing "fluent" like uniform updates
  16417. */
  16418. setFloats(name: string, value: number[]): ShaderMaterial;
  16419. /**
  16420. * Set a vec3 in the shader from a Color3.
  16421. * @param name Define the name of the uniform as defined in the shader
  16422. * @param value Define the value to give to the uniform
  16423. * @return the material itself allowing "fluent" like uniform updates
  16424. */
  16425. setColor3(name: string, value: Color3): ShaderMaterial;
  16426. /**
  16427. * Set a vec3 array in the shader from a Color3 array.
  16428. * @param name Define the name of the uniform as defined in the shader
  16429. * @param value Define the value to give to the uniform
  16430. * @return the material itself allowing "fluent" like uniform updates
  16431. */
  16432. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16433. /**
  16434. * Set a vec4 in the shader from a Color4.
  16435. * @param name Define the name of the uniform as defined in the shader
  16436. * @param value Define the value to give to the uniform
  16437. * @return the material itself allowing "fluent" like uniform updates
  16438. */
  16439. setColor4(name: string, value: Color4): ShaderMaterial;
  16440. /**
  16441. * Set a vec4 array in the shader from a Color4 array.
  16442. * @param name Define the name of the uniform as defined in the shader
  16443. * @param value Define the value to give to the uniform
  16444. * @return the material itself allowing "fluent" like uniform updates
  16445. */
  16446. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16447. /**
  16448. * Set a vec2 in the shader from a Vector2.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the material itself allowing "fluent" like uniform updates
  16452. */
  16453. setVector2(name: string, value: Vector2): ShaderMaterial;
  16454. /**
  16455. * Set a vec3 in the shader from a Vector3.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the material itself allowing "fluent" like uniform updates
  16459. */
  16460. setVector3(name: string, value: Vector3): ShaderMaterial;
  16461. /**
  16462. * Set a vec4 in the shader from a Vector4.
  16463. * @param name Define the name of the uniform as defined in the shader
  16464. * @param value Define the value to give to the uniform
  16465. * @return the material itself allowing "fluent" like uniform updates
  16466. */
  16467. setVector4(name: string, value: Vector4): ShaderMaterial;
  16468. /**
  16469. * Set a mat4 in the shader from a Matrix.
  16470. * @param name Define the name of the uniform as defined in the shader
  16471. * @param value Define the value to give to the uniform
  16472. * @return the material itself allowing "fluent" like uniform updates
  16473. */
  16474. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16475. /**
  16476. * Set a float32Array in the shader from a matrix array.
  16477. * @param name Define the name of the uniform as defined in the shader
  16478. * @param value Define the value to give to the uniform
  16479. * @return the material itself allowing "fluent" like uniform updates
  16480. */
  16481. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16482. /**
  16483. * Set a mat3 in the shader from a Float32Array.
  16484. * @param name Define the name of the uniform as defined in the shader
  16485. * @param value Define the value to give to the uniform
  16486. * @return the material itself allowing "fluent" like uniform updates
  16487. */
  16488. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16489. /**
  16490. * Set a mat2 in the shader from a Float32Array.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the material itself allowing "fluent" like uniform updates
  16494. */
  16495. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16496. /**
  16497. * Set a vec2 array in the shader from a number array.
  16498. * @param name Define the name of the uniform as defined in the shader
  16499. * @param value Define the value to give to the uniform
  16500. * @return the material itself allowing "fluent" like uniform updates
  16501. */
  16502. setArray2(name: string, value: number[]): ShaderMaterial;
  16503. /**
  16504. * Set a vec3 array in the shader from a number array.
  16505. * @param name Define the name of the uniform as defined in the shader
  16506. * @param value Define the value to give to the uniform
  16507. * @return the material itself allowing "fluent" like uniform updates
  16508. */
  16509. setArray3(name: string, value: number[]): ShaderMaterial;
  16510. /**
  16511. * Set a vec4 array in the shader from a number array.
  16512. * @param name Define the name of the uniform as defined in the shader
  16513. * @param value Define the value to give to the uniform
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setArray4(name: string, value: number[]): ShaderMaterial;
  16517. private _checkCache;
  16518. /**
  16519. * Specifies that the submesh is ready to be used
  16520. * @param mesh defines the mesh to check
  16521. * @param subMesh defines which submesh to check
  16522. * @param useInstances specifies that instances should be used
  16523. * @returns a boolean indicating that the submesh is ready or not
  16524. */
  16525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16526. /**
  16527. * Checks if the material is ready to render the requested mesh
  16528. * @param mesh Define the mesh to render
  16529. * @param useInstances Define whether or not the material is used with instances
  16530. * @returns true if ready, otherwise false
  16531. */
  16532. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16533. /**
  16534. * Binds the world matrix to the material
  16535. * @param world defines the world transformation matrix
  16536. * @param effectOverride - If provided, use this effect instead of internal effect
  16537. */
  16538. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16539. /**
  16540. * Binds the submesh to this material by preparing the effect and shader to draw
  16541. * @param world defines the world transformation matrix
  16542. * @param mesh defines the mesh containing the submesh
  16543. * @param subMesh defines the submesh to bind the material to
  16544. */
  16545. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16546. /**
  16547. * Binds the material to the mesh
  16548. * @param world defines the world transformation matrix
  16549. * @param mesh defines the mesh to bind the material to
  16550. * @param effectOverride - If provided, use this effect instead of internal effect
  16551. */
  16552. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16553. protected _afterBind(mesh?: Mesh): void;
  16554. /**
  16555. * Gets the active textures from the material
  16556. * @returns an array of textures
  16557. */
  16558. getActiveTextures(): BaseTexture[];
  16559. /**
  16560. * Specifies if the material uses a texture
  16561. * @param texture defines the texture to check against the material
  16562. * @returns a boolean specifying if the material uses the texture
  16563. */
  16564. hasTexture(texture: BaseTexture): boolean;
  16565. /**
  16566. * Makes a duplicate of the material, and gives it a new name
  16567. * @param name defines the new name for the duplicated material
  16568. * @returns the cloned material
  16569. */
  16570. clone(name: string): ShaderMaterial;
  16571. /**
  16572. * Disposes the material
  16573. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16574. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16575. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16576. */
  16577. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16578. /**
  16579. * Serializes this material in a JSON representation
  16580. * @returns the serialized material object
  16581. */
  16582. serialize(): any;
  16583. /**
  16584. * Creates a shader material from parsed shader material data
  16585. * @param source defines the JSON represnetation of the material
  16586. * @param scene defines the hosting scene
  16587. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16588. * @returns a new material
  16589. */
  16590. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16591. /**
  16592. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16593. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16594. * @param url defines the url to load from
  16595. * @param scene defines the hosting scene
  16596. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16597. * @returns a promise that will resolve to the new ShaderMaterial
  16598. */
  16599. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16600. /**
  16601. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16602. * @param snippetId defines the snippet to load
  16603. * @param scene defines the hosting scene
  16604. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16605. * @returns a promise that will resolve to the new ShaderMaterial
  16606. */
  16607. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16608. }
  16609. }
  16610. declare module BABYLON {
  16611. /** @hidden */
  16612. export var colorPixelShader: {
  16613. name: string;
  16614. shader: string;
  16615. };
  16616. }
  16617. declare module BABYLON {
  16618. /** @hidden */
  16619. export var colorVertexShader: {
  16620. name: string;
  16621. shader: string;
  16622. };
  16623. }
  16624. declare module BABYLON {
  16625. /**
  16626. * Line mesh
  16627. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16628. */
  16629. export class LinesMesh extends Mesh {
  16630. /**
  16631. * If vertex color should be applied to the mesh
  16632. */
  16633. readonly useVertexColor?: boolean | undefined;
  16634. /**
  16635. * If vertex alpha should be applied to the mesh
  16636. */
  16637. readonly useVertexAlpha?: boolean | undefined;
  16638. /**
  16639. * Color of the line (Default: White)
  16640. */
  16641. color: Color3;
  16642. /**
  16643. * Alpha of the line (Default: 1)
  16644. */
  16645. alpha: number;
  16646. /**
  16647. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16648. * This margin is expressed in world space coordinates, so its value may vary.
  16649. * Default value is 0.1
  16650. */
  16651. intersectionThreshold: number;
  16652. private _colorShader;
  16653. private color4;
  16654. /**
  16655. * Creates a new LinesMesh
  16656. * @param name defines the name
  16657. * @param scene defines the hosting scene
  16658. * @param parent defines the parent mesh if any
  16659. * @param source defines the optional source LinesMesh used to clone data from
  16660. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16661. * When false, achieved by calling a clone(), also passing False.
  16662. * This will make creation of children, recursive.
  16663. * @param useVertexColor defines if this LinesMesh supports vertex color
  16664. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16665. */
  16666. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16667. /**
  16668. * If vertex color should be applied to the mesh
  16669. */
  16670. useVertexColor?: boolean | undefined,
  16671. /**
  16672. * If vertex alpha should be applied to the mesh
  16673. */
  16674. useVertexAlpha?: boolean | undefined);
  16675. private _addClipPlaneDefine;
  16676. private _removeClipPlaneDefine;
  16677. isReady(): boolean;
  16678. /**
  16679. * Returns the string "LineMesh"
  16680. */
  16681. getClassName(): string;
  16682. /**
  16683. * @hidden
  16684. */
  16685. get material(): Material;
  16686. /**
  16687. * @hidden
  16688. */
  16689. set material(value: Material);
  16690. /**
  16691. * @hidden
  16692. */
  16693. get checkCollisions(): boolean;
  16694. /** @hidden */
  16695. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16696. /** @hidden */
  16697. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16698. /**
  16699. * Disposes of the line mesh
  16700. * @param doNotRecurse If children should be disposed
  16701. */
  16702. dispose(doNotRecurse?: boolean): void;
  16703. /**
  16704. * Returns a new LineMesh object cloned from the current one.
  16705. */
  16706. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16707. /**
  16708. * Creates a new InstancedLinesMesh object from the mesh model.
  16709. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16710. * @param name defines the name of the new instance
  16711. * @returns a new InstancedLinesMesh
  16712. */
  16713. createInstance(name: string): InstancedLinesMesh;
  16714. }
  16715. /**
  16716. * Creates an instance based on a source LinesMesh
  16717. */
  16718. export class InstancedLinesMesh extends InstancedMesh {
  16719. /**
  16720. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16721. * This margin is expressed in world space coordinates, so its value may vary.
  16722. * Initilized with the intersectionThreshold value of the source LinesMesh
  16723. */
  16724. intersectionThreshold: number;
  16725. constructor(name: string, source: LinesMesh);
  16726. /**
  16727. * Returns the string "InstancedLinesMesh".
  16728. */
  16729. getClassName(): string;
  16730. }
  16731. }
  16732. declare module BABYLON {
  16733. /** @hidden */
  16734. export var linePixelShader: {
  16735. name: string;
  16736. shader: string;
  16737. };
  16738. }
  16739. declare module BABYLON {
  16740. /** @hidden */
  16741. export var lineVertexShader: {
  16742. name: string;
  16743. shader: string;
  16744. };
  16745. }
  16746. declare module BABYLON {
  16747. interface Scene {
  16748. /** @hidden */
  16749. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16750. }
  16751. interface AbstractMesh {
  16752. /**
  16753. * Gets the edgesRenderer associated with the mesh
  16754. */
  16755. edgesRenderer: Nullable<EdgesRenderer>;
  16756. }
  16757. interface LinesMesh {
  16758. /**
  16759. * Enables the edge rendering mode on the mesh.
  16760. * This mode makes the mesh edges visible
  16761. * @param epsilon defines the maximal distance between two angles to detect a face
  16762. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16763. * @returns the currentAbstractMesh
  16764. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16765. */
  16766. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16767. }
  16768. interface InstancedLinesMesh {
  16769. /**
  16770. * Enables the edge rendering mode on the mesh.
  16771. * This mode makes the mesh edges visible
  16772. * @param epsilon defines the maximal distance between two angles to detect a face
  16773. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16774. * @returns the current InstancedLinesMesh
  16775. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16776. */
  16777. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16778. }
  16779. /**
  16780. * Defines the minimum contract an Edges renderer should follow.
  16781. */
  16782. export interface IEdgesRenderer extends IDisposable {
  16783. /**
  16784. * Gets or sets a boolean indicating if the edgesRenderer is active
  16785. */
  16786. isEnabled: boolean;
  16787. /**
  16788. * Renders the edges of the attached mesh,
  16789. */
  16790. render(): void;
  16791. /**
  16792. * Checks wether or not the edges renderer is ready to render.
  16793. * @return true if ready, otherwise false.
  16794. */
  16795. isReady(): boolean;
  16796. /**
  16797. * List of instances to render in case the source mesh has instances
  16798. */
  16799. customInstances: SmartArray<Matrix>;
  16800. }
  16801. /**
  16802. * Defines the additional options of the edges renderer
  16803. */
  16804. export interface IEdgesRendererOptions {
  16805. /**
  16806. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16807. * If not defined, the default value is true
  16808. */
  16809. useAlternateEdgeFinder?: boolean;
  16810. /**
  16811. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16812. * If not defined, the default value is true.
  16813. * 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)
  16814. * This option is used only if useAlternateEdgeFinder = true
  16815. */
  16816. useFastVertexMerger?: boolean;
  16817. /**
  16818. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16819. * The default value is 1e-6
  16820. * This option is used only if useAlternateEdgeFinder = true
  16821. */
  16822. epsilonVertexMerge?: number;
  16823. /**
  16824. * 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
  16825. * 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.
  16826. * This option is used only if useAlternateEdgeFinder = true
  16827. */
  16828. applyTessellation?: boolean;
  16829. /**
  16830. * 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
  16831. * The default value is 1e-6
  16832. * This option is used only if useAlternateEdgeFinder = true
  16833. */
  16834. epsilonVertexAligned?: number;
  16835. }
  16836. /**
  16837. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16838. */
  16839. export class EdgesRenderer implements IEdgesRenderer {
  16840. /**
  16841. * Define the size of the edges with an orthographic camera
  16842. */
  16843. edgesWidthScalerForOrthographic: number;
  16844. /**
  16845. * Define the size of the edges with a perspective camera
  16846. */
  16847. edgesWidthScalerForPerspective: number;
  16848. protected _source: AbstractMesh;
  16849. protected _linesPositions: number[];
  16850. protected _linesNormals: number[];
  16851. protected _linesIndices: number[];
  16852. protected _epsilon: number;
  16853. protected _indicesCount: number;
  16854. protected _lineShader: ShaderMaterial;
  16855. protected _ib: DataBuffer;
  16856. protected _buffers: {
  16857. [key: string]: Nullable<VertexBuffer>;
  16858. };
  16859. protected _buffersForInstances: {
  16860. [key: string]: Nullable<VertexBuffer>;
  16861. };
  16862. protected _checkVerticesInsteadOfIndices: boolean;
  16863. protected _options: Nullable<IEdgesRendererOptions>;
  16864. private _meshRebuildObserver;
  16865. private _meshDisposeObserver;
  16866. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16867. isEnabled: boolean;
  16868. /**
  16869. * List of instances to render in case the source mesh has instances
  16870. */
  16871. customInstances: SmartArray<Matrix>;
  16872. private static GetShader;
  16873. /**
  16874. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16875. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16876. * @param source Mesh used to create edges
  16877. * @param epsilon sum of angles in adjacency to check for edge
  16878. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16879. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16880. * @param options The options to apply when generating the edges
  16881. */
  16882. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16883. protected _prepareRessources(): void;
  16884. /** @hidden */
  16885. _rebuild(): void;
  16886. /**
  16887. * Releases the required resources for the edges renderer
  16888. */
  16889. dispose(): void;
  16890. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16891. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16892. /**
  16893. * Checks if the pair of p0 and p1 is en edge
  16894. * @param faceIndex
  16895. * @param edge
  16896. * @param faceNormals
  16897. * @param p0
  16898. * @param p1
  16899. * @private
  16900. */
  16901. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16902. /**
  16903. * push line into the position, normal and index buffer
  16904. * @protected
  16905. */
  16906. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16907. /**
  16908. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16909. */
  16910. private _tessellateTriangle;
  16911. private _generateEdgesLinesAlternate;
  16912. /**
  16913. * Generates lines edges from adjacencjes
  16914. * @private
  16915. */
  16916. _generateEdgesLines(): void;
  16917. /**
  16918. * Checks wether or not the edges renderer is ready to render.
  16919. * @return true if ready, otherwise false.
  16920. */
  16921. isReady(): boolean;
  16922. /**
  16923. * Renders the edges of the attached mesh,
  16924. */
  16925. render(): void;
  16926. }
  16927. /**
  16928. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16929. */
  16930. export class LineEdgesRenderer extends EdgesRenderer {
  16931. /**
  16932. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16933. * @param source LineMesh used to generate edges
  16934. * @param epsilon not important (specified angle for edge detection)
  16935. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16936. */
  16937. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16938. /**
  16939. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16940. */
  16941. _generateEdgesLines(): void;
  16942. }
  16943. }
  16944. declare module BABYLON {
  16945. /**
  16946. * This represents the object necessary to create a rendering group.
  16947. * This is exclusively used and created by the rendering manager.
  16948. * To modify the behavior, you use the available helpers in your scene or meshes.
  16949. * @hidden
  16950. */
  16951. export class RenderingGroup {
  16952. index: number;
  16953. private static _zeroVector;
  16954. private _scene;
  16955. private _opaqueSubMeshes;
  16956. private _transparentSubMeshes;
  16957. private _alphaTestSubMeshes;
  16958. private _depthOnlySubMeshes;
  16959. private _particleSystems;
  16960. private _spriteManagers;
  16961. private _opaqueSortCompareFn;
  16962. private _alphaTestSortCompareFn;
  16963. private _transparentSortCompareFn;
  16964. private _renderOpaque;
  16965. private _renderAlphaTest;
  16966. private _renderTransparent;
  16967. /** @hidden */
  16968. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16969. onBeforeTransparentRendering: () => void;
  16970. /**
  16971. * Set the opaque sort comparison function.
  16972. * If null the sub meshes will be render in the order they were created
  16973. */
  16974. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16975. /**
  16976. * Set the alpha test sort comparison function.
  16977. * If null the sub meshes will be render in the order they were created
  16978. */
  16979. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16980. /**
  16981. * Set the transparent sort comparison function.
  16982. * If null the sub meshes will be render in the order they were created
  16983. */
  16984. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16985. /**
  16986. * Creates a new rendering group.
  16987. * @param index The rendering group index
  16988. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16989. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16990. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16991. */
  16992. 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>);
  16993. /**
  16994. * Render all the sub meshes contained in the group.
  16995. * @param customRenderFunction Used to override the default render behaviour of the group.
  16996. * @returns true if rendered some submeshes.
  16997. */
  16998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16999. /**
  17000. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17001. * @param subMeshes The submeshes to render
  17002. */
  17003. private renderOpaqueSorted;
  17004. /**
  17005. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17006. * @param subMeshes The submeshes to render
  17007. */
  17008. private renderAlphaTestSorted;
  17009. /**
  17010. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17011. * @param subMeshes The submeshes to render
  17012. */
  17013. private renderTransparentSorted;
  17014. /**
  17015. * Renders the submeshes in a specified order.
  17016. * @param subMeshes The submeshes to sort before render
  17017. * @param sortCompareFn The comparison function use to sort
  17018. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17019. * @param transparent Specifies to activate blending if true
  17020. */
  17021. private static renderSorted;
  17022. /**
  17023. * Renders the submeshes in the order they were dispatched (no sort applied).
  17024. * @param subMeshes The submeshes to render
  17025. */
  17026. private static renderUnsorted;
  17027. /**
  17028. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17029. * are rendered back to front if in the same alpha index.
  17030. *
  17031. * @param a The first submesh
  17032. * @param b The second submesh
  17033. * @returns The result of the comparison
  17034. */
  17035. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17036. /**
  17037. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17038. * are rendered back to front.
  17039. *
  17040. * @param a The first submesh
  17041. * @param b The second submesh
  17042. * @returns The result of the comparison
  17043. */
  17044. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17045. /**
  17046. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17047. * are rendered front to back (prevent overdraw).
  17048. *
  17049. * @param a The first submesh
  17050. * @param b The second submesh
  17051. * @returns The result of the comparison
  17052. */
  17053. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17054. /**
  17055. * Resets the different lists of submeshes to prepare a new frame.
  17056. */
  17057. prepare(): void;
  17058. dispose(): void;
  17059. /**
  17060. * Inserts the submesh in its correct queue depending on its material.
  17061. * @param subMesh The submesh to dispatch
  17062. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17063. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17064. */
  17065. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17066. dispatchSprites(spriteManager: ISpriteManager): void;
  17067. dispatchParticles(particleSystem: IParticleSystem): void;
  17068. private _renderParticles;
  17069. private _renderSprites;
  17070. }
  17071. }
  17072. declare module BABYLON {
  17073. /**
  17074. * Interface describing the different options available in the rendering manager
  17075. * regarding Auto Clear between groups.
  17076. */
  17077. export interface IRenderingManagerAutoClearSetup {
  17078. /**
  17079. * Defines whether or not autoclear is enable.
  17080. */
  17081. autoClear: boolean;
  17082. /**
  17083. * Defines whether or not to autoclear the depth buffer.
  17084. */
  17085. depth: boolean;
  17086. /**
  17087. * Defines whether or not to autoclear the stencil buffer.
  17088. */
  17089. stencil: boolean;
  17090. }
  17091. /**
  17092. * This class is used by the onRenderingGroupObservable
  17093. */
  17094. export class RenderingGroupInfo {
  17095. /**
  17096. * The Scene that being rendered
  17097. */
  17098. scene: Scene;
  17099. /**
  17100. * The camera currently used for the rendering pass
  17101. */
  17102. camera: Nullable<Camera>;
  17103. /**
  17104. * The ID of the renderingGroup being processed
  17105. */
  17106. renderingGroupId: number;
  17107. }
  17108. /**
  17109. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17110. * It is enable to manage the different groups as well as the different necessary sort functions.
  17111. * This should not be used directly aside of the few static configurations
  17112. */
  17113. export class RenderingManager {
  17114. /**
  17115. * The max id used for rendering groups (not included)
  17116. */
  17117. static MAX_RENDERINGGROUPS: number;
  17118. /**
  17119. * The min id used for rendering groups (included)
  17120. */
  17121. static MIN_RENDERINGGROUPS: number;
  17122. /**
  17123. * Used to globally prevent autoclearing scenes.
  17124. */
  17125. static AUTOCLEAR: boolean;
  17126. /**
  17127. * @hidden
  17128. */
  17129. _useSceneAutoClearSetup: boolean;
  17130. private _scene;
  17131. private _renderingGroups;
  17132. private _depthStencilBufferAlreadyCleaned;
  17133. private _autoClearDepthStencil;
  17134. private _customOpaqueSortCompareFn;
  17135. private _customAlphaTestSortCompareFn;
  17136. private _customTransparentSortCompareFn;
  17137. private _renderingGroupInfo;
  17138. /**
  17139. * Instantiates a new rendering group for a particular scene
  17140. * @param scene Defines the scene the groups belongs to
  17141. */
  17142. constructor(scene: Scene);
  17143. private _clearDepthStencilBuffer;
  17144. /**
  17145. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17146. * @hidden
  17147. */
  17148. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17149. /**
  17150. * Resets the different information of the group to prepare a new frame
  17151. * @hidden
  17152. */
  17153. reset(): void;
  17154. /**
  17155. * Dispose and release the group and its associated resources.
  17156. * @hidden
  17157. */
  17158. dispose(): void;
  17159. /**
  17160. * Clear the info related to rendering groups preventing retention points during dispose.
  17161. */
  17162. freeRenderingGroups(): void;
  17163. private _prepareRenderingGroup;
  17164. /**
  17165. * Add a sprite manager to the rendering manager in order to render it this frame.
  17166. * @param spriteManager Define the sprite manager to render
  17167. */
  17168. dispatchSprites(spriteManager: ISpriteManager): void;
  17169. /**
  17170. * Add a particle system to the rendering manager in order to render it this frame.
  17171. * @param particleSystem Define the particle system to render
  17172. */
  17173. dispatchParticles(particleSystem: IParticleSystem): void;
  17174. /**
  17175. * Add a submesh to the manager in order to render it this frame
  17176. * @param subMesh The submesh to dispatch
  17177. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17178. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17179. */
  17180. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17181. /**
  17182. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17183. * This allowed control for front to back rendering or reversly depending of the special needs.
  17184. *
  17185. * @param renderingGroupId The rendering group id corresponding to its index
  17186. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17187. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17188. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17189. */
  17190. 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;
  17191. /**
  17192. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17193. *
  17194. * @param renderingGroupId The rendering group id corresponding to its index
  17195. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17196. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17197. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17198. */
  17199. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17200. /**
  17201. * Gets the current auto clear configuration for one rendering group of the rendering
  17202. * manager.
  17203. * @param index the rendering group index to get the information for
  17204. * @returns The auto clear setup for the requested rendering group
  17205. */
  17206. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17207. }
  17208. }
  17209. declare module BABYLON {
  17210. /**
  17211. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17212. */
  17213. export interface ICustomShaderOptions {
  17214. /**
  17215. * Gets or sets the custom shader name to use
  17216. */
  17217. shaderName: string;
  17218. /**
  17219. * The list of attribute names used in the shader
  17220. */
  17221. attributes?: string[];
  17222. /**
  17223. * The list of unifrom names used in the shader
  17224. */
  17225. uniforms?: string[];
  17226. /**
  17227. * The list of sampler names used in the shader
  17228. */
  17229. samplers?: string[];
  17230. /**
  17231. * The list of defines used in the shader
  17232. */
  17233. defines?: string[];
  17234. }
  17235. /**
  17236. * Interface to implement to create a shadow generator compatible with BJS.
  17237. */
  17238. export interface IShadowGenerator {
  17239. /**
  17240. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17241. * @returns The render target texture if present otherwise, null
  17242. */
  17243. getShadowMap(): Nullable<RenderTargetTexture>;
  17244. /**
  17245. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17246. * @param subMesh The submesh we want to render in the shadow map
  17247. * @param useInstances Defines wether will draw in the map using instances
  17248. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17249. * @returns true if ready otherwise, false
  17250. */
  17251. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17252. /**
  17253. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17254. * @param defines Defines of the material we want to update
  17255. * @param lightIndex Index of the light in the enabled light list of the material
  17256. */
  17257. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17258. /**
  17259. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17260. * defined in the generator but impacting the effect).
  17261. * It implies the unifroms available on the materials are the standard BJS ones.
  17262. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17263. * @param effect The effect we are binfing the information for
  17264. */
  17265. bindShadowLight(lightIndex: string, effect: Effect): void;
  17266. /**
  17267. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17268. * (eq to shadow prjection matrix * light transform matrix)
  17269. * @returns The transform matrix used to create the shadow map
  17270. */
  17271. getTransformMatrix(): Matrix;
  17272. /**
  17273. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17274. * Cube and 2D textures for instance.
  17275. */
  17276. recreateShadowMap(): void;
  17277. /**
  17278. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17279. * @param onCompiled Callback triggered at the and of the effects compilation
  17280. * @param options Sets of optional options forcing the compilation with different modes
  17281. */
  17282. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17283. useInstances: boolean;
  17284. }>): void;
  17285. /**
  17286. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17287. * @param options Sets of optional options forcing the compilation with different modes
  17288. * @returns A promise that resolves when the compilation completes
  17289. */
  17290. forceCompilationAsync(options?: Partial<{
  17291. useInstances: boolean;
  17292. }>): Promise<void>;
  17293. /**
  17294. * Serializes the shadow generator setup to a json object.
  17295. * @returns The serialized JSON object
  17296. */
  17297. serialize(): any;
  17298. /**
  17299. * Disposes the Shadow map and related Textures and effects.
  17300. */
  17301. dispose(): void;
  17302. }
  17303. /**
  17304. * Default implementation IShadowGenerator.
  17305. * This is the main object responsible of generating shadows in the framework.
  17306. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17307. */
  17308. export class ShadowGenerator implements IShadowGenerator {
  17309. /**
  17310. * Name of the shadow generator class
  17311. */
  17312. static CLASSNAME: string;
  17313. /**
  17314. * Shadow generator mode None: no filtering applied.
  17315. */
  17316. static readonly FILTER_NONE: number;
  17317. /**
  17318. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17319. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17320. */
  17321. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17322. /**
  17323. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17324. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17325. */
  17326. static readonly FILTER_POISSONSAMPLING: number;
  17327. /**
  17328. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17329. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17330. */
  17331. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17332. /**
  17333. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17334. * edge artifacts on steep falloff.
  17335. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17336. */
  17337. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17338. /**
  17339. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17340. * edge artifacts on steep falloff.
  17341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17342. */
  17343. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17344. /**
  17345. * Shadow generator mode PCF: Percentage Closer Filtering
  17346. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17347. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17348. */
  17349. static readonly FILTER_PCF: number;
  17350. /**
  17351. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17352. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17353. * Contact Hardening
  17354. */
  17355. static readonly FILTER_PCSS: number;
  17356. /**
  17357. * Reserved for PCF and PCSS
  17358. * Highest Quality.
  17359. *
  17360. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17361. *
  17362. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17363. */
  17364. static readonly QUALITY_HIGH: number;
  17365. /**
  17366. * Reserved for PCF and PCSS
  17367. * Good tradeoff for quality/perf cross devices
  17368. *
  17369. * Execute PCF on a 3*3 kernel.
  17370. *
  17371. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17372. */
  17373. static readonly QUALITY_MEDIUM: number;
  17374. /**
  17375. * Reserved for PCF and PCSS
  17376. * The lowest quality but the fastest.
  17377. *
  17378. * Execute PCF on a 1*1 kernel.
  17379. *
  17380. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17381. */
  17382. static readonly QUALITY_LOW: number;
  17383. /** Gets or sets the custom shader name to use */
  17384. customShaderOptions: ICustomShaderOptions;
  17385. /**
  17386. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17387. */
  17388. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17389. /**
  17390. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17391. */
  17392. onAfterShadowMapRenderObservable: Observable<Effect>;
  17393. /**
  17394. * Observable triggered before a mesh is rendered in the shadow map.
  17395. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17396. */
  17397. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17398. /**
  17399. * Observable triggered after a mesh is rendered in the shadow map.
  17400. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17401. */
  17402. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17403. protected _bias: number;
  17404. /**
  17405. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17406. */
  17407. get bias(): number;
  17408. /**
  17409. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17410. */
  17411. set bias(bias: number);
  17412. protected _normalBias: number;
  17413. /**
  17414. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17415. */
  17416. get normalBias(): number;
  17417. /**
  17418. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17419. */
  17420. set normalBias(normalBias: number);
  17421. protected _blurBoxOffset: number;
  17422. /**
  17423. * Gets the blur box offset: offset applied during the blur pass.
  17424. * Only useful if useKernelBlur = false
  17425. */
  17426. get blurBoxOffset(): number;
  17427. /**
  17428. * Sets the blur box offset: offset applied during the blur pass.
  17429. * Only useful if useKernelBlur = false
  17430. */
  17431. set blurBoxOffset(value: number);
  17432. protected _blurScale: number;
  17433. /**
  17434. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17435. * 2 means half of the size.
  17436. */
  17437. get blurScale(): number;
  17438. /**
  17439. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17440. * 2 means half of the size.
  17441. */
  17442. set blurScale(value: number);
  17443. protected _blurKernel: number;
  17444. /**
  17445. * Gets the blur kernel: kernel size of the blur pass.
  17446. * Only useful if useKernelBlur = true
  17447. */
  17448. get blurKernel(): number;
  17449. /**
  17450. * Sets the blur kernel: kernel size of the blur pass.
  17451. * Only useful if useKernelBlur = true
  17452. */
  17453. set blurKernel(value: number);
  17454. protected _useKernelBlur: boolean;
  17455. /**
  17456. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17457. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17458. */
  17459. get useKernelBlur(): boolean;
  17460. /**
  17461. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17462. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17463. */
  17464. set useKernelBlur(value: boolean);
  17465. protected _depthScale: number;
  17466. /**
  17467. * Gets the depth scale used in ESM mode.
  17468. */
  17469. get depthScale(): number;
  17470. /**
  17471. * Sets the depth scale used in ESM mode.
  17472. * This can override the scale stored on the light.
  17473. */
  17474. set depthScale(value: number);
  17475. protected _validateFilter(filter: number): number;
  17476. protected _filter: number;
  17477. /**
  17478. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17479. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17480. */
  17481. get filter(): number;
  17482. /**
  17483. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17484. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17485. */
  17486. set filter(value: number);
  17487. /**
  17488. * Gets if the current filter is set to Poisson Sampling.
  17489. */
  17490. get usePoissonSampling(): boolean;
  17491. /**
  17492. * Sets the current filter to Poisson Sampling.
  17493. */
  17494. set usePoissonSampling(value: boolean);
  17495. /**
  17496. * Gets if the current filter is set to ESM.
  17497. */
  17498. get useExponentialShadowMap(): boolean;
  17499. /**
  17500. * Sets the current filter is to ESM.
  17501. */
  17502. set useExponentialShadowMap(value: boolean);
  17503. /**
  17504. * Gets if the current filter is set to filtered ESM.
  17505. */
  17506. get useBlurExponentialShadowMap(): boolean;
  17507. /**
  17508. * Gets if the current filter is set to filtered ESM.
  17509. */
  17510. set useBlurExponentialShadowMap(value: boolean);
  17511. /**
  17512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17513. * exponential to prevent steep falloff artifacts).
  17514. */
  17515. get useCloseExponentialShadowMap(): boolean;
  17516. /**
  17517. * Sets the current filter to "close ESM" (using the inverse of the
  17518. * exponential to prevent steep falloff artifacts).
  17519. */
  17520. set useCloseExponentialShadowMap(value: boolean);
  17521. /**
  17522. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17523. * exponential to prevent steep falloff artifacts).
  17524. */
  17525. get useBlurCloseExponentialShadowMap(): boolean;
  17526. /**
  17527. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17528. * exponential to prevent steep falloff artifacts).
  17529. */
  17530. set useBlurCloseExponentialShadowMap(value: boolean);
  17531. /**
  17532. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17533. */
  17534. get usePercentageCloserFiltering(): boolean;
  17535. /**
  17536. * Sets the current filter to "PCF" (percentage closer filtering).
  17537. */
  17538. set usePercentageCloserFiltering(value: boolean);
  17539. protected _filteringQuality: number;
  17540. /**
  17541. * Gets the PCF or PCSS Quality.
  17542. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17543. */
  17544. get filteringQuality(): number;
  17545. /**
  17546. * Sets the PCF or PCSS Quality.
  17547. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17548. */
  17549. set filteringQuality(filteringQuality: number);
  17550. /**
  17551. * Gets if the current filter is set to "PCSS" (contact hardening).
  17552. */
  17553. get useContactHardeningShadow(): boolean;
  17554. /**
  17555. * Sets the current filter to "PCSS" (contact hardening).
  17556. */
  17557. set useContactHardeningShadow(value: boolean);
  17558. protected _contactHardeningLightSizeUVRatio: number;
  17559. /**
  17560. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17561. * Using a ratio helps keeping shape stability independently of the map size.
  17562. *
  17563. * It does not account for the light projection as it was having too much
  17564. * instability during the light setup or during light position changes.
  17565. *
  17566. * Only valid if useContactHardeningShadow is true.
  17567. */
  17568. get contactHardeningLightSizeUVRatio(): number;
  17569. /**
  17570. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17571. * Using a ratio helps keeping shape stability independently of the map size.
  17572. *
  17573. * It does not account for the light projection as it was having too much
  17574. * instability during the light setup or during light position changes.
  17575. *
  17576. * Only valid if useContactHardeningShadow is true.
  17577. */
  17578. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17579. protected _darkness: number;
  17580. /** Gets or sets the actual darkness of a shadow */
  17581. get darkness(): number;
  17582. set darkness(value: number);
  17583. /**
  17584. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17585. * 0 means strongest and 1 would means no shadow.
  17586. * @returns the darkness.
  17587. */
  17588. getDarkness(): number;
  17589. /**
  17590. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17591. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17592. * @returns the shadow generator allowing fluent coding.
  17593. */
  17594. setDarkness(darkness: number): ShadowGenerator;
  17595. protected _transparencyShadow: boolean;
  17596. /** Gets or sets the ability to have transparent shadow */
  17597. get transparencyShadow(): boolean;
  17598. set transparencyShadow(value: boolean);
  17599. /**
  17600. * Sets the ability to have transparent shadow (boolean).
  17601. * @param transparent True if transparent else False
  17602. * @returns the shadow generator allowing fluent coding
  17603. */
  17604. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17605. /**
  17606. * Enables or disables shadows with varying strength based on the transparency
  17607. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17608. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17609. * mesh.visibility * alphaTexture.a
  17610. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17611. */
  17612. enableSoftTransparentShadow: boolean;
  17613. protected _shadowMap: Nullable<RenderTargetTexture>;
  17614. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17615. /**
  17616. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17617. * @returns The render target texture if present otherwise, null
  17618. */
  17619. getShadowMap(): Nullable<RenderTargetTexture>;
  17620. /**
  17621. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17622. * @returns The render target texture if the shadow map is present otherwise, null
  17623. */
  17624. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17625. /**
  17626. * Gets the class name of that object
  17627. * @returns "ShadowGenerator"
  17628. */
  17629. getClassName(): string;
  17630. /**
  17631. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17632. * @param mesh Mesh to add
  17633. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17634. * @returns the Shadow Generator itself
  17635. */
  17636. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17637. /**
  17638. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17639. * @param mesh Mesh to remove
  17640. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17641. * @returns the Shadow Generator itself
  17642. */
  17643. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17644. /**
  17645. * Controls the extent to which the shadows fade out at the edge of the frustum
  17646. */
  17647. frustumEdgeFalloff: number;
  17648. protected _light: IShadowLight;
  17649. /**
  17650. * Returns the associated light object.
  17651. * @returns the light generating the shadow
  17652. */
  17653. getLight(): IShadowLight;
  17654. /**
  17655. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17656. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17657. * It might on the other hand introduce peter panning.
  17658. */
  17659. forceBackFacesOnly: boolean;
  17660. protected _scene: Scene;
  17661. protected _lightDirection: Vector3;
  17662. protected _effect: Effect;
  17663. protected _viewMatrix: Matrix;
  17664. protected _projectionMatrix: Matrix;
  17665. protected _transformMatrix: Matrix;
  17666. protected _cachedPosition: Vector3;
  17667. protected _cachedDirection: Vector3;
  17668. protected _cachedDefines: string;
  17669. protected _currentRenderID: number;
  17670. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17671. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17672. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17673. protected _blurPostProcesses: PostProcess[];
  17674. protected _mapSize: number;
  17675. protected _currentFaceIndex: number;
  17676. protected _currentFaceIndexCache: number;
  17677. protected _textureType: number;
  17678. protected _defaultTextureMatrix: Matrix;
  17679. protected _storedUniqueId: Nullable<number>;
  17680. /** @hidden */
  17681. static _SceneComponentInitialization: (scene: Scene) => void;
  17682. /**
  17683. * Creates a ShadowGenerator object.
  17684. * A ShadowGenerator is the required tool to use the shadows.
  17685. * Each light casting shadows needs to use its own ShadowGenerator.
  17686. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17687. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17688. * @param light The light object generating the shadows.
  17689. * @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.
  17690. */
  17691. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17692. protected _initializeGenerator(): void;
  17693. protected _createTargetRenderTexture(): void;
  17694. protected _initializeShadowMap(): void;
  17695. protected _initializeBlurRTTAndPostProcesses(): void;
  17696. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17697. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17698. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17699. protected _applyFilterValues(): void;
  17700. /**
  17701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17702. * @param onCompiled Callback triggered at the and of the effects compilation
  17703. * @param options Sets of optional options forcing the compilation with different modes
  17704. */
  17705. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17706. useInstances: boolean;
  17707. }>): void;
  17708. /**
  17709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17710. * @param options Sets of optional options forcing the compilation with different modes
  17711. * @returns A promise that resolves when the compilation completes
  17712. */
  17713. forceCompilationAsync(options?: Partial<{
  17714. useInstances: boolean;
  17715. }>): Promise<void>;
  17716. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17717. private _prepareShadowDefines;
  17718. /**
  17719. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17720. * @param subMesh The submesh we want to render in the shadow map
  17721. * @param useInstances Defines wether will draw in the map using instances
  17722. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17723. * @returns true if ready otherwise, false
  17724. */
  17725. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17726. /**
  17727. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17728. * @param defines Defines of the material we want to update
  17729. * @param lightIndex Index of the light in the enabled light list of the material
  17730. */
  17731. prepareDefines(defines: any, lightIndex: number): void;
  17732. /**
  17733. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17734. * defined in the generator but impacting the effect).
  17735. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17736. * @param effect The effect we are binfing the information for
  17737. */
  17738. bindShadowLight(lightIndex: string, effect: Effect): void;
  17739. /**
  17740. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17741. * (eq to shadow prjection matrix * light transform matrix)
  17742. * @returns The transform matrix used to create the shadow map
  17743. */
  17744. getTransformMatrix(): Matrix;
  17745. /**
  17746. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17747. * Cube and 2D textures for instance.
  17748. */
  17749. recreateShadowMap(): void;
  17750. protected _disposeBlurPostProcesses(): void;
  17751. protected _disposeRTTandPostProcesses(): void;
  17752. /**
  17753. * Disposes the ShadowGenerator.
  17754. * Returns nothing.
  17755. */
  17756. dispose(): void;
  17757. /**
  17758. * Serializes the shadow generator setup to a json object.
  17759. * @returns The serialized JSON object
  17760. */
  17761. serialize(): any;
  17762. /**
  17763. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17764. * @param parsedShadowGenerator The JSON object to parse
  17765. * @param scene The scene to create the shadow map for
  17766. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17767. * @returns The parsed shadow generator
  17768. */
  17769. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17770. }
  17771. }
  17772. declare module BABYLON {
  17773. /**
  17774. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17775. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17776. * 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.
  17777. */
  17778. export abstract class Light extends Node {
  17779. /**
  17780. * Falloff Default: light is falling off following the material specification:
  17781. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17782. */
  17783. static readonly FALLOFF_DEFAULT: number;
  17784. /**
  17785. * Falloff Physical: light is falling off following the inverse squared distance law.
  17786. */
  17787. static readonly FALLOFF_PHYSICAL: number;
  17788. /**
  17789. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17790. * to enhance interoperability with other engines.
  17791. */
  17792. static readonly FALLOFF_GLTF: number;
  17793. /**
  17794. * Falloff Standard: light is falling off like in the standard material
  17795. * to enhance interoperability with other materials.
  17796. */
  17797. static readonly FALLOFF_STANDARD: number;
  17798. /**
  17799. * If every light affecting the material is in this lightmapMode,
  17800. * material.lightmapTexture adds or multiplies
  17801. * (depends on material.useLightmapAsShadowmap)
  17802. * after every other light calculations.
  17803. */
  17804. static readonly LIGHTMAP_DEFAULT: number;
  17805. /**
  17806. * material.lightmapTexture as only diffuse lighting from this light
  17807. * adds only specular lighting from this light
  17808. * adds dynamic shadows
  17809. */
  17810. static readonly LIGHTMAP_SPECULAR: number;
  17811. /**
  17812. * material.lightmapTexture as only lighting
  17813. * no light calculation from this light
  17814. * only adds dynamic shadows from this light
  17815. */
  17816. static readonly LIGHTMAP_SHADOWSONLY: number;
  17817. /**
  17818. * Each light type uses the default quantity according to its type:
  17819. * point/spot lights use luminous intensity
  17820. * directional lights use illuminance
  17821. */
  17822. static readonly INTENSITYMODE_AUTOMATIC: number;
  17823. /**
  17824. * lumen (lm)
  17825. */
  17826. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17827. /**
  17828. * candela (lm/sr)
  17829. */
  17830. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17831. /**
  17832. * lux (lm/m^2)
  17833. */
  17834. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17835. /**
  17836. * nit (cd/m^2)
  17837. */
  17838. static readonly INTENSITYMODE_LUMINANCE: number;
  17839. /**
  17840. * Light type const id of the point light.
  17841. */
  17842. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17843. /**
  17844. * Light type const id of the directional light.
  17845. */
  17846. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17847. /**
  17848. * Light type const id of the spot light.
  17849. */
  17850. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17851. /**
  17852. * Light type const id of the hemispheric light.
  17853. */
  17854. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17855. /**
  17856. * Diffuse gives the basic color to an object.
  17857. */
  17858. diffuse: Color3;
  17859. /**
  17860. * Specular produces a highlight color on an object.
  17861. * Note: This is note affecting PBR materials.
  17862. */
  17863. specular: Color3;
  17864. /**
  17865. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17866. * falling off base on range or angle.
  17867. * This can be set to any values in Light.FALLOFF_x.
  17868. *
  17869. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17870. * other types of materials.
  17871. */
  17872. falloffType: number;
  17873. /**
  17874. * Strength of the light.
  17875. * Note: By default it is define in the framework own unit.
  17876. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17877. */
  17878. intensity: number;
  17879. private _range;
  17880. protected _inverseSquaredRange: number;
  17881. /**
  17882. * Defines how far from the source the light is impacting in scene units.
  17883. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17884. */
  17885. get range(): number;
  17886. /**
  17887. * Defines how far from the source the light is impacting in scene units.
  17888. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17889. */
  17890. set range(value: number);
  17891. /**
  17892. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17893. * of light.
  17894. */
  17895. private _photometricScale;
  17896. private _intensityMode;
  17897. /**
  17898. * Gets the photometric scale used to interpret the intensity.
  17899. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17900. */
  17901. get intensityMode(): number;
  17902. /**
  17903. * Sets the photometric scale used to interpret the intensity.
  17904. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17905. */
  17906. set intensityMode(value: number);
  17907. private _radius;
  17908. /**
  17909. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17910. */
  17911. get radius(): number;
  17912. /**
  17913. * sets the light radius used by PBR Materials to simulate soft area lights.
  17914. */
  17915. set radius(value: number);
  17916. private _renderPriority;
  17917. /**
  17918. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17919. * exceeding the number allowed of the materials.
  17920. */
  17921. renderPriority: number;
  17922. private _shadowEnabled;
  17923. /**
  17924. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17925. * the current shadow generator.
  17926. */
  17927. get shadowEnabled(): boolean;
  17928. /**
  17929. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17930. * the current shadow generator.
  17931. */
  17932. set shadowEnabled(value: boolean);
  17933. private _includedOnlyMeshes;
  17934. /**
  17935. * Gets the only meshes impacted by this light.
  17936. */
  17937. get includedOnlyMeshes(): AbstractMesh[];
  17938. /**
  17939. * Sets the only meshes impacted by this light.
  17940. */
  17941. set includedOnlyMeshes(value: AbstractMesh[]);
  17942. private _excludedMeshes;
  17943. /**
  17944. * Gets the meshes not impacted by this light.
  17945. */
  17946. get excludedMeshes(): AbstractMesh[];
  17947. /**
  17948. * Sets the meshes not impacted by this light.
  17949. */
  17950. set excludedMeshes(value: AbstractMesh[]);
  17951. private _excludeWithLayerMask;
  17952. /**
  17953. * Gets the layer id use to find what meshes are not impacted by the light.
  17954. * Inactive if 0
  17955. */
  17956. get excludeWithLayerMask(): number;
  17957. /**
  17958. * Sets the layer id use to find what meshes are not impacted by the light.
  17959. * Inactive if 0
  17960. */
  17961. set excludeWithLayerMask(value: number);
  17962. private _includeOnlyWithLayerMask;
  17963. /**
  17964. * Gets the layer id use to find what meshes are impacted by the light.
  17965. * Inactive if 0
  17966. */
  17967. get includeOnlyWithLayerMask(): number;
  17968. /**
  17969. * Sets the layer id use to find what meshes are impacted by the light.
  17970. * Inactive if 0
  17971. */
  17972. set includeOnlyWithLayerMask(value: number);
  17973. private _lightmapMode;
  17974. /**
  17975. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17976. */
  17977. get lightmapMode(): number;
  17978. /**
  17979. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17980. */
  17981. set lightmapMode(value: number);
  17982. /**
  17983. * Shadow generator associted to the light.
  17984. * @hidden Internal use only.
  17985. */
  17986. _shadowGenerator: Nullable<IShadowGenerator>;
  17987. /**
  17988. * @hidden Internal use only.
  17989. */
  17990. _excludedMeshesIds: string[];
  17991. /**
  17992. * @hidden Internal use only.
  17993. */
  17994. _includedOnlyMeshesIds: string[];
  17995. /**
  17996. * The current light unifom buffer.
  17997. * @hidden Internal use only.
  17998. */
  17999. _uniformBuffer: UniformBuffer;
  18000. /** @hidden */
  18001. _renderId: number;
  18002. /**
  18003. * Creates a Light object in the scene.
  18004. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18005. * @param name The firendly name of the light
  18006. * @param scene The scene the light belongs too
  18007. */
  18008. constructor(name: string, scene: Scene);
  18009. protected abstract _buildUniformLayout(): void;
  18010. /**
  18011. * Sets the passed Effect "effect" with the Light information.
  18012. * @param effect The effect to update
  18013. * @param lightIndex The index of the light in the effect to update
  18014. * @returns The light
  18015. */
  18016. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18017. /**
  18018. * Sets the passed Effect "effect" with the Light textures.
  18019. * @param effect The effect to update
  18020. * @param lightIndex The index of the light in the effect to update
  18021. * @returns The light
  18022. */
  18023. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18024. /**
  18025. * Binds the lights information from the scene to the effect for the given mesh.
  18026. * @param lightIndex Light index
  18027. * @param scene The scene where the light belongs to
  18028. * @param effect The effect we are binding the data to
  18029. * @param useSpecular Defines if specular is supported
  18030. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18031. */
  18032. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18033. /**
  18034. * Sets the passed Effect "effect" with the Light information.
  18035. * @param effect The effect to update
  18036. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18037. * @returns The light
  18038. */
  18039. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18040. /**
  18041. * Returns the string "Light".
  18042. * @returns the class name
  18043. */
  18044. getClassName(): string;
  18045. /** @hidden */
  18046. readonly _isLight: boolean;
  18047. /**
  18048. * Converts the light information to a readable string for debug purpose.
  18049. * @param fullDetails Supports for multiple levels of logging within scene loading
  18050. * @returns the human readable light info
  18051. */
  18052. toString(fullDetails?: boolean): string;
  18053. /** @hidden */
  18054. protected _syncParentEnabledState(): void;
  18055. /**
  18056. * Set the enabled state of this node.
  18057. * @param value - the new enabled state
  18058. */
  18059. setEnabled(value: boolean): void;
  18060. /**
  18061. * Returns the Light associated shadow generator if any.
  18062. * @return the associated shadow generator.
  18063. */
  18064. getShadowGenerator(): Nullable<IShadowGenerator>;
  18065. /**
  18066. * Returns a Vector3, the absolute light position in the World.
  18067. * @returns the world space position of the light
  18068. */
  18069. getAbsolutePosition(): Vector3;
  18070. /**
  18071. * Specifies if the light will affect the passed mesh.
  18072. * @param mesh The mesh to test against the light
  18073. * @return true the mesh is affected otherwise, false.
  18074. */
  18075. canAffectMesh(mesh: AbstractMesh): boolean;
  18076. /**
  18077. * Sort function to order lights for rendering.
  18078. * @param a First Light object to compare to second.
  18079. * @param b Second Light object to compare first.
  18080. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18081. */
  18082. static CompareLightsPriority(a: Light, b: Light): number;
  18083. /**
  18084. * Releases resources associated with this node.
  18085. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18086. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18087. */
  18088. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18089. /**
  18090. * Returns the light type ID (integer).
  18091. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18092. */
  18093. getTypeID(): number;
  18094. /**
  18095. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18096. * @returns the scaled intensity in intensity mode unit
  18097. */
  18098. getScaledIntensity(): number;
  18099. /**
  18100. * Returns a new Light object, named "name", from the current one.
  18101. * @param name The name of the cloned light
  18102. * @param newParent The parent of this light, if it has one
  18103. * @returns the new created light
  18104. */
  18105. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18106. /**
  18107. * Serializes the current light into a Serialization object.
  18108. * @returns the serialized object.
  18109. */
  18110. serialize(): any;
  18111. /**
  18112. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18113. * This new light is named "name" and added to the passed scene.
  18114. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18115. * @param name The friendly name of the light
  18116. * @param scene The scene the new light will belong to
  18117. * @returns the constructor function
  18118. */
  18119. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18120. /**
  18121. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18122. * @param parsedLight The JSON representation of the light
  18123. * @param scene The scene to create the parsed light in
  18124. * @returns the created light after parsing
  18125. */
  18126. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18127. private _hookArrayForExcluded;
  18128. private _hookArrayForIncludedOnly;
  18129. private _resyncMeshes;
  18130. /**
  18131. * Forces the meshes to update their light related information in their rendering used effects
  18132. * @hidden Internal Use Only
  18133. */
  18134. _markMeshesAsLightDirty(): void;
  18135. /**
  18136. * Recomputes the cached photometric scale if needed.
  18137. */
  18138. private _computePhotometricScale;
  18139. /**
  18140. * Returns the Photometric Scale according to the light type and intensity mode.
  18141. */
  18142. private _getPhotometricScale;
  18143. /**
  18144. * Reorder the light in the scene according to their defined priority.
  18145. * @hidden Internal Use Only
  18146. */
  18147. _reorderLightsInScene(): void;
  18148. /**
  18149. * Prepares the list of defines specific to the light type.
  18150. * @param defines the list of defines
  18151. * @param lightIndex defines the index of the light for the effect
  18152. */
  18153. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18154. }
  18155. }
  18156. declare module BABYLON {
  18157. /**
  18158. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18159. * This is the base of the follow, arc rotate cameras and Free camera
  18160. * @see https://doc.babylonjs.com/features/cameras
  18161. */
  18162. export class TargetCamera extends Camera {
  18163. private static _RigCamTransformMatrix;
  18164. private static _TargetTransformMatrix;
  18165. private static _TargetFocalPoint;
  18166. private _tmpUpVector;
  18167. private _tmpTargetVector;
  18168. /**
  18169. * Define the current direction the camera is moving to
  18170. */
  18171. cameraDirection: Vector3;
  18172. /**
  18173. * Define the current rotation the camera is rotating to
  18174. */
  18175. cameraRotation: Vector2;
  18176. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18177. ignoreParentScaling: boolean;
  18178. /**
  18179. * When set, the up vector of the camera will be updated by the rotation of the camera
  18180. */
  18181. updateUpVectorFromRotation: boolean;
  18182. private _tmpQuaternion;
  18183. /**
  18184. * Define the current rotation of the camera
  18185. */
  18186. rotation: Vector3;
  18187. /**
  18188. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18189. */
  18190. rotationQuaternion: Quaternion;
  18191. /**
  18192. * Define the current speed of the camera
  18193. */
  18194. speed: number;
  18195. /**
  18196. * Add constraint to the camera to prevent it to move freely in all directions and
  18197. * around all axis.
  18198. */
  18199. noRotationConstraint: boolean;
  18200. /**
  18201. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18202. * panning
  18203. */
  18204. invertRotation: boolean;
  18205. /**
  18206. * Speed multiplier for inverse camera panning
  18207. */
  18208. inverseRotationSpeed: number;
  18209. /**
  18210. * Define the current target of the camera as an object or a position.
  18211. */
  18212. lockedTarget: any;
  18213. /** @hidden */
  18214. _currentTarget: Vector3;
  18215. /** @hidden */
  18216. _initialFocalDistance: number;
  18217. /** @hidden */
  18218. _viewMatrix: Matrix;
  18219. /** @hidden */
  18220. _camMatrix: Matrix;
  18221. /** @hidden */
  18222. _cameraTransformMatrix: Matrix;
  18223. /** @hidden */
  18224. _cameraRotationMatrix: Matrix;
  18225. /** @hidden */
  18226. _referencePoint: Vector3;
  18227. /** @hidden */
  18228. _transformedReferencePoint: Vector3;
  18229. /** @hidden */
  18230. _reset: () => void;
  18231. private _defaultUp;
  18232. /**
  18233. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18234. * This is the base of the follow, arc rotate cameras and Free camera
  18235. * @see https://doc.babylonjs.com/features/cameras
  18236. * @param name Defines the name of the camera in the scene
  18237. * @param position Defines the start position of the camera in the scene
  18238. * @param scene Defines the scene the camera belongs to
  18239. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18240. */
  18241. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18242. /**
  18243. * Gets the position in front of the camera at a given distance.
  18244. * @param distance The distance from the camera we want the position to be
  18245. * @returns the position
  18246. */
  18247. getFrontPosition(distance: number): Vector3;
  18248. /** @hidden */
  18249. _getLockedTargetPosition(): Nullable<Vector3>;
  18250. private _storedPosition;
  18251. private _storedRotation;
  18252. private _storedRotationQuaternion;
  18253. /**
  18254. * Store current camera state of the camera (fov, position, rotation, etc..)
  18255. * @returns the camera
  18256. */
  18257. storeState(): Camera;
  18258. /**
  18259. * Restored camera state. You must call storeState() first
  18260. * @returns whether it was successful or not
  18261. * @hidden
  18262. */
  18263. _restoreStateValues(): boolean;
  18264. /** @hidden */
  18265. _initCache(): void;
  18266. /** @hidden */
  18267. _updateCache(ignoreParentClass?: boolean): void;
  18268. /** @hidden */
  18269. _isSynchronizedViewMatrix(): boolean;
  18270. /** @hidden */
  18271. _computeLocalCameraSpeed(): number;
  18272. /**
  18273. * Defines the target the camera should look at.
  18274. * @param target Defines the new target as a Vector or a mesh
  18275. */
  18276. setTarget(target: Vector3): void;
  18277. /**
  18278. * Return the current target position of the camera. This value is expressed in local space.
  18279. * @returns the target position
  18280. */
  18281. getTarget(): Vector3;
  18282. /** @hidden */
  18283. _decideIfNeedsToMove(): boolean;
  18284. /** @hidden */
  18285. _updatePosition(): void;
  18286. /** @hidden */
  18287. _checkInputs(): void;
  18288. protected _updateCameraRotationMatrix(): void;
  18289. /**
  18290. * 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)
  18291. * @returns the current camera
  18292. */
  18293. private _rotateUpVectorWithCameraRotationMatrix;
  18294. private _cachedRotationZ;
  18295. private _cachedQuaternionRotationZ;
  18296. /** @hidden */
  18297. _getViewMatrix(): Matrix;
  18298. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18299. /**
  18300. * @hidden
  18301. */
  18302. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18303. /**
  18304. * @hidden
  18305. */
  18306. _updateRigCameras(): void;
  18307. private _getRigCamPositionAndTarget;
  18308. /**
  18309. * Gets the current object class name.
  18310. * @return the class name
  18311. */
  18312. getClassName(): string;
  18313. }
  18314. }
  18315. declare module BABYLON {
  18316. /**
  18317. * Gather the list of keyboard event types as constants.
  18318. */
  18319. export class KeyboardEventTypes {
  18320. /**
  18321. * The keydown event is fired when a key becomes active (pressed).
  18322. */
  18323. static readonly KEYDOWN: number;
  18324. /**
  18325. * The keyup event is fired when a key has been released.
  18326. */
  18327. static readonly KEYUP: number;
  18328. }
  18329. /**
  18330. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18331. */
  18332. export class KeyboardInfo {
  18333. /**
  18334. * Defines the type of event (KeyboardEventTypes)
  18335. */
  18336. type: number;
  18337. /**
  18338. * Defines the related dom event
  18339. */
  18340. event: KeyboardEvent;
  18341. /**
  18342. * Instantiates a new keyboard info.
  18343. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18344. * @param type Defines the type of event (KeyboardEventTypes)
  18345. * @param event Defines the related dom event
  18346. */
  18347. constructor(
  18348. /**
  18349. * Defines the type of event (KeyboardEventTypes)
  18350. */
  18351. type: number,
  18352. /**
  18353. * Defines the related dom event
  18354. */
  18355. event: KeyboardEvent);
  18356. }
  18357. /**
  18358. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18359. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18360. */
  18361. export class KeyboardInfoPre extends KeyboardInfo {
  18362. /**
  18363. * Defines the type of event (KeyboardEventTypes)
  18364. */
  18365. type: number;
  18366. /**
  18367. * Defines the related dom event
  18368. */
  18369. event: KeyboardEvent;
  18370. /**
  18371. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18372. */
  18373. skipOnPointerObservable: boolean;
  18374. /**
  18375. * Instantiates a new keyboard pre info.
  18376. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18377. * @param type Defines the type of event (KeyboardEventTypes)
  18378. * @param event Defines the related dom event
  18379. */
  18380. constructor(
  18381. /**
  18382. * Defines the type of event (KeyboardEventTypes)
  18383. */
  18384. type: number,
  18385. /**
  18386. * Defines the related dom event
  18387. */
  18388. event: KeyboardEvent);
  18389. }
  18390. }
  18391. declare module BABYLON {
  18392. /**
  18393. * Manage the keyboard inputs to control the movement of a free camera.
  18394. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18395. */
  18396. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18397. /**
  18398. * Defines the camera the input is attached to.
  18399. */
  18400. camera: FreeCamera;
  18401. /**
  18402. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18403. */
  18404. keysUp: number[];
  18405. /**
  18406. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18407. */
  18408. keysUpward: number[];
  18409. /**
  18410. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18411. */
  18412. keysDown: number[];
  18413. /**
  18414. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18415. */
  18416. keysDownward: number[];
  18417. /**
  18418. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18419. */
  18420. keysLeft: number[];
  18421. /**
  18422. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18423. */
  18424. keysRight: number[];
  18425. private _keys;
  18426. private _onCanvasBlurObserver;
  18427. private _onKeyboardObserver;
  18428. private _engine;
  18429. private _scene;
  18430. /**
  18431. * Attach the input controls to a specific dom element to get the input from.
  18432. * @param element Defines the element the controls should be listened from
  18433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18434. */
  18435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18436. /**
  18437. * Detach the current controls from the specified dom element.
  18438. * @param element Defines the element to stop listening the inputs from
  18439. */
  18440. detachControl(element: Nullable<HTMLElement>): void;
  18441. /**
  18442. * Update the current camera state depending on the inputs that have been used this frame.
  18443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18444. */
  18445. checkInputs(): void;
  18446. /**
  18447. * Gets the class name of the current intput.
  18448. * @returns the class name
  18449. */
  18450. getClassName(): string;
  18451. /** @hidden */
  18452. _onLostFocus(): void;
  18453. /**
  18454. * Get the friendly name associated with the input class.
  18455. * @returns the input friendly name
  18456. */
  18457. getSimpleName(): string;
  18458. }
  18459. }
  18460. declare module BABYLON {
  18461. /**
  18462. * Gather the list of pointer event types as constants.
  18463. */
  18464. export class PointerEventTypes {
  18465. /**
  18466. * 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.
  18467. */
  18468. static readonly POINTERDOWN: number;
  18469. /**
  18470. * The pointerup event is fired when a pointer is no longer active.
  18471. */
  18472. static readonly POINTERUP: number;
  18473. /**
  18474. * The pointermove event is fired when a pointer changes coordinates.
  18475. */
  18476. static readonly POINTERMOVE: number;
  18477. /**
  18478. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18479. */
  18480. static readonly POINTERWHEEL: number;
  18481. /**
  18482. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18483. */
  18484. static readonly POINTERPICK: number;
  18485. /**
  18486. * The pointertap event is fired when a the object has been touched and released without drag.
  18487. */
  18488. static readonly POINTERTAP: number;
  18489. /**
  18490. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18491. */
  18492. static readonly POINTERDOUBLETAP: number;
  18493. }
  18494. /**
  18495. * Base class of pointer info types.
  18496. */
  18497. export class PointerInfoBase {
  18498. /**
  18499. * Defines the type of event (PointerEventTypes)
  18500. */
  18501. type: number;
  18502. /**
  18503. * Defines the related dom event
  18504. */
  18505. event: PointerEvent | MouseWheelEvent;
  18506. /**
  18507. * Instantiates the base class of pointers info.
  18508. * @param type Defines the type of event (PointerEventTypes)
  18509. * @param event Defines the related dom event
  18510. */
  18511. constructor(
  18512. /**
  18513. * Defines the type of event (PointerEventTypes)
  18514. */
  18515. type: number,
  18516. /**
  18517. * Defines the related dom event
  18518. */
  18519. event: PointerEvent | MouseWheelEvent);
  18520. }
  18521. /**
  18522. * This class is used to store pointer related info for the onPrePointerObservable event.
  18523. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18524. */
  18525. export class PointerInfoPre extends PointerInfoBase {
  18526. /**
  18527. * Ray from a pointer if availible (eg. 6dof controller)
  18528. */
  18529. ray: Nullable<Ray>;
  18530. /**
  18531. * Defines the local position of the pointer on the canvas.
  18532. */
  18533. localPosition: Vector2;
  18534. /**
  18535. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18536. */
  18537. skipOnPointerObservable: boolean;
  18538. /**
  18539. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18540. * @param type Defines the type of event (PointerEventTypes)
  18541. * @param event Defines the related dom event
  18542. * @param localX Defines the local x coordinates of the pointer when the event occured
  18543. * @param localY Defines the local y coordinates of the pointer when the event occured
  18544. */
  18545. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18546. }
  18547. /**
  18548. * This type contains all the data related to a pointer event in Babylon.js.
  18549. * 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.
  18550. */
  18551. export class PointerInfo extends PointerInfoBase {
  18552. /**
  18553. * Defines the picking info associated to the info (if any)\
  18554. */
  18555. pickInfo: Nullable<PickingInfo>;
  18556. /**
  18557. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18558. * @param type Defines the type of event (PointerEventTypes)
  18559. * @param event Defines the related dom event
  18560. * @param pickInfo Defines the picking info associated to the info (if any)\
  18561. */
  18562. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18563. /**
  18564. * Defines the picking info associated to the info (if any)\
  18565. */
  18566. pickInfo: Nullable<PickingInfo>);
  18567. }
  18568. /**
  18569. * Data relating to a touch event on the screen.
  18570. */
  18571. export interface PointerTouch {
  18572. /**
  18573. * X coordinate of touch.
  18574. */
  18575. x: number;
  18576. /**
  18577. * Y coordinate of touch.
  18578. */
  18579. y: number;
  18580. /**
  18581. * Id of touch. Unique for each finger.
  18582. */
  18583. pointerId: number;
  18584. /**
  18585. * Event type passed from DOM.
  18586. */
  18587. type: any;
  18588. }
  18589. }
  18590. declare module BABYLON {
  18591. /**
  18592. * Manage the mouse inputs to control the movement of a free camera.
  18593. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18594. */
  18595. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18596. /**
  18597. * Define if touch is enabled in the mouse input
  18598. */
  18599. touchEnabled: boolean;
  18600. /**
  18601. * Defines the camera the input is attached to.
  18602. */
  18603. camera: FreeCamera;
  18604. /**
  18605. * Defines the buttons associated with the input to handle camera move.
  18606. */
  18607. buttons: number[];
  18608. /**
  18609. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18610. */
  18611. angularSensibility: number;
  18612. private _pointerInput;
  18613. private _onMouseMove;
  18614. private _observer;
  18615. private previousPosition;
  18616. /**
  18617. * Observable for when a pointer move event occurs containing the move offset
  18618. */
  18619. onPointerMovedObservable: Observable<{
  18620. offsetX: number;
  18621. offsetY: number;
  18622. }>;
  18623. /**
  18624. * @hidden
  18625. * If the camera should be rotated automatically based on pointer movement
  18626. */
  18627. _allowCameraRotation: boolean;
  18628. /**
  18629. * Manage the mouse inputs to control the movement of a free camera.
  18630. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18631. * @param touchEnabled Defines if touch is enabled or not
  18632. */
  18633. constructor(
  18634. /**
  18635. * Define if touch is enabled in the mouse input
  18636. */
  18637. touchEnabled?: boolean);
  18638. /**
  18639. * Attach the input controls to a specific dom element to get the input from.
  18640. * @param element Defines the element the controls should be listened from
  18641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18642. */
  18643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18644. /**
  18645. * Called on JS contextmenu event.
  18646. * Override this method to provide functionality.
  18647. */
  18648. protected onContextMenu(evt: PointerEvent): void;
  18649. /**
  18650. * Detach the current controls from the specified dom element.
  18651. * @param element Defines the element to stop listening the inputs from
  18652. */
  18653. detachControl(element: Nullable<HTMLElement>): void;
  18654. /**
  18655. * Gets the class name of the current intput.
  18656. * @returns the class name
  18657. */
  18658. getClassName(): string;
  18659. /**
  18660. * Get the friendly name associated with the input class.
  18661. * @returns the input friendly name
  18662. */
  18663. getSimpleName(): string;
  18664. }
  18665. }
  18666. declare module BABYLON {
  18667. /**
  18668. * Manage the touch inputs to control the movement of a free camera.
  18669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18670. */
  18671. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18672. /**
  18673. * Defines the camera the input is attached to.
  18674. */
  18675. camera: FreeCamera;
  18676. /**
  18677. * Defines the touch sensibility for rotation.
  18678. * The higher the faster.
  18679. */
  18680. touchAngularSensibility: number;
  18681. /**
  18682. * Defines the touch sensibility for move.
  18683. * The higher the faster.
  18684. */
  18685. touchMoveSensibility: number;
  18686. private _offsetX;
  18687. private _offsetY;
  18688. private _pointerPressed;
  18689. private _pointerInput;
  18690. private _observer;
  18691. private _onLostFocus;
  18692. /**
  18693. * Attach the input controls to a specific dom element to get the input from.
  18694. * @param element Defines the element the controls should be listened from
  18695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18696. */
  18697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18698. /**
  18699. * Detach the current controls from the specified dom element.
  18700. * @param element Defines the element to stop listening the inputs from
  18701. */
  18702. detachControl(element: Nullable<HTMLElement>): void;
  18703. /**
  18704. * Update the current camera state depending on the inputs that have been used this frame.
  18705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18706. */
  18707. checkInputs(): void;
  18708. /**
  18709. * Gets the class name of the current intput.
  18710. * @returns the class name
  18711. */
  18712. getClassName(): string;
  18713. /**
  18714. * Get the friendly name associated with the input class.
  18715. * @returns the input friendly name
  18716. */
  18717. getSimpleName(): string;
  18718. }
  18719. }
  18720. declare module BABYLON {
  18721. /**
  18722. * Default Inputs manager for the FreeCamera.
  18723. * It groups all the default supported inputs for ease of use.
  18724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18725. */
  18726. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18727. /**
  18728. * @hidden
  18729. */
  18730. _mouseInput: Nullable<FreeCameraMouseInput>;
  18731. /**
  18732. * Instantiates a new FreeCameraInputsManager.
  18733. * @param camera Defines the camera the inputs belong to
  18734. */
  18735. constructor(camera: FreeCamera);
  18736. /**
  18737. * Add keyboard input support to the input manager.
  18738. * @returns the current input manager
  18739. */
  18740. addKeyboard(): FreeCameraInputsManager;
  18741. /**
  18742. * Add mouse input support to the input manager.
  18743. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18744. * @returns the current input manager
  18745. */
  18746. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18747. /**
  18748. * Removes the mouse input support from the manager
  18749. * @returns the current input manager
  18750. */
  18751. removeMouse(): FreeCameraInputsManager;
  18752. /**
  18753. * Add touch input support to the input manager.
  18754. * @returns the current input manager
  18755. */
  18756. addTouch(): FreeCameraInputsManager;
  18757. /**
  18758. * Remove all attached input methods from a camera
  18759. */
  18760. clear(): void;
  18761. }
  18762. }
  18763. declare module BABYLON {
  18764. /**
  18765. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18766. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18767. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18768. */
  18769. export class FreeCamera extends TargetCamera {
  18770. /**
  18771. * Define the collision ellipsoid of the camera.
  18772. * This is helpful to simulate a camera body like the player body around the camera
  18773. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18774. */
  18775. ellipsoid: Vector3;
  18776. /**
  18777. * Define an offset for the position of the ellipsoid around the camera.
  18778. * This can be helpful to determine the center of the body near the gravity center of the body
  18779. * instead of its head.
  18780. */
  18781. ellipsoidOffset: Vector3;
  18782. /**
  18783. * Enable or disable collisions of the camera with the rest of the scene objects.
  18784. */
  18785. checkCollisions: boolean;
  18786. /**
  18787. * Enable or disable gravity on the camera.
  18788. */
  18789. applyGravity: boolean;
  18790. /**
  18791. * Define the input manager associated to the camera.
  18792. */
  18793. inputs: FreeCameraInputsManager;
  18794. /**
  18795. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18796. * Higher values reduce sensitivity.
  18797. */
  18798. get angularSensibility(): number;
  18799. /**
  18800. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18801. * Higher values reduce sensitivity.
  18802. */
  18803. set angularSensibility(value: number);
  18804. /**
  18805. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18806. */
  18807. get keysUp(): number[];
  18808. set keysUp(value: number[]);
  18809. /**
  18810. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18811. */
  18812. get keysUpward(): number[];
  18813. set keysUpward(value: number[]);
  18814. /**
  18815. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18816. */
  18817. get keysDown(): number[];
  18818. set keysDown(value: number[]);
  18819. /**
  18820. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18821. */
  18822. get keysDownward(): number[];
  18823. set keysDownward(value: number[]);
  18824. /**
  18825. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18826. */
  18827. get keysLeft(): number[];
  18828. set keysLeft(value: number[]);
  18829. /**
  18830. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18831. */
  18832. get keysRight(): number[];
  18833. set keysRight(value: number[]);
  18834. /**
  18835. * Event raised when the camera collide with a mesh in the scene.
  18836. */
  18837. onCollide: (collidedMesh: AbstractMesh) => void;
  18838. private _collider;
  18839. private _needMoveForGravity;
  18840. private _oldPosition;
  18841. private _diffPosition;
  18842. private _newPosition;
  18843. /** @hidden */
  18844. _localDirection: Vector3;
  18845. /** @hidden */
  18846. _transformedDirection: Vector3;
  18847. /**
  18848. * Instantiates a Free Camera.
  18849. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18850. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18851. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18852. * @param name Define the name of the camera in the scene
  18853. * @param position Define the start position of the camera in the scene
  18854. * @param scene Define the scene the camera belongs to
  18855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18856. */
  18857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18858. /**
  18859. * Attached controls to the current camera.
  18860. * @param element Defines the element the controls should be listened from
  18861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18862. */
  18863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18864. /**
  18865. * Detach the current controls from the camera.
  18866. * The camera will stop reacting to inputs.
  18867. * @param element Defines the element to stop listening the inputs from
  18868. */
  18869. detachControl(element: HTMLElement): void;
  18870. private _collisionMask;
  18871. /**
  18872. * Define a collision mask to limit the list of object the camera can collide with
  18873. */
  18874. get collisionMask(): number;
  18875. set collisionMask(mask: number);
  18876. /** @hidden */
  18877. _collideWithWorld(displacement: Vector3): void;
  18878. private _onCollisionPositionChange;
  18879. /** @hidden */
  18880. _checkInputs(): void;
  18881. /** @hidden */
  18882. _decideIfNeedsToMove(): boolean;
  18883. /** @hidden */
  18884. _updatePosition(): void;
  18885. /**
  18886. * Destroy the camera and release the current resources hold by it.
  18887. */
  18888. dispose(): void;
  18889. /**
  18890. * Gets the current object class name.
  18891. * @return the class name
  18892. */
  18893. getClassName(): string;
  18894. }
  18895. }
  18896. declare module BABYLON {
  18897. /**
  18898. * Represents a gamepad control stick position
  18899. */
  18900. export class StickValues {
  18901. /**
  18902. * The x component of the control stick
  18903. */
  18904. x: number;
  18905. /**
  18906. * The y component of the control stick
  18907. */
  18908. y: number;
  18909. /**
  18910. * Initializes the gamepad x and y control stick values
  18911. * @param x The x component of the gamepad control stick value
  18912. * @param y The y component of the gamepad control stick value
  18913. */
  18914. constructor(
  18915. /**
  18916. * The x component of the control stick
  18917. */
  18918. x: number,
  18919. /**
  18920. * The y component of the control stick
  18921. */
  18922. y: number);
  18923. }
  18924. /**
  18925. * An interface which manages callbacks for gamepad button changes
  18926. */
  18927. export interface GamepadButtonChanges {
  18928. /**
  18929. * Called when a gamepad has been changed
  18930. */
  18931. changed: boolean;
  18932. /**
  18933. * Called when a gamepad press event has been triggered
  18934. */
  18935. pressChanged: boolean;
  18936. /**
  18937. * Called when a touch event has been triggered
  18938. */
  18939. touchChanged: boolean;
  18940. /**
  18941. * Called when a value has changed
  18942. */
  18943. valueChanged: boolean;
  18944. }
  18945. /**
  18946. * Represents a gamepad
  18947. */
  18948. export class Gamepad {
  18949. /**
  18950. * The id of the gamepad
  18951. */
  18952. id: string;
  18953. /**
  18954. * The index of the gamepad
  18955. */
  18956. index: number;
  18957. /**
  18958. * The browser gamepad
  18959. */
  18960. browserGamepad: any;
  18961. /**
  18962. * Specifies what type of gamepad this represents
  18963. */
  18964. type: number;
  18965. private _leftStick;
  18966. private _rightStick;
  18967. /** @hidden */
  18968. _isConnected: boolean;
  18969. private _leftStickAxisX;
  18970. private _leftStickAxisY;
  18971. private _rightStickAxisX;
  18972. private _rightStickAxisY;
  18973. /**
  18974. * Triggered when the left control stick has been changed
  18975. */
  18976. private _onleftstickchanged;
  18977. /**
  18978. * Triggered when the right control stick has been changed
  18979. */
  18980. private _onrightstickchanged;
  18981. /**
  18982. * Represents a gamepad controller
  18983. */
  18984. static GAMEPAD: number;
  18985. /**
  18986. * Represents a generic controller
  18987. */
  18988. static GENERIC: number;
  18989. /**
  18990. * Represents an XBox controller
  18991. */
  18992. static XBOX: number;
  18993. /**
  18994. * Represents a pose-enabled controller
  18995. */
  18996. static POSE_ENABLED: number;
  18997. /**
  18998. * Represents an Dual Shock controller
  18999. */
  19000. static DUALSHOCK: number;
  19001. /**
  19002. * Specifies whether the left control stick should be Y-inverted
  19003. */
  19004. protected _invertLeftStickY: boolean;
  19005. /**
  19006. * Specifies if the gamepad has been connected
  19007. */
  19008. get isConnected(): boolean;
  19009. /**
  19010. * Initializes the gamepad
  19011. * @param id The id of the gamepad
  19012. * @param index The index of the gamepad
  19013. * @param browserGamepad The browser gamepad
  19014. * @param leftStickX The x component of the left joystick
  19015. * @param leftStickY The y component of the left joystick
  19016. * @param rightStickX The x component of the right joystick
  19017. * @param rightStickY The y component of the right joystick
  19018. */
  19019. constructor(
  19020. /**
  19021. * The id of the gamepad
  19022. */
  19023. id: string,
  19024. /**
  19025. * The index of the gamepad
  19026. */
  19027. index: number,
  19028. /**
  19029. * The browser gamepad
  19030. */
  19031. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19032. /**
  19033. * Callback triggered when the left joystick has changed
  19034. * @param callback
  19035. */
  19036. onleftstickchanged(callback: (values: StickValues) => void): void;
  19037. /**
  19038. * Callback triggered when the right joystick has changed
  19039. * @param callback
  19040. */
  19041. onrightstickchanged(callback: (values: StickValues) => void): void;
  19042. /**
  19043. * Gets the left joystick
  19044. */
  19045. get leftStick(): StickValues;
  19046. /**
  19047. * Sets the left joystick values
  19048. */
  19049. set leftStick(newValues: StickValues);
  19050. /**
  19051. * Gets the right joystick
  19052. */
  19053. get rightStick(): StickValues;
  19054. /**
  19055. * Sets the right joystick value
  19056. */
  19057. set rightStick(newValues: StickValues);
  19058. /**
  19059. * Updates the gamepad joystick positions
  19060. */
  19061. update(): void;
  19062. /**
  19063. * Disposes the gamepad
  19064. */
  19065. dispose(): void;
  19066. }
  19067. /**
  19068. * Represents a generic gamepad
  19069. */
  19070. export class GenericPad extends Gamepad {
  19071. private _buttons;
  19072. private _onbuttondown;
  19073. private _onbuttonup;
  19074. /**
  19075. * Observable triggered when a button has been pressed
  19076. */
  19077. onButtonDownObservable: Observable<number>;
  19078. /**
  19079. * Observable triggered when a button has been released
  19080. */
  19081. onButtonUpObservable: Observable<number>;
  19082. /**
  19083. * Callback triggered when a button has been pressed
  19084. * @param callback Called when a button has been pressed
  19085. */
  19086. onbuttondown(callback: (buttonPressed: number) => void): void;
  19087. /**
  19088. * Callback triggered when a button has been released
  19089. * @param callback Called when a button has been released
  19090. */
  19091. onbuttonup(callback: (buttonReleased: number) => void): void;
  19092. /**
  19093. * Initializes the generic gamepad
  19094. * @param id The id of the generic gamepad
  19095. * @param index The index of the generic gamepad
  19096. * @param browserGamepad The browser gamepad
  19097. */
  19098. constructor(id: string, index: number, browserGamepad: any);
  19099. private _setButtonValue;
  19100. /**
  19101. * Updates the generic gamepad
  19102. */
  19103. update(): void;
  19104. /**
  19105. * Disposes the generic gamepad
  19106. */
  19107. dispose(): void;
  19108. }
  19109. }
  19110. declare module BABYLON {
  19111. /**
  19112. * Defines the types of pose enabled controllers that are supported
  19113. */
  19114. export enum PoseEnabledControllerType {
  19115. /**
  19116. * HTC Vive
  19117. */
  19118. VIVE = 0,
  19119. /**
  19120. * Oculus Rift
  19121. */
  19122. OCULUS = 1,
  19123. /**
  19124. * Windows mixed reality
  19125. */
  19126. WINDOWS = 2,
  19127. /**
  19128. * Samsung gear VR
  19129. */
  19130. GEAR_VR = 3,
  19131. /**
  19132. * Google Daydream
  19133. */
  19134. DAYDREAM = 4,
  19135. /**
  19136. * Generic
  19137. */
  19138. GENERIC = 5
  19139. }
  19140. /**
  19141. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19142. */
  19143. export interface MutableGamepadButton {
  19144. /**
  19145. * Value of the button/trigger
  19146. */
  19147. value: number;
  19148. /**
  19149. * If the button/trigger is currently touched
  19150. */
  19151. touched: boolean;
  19152. /**
  19153. * If the button/trigger is currently pressed
  19154. */
  19155. pressed: boolean;
  19156. }
  19157. /**
  19158. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19159. * @hidden
  19160. */
  19161. export interface ExtendedGamepadButton extends GamepadButton {
  19162. /**
  19163. * If the button/trigger is currently pressed
  19164. */
  19165. readonly pressed: boolean;
  19166. /**
  19167. * If the button/trigger is currently touched
  19168. */
  19169. readonly touched: boolean;
  19170. /**
  19171. * Value of the button/trigger
  19172. */
  19173. readonly value: number;
  19174. }
  19175. /** @hidden */
  19176. export interface _GamePadFactory {
  19177. /**
  19178. * Returns whether or not the current gamepad can be created for this type of controller.
  19179. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19180. * @returns true if it can be created, otherwise false
  19181. */
  19182. canCreate(gamepadInfo: any): boolean;
  19183. /**
  19184. * Creates a new instance of the Gamepad.
  19185. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19186. * @returns the new gamepad instance
  19187. */
  19188. create(gamepadInfo: any): Gamepad;
  19189. }
  19190. /**
  19191. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19192. */
  19193. export class PoseEnabledControllerHelper {
  19194. /** @hidden */
  19195. static _ControllerFactories: _GamePadFactory[];
  19196. /** @hidden */
  19197. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19198. /**
  19199. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19200. * @param vrGamepad the gamepad to initialized
  19201. * @returns a vr controller of the type the gamepad identified as
  19202. */
  19203. static InitiateController(vrGamepad: any): Gamepad;
  19204. }
  19205. /**
  19206. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19207. */
  19208. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19209. /**
  19210. * If the controller is used in a webXR session
  19211. */
  19212. isXR: boolean;
  19213. private _deviceRoomPosition;
  19214. private _deviceRoomRotationQuaternion;
  19215. /**
  19216. * The device position in babylon space
  19217. */
  19218. devicePosition: Vector3;
  19219. /**
  19220. * The device rotation in babylon space
  19221. */
  19222. deviceRotationQuaternion: Quaternion;
  19223. /**
  19224. * The scale factor of the device in babylon space
  19225. */
  19226. deviceScaleFactor: number;
  19227. /**
  19228. * (Likely devicePosition should be used instead) The device position in its room space
  19229. */
  19230. position: Vector3;
  19231. /**
  19232. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19233. */
  19234. rotationQuaternion: Quaternion;
  19235. /**
  19236. * The type of controller (Eg. Windows mixed reality)
  19237. */
  19238. controllerType: PoseEnabledControllerType;
  19239. protected _calculatedPosition: Vector3;
  19240. private _calculatedRotation;
  19241. /**
  19242. * The raw pose from the device
  19243. */
  19244. rawPose: DevicePose;
  19245. private _trackPosition;
  19246. private _maxRotationDistFromHeadset;
  19247. private _draggedRoomRotation;
  19248. /**
  19249. * @hidden
  19250. */
  19251. _disableTrackPosition(fixedPosition: Vector3): void;
  19252. /**
  19253. * Internal, the mesh attached to the controller
  19254. * @hidden
  19255. */
  19256. _mesh: Nullable<AbstractMesh>;
  19257. private _poseControlledCamera;
  19258. private _leftHandSystemQuaternion;
  19259. /**
  19260. * Internal, matrix used to convert room space to babylon space
  19261. * @hidden
  19262. */
  19263. _deviceToWorld: Matrix;
  19264. /**
  19265. * Node to be used when casting a ray from the controller
  19266. * @hidden
  19267. */
  19268. _pointingPoseNode: Nullable<TransformNode>;
  19269. /**
  19270. * Name of the child mesh that can be used to cast a ray from the controller
  19271. */
  19272. static readonly POINTING_POSE: string;
  19273. /**
  19274. * Creates a new PoseEnabledController from a gamepad
  19275. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19276. */
  19277. constructor(browserGamepad: any);
  19278. private _workingMatrix;
  19279. /**
  19280. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19281. */
  19282. update(): void;
  19283. /**
  19284. * Updates only the pose device and mesh without doing any button event checking
  19285. */
  19286. protected _updatePoseAndMesh(): void;
  19287. /**
  19288. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19289. * @param poseData raw pose fromthe device
  19290. */
  19291. updateFromDevice(poseData: DevicePose): void;
  19292. /**
  19293. * @hidden
  19294. */
  19295. _meshAttachedObservable: Observable<AbstractMesh>;
  19296. /**
  19297. * Attaches a mesh to the controller
  19298. * @param mesh the mesh to be attached
  19299. */
  19300. attachToMesh(mesh: AbstractMesh): void;
  19301. /**
  19302. * Attaches the controllers mesh to a camera
  19303. * @param camera the camera the mesh should be attached to
  19304. */
  19305. attachToPoseControlledCamera(camera: TargetCamera): void;
  19306. /**
  19307. * Disposes of the controller
  19308. */
  19309. dispose(): void;
  19310. /**
  19311. * The mesh that is attached to the controller
  19312. */
  19313. get mesh(): Nullable<AbstractMesh>;
  19314. /**
  19315. * Gets the ray of the controller in the direction the controller is pointing
  19316. * @param length the length the resulting ray should be
  19317. * @returns a ray in the direction the controller is pointing
  19318. */
  19319. getForwardRay(length?: number): Ray;
  19320. }
  19321. }
  19322. declare module BABYLON {
  19323. /**
  19324. * Defines the WebVRController object that represents controllers tracked in 3D space
  19325. */
  19326. export abstract class WebVRController extends PoseEnabledController {
  19327. /**
  19328. * Internal, the default controller model for the controller
  19329. */
  19330. protected _defaultModel: Nullable<AbstractMesh>;
  19331. /**
  19332. * Fired when the trigger state has changed
  19333. */
  19334. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19335. /**
  19336. * Fired when the main button state has changed
  19337. */
  19338. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19339. /**
  19340. * Fired when the secondary button state has changed
  19341. */
  19342. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19343. /**
  19344. * Fired when the pad state has changed
  19345. */
  19346. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19347. /**
  19348. * Fired when controllers stick values have changed
  19349. */
  19350. onPadValuesChangedObservable: Observable<StickValues>;
  19351. /**
  19352. * Array of button availible on the controller
  19353. */
  19354. protected _buttons: Array<MutableGamepadButton>;
  19355. private _onButtonStateChange;
  19356. /**
  19357. * Fired when a controller button's state has changed
  19358. * @param callback the callback containing the button that was modified
  19359. */
  19360. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19361. /**
  19362. * X and Y axis corresponding to the controllers joystick
  19363. */
  19364. pad: StickValues;
  19365. /**
  19366. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19367. */
  19368. hand: string;
  19369. /**
  19370. * The default controller model for the controller
  19371. */
  19372. get defaultModel(): Nullable<AbstractMesh>;
  19373. /**
  19374. * Creates a new WebVRController from a gamepad
  19375. * @param vrGamepad the gamepad that the WebVRController should be created from
  19376. */
  19377. constructor(vrGamepad: any);
  19378. /**
  19379. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19380. */
  19381. update(): void;
  19382. /**
  19383. * Function to be called when a button is modified
  19384. */
  19385. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19386. /**
  19387. * Loads a mesh and attaches it to the controller
  19388. * @param scene the scene the mesh should be added to
  19389. * @param meshLoaded callback for when the mesh has been loaded
  19390. */
  19391. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19392. private _setButtonValue;
  19393. private _changes;
  19394. private _checkChanges;
  19395. /**
  19396. * Disposes of th webVRCOntroller
  19397. */
  19398. dispose(): void;
  19399. }
  19400. }
  19401. declare module BABYLON {
  19402. /**
  19403. * The HemisphericLight simulates the ambient environment light,
  19404. * so the passed direction is the light reflection direction, not the incoming direction.
  19405. */
  19406. export class HemisphericLight extends Light {
  19407. /**
  19408. * The groundColor is the light in the opposite direction to the one specified during creation.
  19409. * 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.
  19410. */
  19411. groundColor: Color3;
  19412. /**
  19413. * The light reflection direction, not the incoming direction.
  19414. */
  19415. direction: Vector3;
  19416. /**
  19417. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19418. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19419. * The HemisphericLight can't cast shadows.
  19420. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19421. * @param name The friendly name of the light
  19422. * @param direction The direction of the light reflection
  19423. * @param scene The scene the light belongs to
  19424. */
  19425. constructor(name: string, direction: Vector3, scene: Scene);
  19426. protected _buildUniformLayout(): void;
  19427. /**
  19428. * Returns the string "HemisphericLight".
  19429. * @return The class name
  19430. */
  19431. getClassName(): string;
  19432. /**
  19433. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19434. * Returns the updated direction.
  19435. * @param target The target the direction should point to
  19436. * @return The computed direction
  19437. */
  19438. setDirectionToTarget(target: Vector3): Vector3;
  19439. /**
  19440. * Returns the shadow generator associated to the light.
  19441. * @returns Always null for hemispheric lights because it does not support shadows.
  19442. */
  19443. getShadowGenerator(): Nullable<IShadowGenerator>;
  19444. /**
  19445. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19446. * @param effect The effect to update
  19447. * @param lightIndex The index of the light in the effect to update
  19448. * @returns The hemispheric light
  19449. */
  19450. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19451. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19452. /**
  19453. * Computes the world matrix of the node
  19454. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19455. * @param useWasUpdatedFlag defines a reserved property
  19456. * @returns the world matrix
  19457. */
  19458. computeWorldMatrix(): Matrix;
  19459. /**
  19460. * Returns the integer 3.
  19461. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19462. */
  19463. getTypeID(): number;
  19464. /**
  19465. * Prepares the list of defines specific to the light type.
  19466. * @param defines the list of defines
  19467. * @param lightIndex defines the index of the light for the effect
  19468. */
  19469. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19470. }
  19471. }
  19472. declare module BABYLON {
  19473. /** @hidden */
  19474. export var vrMultiviewToSingleviewPixelShader: {
  19475. name: string;
  19476. shader: string;
  19477. };
  19478. }
  19479. declare module BABYLON {
  19480. /**
  19481. * Renders to multiple views with a single draw call
  19482. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19483. */
  19484. export class MultiviewRenderTarget extends RenderTargetTexture {
  19485. /**
  19486. * Creates a multiview render target
  19487. * @param scene scene used with the render target
  19488. * @param size the size of the render target (used for each view)
  19489. */
  19490. constructor(scene: Scene, size?: number | {
  19491. width: number;
  19492. height: number;
  19493. } | {
  19494. ratio: number;
  19495. });
  19496. /**
  19497. * @hidden
  19498. * @param faceIndex the face index, if its a cube texture
  19499. */
  19500. _bindFrameBuffer(faceIndex?: number): void;
  19501. /**
  19502. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19503. * @returns the view count
  19504. */
  19505. getViewCount(): number;
  19506. }
  19507. }
  19508. declare module BABYLON {
  19509. interface Engine {
  19510. /**
  19511. * Creates a new multiview render target
  19512. * @param width defines the width of the texture
  19513. * @param height defines the height of the texture
  19514. * @returns the created multiview texture
  19515. */
  19516. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19517. /**
  19518. * Binds a multiview framebuffer to be drawn to
  19519. * @param multiviewTexture texture to bind
  19520. */
  19521. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19522. }
  19523. interface Camera {
  19524. /**
  19525. * @hidden
  19526. * 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)
  19527. */
  19528. _useMultiviewToSingleView: boolean;
  19529. /**
  19530. * @hidden
  19531. * 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)
  19532. */
  19533. _multiviewTexture: Nullable<RenderTargetTexture>;
  19534. /**
  19535. * @hidden
  19536. * ensures the multiview texture of the camera exists and has the specified width/height
  19537. * @param width height to set on the multiview texture
  19538. * @param height width to set on the multiview texture
  19539. */
  19540. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19541. }
  19542. interface Scene {
  19543. /** @hidden */
  19544. _transformMatrixR: Matrix;
  19545. /** @hidden */
  19546. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19547. /** @hidden */
  19548. _createMultiviewUbo(): void;
  19549. /** @hidden */
  19550. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19551. /** @hidden */
  19552. _renderMultiviewToSingleView(camera: Camera): void;
  19553. }
  19554. }
  19555. declare module BABYLON {
  19556. /**
  19557. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19558. * This will not be used for webXR as it supports displaying texture arrays directly
  19559. */
  19560. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19561. /**
  19562. * Initializes a VRMultiviewToSingleview
  19563. * @param name name of the post process
  19564. * @param camera camera to be applied to
  19565. * @param scaleFactor scaling factor to the size of the output texture
  19566. */
  19567. constructor(name: string, camera: Camera, scaleFactor: number);
  19568. }
  19569. }
  19570. declare module BABYLON {
  19571. /**
  19572. * Interface used to define additional presentation attributes
  19573. */
  19574. export interface IVRPresentationAttributes {
  19575. /**
  19576. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19577. */
  19578. highRefreshRate: boolean;
  19579. /**
  19580. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19581. */
  19582. foveationLevel: number;
  19583. }
  19584. interface Engine {
  19585. /** @hidden */
  19586. _vrDisplay: any;
  19587. /** @hidden */
  19588. _vrSupported: boolean;
  19589. /** @hidden */
  19590. _oldSize: Size;
  19591. /** @hidden */
  19592. _oldHardwareScaleFactor: number;
  19593. /** @hidden */
  19594. _vrExclusivePointerMode: boolean;
  19595. /** @hidden */
  19596. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19597. /** @hidden */
  19598. _onVRDisplayPointerRestricted: () => void;
  19599. /** @hidden */
  19600. _onVRDisplayPointerUnrestricted: () => void;
  19601. /** @hidden */
  19602. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19603. /** @hidden */
  19604. _onVrDisplayDisconnect: Nullable<() => void>;
  19605. /** @hidden */
  19606. _onVrDisplayPresentChange: Nullable<() => void>;
  19607. /**
  19608. * Observable signaled when VR display mode changes
  19609. */
  19610. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19611. /**
  19612. * Observable signaled when VR request present is complete
  19613. */
  19614. onVRRequestPresentComplete: Observable<boolean>;
  19615. /**
  19616. * Observable signaled when VR request present starts
  19617. */
  19618. onVRRequestPresentStart: Observable<Engine>;
  19619. /**
  19620. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19621. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19622. */
  19623. isInVRExclusivePointerMode: boolean;
  19624. /**
  19625. * Gets a boolean indicating if a webVR device was detected
  19626. * @returns true if a webVR device was detected
  19627. */
  19628. isVRDevicePresent(): boolean;
  19629. /**
  19630. * Gets the current webVR device
  19631. * @returns the current webVR device (or null)
  19632. */
  19633. getVRDevice(): any;
  19634. /**
  19635. * Initializes a webVR display and starts listening to display change events
  19636. * The onVRDisplayChangedObservable will be notified upon these changes
  19637. * @returns A promise containing a VRDisplay and if vr is supported
  19638. */
  19639. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19640. /** @hidden */
  19641. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19642. /**
  19643. * Gets or sets the presentation attributes used to configure VR rendering
  19644. */
  19645. vrPresentationAttributes?: IVRPresentationAttributes;
  19646. /**
  19647. * Call this function to switch to webVR mode
  19648. * Will do nothing if webVR is not supported or if there is no webVR device
  19649. * @param options the webvr options provided to the camera. mainly used for multiview
  19650. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19651. */
  19652. enableVR(options: WebVROptions): void;
  19653. /** @hidden */
  19654. _onVRFullScreenTriggered(): void;
  19655. }
  19656. }
  19657. declare module BABYLON {
  19658. /**
  19659. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19660. * IMPORTANT!! The data is right-hand data.
  19661. * @export
  19662. * @interface DevicePose
  19663. */
  19664. export interface DevicePose {
  19665. /**
  19666. * The position of the device, values in array are [x,y,z].
  19667. */
  19668. readonly position: Nullable<Float32Array>;
  19669. /**
  19670. * The linearVelocity of the device, values in array are [x,y,z].
  19671. */
  19672. readonly linearVelocity: Nullable<Float32Array>;
  19673. /**
  19674. * The linearAcceleration of the device, values in array are [x,y,z].
  19675. */
  19676. readonly linearAcceleration: Nullable<Float32Array>;
  19677. /**
  19678. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19679. */
  19680. readonly orientation: Nullable<Float32Array>;
  19681. /**
  19682. * The angularVelocity of the device, values in array are [x,y,z].
  19683. */
  19684. readonly angularVelocity: Nullable<Float32Array>;
  19685. /**
  19686. * The angularAcceleration of the device, values in array are [x,y,z].
  19687. */
  19688. readonly angularAcceleration: Nullable<Float32Array>;
  19689. }
  19690. /**
  19691. * Interface representing a pose controlled object in Babylon.
  19692. * A pose controlled object has both regular pose values as well as pose values
  19693. * from an external device such as a VR head mounted display
  19694. */
  19695. export interface PoseControlled {
  19696. /**
  19697. * The position of the object in babylon space.
  19698. */
  19699. position: Vector3;
  19700. /**
  19701. * The rotation quaternion of the object in babylon space.
  19702. */
  19703. rotationQuaternion: Quaternion;
  19704. /**
  19705. * The position of the device in babylon space.
  19706. */
  19707. devicePosition?: Vector3;
  19708. /**
  19709. * The rotation quaternion of the device in babylon space.
  19710. */
  19711. deviceRotationQuaternion: Quaternion;
  19712. /**
  19713. * The raw pose coming from the device.
  19714. */
  19715. rawPose: Nullable<DevicePose>;
  19716. /**
  19717. * The scale of the device to be used when translating from device space to babylon space.
  19718. */
  19719. deviceScaleFactor: number;
  19720. /**
  19721. * Updates the poseControlled values based on the input device pose.
  19722. * @param poseData the pose data to update the object with
  19723. */
  19724. updateFromDevice(poseData: DevicePose): void;
  19725. }
  19726. /**
  19727. * Set of options to customize the webVRCamera
  19728. */
  19729. export interface WebVROptions {
  19730. /**
  19731. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19732. */
  19733. trackPosition?: boolean;
  19734. /**
  19735. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19736. */
  19737. positionScale?: number;
  19738. /**
  19739. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19740. */
  19741. displayName?: string;
  19742. /**
  19743. * Should the native controller meshes be initialized. (default: true)
  19744. */
  19745. controllerMeshes?: boolean;
  19746. /**
  19747. * Creating a default HemiLight only on controllers. (default: true)
  19748. */
  19749. defaultLightingOnControllers?: boolean;
  19750. /**
  19751. * If you don't want to use the default VR button of the helper. (default: false)
  19752. */
  19753. useCustomVRButton?: boolean;
  19754. /**
  19755. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19756. */
  19757. customVRButton?: HTMLButtonElement;
  19758. /**
  19759. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19760. */
  19761. rayLength?: number;
  19762. /**
  19763. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19764. */
  19765. defaultHeight?: number;
  19766. /**
  19767. * If multiview should be used if availible (default: false)
  19768. */
  19769. useMultiview?: boolean;
  19770. }
  19771. /**
  19772. * This represents a WebVR camera.
  19773. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19774. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19775. */
  19776. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19777. private webVROptions;
  19778. /**
  19779. * @hidden
  19780. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19781. */
  19782. _vrDevice: any;
  19783. /**
  19784. * The rawPose of the vrDevice.
  19785. */
  19786. rawPose: Nullable<DevicePose>;
  19787. private _onVREnabled;
  19788. private _specsVersion;
  19789. private _attached;
  19790. private _frameData;
  19791. protected _descendants: Array<Node>;
  19792. private _deviceRoomPosition;
  19793. /** @hidden */
  19794. _deviceRoomRotationQuaternion: Quaternion;
  19795. private _standingMatrix;
  19796. /**
  19797. * Represents device position in babylon space.
  19798. */
  19799. devicePosition: Vector3;
  19800. /**
  19801. * Represents device rotation in babylon space.
  19802. */
  19803. deviceRotationQuaternion: Quaternion;
  19804. /**
  19805. * The scale of the device to be used when translating from device space to babylon space.
  19806. */
  19807. deviceScaleFactor: number;
  19808. private _deviceToWorld;
  19809. private _worldToDevice;
  19810. /**
  19811. * References to the webVR controllers for the vrDevice.
  19812. */
  19813. controllers: Array<WebVRController>;
  19814. /**
  19815. * Emits an event when a controller is attached.
  19816. */
  19817. onControllersAttachedObservable: Observable<WebVRController[]>;
  19818. /**
  19819. * Emits an event when a controller's mesh has been loaded;
  19820. */
  19821. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19822. /**
  19823. * Emits an event when the HMD's pose has been updated.
  19824. */
  19825. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19826. private _poseSet;
  19827. /**
  19828. * If the rig cameras be used as parent instead of this camera.
  19829. */
  19830. rigParenting: boolean;
  19831. private _lightOnControllers;
  19832. private _defaultHeight?;
  19833. /**
  19834. * Instantiates a WebVRFreeCamera.
  19835. * @param name The name of the WebVRFreeCamera
  19836. * @param position The starting anchor position for the camera
  19837. * @param scene The scene the camera belongs to
  19838. * @param webVROptions a set of customizable options for the webVRCamera
  19839. */
  19840. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19841. /**
  19842. * Gets the device distance from the ground in meters.
  19843. * @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.
  19844. */
  19845. deviceDistanceToRoomGround(): number;
  19846. /**
  19847. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19848. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19849. */
  19850. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19851. /**
  19852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19853. * @returns A promise with a boolean set to if the standing matrix is supported.
  19854. */
  19855. useStandingMatrixAsync(): Promise<boolean>;
  19856. /**
  19857. * Disposes the camera
  19858. */
  19859. dispose(): void;
  19860. /**
  19861. * Gets a vrController by name.
  19862. * @param name The name of the controller to retreive
  19863. * @returns the controller matching the name specified or null if not found
  19864. */
  19865. getControllerByName(name: string): Nullable<WebVRController>;
  19866. private _leftController;
  19867. /**
  19868. * The controller corresponding to the users left hand.
  19869. */
  19870. get leftController(): Nullable<WebVRController>;
  19871. private _rightController;
  19872. /**
  19873. * The controller corresponding to the users right hand.
  19874. */
  19875. get rightController(): Nullable<WebVRController>;
  19876. /**
  19877. * Casts a ray forward from the vrCamera's gaze.
  19878. * @param length Length of the ray (default: 100)
  19879. * @returns the ray corresponding to the gaze
  19880. */
  19881. getForwardRay(length?: number): Ray;
  19882. /**
  19883. * @hidden
  19884. * Updates the camera based on device's frame data
  19885. */
  19886. _checkInputs(): void;
  19887. /**
  19888. * Updates the poseControlled values based on the input device pose.
  19889. * @param poseData Pose coming from the device
  19890. */
  19891. updateFromDevice(poseData: DevicePose): void;
  19892. private _htmlElementAttached;
  19893. private _detachIfAttached;
  19894. /**
  19895. * WebVR's attach control will start broadcasting frames to the device.
  19896. * Note that in certain browsers (chrome for example) this function must be called
  19897. * within a user-interaction callback. Example:
  19898. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19899. *
  19900. * @param element html element to attach the vrDevice to
  19901. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19902. */
  19903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19904. /**
  19905. * Detaches the camera from the html element and disables VR
  19906. *
  19907. * @param element html element to detach from
  19908. */
  19909. detachControl(element: HTMLElement): void;
  19910. /**
  19911. * @returns the name of this class
  19912. */
  19913. getClassName(): string;
  19914. /**
  19915. * Calls resetPose on the vrDisplay
  19916. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19917. */
  19918. resetToCurrentRotation(): void;
  19919. /**
  19920. * @hidden
  19921. * Updates the rig cameras (left and right eye)
  19922. */
  19923. _updateRigCameras(): void;
  19924. private _workingVector;
  19925. private _oneVector;
  19926. private _workingMatrix;
  19927. private updateCacheCalled;
  19928. private _correctPositionIfNotTrackPosition;
  19929. /**
  19930. * @hidden
  19931. * Updates the cached values of the camera
  19932. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19933. */
  19934. _updateCache(ignoreParentClass?: boolean): void;
  19935. /**
  19936. * @hidden
  19937. * Get current device position in babylon world
  19938. */
  19939. _computeDevicePosition(): void;
  19940. /**
  19941. * Updates the current device position and rotation in the babylon world
  19942. */
  19943. update(): void;
  19944. /**
  19945. * @hidden
  19946. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19947. * @returns an identity matrix
  19948. */
  19949. _getViewMatrix(): Matrix;
  19950. private _tmpMatrix;
  19951. /**
  19952. * This function is called by the two RIG cameras.
  19953. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19954. * @hidden
  19955. */
  19956. _getWebVRViewMatrix(): Matrix;
  19957. /** @hidden */
  19958. _getWebVRProjectionMatrix(): Matrix;
  19959. private _onGamepadConnectedObserver;
  19960. private _onGamepadDisconnectedObserver;
  19961. private _updateCacheWhenTrackingDisabledObserver;
  19962. /**
  19963. * Initializes the controllers and their meshes
  19964. */
  19965. initControllers(): void;
  19966. }
  19967. }
  19968. declare module BABYLON {
  19969. /**
  19970. * "Static Class" containing the most commonly used helper while dealing with material for
  19971. * rendering purpose.
  19972. *
  19973. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19974. *
  19975. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19976. */
  19977. export class MaterialHelper {
  19978. /**
  19979. * Bind the current view position to an effect.
  19980. * @param effect The effect to be bound
  19981. * @param scene The scene the eyes position is used from
  19982. * @param variableName name of the shader variable that will hold the eye position
  19983. */
  19984. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19985. /**
  19986. * Helps preparing the defines values about the UVs in used in the effect.
  19987. * UVs are shared as much as we can accross channels in the shaders.
  19988. * @param texture The texture we are preparing the UVs for
  19989. * @param defines The defines to update
  19990. * @param key The channel key "diffuse", "specular"... used in the shader
  19991. */
  19992. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19993. /**
  19994. * Binds a texture matrix value to its corrsponding uniform
  19995. * @param texture The texture to bind the matrix for
  19996. * @param uniformBuffer The uniform buffer receivin the data
  19997. * @param key The channel key "diffuse", "specular"... used in the shader
  19998. */
  19999. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20000. /**
  20001. * Gets the current status of the fog (should it be enabled?)
  20002. * @param mesh defines the mesh to evaluate for fog support
  20003. * @param scene defines the hosting scene
  20004. * @returns true if fog must be enabled
  20005. */
  20006. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20007. /**
  20008. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20009. * @param mesh defines the current mesh
  20010. * @param scene defines the current scene
  20011. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20012. * @param pointsCloud defines if point cloud rendering has to be turned on
  20013. * @param fogEnabled defines if fog has to be turned on
  20014. * @param alphaTest defines if alpha testing has to be turned on
  20015. * @param defines defines the current list of defines
  20016. */
  20017. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20018. /**
  20019. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20020. * @param scene defines the current scene
  20021. * @param engine defines the current engine
  20022. * @param defines specifies the list of active defines
  20023. * @param useInstances defines if instances have to be turned on
  20024. * @param useClipPlane defines if clip plane have to be turned on
  20025. * @param useInstances defines if instances have to be turned on
  20026. * @param useThinInstances defines if thin instances have to be turned on
  20027. */
  20028. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20029. /**
  20030. * Prepares the defines for bones
  20031. * @param mesh The mesh containing the geometry data we will draw
  20032. * @param defines The defines to update
  20033. */
  20034. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20035. /**
  20036. * Prepares the defines for morph targets
  20037. * @param mesh The mesh containing the geometry data we will draw
  20038. * @param defines The defines to update
  20039. */
  20040. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20041. /**
  20042. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20043. * @param mesh The mesh containing the geometry data we will draw
  20044. * @param defines The defines to update
  20045. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20046. * @param useBones Precise whether bones should be used or not (override mesh info)
  20047. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20048. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20049. * @returns false if defines are considered not dirty and have not been checked
  20050. */
  20051. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20052. /**
  20053. * Prepares the defines related to multiview
  20054. * @param scene The scene we are intending to draw
  20055. * @param defines The defines to update
  20056. */
  20057. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20058. /**
  20059. * Prepares the defines related to the prepass
  20060. * @param scene The scene we are intending to draw
  20061. * @param defines The defines to update
  20062. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20063. */
  20064. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20065. /**
  20066. * Prepares the defines related to the light information passed in parameter
  20067. * @param scene The scene we are intending to draw
  20068. * @param mesh The mesh the effect is compiling for
  20069. * @param light The light the effect is compiling for
  20070. * @param lightIndex The index of the light
  20071. * @param defines The defines to update
  20072. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20073. * @param state Defines the current state regarding what is needed (normals, etc...)
  20074. */
  20075. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20076. needNormals: boolean;
  20077. needRebuild: boolean;
  20078. shadowEnabled: boolean;
  20079. specularEnabled: boolean;
  20080. lightmapMode: boolean;
  20081. }): void;
  20082. /**
  20083. * Prepares the defines related to the light information passed in parameter
  20084. * @param scene The scene we are intending to draw
  20085. * @param mesh The mesh the effect is compiling for
  20086. * @param defines The defines to update
  20087. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20088. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20089. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20090. * @returns true if normals will be required for the rest of the effect
  20091. */
  20092. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20093. /**
  20094. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20095. * @param lightIndex defines the light index
  20096. * @param uniformsList The uniform list
  20097. * @param samplersList The sampler list
  20098. * @param projectedLightTexture defines if projected texture must be used
  20099. * @param uniformBuffersList defines an optional list of uniform buffers
  20100. */
  20101. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20102. /**
  20103. * Prepares the uniforms and samplers list to be used in the effect
  20104. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20105. * @param samplersList The sampler list
  20106. * @param defines The defines helping in the list generation
  20107. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20108. */
  20109. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20110. /**
  20111. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20112. * @param defines The defines to update while falling back
  20113. * @param fallbacks The authorized effect fallbacks
  20114. * @param maxSimultaneousLights The maximum number of lights allowed
  20115. * @param rank the current rank of the Effect
  20116. * @returns The newly affected rank
  20117. */
  20118. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20119. private static _TmpMorphInfluencers;
  20120. /**
  20121. * Prepares the list of attributes required for morph targets according to the effect defines.
  20122. * @param attribs The current list of supported attribs
  20123. * @param mesh The mesh to prepare the morph targets attributes for
  20124. * @param influencers The number of influencers
  20125. */
  20126. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20127. /**
  20128. * Prepares the list of attributes required for morph targets according to the effect defines.
  20129. * @param attribs The current list of supported attribs
  20130. * @param mesh The mesh to prepare the morph targets attributes for
  20131. * @param defines The current Defines of the effect
  20132. */
  20133. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20134. /**
  20135. * Prepares the list of attributes required for bones according to the effect defines.
  20136. * @param attribs The current list of supported attribs
  20137. * @param mesh The mesh to prepare the bones attributes for
  20138. * @param defines The current Defines of the effect
  20139. * @param fallbacks The current efffect fallback strategy
  20140. */
  20141. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20142. /**
  20143. * Check and prepare the list of attributes required for instances according to the effect defines.
  20144. * @param attribs The current list of supported attribs
  20145. * @param defines The current MaterialDefines of the effect
  20146. */
  20147. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20148. /**
  20149. * Add the list of attributes required for instances to the attribs array.
  20150. * @param attribs The current list of supported attribs
  20151. */
  20152. static PushAttributesForInstances(attribs: string[]): void;
  20153. /**
  20154. * Binds the light information to the effect.
  20155. * @param light The light containing the generator
  20156. * @param effect The effect we are binding the data to
  20157. * @param lightIndex The light index in the effect used to render
  20158. */
  20159. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20160. /**
  20161. * Binds the lights information from the scene to the effect for the given mesh.
  20162. * @param light Light to bind
  20163. * @param lightIndex Light index
  20164. * @param scene The scene where the light belongs to
  20165. * @param effect The effect we are binding the data to
  20166. * @param useSpecular Defines if specular is supported
  20167. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20168. */
  20169. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20170. /**
  20171. * Binds the lights information from the scene to the effect for the given mesh.
  20172. * @param scene The scene the lights belongs to
  20173. * @param mesh The mesh we are binding the information to render
  20174. * @param effect The effect we are binding the data to
  20175. * @param defines The generated defines for the effect
  20176. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20177. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20178. */
  20179. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20180. private static _tempFogColor;
  20181. /**
  20182. * Binds the fog information from the scene to the effect for the given mesh.
  20183. * @param scene The scene the lights belongs to
  20184. * @param mesh The mesh we are binding the information to render
  20185. * @param effect The effect we are binding the data to
  20186. * @param linearSpace Defines if the fog effect is applied in linear space
  20187. */
  20188. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20189. /**
  20190. * Binds the bones information from the mesh to the effect.
  20191. * @param mesh The mesh we are binding the information to render
  20192. * @param effect The effect we are binding the data to
  20193. */
  20194. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20195. /**
  20196. * Binds the morph targets information from the mesh to the effect.
  20197. * @param abstractMesh The mesh we are binding the information to render
  20198. * @param effect The effect we are binding the data to
  20199. */
  20200. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20201. /**
  20202. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20203. * @param defines The generated defines used in the effect
  20204. * @param effect The effect we are binding the data to
  20205. * @param scene The scene we are willing to render with logarithmic scale for
  20206. */
  20207. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20208. /**
  20209. * Binds the clip plane information from the scene to the effect.
  20210. * @param scene The scene the clip plane information are extracted from
  20211. * @param effect The effect we are binding the data to
  20212. */
  20213. static BindClipPlane(effect: Effect, scene: Scene): void;
  20214. }
  20215. }
  20216. declare module BABYLON {
  20217. /**
  20218. * Block used to expose an input value
  20219. */
  20220. export class InputBlock extends NodeMaterialBlock {
  20221. private _mode;
  20222. private _associatedVariableName;
  20223. private _storedValue;
  20224. private _valueCallback;
  20225. private _type;
  20226. private _animationType;
  20227. /** Gets or set a value used to limit the range of float values */
  20228. min: number;
  20229. /** Gets or set a value used to limit the range of float values */
  20230. max: number;
  20231. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20232. isBoolean: boolean;
  20233. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20234. matrixMode: number;
  20235. /** @hidden */
  20236. _systemValue: Nullable<NodeMaterialSystemValues>;
  20237. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20238. visibleInInspector: boolean;
  20239. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20240. isConstant: boolean;
  20241. /** Gets or sets the group to use to display this block in the Inspector */
  20242. groupInInspector: string;
  20243. /** Gets an observable raised when the value is changed */
  20244. onValueChangedObservable: Observable<InputBlock>;
  20245. /**
  20246. * Gets or sets the connection point type (default is float)
  20247. */
  20248. get type(): NodeMaterialBlockConnectionPointTypes;
  20249. /**
  20250. * Creates a new InputBlock
  20251. * @param name defines the block name
  20252. * @param target defines the target of that block (Vertex by default)
  20253. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20254. */
  20255. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20256. /**
  20257. * Validates if a name is a reserve word.
  20258. * @param newName the new name to be given to the node.
  20259. * @returns false if the name is a reserve word, else true.
  20260. */
  20261. validateBlockName(newName: string): boolean;
  20262. /**
  20263. * Gets the output component
  20264. */
  20265. get output(): NodeMaterialConnectionPoint;
  20266. /**
  20267. * Set the source of this connection point to a vertex attribute
  20268. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20269. * @returns the current connection point
  20270. */
  20271. setAsAttribute(attributeName?: string): InputBlock;
  20272. /**
  20273. * Set the source of this connection point to a system value
  20274. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20275. * @returns the current connection point
  20276. */
  20277. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20278. /**
  20279. * Gets or sets the value of that point.
  20280. * Please note that this value will be ignored if valueCallback is defined
  20281. */
  20282. get value(): any;
  20283. set value(value: any);
  20284. /**
  20285. * Gets or sets a callback used to get the value of that point.
  20286. * Please note that setting this value will force the connection point to ignore the value property
  20287. */
  20288. get valueCallback(): () => any;
  20289. set valueCallback(value: () => any);
  20290. /**
  20291. * Gets or sets the associated variable name in the shader
  20292. */
  20293. get associatedVariableName(): string;
  20294. set associatedVariableName(value: string);
  20295. /** Gets or sets the type of animation applied to the input */
  20296. get animationType(): AnimatedInputBlockTypes;
  20297. set animationType(value: AnimatedInputBlockTypes);
  20298. /**
  20299. * Gets a boolean indicating that this connection point not defined yet
  20300. */
  20301. get isUndefined(): boolean;
  20302. /**
  20303. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20304. * In this case the connection point name must be the name of the uniform to use.
  20305. * Can only be set on inputs
  20306. */
  20307. get isUniform(): boolean;
  20308. set isUniform(value: boolean);
  20309. /**
  20310. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20311. * In this case the connection point name must be the name of the attribute to use
  20312. * Can only be set on inputs
  20313. */
  20314. get isAttribute(): boolean;
  20315. set isAttribute(value: boolean);
  20316. /**
  20317. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20318. * Can only be set on exit points
  20319. */
  20320. get isVarying(): boolean;
  20321. set isVarying(value: boolean);
  20322. /**
  20323. * Gets a boolean indicating that the current connection point is a system value
  20324. */
  20325. get isSystemValue(): boolean;
  20326. /**
  20327. * Gets or sets the current well known value or null if not defined as a system value
  20328. */
  20329. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20330. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20331. /**
  20332. * Gets the current class name
  20333. * @returns the class name
  20334. */
  20335. getClassName(): string;
  20336. /**
  20337. * Animate the input if animationType !== None
  20338. * @param scene defines the rendering scene
  20339. */
  20340. animate(scene: Scene): void;
  20341. private _emitDefine;
  20342. initialize(state: NodeMaterialBuildState): void;
  20343. /**
  20344. * Set the input block to its default value (based on its type)
  20345. */
  20346. setDefaultValue(): void;
  20347. private _emitConstant;
  20348. /** @hidden */
  20349. get _noContextSwitch(): boolean;
  20350. private _emit;
  20351. /** @hidden */
  20352. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20353. /** @hidden */
  20354. _transmit(effect: Effect, scene: Scene): void;
  20355. protected _buildBlock(state: NodeMaterialBuildState): void;
  20356. protected _dumpPropertiesCode(): string;
  20357. dispose(): void;
  20358. serialize(): any;
  20359. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20360. }
  20361. }
  20362. declare module BABYLON {
  20363. /**
  20364. * Enum used to define the compatibility state between two connection points
  20365. */
  20366. export enum NodeMaterialConnectionPointCompatibilityStates {
  20367. /** Points are compatibles */
  20368. Compatible = 0,
  20369. /** Points are incompatible because of their types */
  20370. TypeIncompatible = 1,
  20371. /** Points are incompatible because of their targets (vertex vs fragment) */
  20372. TargetIncompatible = 2
  20373. }
  20374. /**
  20375. * Defines the direction of a connection point
  20376. */
  20377. export enum NodeMaterialConnectionPointDirection {
  20378. /** Input */
  20379. Input = 0,
  20380. /** Output */
  20381. Output = 1
  20382. }
  20383. /**
  20384. * Defines a connection point for a block
  20385. */
  20386. export class NodeMaterialConnectionPoint {
  20387. /** @hidden */
  20388. _ownerBlock: NodeMaterialBlock;
  20389. /** @hidden */
  20390. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20391. private _endpoints;
  20392. private _associatedVariableName;
  20393. private _direction;
  20394. /** @hidden */
  20395. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20396. /** @hidden */
  20397. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20398. private _type;
  20399. /** @hidden */
  20400. _enforceAssociatedVariableName: boolean;
  20401. /** Gets the direction of the point */
  20402. get direction(): NodeMaterialConnectionPointDirection;
  20403. /** Indicates that this connection point needs dual validation before being connected to another point */
  20404. needDualDirectionValidation: boolean;
  20405. /**
  20406. * Gets or sets the additional types supported by this connection point
  20407. */
  20408. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20409. /**
  20410. * Gets or sets the additional types excluded by this connection point
  20411. */
  20412. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20413. /**
  20414. * Observable triggered when this point is connected
  20415. */
  20416. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20417. /**
  20418. * Gets or sets the associated variable name in the shader
  20419. */
  20420. get associatedVariableName(): string;
  20421. set associatedVariableName(value: string);
  20422. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20423. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20424. /**
  20425. * Gets or sets the connection point type (default is float)
  20426. */
  20427. get type(): NodeMaterialBlockConnectionPointTypes;
  20428. set type(value: NodeMaterialBlockConnectionPointTypes);
  20429. /**
  20430. * Gets or sets the connection point name
  20431. */
  20432. name: string;
  20433. /**
  20434. * Gets or sets the connection point name
  20435. */
  20436. displayName: string;
  20437. /**
  20438. * Gets or sets a boolean indicating that this connection point can be omitted
  20439. */
  20440. isOptional: boolean;
  20441. /**
  20442. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20443. */
  20444. isExposedOnFrame: boolean;
  20445. /**
  20446. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20447. */
  20448. define: string;
  20449. /** @hidden */
  20450. _prioritizeVertex: boolean;
  20451. private _target;
  20452. /** Gets or sets the target of that connection point */
  20453. get target(): NodeMaterialBlockTargets;
  20454. set target(value: NodeMaterialBlockTargets);
  20455. /**
  20456. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20457. */
  20458. get isConnected(): boolean;
  20459. /**
  20460. * Gets a boolean indicating that the current point is connected to an input block
  20461. */
  20462. get isConnectedToInputBlock(): boolean;
  20463. /**
  20464. * Gets a the connected input block (if any)
  20465. */
  20466. get connectInputBlock(): Nullable<InputBlock>;
  20467. /** Get the other side of the connection (if any) */
  20468. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20469. /** Get the block that owns this connection point */
  20470. get ownerBlock(): NodeMaterialBlock;
  20471. /** Get the block connected on the other side of this connection (if any) */
  20472. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20473. /** Get the block connected on the endpoints of this connection (if any) */
  20474. get connectedBlocks(): Array<NodeMaterialBlock>;
  20475. /** Gets the list of connected endpoints */
  20476. get endpoints(): NodeMaterialConnectionPoint[];
  20477. /** Gets a boolean indicating if that output point is connected to at least one input */
  20478. get hasEndpoints(): boolean;
  20479. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20480. get isConnectedInVertexShader(): boolean;
  20481. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20482. get isConnectedInFragmentShader(): boolean;
  20483. /**
  20484. * Creates a block suitable to be used as an input for this input point.
  20485. * If null is returned, a block based on the point type will be created.
  20486. * @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
  20487. */
  20488. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20489. /**
  20490. * Creates a new connection point
  20491. * @param name defines the connection point name
  20492. * @param ownerBlock defines the block hosting this connection point
  20493. * @param direction defines the direction of the connection point
  20494. */
  20495. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20496. /**
  20497. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20498. * @returns the class name
  20499. */
  20500. getClassName(): string;
  20501. /**
  20502. * Gets a boolean indicating if the current point can be connected to another point
  20503. * @param connectionPoint defines the other connection point
  20504. * @returns a boolean
  20505. */
  20506. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20507. /**
  20508. * Gets a number indicating if the current point can be connected to another point
  20509. * @param connectionPoint defines the other connection point
  20510. * @returns a number defining the compatibility state
  20511. */
  20512. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20513. /**
  20514. * Connect this point to another connection point
  20515. * @param connectionPoint defines the other connection point
  20516. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20517. * @returns the current connection point
  20518. */
  20519. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20520. /**
  20521. * Disconnect this point from one of his endpoint
  20522. * @param endpoint defines the other connection point
  20523. * @returns the current connection point
  20524. */
  20525. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20526. /**
  20527. * Serializes this point in a JSON representation
  20528. * @param isInput defines if the connection point is an input (default is true)
  20529. * @returns the serialized point object
  20530. */
  20531. serialize(isInput?: boolean): any;
  20532. /**
  20533. * Release resources
  20534. */
  20535. dispose(): void;
  20536. }
  20537. }
  20538. declare module BABYLON {
  20539. /**
  20540. * Enum used to define the material modes
  20541. */
  20542. export enum NodeMaterialModes {
  20543. /** Regular material */
  20544. Material = 0,
  20545. /** For post process */
  20546. PostProcess = 1,
  20547. /** For particle system */
  20548. Particle = 2
  20549. }
  20550. }
  20551. declare module BABYLON {
  20552. /**
  20553. * Block used to read a texture from a sampler
  20554. */
  20555. export class TextureBlock extends NodeMaterialBlock {
  20556. private _defineName;
  20557. private _linearDefineName;
  20558. private _gammaDefineName;
  20559. private _tempTextureRead;
  20560. private _samplerName;
  20561. private _transformedUVName;
  20562. private _textureTransformName;
  20563. private _textureInfoName;
  20564. private _mainUVName;
  20565. private _mainUVDefineName;
  20566. private _fragmentOnly;
  20567. /**
  20568. * Gets or sets the texture associated with the node
  20569. */
  20570. texture: Nullable<Texture>;
  20571. /**
  20572. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20573. */
  20574. convertToGammaSpace: boolean;
  20575. /**
  20576. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20577. */
  20578. convertToLinearSpace: boolean;
  20579. /**
  20580. * Create a new TextureBlock
  20581. * @param name defines the block name
  20582. */
  20583. constructor(name: string, fragmentOnly?: boolean);
  20584. /**
  20585. * Gets the current class name
  20586. * @returns the class name
  20587. */
  20588. getClassName(): string;
  20589. /**
  20590. * Gets the uv input component
  20591. */
  20592. get uv(): NodeMaterialConnectionPoint;
  20593. /**
  20594. * Gets the rgba output component
  20595. */
  20596. get rgba(): NodeMaterialConnectionPoint;
  20597. /**
  20598. * Gets the rgb output component
  20599. */
  20600. get rgb(): NodeMaterialConnectionPoint;
  20601. /**
  20602. * Gets the r output component
  20603. */
  20604. get r(): NodeMaterialConnectionPoint;
  20605. /**
  20606. * Gets the g output component
  20607. */
  20608. get g(): NodeMaterialConnectionPoint;
  20609. /**
  20610. * Gets the b output component
  20611. */
  20612. get b(): NodeMaterialConnectionPoint;
  20613. /**
  20614. * Gets the a output component
  20615. */
  20616. get a(): NodeMaterialConnectionPoint;
  20617. get target(): NodeMaterialBlockTargets;
  20618. autoConfigure(material: NodeMaterial): void;
  20619. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20621. isReady(): boolean;
  20622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20623. private get _isMixed();
  20624. private _injectVertexCode;
  20625. private _writeTextureRead;
  20626. private _writeOutput;
  20627. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20628. protected _dumpPropertiesCode(): string;
  20629. serialize(): any;
  20630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20631. }
  20632. }
  20633. declare module BABYLON {
  20634. /** @hidden */
  20635. export var reflectionFunction: {
  20636. name: string;
  20637. shader: string;
  20638. };
  20639. }
  20640. declare module BABYLON {
  20641. /**
  20642. * Base block used to read a reflection texture from a sampler
  20643. */
  20644. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20645. /** @hidden */
  20646. _define3DName: string;
  20647. /** @hidden */
  20648. _defineCubicName: string;
  20649. /** @hidden */
  20650. _defineExplicitName: string;
  20651. /** @hidden */
  20652. _defineProjectionName: string;
  20653. /** @hidden */
  20654. _defineLocalCubicName: string;
  20655. /** @hidden */
  20656. _defineSphericalName: string;
  20657. /** @hidden */
  20658. _definePlanarName: string;
  20659. /** @hidden */
  20660. _defineEquirectangularName: string;
  20661. /** @hidden */
  20662. _defineMirroredEquirectangularFixedName: string;
  20663. /** @hidden */
  20664. _defineEquirectangularFixedName: string;
  20665. /** @hidden */
  20666. _defineSkyboxName: string;
  20667. /** @hidden */
  20668. _defineOppositeZ: string;
  20669. /** @hidden */
  20670. _cubeSamplerName: string;
  20671. /** @hidden */
  20672. _2DSamplerName: string;
  20673. protected _positionUVWName: string;
  20674. protected _directionWName: string;
  20675. protected _reflectionVectorName: string;
  20676. /** @hidden */
  20677. _reflectionCoordsName: string;
  20678. /** @hidden */
  20679. _reflectionMatrixName: string;
  20680. protected _reflectionColorName: string;
  20681. /**
  20682. * Gets or sets the texture associated with the node
  20683. */
  20684. texture: Nullable<BaseTexture>;
  20685. /**
  20686. * Create a new ReflectionTextureBaseBlock
  20687. * @param name defines the block name
  20688. */
  20689. constructor(name: string);
  20690. /**
  20691. * Gets the current class name
  20692. * @returns the class name
  20693. */
  20694. getClassName(): string;
  20695. /**
  20696. * Gets the world position input component
  20697. */
  20698. abstract get position(): NodeMaterialConnectionPoint;
  20699. /**
  20700. * Gets the world position input component
  20701. */
  20702. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20703. /**
  20704. * Gets the world normal input component
  20705. */
  20706. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20707. /**
  20708. * Gets the world input component
  20709. */
  20710. abstract get world(): NodeMaterialConnectionPoint;
  20711. /**
  20712. * Gets the camera (or eye) position component
  20713. */
  20714. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20715. /**
  20716. * Gets the view input component
  20717. */
  20718. abstract get view(): NodeMaterialConnectionPoint;
  20719. protected _getTexture(): Nullable<BaseTexture>;
  20720. autoConfigure(material: NodeMaterial): void;
  20721. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20722. isReady(): boolean;
  20723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20724. /**
  20725. * Gets the code to inject in the vertex shader
  20726. * @param state current state of the node material building
  20727. * @returns the shader code
  20728. */
  20729. handleVertexSide(state: NodeMaterialBuildState): string;
  20730. /**
  20731. * Handles the inits for the fragment code path
  20732. * @param state node material build state
  20733. */
  20734. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20735. /**
  20736. * Generates the reflection coords code for the fragment code path
  20737. * @param worldNormalVarName name of the world normal variable
  20738. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20739. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20740. * @returns the shader code
  20741. */
  20742. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20743. /**
  20744. * Generates the reflection color code for the fragment code path
  20745. * @param lodVarName name of the lod variable
  20746. * @param swizzleLookupTexture swizzle to use for the final color variable
  20747. * @returns the shader code
  20748. */
  20749. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20750. /**
  20751. * Generates the code corresponding to the connected output points
  20752. * @param state node material build state
  20753. * @param varName name of the variable to output
  20754. * @returns the shader code
  20755. */
  20756. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20757. protected _buildBlock(state: NodeMaterialBuildState): this;
  20758. protected _dumpPropertiesCode(): string;
  20759. serialize(): any;
  20760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20761. }
  20762. }
  20763. declare module BABYLON {
  20764. /**
  20765. * Defines a connection point to be used for points with a custom object type
  20766. */
  20767. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20768. private _blockType;
  20769. private _blockName;
  20770. private _nameForCheking?;
  20771. /**
  20772. * Creates a new connection point
  20773. * @param name defines the connection point name
  20774. * @param ownerBlock defines the block hosting this connection point
  20775. * @param direction defines the direction of the connection point
  20776. */
  20777. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20778. /**
  20779. * Gets a number indicating if the current point can be connected to another point
  20780. * @param connectionPoint defines the other connection point
  20781. * @returns a number defining the compatibility state
  20782. */
  20783. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20784. /**
  20785. * Creates a block suitable to be used as an input for this input point.
  20786. * If null is returned, a block based on the point type will be created.
  20787. * @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
  20788. */
  20789. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20790. }
  20791. }
  20792. declare module BABYLON {
  20793. /**
  20794. * Enum defining the type of properties that can be edited in the property pages in the NME
  20795. */
  20796. export enum PropertyTypeForEdition {
  20797. /** property is a boolean */
  20798. Boolean = 0,
  20799. /** property is a float */
  20800. Float = 1,
  20801. /** property is a Vector2 */
  20802. Vector2 = 2,
  20803. /** property is a list of values */
  20804. List = 3
  20805. }
  20806. /**
  20807. * Interface that defines an option in a variable of type list
  20808. */
  20809. export interface IEditablePropertyListOption {
  20810. /** label of the option */
  20811. "label": string;
  20812. /** value of the option */
  20813. "value": number;
  20814. }
  20815. /**
  20816. * Interface that defines the options available for an editable property
  20817. */
  20818. export interface IEditablePropertyOption {
  20819. /** min value */
  20820. "min"?: number;
  20821. /** max value */
  20822. "max"?: number;
  20823. /** notifiers: indicates which actions to take when the property is changed */
  20824. "notifiers"?: {
  20825. /** the material should be rebuilt */
  20826. "rebuild"?: boolean;
  20827. /** the preview should be updated */
  20828. "update"?: boolean;
  20829. };
  20830. /** list of the options for a variable of type list */
  20831. "options"?: IEditablePropertyListOption[];
  20832. }
  20833. /**
  20834. * Interface that describes an editable property
  20835. */
  20836. export interface IPropertyDescriptionForEdition {
  20837. /** name of the property */
  20838. "propertyName": string;
  20839. /** display name of the property */
  20840. "displayName": string;
  20841. /** type of the property */
  20842. "type": PropertyTypeForEdition;
  20843. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20844. "groupName": string;
  20845. /** options for the property */
  20846. "options": IEditablePropertyOption;
  20847. }
  20848. /**
  20849. * Decorator that flags a property in a node material block as being editable
  20850. */
  20851. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20852. }
  20853. declare module BABYLON {
  20854. /**
  20855. * Block used to implement the refraction part of the sub surface module of the PBR material
  20856. */
  20857. export class RefractionBlock extends NodeMaterialBlock {
  20858. /** @hidden */
  20859. _define3DName: string;
  20860. /** @hidden */
  20861. _refractionMatrixName: string;
  20862. /** @hidden */
  20863. _defineLODRefractionAlpha: string;
  20864. /** @hidden */
  20865. _defineLinearSpecularRefraction: string;
  20866. /** @hidden */
  20867. _defineOppositeZ: string;
  20868. /** @hidden */
  20869. _cubeSamplerName: string;
  20870. /** @hidden */
  20871. _2DSamplerName: string;
  20872. /** @hidden */
  20873. _vRefractionMicrosurfaceInfosName: string;
  20874. /** @hidden */
  20875. _vRefractionInfosName: string;
  20876. private _scene;
  20877. /**
  20878. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20879. * Materials half opaque for instance using refraction could benefit from this control.
  20880. */
  20881. linkRefractionWithTransparency: boolean;
  20882. /**
  20883. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20884. */
  20885. invertRefractionY: boolean;
  20886. /**
  20887. * Gets or sets the texture associated with the node
  20888. */
  20889. texture: Nullable<BaseTexture>;
  20890. /**
  20891. * Create a new RefractionBlock
  20892. * @param name defines the block name
  20893. */
  20894. constructor(name: string);
  20895. /**
  20896. * Gets the current class name
  20897. * @returns the class name
  20898. */
  20899. getClassName(): string;
  20900. /**
  20901. * Gets the intensity input component
  20902. */
  20903. get intensity(): NodeMaterialConnectionPoint;
  20904. /**
  20905. * Gets the index of refraction input component
  20906. */
  20907. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20908. /**
  20909. * Gets the tint at distance input component
  20910. */
  20911. get tintAtDistance(): NodeMaterialConnectionPoint;
  20912. /**
  20913. * Gets the view input component
  20914. */
  20915. get view(): NodeMaterialConnectionPoint;
  20916. /**
  20917. * Gets the refraction object output component
  20918. */
  20919. get refraction(): NodeMaterialConnectionPoint;
  20920. /**
  20921. * Returns true if the block has a texture
  20922. */
  20923. get hasTexture(): boolean;
  20924. protected _getTexture(): Nullable<BaseTexture>;
  20925. autoConfigure(material: NodeMaterial): void;
  20926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20927. isReady(): boolean;
  20928. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20929. /**
  20930. * Gets the main code of the block (fragment side)
  20931. * @param state current state of the node material building
  20932. * @returns the shader code
  20933. */
  20934. getCode(state: NodeMaterialBuildState): string;
  20935. protected _buildBlock(state: NodeMaterialBuildState): this;
  20936. protected _dumpPropertiesCode(): string;
  20937. serialize(): any;
  20938. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20939. }
  20940. }
  20941. declare module BABYLON {
  20942. /**
  20943. * Base block used as input for post process
  20944. */
  20945. export class CurrentScreenBlock extends NodeMaterialBlock {
  20946. private _samplerName;
  20947. private _linearDefineName;
  20948. private _gammaDefineName;
  20949. private _mainUVName;
  20950. private _tempTextureRead;
  20951. /**
  20952. * Gets or sets the texture associated with the node
  20953. */
  20954. texture: Nullable<BaseTexture>;
  20955. /**
  20956. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20957. */
  20958. convertToGammaSpace: boolean;
  20959. /**
  20960. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20961. */
  20962. convertToLinearSpace: boolean;
  20963. /**
  20964. * Create a new CurrentScreenBlock
  20965. * @param name defines the block name
  20966. */
  20967. constructor(name: string);
  20968. /**
  20969. * Gets the current class name
  20970. * @returns the class name
  20971. */
  20972. getClassName(): string;
  20973. /**
  20974. * Gets the uv input component
  20975. */
  20976. get uv(): NodeMaterialConnectionPoint;
  20977. /**
  20978. * Gets the rgba output component
  20979. */
  20980. get rgba(): NodeMaterialConnectionPoint;
  20981. /**
  20982. * Gets the rgb output component
  20983. */
  20984. get rgb(): NodeMaterialConnectionPoint;
  20985. /**
  20986. * Gets the r output component
  20987. */
  20988. get r(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the g output component
  20991. */
  20992. get g(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the b output component
  20995. */
  20996. get b(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the a output component
  20999. */
  21000. get a(): NodeMaterialConnectionPoint;
  21001. /**
  21002. * Initialize the block and prepare the context for build
  21003. * @param state defines the state that will be used for the build
  21004. */
  21005. initialize(state: NodeMaterialBuildState): void;
  21006. get target(): NodeMaterialBlockTargets;
  21007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21008. isReady(): boolean;
  21009. private _injectVertexCode;
  21010. private _writeTextureRead;
  21011. private _writeOutput;
  21012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21013. serialize(): any;
  21014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21015. }
  21016. }
  21017. declare module BABYLON {
  21018. /**
  21019. * Base block used for the particle texture
  21020. */
  21021. export class ParticleTextureBlock extends NodeMaterialBlock {
  21022. private _samplerName;
  21023. private _linearDefineName;
  21024. private _gammaDefineName;
  21025. private _tempTextureRead;
  21026. /**
  21027. * Gets or sets the texture associated with the node
  21028. */
  21029. texture: Nullable<BaseTexture>;
  21030. /**
  21031. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21032. */
  21033. convertToGammaSpace: boolean;
  21034. /**
  21035. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21036. */
  21037. convertToLinearSpace: boolean;
  21038. /**
  21039. * Create a new ParticleTextureBlock
  21040. * @param name defines the block name
  21041. */
  21042. constructor(name: string);
  21043. /**
  21044. * Gets the current class name
  21045. * @returns the class name
  21046. */
  21047. getClassName(): string;
  21048. /**
  21049. * Gets the uv input component
  21050. */
  21051. get uv(): NodeMaterialConnectionPoint;
  21052. /**
  21053. * Gets the rgba output component
  21054. */
  21055. get rgba(): NodeMaterialConnectionPoint;
  21056. /**
  21057. * Gets the rgb output component
  21058. */
  21059. get rgb(): NodeMaterialConnectionPoint;
  21060. /**
  21061. * Gets the r output component
  21062. */
  21063. get r(): NodeMaterialConnectionPoint;
  21064. /**
  21065. * Gets the g output component
  21066. */
  21067. get g(): NodeMaterialConnectionPoint;
  21068. /**
  21069. * Gets the b output component
  21070. */
  21071. get b(): NodeMaterialConnectionPoint;
  21072. /**
  21073. * Gets the a output component
  21074. */
  21075. get a(): NodeMaterialConnectionPoint;
  21076. /**
  21077. * Initialize the block and prepare the context for build
  21078. * @param state defines the state that will be used for the build
  21079. */
  21080. initialize(state: NodeMaterialBuildState): void;
  21081. autoConfigure(material: NodeMaterial): void;
  21082. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21083. isReady(): boolean;
  21084. private _writeOutput;
  21085. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21086. serialize(): any;
  21087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21088. }
  21089. }
  21090. declare module BABYLON {
  21091. /**
  21092. * Class used to store shared data between 2 NodeMaterialBuildState
  21093. */
  21094. export class NodeMaterialBuildStateSharedData {
  21095. /**
  21096. * Gets the list of emitted varyings
  21097. */
  21098. temps: string[];
  21099. /**
  21100. * Gets the list of emitted varyings
  21101. */
  21102. varyings: string[];
  21103. /**
  21104. * Gets the varying declaration string
  21105. */
  21106. varyingDeclaration: string;
  21107. /**
  21108. * Input blocks
  21109. */
  21110. inputBlocks: InputBlock[];
  21111. /**
  21112. * Input blocks
  21113. */
  21114. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21115. /**
  21116. * Bindable blocks (Blocks that need to set data to the effect)
  21117. */
  21118. bindableBlocks: NodeMaterialBlock[];
  21119. /**
  21120. * List of blocks that can provide a compilation fallback
  21121. */
  21122. blocksWithFallbacks: NodeMaterialBlock[];
  21123. /**
  21124. * List of blocks that can provide a define update
  21125. */
  21126. blocksWithDefines: NodeMaterialBlock[];
  21127. /**
  21128. * List of blocks that can provide a repeatable content
  21129. */
  21130. repeatableContentBlocks: NodeMaterialBlock[];
  21131. /**
  21132. * List of blocks that can provide a dynamic list of uniforms
  21133. */
  21134. dynamicUniformBlocks: NodeMaterialBlock[];
  21135. /**
  21136. * List of blocks that can block the isReady function for the material
  21137. */
  21138. blockingBlocks: NodeMaterialBlock[];
  21139. /**
  21140. * Gets the list of animated inputs
  21141. */
  21142. animatedInputs: InputBlock[];
  21143. /**
  21144. * Build Id used to avoid multiple recompilations
  21145. */
  21146. buildId: number;
  21147. /** List of emitted variables */
  21148. variableNames: {
  21149. [key: string]: number;
  21150. };
  21151. /** List of emitted defines */
  21152. defineNames: {
  21153. [key: string]: number;
  21154. };
  21155. /** Should emit comments? */
  21156. emitComments: boolean;
  21157. /** Emit build activity */
  21158. verbose: boolean;
  21159. /** Gets or sets the hosting scene */
  21160. scene: Scene;
  21161. /**
  21162. * Gets the compilation hints emitted at compilation time
  21163. */
  21164. hints: {
  21165. needWorldViewMatrix: boolean;
  21166. needWorldViewProjectionMatrix: boolean;
  21167. needAlphaBlending: boolean;
  21168. needAlphaTesting: boolean;
  21169. };
  21170. /**
  21171. * List of compilation checks
  21172. */
  21173. checks: {
  21174. emitVertex: boolean;
  21175. emitFragment: boolean;
  21176. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21177. };
  21178. /**
  21179. * Is vertex program allowed to be empty?
  21180. */
  21181. allowEmptyVertexProgram: boolean;
  21182. /** Creates a new shared data */
  21183. constructor();
  21184. /**
  21185. * Emits console errors and exceptions if there is a failing check
  21186. */
  21187. emitErrors(): void;
  21188. }
  21189. }
  21190. declare module BABYLON {
  21191. /**
  21192. * Class used to store node based material build state
  21193. */
  21194. export class NodeMaterialBuildState {
  21195. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21196. supportUniformBuffers: boolean;
  21197. /**
  21198. * Gets the list of emitted attributes
  21199. */
  21200. attributes: string[];
  21201. /**
  21202. * Gets the list of emitted uniforms
  21203. */
  21204. uniforms: string[];
  21205. /**
  21206. * Gets the list of emitted constants
  21207. */
  21208. constants: string[];
  21209. /**
  21210. * Gets the list of emitted samplers
  21211. */
  21212. samplers: string[];
  21213. /**
  21214. * Gets the list of emitted functions
  21215. */
  21216. functions: {
  21217. [key: string]: string;
  21218. };
  21219. /**
  21220. * Gets the list of emitted extensions
  21221. */
  21222. extensions: {
  21223. [key: string]: string;
  21224. };
  21225. /**
  21226. * Gets the target of the compilation state
  21227. */
  21228. target: NodeMaterialBlockTargets;
  21229. /**
  21230. * Gets the list of emitted counters
  21231. */
  21232. counters: {
  21233. [key: string]: number;
  21234. };
  21235. /**
  21236. * Shared data between multiple NodeMaterialBuildState instances
  21237. */
  21238. sharedData: NodeMaterialBuildStateSharedData;
  21239. /** @hidden */
  21240. _vertexState: NodeMaterialBuildState;
  21241. /** @hidden */
  21242. _attributeDeclaration: string;
  21243. /** @hidden */
  21244. _uniformDeclaration: string;
  21245. /** @hidden */
  21246. _constantDeclaration: string;
  21247. /** @hidden */
  21248. _samplerDeclaration: string;
  21249. /** @hidden */
  21250. _varyingTransfer: string;
  21251. /** @hidden */
  21252. _injectAtEnd: string;
  21253. private _repeatableContentAnchorIndex;
  21254. /** @hidden */
  21255. _builtCompilationString: string;
  21256. /**
  21257. * Gets the emitted compilation strings
  21258. */
  21259. compilationString: string;
  21260. /**
  21261. * Finalize the compilation strings
  21262. * @param state defines the current compilation state
  21263. */
  21264. finalize(state: NodeMaterialBuildState): void;
  21265. /** @hidden */
  21266. get _repeatableContentAnchor(): string;
  21267. /** @hidden */
  21268. _getFreeVariableName(prefix: string): string;
  21269. /** @hidden */
  21270. _getFreeDefineName(prefix: string): string;
  21271. /** @hidden */
  21272. _excludeVariableName(name: string): void;
  21273. /** @hidden */
  21274. _emit2DSampler(name: string): void;
  21275. /** @hidden */
  21276. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21277. /** @hidden */
  21278. _emitExtension(name: string, extension: string, define?: string): void;
  21279. /** @hidden */
  21280. _emitFunction(name: string, code: string, comments: string): void;
  21281. /** @hidden */
  21282. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21283. replaceStrings?: {
  21284. search: RegExp;
  21285. replace: string;
  21286. }[];
  21287. repeatKey?: string;
  21288. }): string;
  21289. /** @hidden */
  21290. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21291. repeatKey?: string;
  21292. removeAttributes?: boolean;
  21293. removeUniforms?: boolean;
  21294. removeVaryings?: boolean;
  21295. removeIfDef?: boolean;
  21296. replaceStrings?: {
  21297. search: RegExp;
  21298. replace: string;
  21299. }[];
  21300. }, storeKey?: string): void;
  21301. /** @hidden */
  21302. _registerTempVariable(name: string): boolean;
  21303. /** @hidden */
  21304. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21305. /** @hidden */
  21306. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21307. /** @hidden */
  21308. _emitFloat(value: number): string;
  21309. }
  21310. }
  21311. declare module BABYLON {
  21312. /**
  21313. * Helper class used to generate session unique ID
  21314. */
  21315. export class UniqueIdGenerator {
  21316. private static _UniqueIdCounter;
  21317. /**
  21318. * Gets an unique (relatively to the current scene) Id
  21319. */
  21320. static get UniqueId(): number;
  21321. }
  21322. }
  21323. declare module BABYLON {
  21324. /**
  21325. * Defines a block that can be used inside a node based material
  21326. */
  21327. export class NodeMaterialBlock {
  21328. private _buildId;
  21329. private _buildTarget;
  21330. private _target;
  21331. private _isFinalMerger;
  21332. private _isInput;
  21333. private _name;
  21334. protected _isUnique: boolean;
  21335. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21336. inputsAreExclusive: boolean;
  21337. /** @hidden */
  21338. _codeVariableName: string;
  21339. /** @hidden */
  21340. _inputs: NodeMaterialConnectionPoint[];
  21341. /** @hidden */
  21342. _outputs: NodeMaterialConnectionPoint[];
  21343. /** @hidden */
  21344. _preparationId: number;
  21345. /**
  21346. * Gets the name of the block
  21347. */
  21348. get name(): string;
  21349. /**
  21350. * Sets the name of the block. Will check if the name is valid.
  21351. */
  21352. set name(newName: string);
  21353. /**
  21354. * Gets or sets the unique id of the node
  21355. */
  21356. uniqueId: number;
  21357. /**
  21358. * Gets or sets the comments associated with this block
  21359. */
  21360. comments: string;
  21361. /**
  21362. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21363. */
  21364. get isUnique(): boolean;
  21365. /**
  21366. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21367. */
  21368. get isFinalMerger(): boolean;
  21369. /**
  21370. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21371. */
  21372. get isInput(): boolean;
  21373. /**
  21374. * Gets or sets the build Id
  21375. */
  21376. get buildId(): number;
  21377. set buildId(value: number);
  21378. /**
  21379. * Gets or sets the target of the block
  21380. */
  21381. get target(): NodeMaterialBlockTargets;
  21382. set target(value: NodeMaterialBlockTargets);
  21383. /**
  21384. * Gets the list of input points
  21385. */
  21386. get inputs(): NodeMaterialConnectionPoint[];
  21387. /** Gets the list of output points */
  21388. get outputs(): NodeMaterialConnectionPoint[];
  21389. /**
  21390. * Find an input by its name
  21391. * @param name defines the name of the input to look for
  21392. * @returns the input or null if not found
  21393. */
  21394. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21395. /**
  21396. * Find an output by its name
  21397. * @param name defines the name of the outputto look for
  21398. * @returns the output or null if not found
  21399. */
  21400. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21401. /**
  21402. * Creates a new NodeMaterialBlock
  21403. * @param name defines the block name
  21404. * @param target defines the target of that block (Vertex by default)
  21405. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21406. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21407. */
  21408. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21409. /**
  21410. * Initialize the block and prepare the context for build
  21411. * @param state defines the state that will be used for the build
  21412. */
  21413. initialize(state: NodeMaterialBuildState): void;
  21414. /**
  21415. * Bind data to effect. Will only be called for blocks with isBindable === true
  21416. * @param effect defines the effect to bind data to
  21417. * @param nodeMaterial defines the hosting NodeMaterial
  21418. * @param mesh defines the mesh that will be rendered
  21419. * @param subMesh defines the submesh that will be rendered
  21420. */
  21421. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21422. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21423. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21424. protected _writeFloat(value: number): string;
  21425. /**
  21426. * Gets the current class name e.g. "NodeMaterialBlock"
  21427. * @returns the class name
  21428. */
  21429. getClassName(): string;
  21430. /**
  21431. * Register a new input. Must be called inside a block constructor
  21432. * @param name defines the connection point name
  21433. * @param type defines the connection point type
  21434. * @param isOptional defines a boolean indicating that this input can be omitted
  21435. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21436. * @param point an already created connection point. If not provided, create a new one
  21437. * @returns the current block
  21438. */
  21439. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21440. /**
  21441. * Register a new output. Must be called inside a block constructor
  21442. * @param name defines the connection point name
  21443. * @param type defines the connection point type
  21444. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21445. * @param point an already created connection point. If not provided, create a new one
  21446. * @returns the current block
  21447. */
  21448. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21449. /**
  21450. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21451. * @param forOutput defines an optional connection point to check compatibility with
  21452. * @returns the first available input or null
  21453. */
  21454. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21455. /**
  21456. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21457. * @param forBlock defines an optional block to check compatibility with
  21458. * @returns the first available input or null
  21459. */
  21460. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21461. /**
  21462. * Gets the sibling of the given output
  21463. * @param current defines the current output
  21464. * @returns the next output in the list or null
  21465. */
  21466. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21467. /**
  21468. * Connect current block with another block
  21469. * @param other defines the block to connect with
  21470. * @param options define the various options to help pick the right connections
  21471. * @returns the current block
  21472. */
  21473. connectTo(other: NodeMaterialBlock, options?: {
  21474. input?: string;
  21475. output?: string;
  21476. outputSwizzle?: string;
  21477. }): this | undefined;
  21478. protected _buildBlock(state: NodeMaterialBuildState): void;
  21479. /**
  21480. * Add uniforms, samplers and uniform buffers at compilation time
  21481. * @param state defines the state to update
  21482. * @param nodeMaterial defines the node material requesting the update
  21483. * @param defines defines the material defines to update
  21484. * @param uniformBuffers defines the list of uniform buffer names
  21485. */
  21486. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21487. /**
  21488. * Add potential fallbacks if shader compilation fails
  21489. * @param mesh defines the mesh to be rendered
  21490. * @param fallbacks defines the current prioritized list of fallbacks
  21491. */
  21492. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21493. /**
  21494. * Initialize defines for shader compilation
  21495. * @param mesh defines the mesh to be rendered
  21496. * @param nodeMaterial defines the node material requesting the update
  21497. * @param defines defines the material defines to update
  21498. * @param useInstances specifies that instances should be used
  21499. */
  21500. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21501. /**
  21502. * Update defines for shader compilation
  21503. * @param mesh defines the mesh to be rendered
  21504. * @param nodeMaterial defines the node material requesting the update
  21505. * @param defines defines the material defines to update
  21506. * @param useInstances specifies that instances should be used
  21507. * @param subMesh defines which submesh to render
  21508. */
  21509. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21510. /**
  21511. * Lets the block try to connect some inputs automatically
  21512. * @param material defines the hosting NodeMaterial
  21513. */
  21514. autoConfigure(material: NodeMaterial): void;
  21515. /**
  21516. * Function called when a block is declared as repeatable content generator
  21517. * @param vertexShaderState defines the current compilation state for the vertex shader
  21518. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21519. * @param mesh defines the mesh to be rendered
  21520. * @param defines defines the material defines to update
  21521. */
  21522. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21523. /**
  21524. * Checks if the block is ready
  21525. * @param mesh defines the mesh to be rendered
  21526. * @param nodeMaterial defines the node material requesting the update
  21527. * @param defines defines the material defines to update
  21528. * @param useInstances specifies that instances should be used
  21529. * @returns true if the block is ready
  21530. */
  21531. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21532. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21533. private _processBuild;
  21534. /**
  21535. * Validates the new name for the block node.
  21536. * @param newName the new name to be given to the node.
  21537. * @returns false if the name is a reserve word, else true.
  21538. */
  21539. validateBlockName(newName: string): boolean;
  21540. /**
  21541. * Compile the current node and generate the shader code
  21542. * @param state defines the current compilation state (uniforms, samplers, current string)
  21543. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21544. * @returns true if already built
  21545. */
  21546. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21547. protected _inputRename(name: string): string;
  21548. protected _outputRename(name: string): string;
  21549. protected _dumpPropertiesCode(): string;
  21550. /** @hidden */
  21551. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21552. /** @hidden */
  21553. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21554. /**
  21555. * Clone the current block to a new identical block
  21556. * @param scene defines the hosting scene
  21557. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21558. * @returns a copy of the current block
  21559. */
  21560. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21561. /**
  21562. * Serializes this block in a JSON representation
  21563. * @returns the serialized block object
  21564. */
  21565. serialize(): any;
  21566. /** @hidden */
  21567. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21568. private _deserializePortDisplayNamesAndExposedOnFrame;
  21569. /**
  21570. * Release resources
  21571. */
  21572. dispose(): void;
  21573. }
  21574. }
  21575. declare module BABYLON {
  21576. /**
  21577. * Base class of materials working in push mode in babylon JS
  21578. * @hidden
  21579. */
  21580. export class PushMaterial extends Material {
  21581. protected _activeEffect: Effect;
  21582. protected _normalMatrix: Matrix;
  21583. constructor(name: string, scene: Scene);
  21584. getEffect(): Effect;
  21585. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21586. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21587. /**
  21588. * Binds the given world matrix to the active effect
  21589. *
  21590. * @param world the matrix to bind
  21591. */
  21592. bindOnlyWorldMatrix(world: Matrix): void;
  21593. /**
  21594. * Binds the given normal matrix to the active effect
  21595. *
  21596. * @param normalMatrix the matrix to bind
  21597. */
  21598. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21599. bind(world: Matrix, mesh?: Mesh): void;
  21600. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21601. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21602. }
  21603. }
  21604. declare module BABYLON {
  21605. /**
  21606. * Root class for all node material optimizers
  21607. */
  21608. export class NodeMaterialOptimizer {
  21609. /**
  21610. * Function used to optimize a NodeMaterial graph
  21611. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21612. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21613. */
  21614. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21615. }
  21616. }
  21617. declare module BABYLON {
  21618. /**
  21619. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21620. */
  21621. export class TransformBlock extends NodeMaterialBlock {
  21622. /**
  21623. * Defines the value to use to complement W value to transform it to a Vector4
  21624. */
  21625. complementW: number;
  21626. /**
  21627. * Defines the value to use to complement z value to transform it to a Vector4
  21628. */
  21629. complementZ: number;
  21630. /**
  21631. * Creates a new TransformBlock
  21632. * @param name defines the block name
  21633. */
  21634. constructor(name: string);
  21635. /**
  21636. * Gets the current class name
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Gets the vector input
  21642. */
  21643. get vector(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the output component
  21646. */
  21647. get output(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the xyz output component
  21650. */
  21651. get xyz(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the matrix transform input
  21654. */
  21655. get transform(): NodeMaterialConnectionPoint;
  21656. protected _buildBlock(state: NodeMaterialBuildState): this;
  21657. /**
  21658. * Update defines for shader compilation
  21659. * @param mesh defines the mesh to be rendered
  21660. * @param nodeMaterial defines the node material requesting the update
  21661. * @param defines defines the material defines to update
  21662. * @param useInstances specifies that instances should be used
  21663. * @param subMesh defines which submesh to render
  21664. */
  21665. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21666. serialize(): any;
  21667. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21668. protected _dumpPropertiesCode(): string;
  21669. }
  21670. }
  21671. declare module BABYLON {
  21672. /**
  21673. * Block used to output the vertex position
  21674. */
  21675. export class VertexOutputBlock extends NodeMaterialBlock {
  21676. /**
  21677. * Creates a new VertexOutputBlock
  21678. * @param name defines the block name
  21679. */
  21680. constructor(name: string);
  21681. /**
  21682. * Gets the current class name
  21683. * @returns the class name
  21684. */
  21685. getClassName(): string;
  21686. /**
  21687. * Gets the vector input component
  21688. */
  21689. get vector(): NodeMaterialConnectionPoint;
  21690. protected _buildBlock(state: NodeMaterialBuildState): this;
  21691. }
  21692. }
  21693. declare module BABYLON {
  21694. /**
  21695. * Block used to output the final color
  21696. */
  21697. export class FragmentOutputBlock extends NodeMaterialBlock {
  21698. /**
  21699. * Create a new FragmentOutputBlock
  21700. * @param name defines the block name
  21701. */
  21702. constructor(name: string);
  21703. /**
  21704. * Gets the current class name
  21705. * @returns the class name
  21706. */
  21707. getClassName(): string;
  21708. /**
  21709. * Gets the rgba input component
  21710. */
  21711. get rgba(): NodeMaterialConnectionPoint;
  21712. /**
  21713. * Gets the rgb input component
  21714. */
  21715. get rgb(): NodeMaterialConnectionPoint;
  21716. /**
  21717. * Gets the a input component
  21718. */
  21719. get a(): NodeMaterialConnectionPoint;
  21720. protected _buildBlock(state: NodeMaterialBuildState): this;
  21721. }
  21722. }
  21723. declare module BABYLON {
  21724. /**
  21725. * Block used for the particle ramp gradient section
  21726. */
  21727. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21728. /**
  21729. * Create a new ParticleRampGradientBlock
  21730. * @param name defines the block name
  21731. */
  21732. constructor(name: string);
  21733. /**
  21734. * Gets the current class name
  21735. * @returns the class name
  21736. */
  21737. getClassName(): string;
  21738. /**
  21739. * Gets the color input component
  21740. */
  21741. get color(): NodeMaterialConnectionPoint;
  21742. /**
  21743. * Gets the rampColor output component
  21744. */
  21745. get rampColor(): NodeMaterialConnectionPoint;
  21746. /**
  21747. * Initialize the block and prepare the context for build
  21748. * @param state defines the state that will be used for the build
  21749. */
  21750. initialize(state: NodeMaterialBuildState): void;
  21751. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21752. }
  21753. }
  21754. declare module BABYLON {
  21755. /**
  21756. * Block used for the particle blend multiply section
  21757. */
  21758. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21759. /**
  21760. * Create a new ParticleBlendMultiplyBlock
  21761. * @param name defines the block name
  21762. */
  21763. constructor(name: string);
  21764. /**
  21765. * Gets the current class name
  21766. * @returns the class name
  21767. */
  21768. getClassName(): string;
  21769. /**
  21770. * Gets the color input component
  21771. */
  21772. get color(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the alphaTexture input component
  21775. */
  21776. get alphaTexture(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the alphaColor input component
  21779. */
  21780. get alphaColor(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the blendColor output component
  21783. */
  21784. get blendColor(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Initialize the block and prepare the context for build
  21787. * @param state defines the state that will be used for the build
  21788. */
  21789. initialize(state: NodeMaterialBuildState): void;
  21790. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21791. }
  21792. }
  21793. declare module BABYLON {
  21794. /**
  21795. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21796. */
  21797. export class VectorMergerBlock extends NodeMaterialBlock {
  21798. /**
  21799. * Create a new VectorMergerBlock
  21800. * @param name defines the block name
  21801. */
  21802. constructor(name: string);
  21803. /**
  21804. * Gets the current class name
  21805. * @returns the class name
  21806. */
  21807. getClassName(): string;
  21808. /**
  21809. * Gets the xyz component (input)
  21810. */
  21811. get xyzIn(): NodeMaterialConnectionPoint;
  21812. /**
  21813. * Gets the xy component (input)
  21814. */
  21815. get xyIn(): NodeMaterialConnectionPoint;
  21816. /**
  21817. * Gets the x component (input)
  21818. */
  21819. get x(): NodeMaterialConnectionPoint;
  21820. /**
  21821. * Gets the y component (input)
  21822. */
  21823. get y(): NodeMaterialConnectionPoint;
  21824. /**
  21825. * Gets the z component (input)
  21826. */
  21827. get z(): NodeMaterialConnectionPoint;
  21828. /**
  21829. * Gets the w component (input)
  21830. */
  21831. get w(): NodeMaterialConnectionPoint;
  21832. /**
  21833. * Gets the xyzw component (output)
  21834. */
  21835. get xyzw(): NodeMaterialConnectionPoint;
  21836. /**
  21837. * Gets the xyz component (output)
  21838. */
  21839. get xyzOut(): NodeMaterialConnectionPoint;
  21840. /**
  21841. * Gets the xy component (output)
  21842. */
  21843. get xyOut(): NodeMaterialConnectionPoint;
  21844. /**
  21845. * Gets the xy component (output)
  21846. * @deprecated Please use xyOut instead.
  21847. */
  21848. get xy(): NodeMaterialConnectionPoint;
  21849. /**
  21850. * Gets the xyz component (output)
  21851. * @deprecated Please use xyzOut instead.
  21852. */
  21853. get xyz(): NodeMaterialConnectionPoint;
  21854. protected _buildBlock(state: NodeMaterialBuildState): this;
  21855. }
  21856. }
  21857. declare module BABYLON {
  21858. /**
  21859. * Block used to remap a float from a range to a new one
  21860. */
  21861. export class RemapBlock extends NodeMaterialBlock {
  21862. /**
  21863. * Gets or sets the source range
  21864. */
  21865. sourceRange: Vector2;
  21866. /**
  21867. * Gets or sets the target range
  21868. */
  21869. targetRange: Vector2;
  21870. /**
  21871. * Creates a new RemapBlock
  21872. * @param name defines the block name
  21873. */
  21874. constructor(name: string);
  21875. /**
  21876. * Gets the current class name
  21877. * @returns the class name
  21878. */
  21879. getClassName(): string;
  21880. /**
  21881. * Gets the input component
  21882. */
  21883. get input(): NodeMaterialConnectionPoint;
  21884. /**
  21885. * Gets the source min input component
  21886. */
  21887. get sourceMin(): NodeMaterialConnectionPoint;
  21888. /**
  21889. * Gets the source max input component
  21890. */
  21891. get sourceMax(): NodeMaterialConnectionPoint;
  21892. /**
  21893. * Gets the target min input component
  21894. */
  21895. get targetMin(): NodeMaterialConnectionPoint;
  21896. /**
  21897. * Gets the target max input component
  21898. */
  21899. get targetMax(): NodeMaterialConnectionPoint;
  21900. /**
  21901. * Gets the output component
  21902. */
  21903. get output(): NodeMaterialConnectionPoint;
  21904. protected _buildBlock(state: NodeMaterialBuildState): this;
  21905. protected _dumpPropertiesCode(): string;
  21906. serialize(): any;
  21907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21908. }
  21909. }
  21910. declare module BABYLON {
  21911. /**
  21912. * Block used to multiply 2 values
  21913. */
  21914. export class MultiplyBlock extends NodeMaterialBlock {
  21915. /**
  21916. * Creates a new MultiplyBlock
  21917. * @param name defines the block name
  21918. */
  21919. constructor(name: string);
  21920. /**
  21921. * Gets the current class name
  21922. * @returns the class name
  21923. */
  21924. getClassName(): string;
  21925. /**
  21926. * Gets the left operand input component
  21927. */
  21928. get left(): NodeMaterialConnectionPoint;
  21929. /**
  21930. * Gets the right operand input component
  21931. */
  21932. get right(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the output component
  21935. */
  21936. get output(): NodeMaterialConnectionPoint;
  21937. protected _buildBlock(state: NodeMaterialBuildState): this;
  21938. }
  21939. }
  21940. declare module BABYLON {
  21941. /**
  21942. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21943. */
  21944. export class ColorSplitterBlock extends NodeMaterialBlock {
  21945. /**
  21946. * Create a new ColorSplitterBlock
  21947. * @param name defines the block name
  21948. */
  21949. constructor(name: string);
  21950. /**
  21951. * Gets the current class name
  21952. * @returns the class name
  21953. */
  21954. getClassName(): string;
  21955. /**
  21956. * Gets the rgba component (input)
  21957. */
  21958. get rgba(): NodeMaterialConnectionPoint;
  21959. /**
  21960. * Gets the rgb component (input)
  21961. */
  21962. get rgbIn(): NodeMaterialConnectionPoint;
  21963. /**
  21964. * Gets the rgb component (output)
  21965. */
  21966. get rgbOut(): NodeMaterialConnectionPoint;
  21967. /**
  21968. * Gets the r component (output)
  21969. */
  21970. get r(): NodeMaterialConnectionPoint;
  21971. /**
  21972. * Gets the g component (output)
  21973. */
  21974. get g(): NodeMaterialConnectionPoint;
  21975. /**
  21976. * Gets the b component (output)
  21977. */
  21978. get b(): NodeMaterialConnectionPoint;
  21979. /**
  21980. * Gets the a component (output)
  21981. */
  21982. get a(): NodeMaterialConnectionPoint;
  21983. protected _inputRename(name: string): string;
  21984. protected _outputRename(name: string): string;
  21985. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21986. }
  21987. }
  21988. declare module BABYLON {
  21989. /**
  21990. * Interface used to configure the node material editor
  21991. */
  21992. export interface INodeMaterialEditorOptions {
  21993. /** Define the URl to load node editor script */
  21994. editorURL?: string;
  21995. }
  21996. /** @hidden */
  21997. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21998. NORMAL: boolean;
  21999. TANGENT: boolean;
  22000. UV1: boolean;
  22001. /** BONES */
  22002. NUM_BONE_INFLUENCERS: number;
  22003. BonesPerMesh: number;
  22004. BONETEXTURE: boolean;
  22005. /** MORPH TARGETS */
  22006. MORPHTARGETS: boolean;
  22007. MORPHTARGETS_NORMAL: boolean;
  22008. MORPHTARGETS_TANGENT: boolean;
  22009. MORPHTARGETS_UV: boolean;
  22010. NUM_MORPH_INFLUENCERS: number;
  22011. /** IMAGE PROCESSING */
  22012. IMAGEPROCESSING: boolean;
  22013. VIGNETTE: boolean;
  22014. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22015. VIGNETTEBLENDMODEOPAQUE: boolean;
  22016. TONEMAPPING: boolean;
  22017. TONEMAPPING_ACES: boolean;
  22018. CONTRAST: boolean;
  22019. EXPOSURE: boolean;
  22020. COLORCURVES: boolean;
  22021. COLORGRADING: boolean;
  22022. COLORGRADING3D: boolean;
  22023. SAMPLER3DGREENDEPTH: boolean;
  22024. SAMPLER3DBGRMAP: boolean;
  22025. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22026. /** MISC. */
  22027. BUMPDIRECTUV: number;
  22028. constructor();
  22029. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22030. }
  22031. /**
  22032. * Class used to configure NodeMaterial
  22033. */
  22034. export interface INodeMaterialOptions {
  22035. /**
  22036. * Defines if blocks should emit comments
  22037. */
  22038. emitComments: boolean;
  22039. }
  22040. /**
  22041. * Class used to create a node based material built by assembling shader blocks
  22042. */
  22043. export class NodeMaterial extends PushMaterial {
  22044. private static _BuildIdGenerator;
  22045. private _options;
  22046. private _vertexCompilationState;
  22047. private _fragmentCompilationState;
  22048. private _sharedData;
  22049. private _buildId;
  22050. private _buildWasSuccessful;
  22051. private _cachedWorldViewMatrix;
  22052. private _cachedWorldViewProjectionMatrix;
  22053. private _optimizers;
  22054. private _animationFrame;
  22055. /** Define the Url to load node editor script */
  22056. static EditorURL: string;
  22057. /** Define the Url to load snippets */
  22058. static SnippetUrl: string;
  22059. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22060. static IgnoreTexturesAtLoadTime: boolean;
  22061. private BJSNODEMATERIALEDITOR;
  22062. /** Get the inspector from bundle or global */
  22063. private _getGlobalNodeMaterialEditor;
  22064. /**
  22065. * Snippet ID if the material was created from the snippet server
  22066. */
  22067. snippetId: string;
  22068. /**
  22069. * Gets or sets data used by visual editor
  22070. * @see https://nme.babylonjs.com
  22071. */
  22072. editorData: any;
  22073. /**
  22074. * 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)
  22075. */
  22076. ignoreAlpha: boolean;
  22077. /**
  22078. * Defines the maximum number of lights that can be used in the material
  22079. */
  22080. maxSimultaneousLights: number;
  22081. /**
  22082. * Observable raised when the material is built
  22083. */
  22084. onBuildObservable: Observable<NodeMaterial>;
  22085. /**
  22086. * Gets or sets the root nodes of the material vertex shader
  22087. */
  22088. _vertexOutputNodes: NodeMaterialBlock[];
  22089. /**
  22090. * Gets or sets the root nodes of the material fragment (pixel) shader
  22091. */
  22092. _fragmentOutputNodes: NodeMaterialBlock[];
  22093. /** Gets or sets options to control the node material overall behavior */
  22094. get options(): INodeMaterialOptions;
  22095. set options(options: INodeMaterialOptions);
  22096. /**
  22097. * Default configuration related to image processing available in the standard Material.
  22098. */
  22099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22100. /**
  22101. * Gets the image processing configuration used either in this material.
  22102. */
  22103. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22104. /**
  22105. * Sets the Default image processing configuration used either in the this material.
  22106. *
  22107. * If sets to null, the scene one is in use.
  22108. */
  22109. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22110. /**
  22111. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22112. */
  22113. attachedBlocks: NodeMaterialBlock[];
  22114. /**
  22115. * Specifies the mode of the node material
  22116. * @hidden
  22117. */
  22118. _mode: NodeMaterialModes;
  22119. /**
  22120. * Gets the mode property
  22121. */
  22122. get mode(): NodeMaterialModes;
  22123. /**
  22124. * Create a new node based material
  22125. * @param name defines the material name
  22126. * @param scene defines the hosting scene
  22127. * @param options defines creation option
  22128. */
  22129. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22130. /**
  22131. * Gets the current class name of the material e.g. "NodeMaterial"
  22132. * @returns the class name
  22133. */
  22134. getClassName(): string;
  22135. /**
  22136. * Keep track of the image processing observer to allow dispose and replace.
  22137. */
  22138. private _imageProcessingObserver;
  22139. /**
  22140. * Attaches a new image processing configuration to the Standard Material.
  22141. * @param configuration
  22142. */
  22143. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22144. /**
  22145. * Get a block by its name
  22146. * @param name defines the name of the block to retrieve
  22147. * @returns the required block or null if not found
  22148. */
  22149. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22150. /**
  22151. * Get a block by its name
  22152. * @param predicate defines the predicate used to find the good candidate
  22153. * @returns the required block or null if not found
  22154. */
  22155. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22156. /**
  22157. * Get an input block by its name
  22158. * @param predicate defines the predicate used to find the good candidate
  22159. * @returns the required input block or null if not found
  22160. */
  22161. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22162. /**
  22163. * Gets the list of input blocks attached to this material
  22164. * @returns an array of InputBlocks
  22165. */
  22166. getInputBlocks(): InputBlock[];
  22167. /**
  22168. * Adds a new optimizer to the list of optimizers
  22169. * @param optimizer defines the optimizers to add
  22170. * @returns the current material
  22171. */
  22172. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22173. /**
  22174. * Remove an optimizer from the list of optimizers
  22175. * @param optimizer defines the optimizers to remove
  22176. * @returns the current material
  22177. */
  22178. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22179. /**
  22180. * Add a new block to the list of output nodes
  22181. * @param node defines the node to add
  22182. * @returns the current material
  22183. */
  22184. addOutputNode(node: NodeMaterialBlock): this;
  22185. /**
  22186. * Remove a block from the list of root nodes
  22187. * @param node defines the node to remove
  22188. * @returns the current material
  22189. */
  22190. removeOutputNode(node: NodeMaterialBlock): this;
  22191. private _addVertexOutputNode;
  22192. private _removeVertexOutputNode;
  22193. private _addFragmentOutputNode;
  22194. private _removeFragmentOutputNode;
  22195. /**
  22196. * Specifies if the material will require alpha blending
  22197. * @returns a boolean specifying if alpha blending is needed
  22198. */
  22199. needAlphaBlending(): boolean;
  22200. /**
  22201. * Specifies if this material should be rendered in alpha test mode
  22202. * @returns a boolean specifying if an alpha test is needed.
  22203. */
  22204. needAlphaTesting(): boolean;
  22205. private _initializeBlock;
  22206. private _resetDualBlocks;
  22207. /**
  22208. * Remove a block from the current node material
  22209. * @param block defines the block to remove
  22210. */
  22211. removeBlock(block: NodeMaterialBlock): void;
  22212. /**
  22213. * Build the material and generates the inner effect
  22214. * @param verbose defines if the build should log activity
  22215. */
  22216. build(verbose?: boolean): void;
  22217. /**
  22218. * Runs an otpimization phase to try to improve the shader code
  22219. */
  22220. optimize(): void;
  22221. private _prepareDefinesForAttributes;
  22222. /**
  22223. * Create a post process from the material
  22224. * @param camera The camera to apply the render pass to.
  22225. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22227. * @param engine The engine which the post process will be applied. (default: current engine)
  22228. * @param reusable If the post process can be reused on the same frame. (default: false)
  22229. * @param textureType Type of textures used when performing the post process. (default: 0)
  22230. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22231. * @returns the post process created
  22232. */
  22233. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22234. /**
  22235. * Create the post process effect from the material
  22236. * @param postProcess The post process to create the effect for
  22237. */
  22238. createEffectForPostProcess(postProcess: PostProcess): void;
  22239. private _createEffectOrPostProcess;
  22240. private _createEffectForParticles;
  22241. /**
  22242. * Create the effect to be used as the custom effect for a particle system
  22243. * @param particleSystem Particle system to create the effect for
  22244. * @param onCompiled defines a function to call when the effect creation is successful
  22245. * @param onError defines a function to call when the effect creation has failed
  22246. */
  22247. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22248. private _processDefines;
  22249. /**
  22250. * Get if the submesh is ready to be used and all its information available.
  22251. * Child classes can use it to update shaders
  22252. * @param mesh defines the mesh to check
  22253. * @param subMesh defines which submesh to check
  22254. * @param useInstances specifies that instances should be used
  22255. * @returns a boolean indicating that the submesh is ready or not
  22256. */
  22257. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22258. /**
  22259. * Get a string representing the shaders built by the current node graph
  22260. */
  22261. get compiledShaders(): string;
  22262. /**
  22263. * Binds the world matrix to the material
  22264. * @param world defines the world transformation matrix
  22265. */
  22266. bindOnlyWorldMatrix(world: Matrix): void;
  22267. /**
  22268. * Binds the submesh to this material by preparing the effect and shader to draw
  22269. * @param world defines the world transformation matrix
  22270. * @param mesh defines the mesh containing the submesh
  22271. * @param subMesh defines the submesh to bind the material to
  22272. */
  22273. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22274. /**
  22275. * Gets the active textures from the material
  22276. * @returns an array of textures
  22277. */
  22278. getActiveTextures(): BaseTexture[];
  22279. /**
  22280. * Gets the list of texture blocks
  22281. * @returns an array of texture blocks
  22282. */
  22283. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22284. /**
  22285. * Specifies if the material uses a texture
  22286. * @param texture defines the texture to check against the material
  22287. * @returns a boolean specifying if the material uses the texture
  22288. */
  22289. hasTexture(texture: BaseTexture): boolean;
  22290. /**
  22291. * Disposes the material
  22292. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22293. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22294. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22295. */
  22296. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22297. /** Creates the node editor window. */
  22298. private _createNodeEditor;
  22299. /**
  22300. * Launch the node material editor
  22301. * @param config Define the configuration of the editor
  22302. * @return a promise fulfilled when the node editor is visible
  22303. */
  22304. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22305. /**
  22306. * Clear the current material
  22307. */
  22308. clear(): void;
  22309. /**
  22310. * Clear the current material and set it to a default state
  22311. */
  22312. setToDefault(): void;
  22313. /**
  22314. * Clear the current material and set it to a default state for post process
  22315. */
  22316. setToDefaultPostProcess(): void;
  22317. /**
  22318. * Clear the current material and set it to a default state for particle
  22319. */
  22320. setToDefaultParticle(): void;
  22321. /**
  22322. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22323. * @param url defines the url to load from
  22324. * @returns a promise that will fullfil when the material is fully loaded
  22325. */
  22326. loadAsync(url: string): Promise<void>;
  22327. private _gatherBlocks;
  22328. /**
  22329. * Generate a string containing the code declaration required to create an equivalent of this material
  22330. * @returns a string
  22331. */
  22332. generateCode(): string;
  22333. /**
  22334. * Serializes this material in a JSON representation
  22335. * @returns the serialized material object
  22336. */
  22337. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22338. private _restoreConnections;
  22339. /**
  22340. * Clear the current graph and load a new one from a serialization object
  22341. * @param source defines the JSON representation of the material
  22342. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22343. * @param merge defines whether or not the source must be merged or replace the current content
  22344. */
  22345. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22346. /**
  22347. * Makes a duplicate of the current material.
  22348. * @param name - name to use for the new material.
  22349. */
  22350. clone(name: string): NodeMaterial;
  22351. /**
  22352. * Creates a node material from parsed material data
  22353. * @param source defines the JSON representation of the material
  22354. * @param scene defines the hosting scene
  22355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22356. * @returns a new node material
  22357. */
  22358. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22359. /**
  22360. * Creates a node material from a snippet saved in a remote file
  22361. * @param name defines the name of the material to create
  22362. * @param url defines the url to load from
  22363. * @param scene defines the hosting scene
  22364. * @returns a promise that will resolve to the new node material
  22365. */
  22366. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22367. /**
  22368. * Creates a node material from a snippet saved by the node material editor
  22369. * @param snippetId defines the snippet to load
  22370. * @param scene defines the hosting scene
  22371. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22372. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22373. * @returns a promise that will resolve to the new node material
  22374. */
  22375. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22376. /**
  22377. * Creates a new node material set to default basic configuration
  22378. * @param name defines the name of the material
  22379. * @param scene defines the hosting scene
  22380. * @returns a new NodeMaterial
  22381. */
  22382. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22383. }
  22384. }
  22385. declare module BABYLON {
  22386. /**
  22387. * Size options for a post process
  22388. */
  22389. export type PostProcessOptions = {
  22390. width: number;
  22391. height: number;
  22392. };
  22393. /**
  22394. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22395. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22396. */
  22397. export class PostProcess {
  22398. /** Name of the PostProcess. */
  22399. name: string;
  22400. /**
  22401. * Gets or sets the unique id of the post process
  22402. */
  22403. uniqueId: number;
  22404. /**
  22405. * Width of the texture to apply the post process on
  22406. */
  22407. width: number;
  22408. /**
  22409. * Height of the texture to apply the post process on
  22410. */
  22411. height: number;
  22412. /**
  22413. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22414. */
  22415. nodeMaterialSource: Nullable<NodeMaterial>;
  22416. /**
  22417. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22418. * @hidden
  22419. */
  22420. _outputTexture: Nullable<InternalTexture>;
  22421. /**
  22422. * Sampling mode used by the shader
  22423. * See https://doc.babylonjs.com/classes/3.1/texture
  22424. */
  22425. renderTargetSamplingMode: number;
  22426. /**
  22427. * Clear color to use when screen clearing
  22428. */
  22429. clearColor: Color4;
  22430. /**
  22431. * If the buffer needs to be cleared before applying the post process. (default: true)
  22432. * Should be set to false if shader will overwrite all previous pixels.
  22433. */
  22434. autoClear: boolean;
  22435. /**
  22436. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22437. */
  22438. alphaMode: number;
  22439. /**
  22440. * Sets the setAlphaBlendConstants of the babylon engine
  22441. */
  22442. alphaConstants: Color4;
  22443. /**
  22444. * Animations to be used for the post processing
  22445. */
  22446. animations: Animation[];
  22447. /**
  22448. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22449. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22450. */
  22451. enablePixelPerfectMode: boolean;
  22452. /**
  22453. * Force the postprocess to be applied without taking in account viewport
  22454. */
  22455. forceFullscreenViewport: boolean;
  22456. /**
  22457. * List of inspectable custom properties (used by the Inspector)
  22458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22459. */
  22460. inspectableCustomProperties: IInspectable[];
  22461. /**
  22462. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22463. *
  22464. * | Value | Type | Description |
  22465. * | ----- | ----------------------------------- | ----------- |
  22466. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22467. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22468. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22469. *
  22470. */
  22471. scaleMode: number;
  22472. /**
  22473. * Force textures to be a power of two (default: false)
  22474. */
  22475. alwaysForcePOT: boolean;
  22476. private _samples;
  22477. /**
  22478. * Number of sample textures (default: 1)
  22479. */
  22480. get samples(): number;
  22481. set samples(n: number);
  22482. /**
  22483. * Modify the scale of the post process to be the same as the viewport (default: false)
  22484. */
  22485. adaptScaleToCurrentViewport: boolean;
  22486. private _camera;
  22487. protected _scene: Scene;
  22488. private _engine;
  22489. private _options;
  22490. private _reusable;
  22491. private _textureType;
  22492. private _textureFormat;
  22493. /**
  22494. * Smart array of input and output textures for the post process.
  22495. * @hidden
  22496. */
  22497. _textures: SmartArray<InternalTexture>;
  22498. /**
  22499. * The index in _textures that corresponds to the output texture.
  22500. * @hidden
  22501. */
  22502. _currentRenderTextureInd: number;
  22503. private _effect;
  22504. private _samplers;
  22505. private _fragmentUrl;
  22506. private _vertexUrl;
  22507. private _parameters;
  22508. private _scaleRatio;
  22509. protected _indexParameters: any;
  22510. private _shareOutputWithPostProcess;
  22511. private _texelSize;
  22512. private _forcedOutputTexture;
  22513. /**
  22514. * Returns the fragment url or shader name used in the post process.
  22515. * @returns the fragment url or name in the shader store.
  22516. */
  22517. getEffectName(): string;
  22518. /**
  22519. * An event triggered when the postprocess is activated.
  22520. */
  22521. onActivateObservable: Observable<Camera>;
  22522. private _onActivateObserver;
  22523. /**
  22524. * A function that is added to the onActivateObservable
  22525. */
  22526. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22527. /**
  22528. * An event triggered when the postprocess changes its size.
  22529. */
  22530. onSizeChangedObservable: Observable<PostProcess>;
  22531. private _onSizeChangedObserver;
  22532. /**
  22533. * A function that is added to the onSizeChangedObservable
  22534. */
  22535. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22536. /**
  22537. * An event triggered when the postprocess applies its effect.
  22538. */
  22539. onApplyObservable: Observable<Effect>;
  22540. private _onApplyObserver;
  22541. /**
  22542. * A function that is added to the onApplyObservable
  22543. */
  22544. set onApply(callback: (effect: Effect) => void);
  22545. /**
  22546. * An event triggered before rendering the postprocess
  22547. */
  22548. onBeforeRenderObservable: Observable<Effect>;
  22549. private _onBeforeRenderObserver;
  22550. /**
  22551. * A function that is added to the onBeforeRenderObservable
  22552. */
  22553. set onBeforeRender(callback: (effect: Effect) => void);
  22554. /**
  22555. * An event triggered after rendering the postprocess
  22556. */
  22557. onAfterRenderObservable: Observable<Effect>;
  22558. private _onAfterRenderObserver;
  22559. /**
  22560. * A function that is added to the onAfterRenderObservable
  22561. */
  22562. set onAfterRender(callback: (efect: Effect) => void);
  22563. /**
  22564. * 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
  22565. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22566. */
  22567. get inputTexture(): InternalTexture;
  22568. set inputTexture(value: InternalTexture);
  22569. /**
  22570. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22571. * the only way to unset it is to use this function to restore its internal state
  22572. */
  22573. restoreDefaultInputTexture(): void;
  22574. /**
  22575. * Gets the camera which post process is applied to.
  22576. * @returns The camera the post process is applied to.
  22577. */
  22578. getCamera(): Camera;
  22579. /**
  22580. * Gets the texel size of the postprocess.
  22581. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22582. */
  22583. get texelSize(): Vector2;
  22584. /**
  22585. * Creates a new instance PostProcess
  22586. * @param name The name of the PostProcess.
  22587. * @param fragmentUrl The url of the fragment shader to be used.
  22588. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22589. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22590. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22591. * @param camera The camera to apply the render pass to.
  22592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22593. * @param engine The engine which the post process will be applied. (default: current engine)
  22594. * @param reusable If the post process can be reused on the same frame. (default: false)
  22595. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22596. * @param textureType Type of textures used when performing the post process. (default: 0)
  22597. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22598. * @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
  22599. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22600. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22601. */
  22602. constructor(
  22603. /** Name of the PostProcess. */
  22604. 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);
  22605. /**
  22606. * Gets a string idenfifying the name of the class
  22607. * @returns "PostProcess" string
  22608. */
  22609. getClassName(): string;
  22610. /**
  22611. * Gets the engine which this post process belongs to.
  22612. * @returns The engine the post process was enabled with.
  22613. */
  22614. getEngine(): Engine;
  22615. /**
  22616. * The effect that is created when initializing the post process.
  22617. * @returns The created effect corresponding the the postprocess.
  22618. */
  22619. getEffect(): Effect;
  22620. /**
  22621. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22622. * @param postProcess The post process to share the output with.
  22623. * @returns This post process.
  22624. */
  22625. shareOutputWith(postProcess: PostProcess): PostProcess;
  22626. /**
  22627. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22628. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22629. */
  22630. useOwnOutput(): void;
  22631. /**
  22632. * Updates the effect with the current post process compile time values and recompiles the shader.
  22633. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22634. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22635. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22636. * @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
  22637. * @param onCompiled Called when the shader has been compiled.
  22638. * @param onError Called if there is an error when compiling a shader.
  22639. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22640. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22641. */
  22642. 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;
  22643. /**
  22644. * The post process is reusable if it can be used multiple times within one frame.
  22645. * @returns If the post process is reusable
  22646. */
  22647. isReusable(): boolean;
  22648. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22649. markTextureDirty(): void;
  22650. /**
  22651. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22652. * 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.
  22653. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22654. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22655. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22656. * @returns The target texture that was bound to be written to.
  22657. */
  22658. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22659. /**
  22660. * If the post process is supported.
  22661. */
  22662. get isSupported(): boolean;
  22663. /**
  22664. * The aspect ratio of the output texture.
  22665. */
  22666. get aspectRatio(): number;
  22667. /**
  22668. * Get a value indicating if the post-process is ready to be used
  22669. * @returns true if the post-process is ready (shader is compiled)
  22670. */
  22671. isReady(): boolean;
  22672. /**
  22673. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22674. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22675. */
  22676. apply(): Nullable<Effect>;
  22677. private _disposeTextures;
  22678. /**
  22679. * Disposes the post process.
  22680. * @param camera The camera to dispose the post process on.
  22681. */
  22682. dispose(camera?: Camera): void;
  22683. }
  22684. }
  22685. declare module BABYLON {
  22686. /** @hidden */
  22687. export var kernelBlurVaryingDeclaration: {
  22688. name: string;
  22689. shader: string;
  22690. };
  22691. }
  22692. declare module BABYLON {
  22693. /** @hidden */
  22694. export var kernelBlurFragment: {
  22695. name: string;
  22696. shader: string;
  22697. };
  22698. }
  22699. declare module BABYLON {
  22700. /** @hidden */
  22701. export var kernelBlurFragment2: {
  22702. name: string;
  22703. shader: string;
  22704. };
  22705. }
  22706. declare module BABYLON {
  22707. /** @hidden */
  22708. export var kernelBlurPixelShader: {
  22709. name: string;
  22710. shader: string;
  22711. };
  22712. }
  22713. declare module BABYLON {
  22714. /** @hidden */
  22715. export var kernelBlurVertex: {
  22716. name: string;
  22717. shader: string;
  22718. };
  22719. }
  22720. declare module BABYLON {
  22721. /** @hidden */
  22722. export var kernelBlurVertexShader: {
  22723. name: string;
  22724. shader: string;
  22725. };
  22726. }
  22727. declare module BABYLON {
  22728. /**
  22729. * The Blur Post Process which blurs an image based on a kernel and direction.
  22730. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22731. */
  22732. export class BlurPostProcess extends PostProcess {
  22733. /** The direction in which to blur the image. */
  22734. direction: Vector2;
  22735. private blockCompilation;
  22736. protected _kernel: number;
  22737. protected _idealKernel: number;
  22738. protected _packedFloat: boolean;
  22739. private _staticDefines;
  22740. /**
  22741. * Sets the length in pixels of the blur sample region
  22742. */
  22743. set kernel(v: number);
  22744. /**
  22745. * Gets the length in pixels of the blur sample region
  22746. */
  22747. get kernel(): number;
  22748. /**
  22749. * Sets wether or not the blur needs to unpack/repack floats
  22750. */
  22751. set packedFloat(v: boolean);
  22752. /**
  22753. * Gets wether or not the blur is unpacking/repacking floats
  22754. */
  22755. get packedFloat(): boolean;
  22756. /**
  22757. * Creates a new instance BlurPostProcess
  22758. * @param name The name of the effect.
  22759. * @param direction The direction in which to blur the image.
  22760. * @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.
  22761. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22762. * @param camera The camera to apply the render pass to.
  22763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22764. * @param engine The engine which the post process will be applied. (default: current engine)
  22765. * @param reusable If the post process can be reused on the same frame. (default: false)
  22766. * @param textureType Type of textures used when performing the post process. (default: 0)
  22767. * @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)
  22768. */
  22769. constructor(name: string,
  22770. /** The direction in which to blur the image. */
  22771. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22772. /**
  22773. * Updates the effect with the current post process compile time values and recompiles the shader.
  22774. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22775. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22776. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22777. * @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
  22778. * @param onCompiled Called when the shader has been compiled.
  22779. * @param onError Called if there is an error when compiling a shader.
  22780. */
  22781. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22782. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22783. /**
  22784. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22785. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22786. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22787. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22788. * The gaps between physical kernels are compensated for in the weighting of the samples
  22789. * @param idealKernel Ideal blur kernel.
  22790. * @return Nearest best kernel.
  22791. */
  22792. protected _nearestBestKernel(idealKernel: number): number;
  22793. /**
  22794. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22795. * @param x The point on the Gaussian distribution to sample.
  22796. * @return the value of the Gaussian function at x.
  22797. */
  22798. protected _gaussianWeight(x: number): number;
  22799. /**
  22800. * Generates a string that can be used as a floating point number in GLSL.
  22801. * @param x Value to print.
  22802. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22803. * @return GLSL float string.
  22804. */
  22805. protected _glslFloat(x: number, decimalFigures?: number): string;
  22806. }
  22807. }
  22808. declare module BABYLON {
  22809. /**
  22810. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22811. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22812. * You can then easily use it as a reflectionTexture on a flat surface.
  22813. * In case the surface is not a plane, please consider relying on reflection probes.
  22814. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22815. */
  22816. export class MirrorTexture extends RenderTargetTexture {
  22817. private scene;
  22818. /**
  22819. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22820. * 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.
  22821. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22822. */
  22823. mirrorPlane: Plane;
  22824. /**
  22825. * Define the blur ratio used to blur the reflection if needed.
  22826. */
  22827. set blurRatio(value: number);
  22828. get blurRatio(): number;
  22829. /**
  22830. * Define the adaptive blur kernel used to blur the reflection if needed.
  22831. * This will autocompute the closest best match for the `blurKernel`
  22832. */
  22833. set adaptiveBlurKernel(value: number);
  22834. /**
  22835. * Define the blur kernel used to blur the reflection if needed.
  22836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22837. */
  22838. set blurKernel(value: number);
  22839. /**
  22840. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22841. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22842. */
  22843. set blurKernelX(value: number);
  22844. get blurKernelX(): number;
  22845. /**
  22846. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22847. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22848. */
  22849. set blurKernelY(value: number);
  22850. get blurKernelY(): number;
  22851. private _autoComputeBlurKernel;
  22852. protected _onRatioRescale(): void;
  22853. private _updateGammaSpace;
  22854. private _imageProcessingConfigChangeObserver;
  22855. private _transformMatrix;
  22856. private _mirrorMatrix;
  22857. private _savedViewMatrix;
  22858. private _blurX;
  22859. private _blurY;
  22860. private _adaptiveBlurKernel;
  22861. private _blurKernelX;
  22862. private _blurKernelY;
  22863. private _blurRatio;
  22864. /**
  22865. * Instantiates a Mirror Texture.
  22866. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22867. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22868. * You can then easily use it as a reflectionTexture on a flat surface.
  22869. * In case the surface is not a plane, please consider relying on reflection probes.
  22870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22871. * @param name
  22872. * @param size
  22873. * @param scene
  22874. * @param generateMipMaps
  22875. * @param type
  22876. * @param samplingMode
  22877. * @param generateDepthBuffer
  22878. */
  22879. constructor(name: string, size: number | {
  22880. width: number;
  22881. height: number;
  22882. } | {
  22883. ratio: number;
  22884. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22885. private _preparePostProcesses;
  22886. /**
  22887. * Clone the mirror texture.
  22888. * @returns the cloned texture
  22889. */
  22890. clone(): MirrorTexture;
  22891. /**
  22892. * Serialize the texture to a JSON representation you could use in Parse later on
  22893. * @returns the serialized JSON representation
  22894. */
  22895. serialize(): any;
  22896. /**
  22897. * Dispose the texture and release its associated resources.
  22898. */
  22899. dispose(): void;
  22900. }
  22901. }
  22902. declare module BABYLON {
  22903. /**
  22904. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22905. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22906. */
  22907. export class Texture extends BaseTexture {
  22908. /**
  22909. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22910. */
  22911. static SerializeBuffers: boolean;
  22912. /** @hidden */
  22913. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22914. /** @hidden */
  22915. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22916. /** @hidden */
  22917. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22918. /** nearest is mag = nearest and min = nearest and mip = linear */
  22919. static readonly NEAREST_SAMPLINGMODE: number;
  22920. /** nearest is mag = nearest and min = nearest and mip = linear */
  22921. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22923. static readonly BILINEAR_SAMPLINGMODE: number;
  22924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22925. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22926. /** Trilinear is mag = linear and min = linear and mip = linear */
  22927. static readonly TRILINEAR_SAMPLINGMODE: number;
  22928. /** Trilinear is mag = linear and min = linear and mip = linear */
  22929. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22930. /** mag = nearest and min = nearest and mip = nearest */
  22931. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22932. /** mag = nearest and min = linear and mip = nearest */
  22933. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22934. /** mag = nearest and min = linear and mip = linear */
  22935. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22936. /** mag = nearest and min = linear and mip = none */
  22937. static readonly NEAREST_LINEAR: number;
  22938. /** mag = nearest and min = nearest and mip = none */
  22939. static readonly NEAREST_NEAREST: number;
  22940. /** mag = linear and min = nearest and mip = nearest */
  22941. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22942. /** mag = linear and min = nearest and mip = linear */
  22943. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22944. /** mag = linear and min = linear and mip = none */
  22945. static readonly LINEAR_LINEAR: number;
  22946. /** mag = linear and min = nearest and mip = none */
  22947. static readonly LINEAR_NEAREST: number;
  22948. /** Explicit coordinates mode */
  22949. static readonly EXPLICIT_MODE: number;
  22950. /** Spherical coordinates mode */
  22951. static readonly SPHERICAL_MODE: number;
  22952. /** Planar coordinates mode */
  22953. static readonly PLANAR_MODE: number;
  22954. /** Cubic coordinates mode */
  22955. static readonly CUBIC_MODE: number;
  22956. /** Projection coordinates mode */
  22957. static readonly PROJECTION_MODE: number;
  22958. /** Inverse Cubic coordinates mode */
  22959. static readonly SKYBOX_MODE: number;
  22960. /** Inverse Cubic coordinates mode */
  22961. static readonly INVCUBIC_MODE: number;
  22962. /** Equirectangular coordinates mode */
  22963. static readonly EQUIRECTANGULAR_MODE: number;
  22964. /** Equirectangular Fixed coordinates mode */
  22965. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22966. /** Equirectangular Fixed Mirrored coordinates mode */
  22967. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22968. /** Texture is not repeating outside of 0..1 UVs */
  22969. static readonly CLAMP_ADDRESSMODE: number;
  22970. /** Texture is repeating outside of 0..1 UVs */
  22971. static readonly WRAP_ADDRESSMODE: number;
  22972. /** Texture is repeating and mirrored */
  22973. static readonly MIRROR_ADDRESSMODE: number;
  22974. /**
  22975. * 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
  22976. */
  22977. static UseSerializedUrlIfAny: boolean;
  22978. /**
  22979. * Define the url of the texture.
  22980. */
  22981. url: Nullable<string>;
  22982. /**
  22983. * Define an offset on the texture to offset the u coordinates of the UVs
  22984. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. uOffset: number;
  22987. /**
  22988. * Define an offset on the texture to offset the v coordinates of the UVs
  22989. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22990. */
  22991. vOffset: number;
  22992. /**
  22993. * Define an offset on the texture to scale the u coordinates of the UVs
  22994. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. uScale: number;
  22997. /**
  22998. * Define an offset on the texture to scale the v coordinates of the UVs
  22999. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23000. */
  23001. vScale: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23004. * @see https://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. uAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23009. * @see https://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. vAng: number;
  23012. /**
  23013. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23014. * @see https://doc.babylonjs.com/how_to/more_materials
  23015. */
  23016. wAng: number;
  23017. /**
  23018. * Defines the center of rotation (U)
  23019. */
  23020. uRotationCenter: number;
  23021. /**
  23022. * Defines the center of rotation (V)
  23023. */
  23024. vRotationCenter: number;
  23025. /**
  23026. * Defines the center of rotation (W)
  23027. */
  23028. wRotationCenter: number;
  23029. /**
  23030. * Are mip maps generated for this texture or not.
  23031. */
  23032. get noMipmap(): boolean;
  23033. /**
  23034. * List of inspectable custom properties (used by the Inspector)
  23035. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23036. */
  23037. inspectableCustomProperties: Nullable<IInspectable[]>;
  23038. private _noMipmap;
  23039. /** @hidden */
  23040. _invertY: boolean;
  23041. private _rowGenerationMatrix;
  23042. private _cachedTextureMatrix;
  23043. private _projectionModeMatrix;
  23044. private _t0;
  23045. private _t1;
  23046. private _t2;
  23047. private _cachedUOffset;
  23048. private _cachedVOffset;
  23049. private _cachedUScale;
  23050. private _cachedVScale;
  23051. private _cachedUAng;
  23052. private _cachedVAng;
  23053. private _cachedWAng;
  23054. private _cachedProjectionMatrixId;
  23055. private _cachedCoordinatesMode;
  23056. /** @hidden */
  23057. protected _initialSamplingMode: number;
  23058. /** @hidden */
  23059. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23060. private _deleteBuffer;
  23061. protected _format: Nullable<number>;
  23062. private _delayedOnLoad;
  23063. private _delayedOnError;
  23064. private _mimeType?;
  23065. /**
  23066. * Observable triggered once the texture has been loaded.
  23067. */
  23068. onLoadObservable: Observable<Texture>;
  23069. protected _isBlocking: boolean;
  23070. /**
  23071. * Is the texture preventing material to render while loading.
  23072. * If false, a default texture will be used instead of the loading one during the preparation step.
  23073. */
  23074. set isBlocking(value: boolean);
  23075. get isBlocking(): boolean;
  23076. /**
  23077. * Get the current sampling mode associated with the texture.
  23078. */
  23079. get samplingMode(): number;
  23080. /**
  23081. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23082. */
  23083. get invertY(): boolean;
  23084. /**
  23085. * Instantiates a new texture.
  23086. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23087. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23088. * @param url defines the url of the picture to load as a texture
  23089. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23090. * @param noMipmap defines if the texture will require mip maps or not
  23091. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23092. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23093. * @param onLoad defines a callback triggered when the texture has been loaded
  23094. * @param onError defines a callback triggered when an error occurred during the loading session
  23095. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23096. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23097. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23098. * @param mimeType defines an optional mime type information
  23099. */
  23100. 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);
  23101. /**
  23102. * Update the url (and optional buffer) of this texture if url was null during construction.
  23103. * @param url the url of the texture
  23104. * @param buffer the buffer of the texture (defaults to null)
  23105. * @param onLoad callback called when the texture is loaded (defaults to null)
  23106. */
  23107. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23108. /**
  23109. * Finish the loading sequence of a texture flagged as delayed load.
  23110. * @hidden
  23111. */
  23112. delayLoad(): void;
  23113. private _prepareRowForTextureGeneration;
  23114. /**
  23115. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23116. * @returns the transform matrix of the texture.
  23117. */
  23118. getTextureMatrix(uBase?: number): Matrix;
  23119. /**
  23120. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23121. * @returns The reflection texture transform
  23122. */
  23123. getReflectionTextureMatrix(): Matrix;
  23124. /**
  23125. * Clones the texture.
  23126. * @returns the cloned texture
  23127. */
  23128. clone(): Texture;
  23129. /**
  23130. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23131. * @returns The JSON representation of the texture
  23132. */
  23133. serialize(): any;
  23134. /**
  23135. * Get the current class name of the texture useful for serialization or dynamic coding.
  23136. * @returns "Texture"
  23137. */
  23138. getClassName(): string;
  23139. /**
  23140. * Dispose the texture and release its associated resources.
  23141. */
  23142. dispose(): void;
  23143. /**
  23144. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23145. * @param parsedTexture Define the JSON representation of the texture
  23146. * @param scene Define the scene the parsed texture should be instantiated in
  23147. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23148. * @returns The parsed texture if successful
  23149. */
  23150. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23151. /**
  23152. * Creates a texture from its base 64 representation.
  23153. * @param data Define the base64 payload without the data: prefix
  23154. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23155. * @param scene Define the scene the texture should belong to
  23156. * @param noMipmap Forces the texture to not create mip map information if true
  23157. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23158. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23159. * @param onLoad define a callback triggered when the texture has been loaded
  23160. * @param onError define a callback triggered when an error occurred during the loading session
  23161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23162. * @returns the created texture
  23163. */
  23164. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23165. /**
  23166. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23167. * @param data Define the base64 payload without the data: prefix
  23168. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23169. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23170. * @param scene Define the scene the texture should belong to
  23171. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23172. * @param noMipmap Forces the texture to not create mip map information if true
  23173. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23174. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23175. * @param onLoad define a callback triggered when the texture has been loaded
  23176. * @param onError define a callback triggered when an error occurred during the loading session
  23177. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23178. * @returns the created texture
  23179. */
  23180. 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;
  23181. }
  23182. }
  23183. declare module BABYLON {
  23184. /**
  23185. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23186. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23187. */
  23188. export class PostProcessManager {
  23189. private _scene;
  23190. private _indexBuffer;
  23191. private _vertexBuffers;
  23192. /**
  23193. * Creates a new instance PostProcess
  23194. * @param scene The scene that the post process is associated with.
  23195. */
  23196. constructor(scene: Scene);
  23197. private _prepareBuffers;
  23198. private _buildIndexBuffer;
  23199. /**
  23200. * Rebuilds the vertex buffers of the manager.
  23201. * @hidden
  23202. */
  23203. _rebuild(): void;
  23204. /**
  23205. * Prepares a frame to be run through a post process.
  23206. * @param sourceTexture The input texture to the post procesess. (default: null)
  23207. * @param postProcesses An array of post processes to be run. (default: null)
  23208. * @returns True if the post processes were able to be run.
  23209. * @hidden
  23210. */
  23211. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23212. /**
  23213. * Manually render a set of post processes to a texture.
  23214. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23215. * @param postProcesses An array of post processes to be run.
  23216. * @param targetTexture The target texture to render to.
  23217. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23218. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23219. * @param lodLevel defines which lod of the texture to render to
  23220. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23221. */
  23222. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23223. /**
  23224. * Finalize the result of the output of the postprocesses.
  23225. * @param doNotPresent If true the result will not be displayed to the screen.
  23226. * @param targetTexture The target texture to render to.
  23227. * @param faceIndex The index of the face to bind the target texture to.
  23228. * @param postProcesses The array of post processes to render.
  23229. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23230. * @hidden
  23231. */
  23232. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23233. /**
  23234. * Disposes of the post process manager.
  23235. */
  23236. dispose(): void;
  23237. }
  23238. }
  23239. declare module BABYLON {
  23240. /**
  23241. * This Helps creating a texture that will be created from a camera in your scene.
  23242. * It is basically a dynamic texture that could be used to create special effects for instance.
  23243. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23244. */
  23245. export class RenderTargetTexture extends Texture {
  23246. isCube: boolean;
  23247. /**
  23248. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23249. */
  23250. static readonly REFRESHRATE_RENDER_ONCE: number;
  23251. /**
  23252. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23253. */
  23254. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23255. /**
  23256. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23257. * the central point of your effect and can save a lot of performances.
  23258. */
  23259. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23260. /**
  23261. * Use this predicate to dynamically define the list of mesh you want to render.
  23262. * If set, the renderList property will be overwritten.
  23263. */
  23264. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23265. private _renderList;
  23266. /**
  23267. * Use this list to define the list of mesh you want to render.
  23268. */
  23269. get renderList(): Nullable<Array<AbstractMesh>>;
  23270. set renderList(value: Nullable<Array<AbstractMesh>>);
  23271. /**
  23272. * Use this function to overload the renderList array at rendering time.
  23273. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23274. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23275. * the cube (if the RTT is a cube, else layerOrFace=0).
  23276. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23277. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23278. * hold dummy elements!
  23279. */
  23280. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23281. private _hookArray;
  23282. /**
  23283. * Define if particles should be rendered in your texture.
  23284. */
  23285. renderParticles: boolean;
  23286. /**
  23287. * Define if sprites should be rendered in your texture.
  23288. */
  23289. renderSprites: boolean;
  23290. /**
  23291. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23292. */
  23293. coordinatesMode: number;
  23294. /**
  23295. * Define the camera used to render the texture.
  23296. */
  23297. activeCamera: Nullable<Camera>;
  23298. /**
  23299. * Override the mesh isReady function with your own one.
  23300. */
  23301. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23302. /**
  23303. * Override the render function of the texture with your own one.
  23304. */
  23305. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23306. /**
  23307. * Define if camera post processes should be use while rendering the texture.
  23308. */
  23309. useCameraPostProcesses: boolean;
  23310. /**
  23311. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23312. */
  23313. ignoreCameraViewport: boolean;
  23314. private _postProcessManager;
  23315. private _postProcesses;
  23316. private _resizeObserver;
  23317. /**
  23318. * An event triggered when the texture is unbind.
  23319. */
  23320. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23321. /**
  23322. * An event triggered when the texture is unbind.
  23323. */
  23324. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23325. private _onAfterUnbindObserver;
  23326. /**
  23327. * Set a after unbind callback in the texture.
  23328. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23329. */
  23330. set onAfterUnbind(callback: () => void);
  23331. /**
  23332. * An event triggered before rendering the texture
  23333. */
  23334. onBeforeRenderObservable: Observable<number>;
  23335. private _onBeforeRenderObserver;
  23336. /**
  23337. * Set a before render callback in the texture.
  23338. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23339. */
  23340. set onBeforeRender(callback: (faceIndex: number) => void);
  23341. /**
  23342. * An event triggered after rendering the texture
  23343. */
  23344. onAfterRenderObservable: Observable<number>;
  23345. private _onAfterRenderObserver;
  23346. /**
  23347. * Set a after render callback in the texture.
  23348. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23349. */
  23350. set onAfterRender(callback: (faceIndex: number) => void);
  23351. /**
  23352. * An event triggered after the texture clear
  23353. */
  23354. onClearObservable: Observable<Engine>;
  23355. private _onClearObserver;
  23356. /**
  23357. * Set a clear callback in the texture.
  23358. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23359. */
  23360. set onClear(callback: (Engine: Engine) => void);
  23361. /**
  23362. * An event triggered when the texture is resized.
  23363. */
  23364. onResizeObservable: Observable<RenderTargetTexture>;
  23365. /**
  23366. * Define the clear color of the Render Target if it should be different from the scene.
  23367. */
  23368. clearColor: Color4;
  23369. protected _size: number | {
  23370. width: number;
  23371. height: number;
  23372. layers?: number;
  23373. };
  23374. protected _initialSizeParameter: number | {
  23375. width: number;
  23376. height: number;
  23377. } | {
  23378. ratio: number;
  23379. };
  23380. protected _sizeRatio: Nullable<number>;
  23381. /** @hidden */
  23382. _generateMipMaps: boolean;
  23383. protected _renderingManager: RenderingManager;
  23384. /** @hidden */
  23385. _waitingRenderList: string[];
  23386. protected _doNotChangeAspectRatio: boolean;
  23387. protected _currentRefreshId: number;
  23388. protected _refreshRate: number;
  23389. protected _textureMatrix: Matrix;
  23390. protected _samples: number;
  23391. protected _renderTargetOptions: RenderTargetCreationOptions;
  23392. /**
  23393. * Gets render target creation options that were used.
  23394. */
  23395. get renderTargetOptions(): RenderTargetCreationOptions;
  23396. protected _onRatioRescale(): void;
  23397. /**
  23398. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23399. * It must define where the camera used to render the texture is set
  23400. */
  23401. boundingBoxPosition: Vector3;
  23402. private _boundingBoxSize;
  23403. /**
  23404. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23405. * When defined, the cubemap will switch to local mode
  23406. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23407. * @example https://www.babylonjs-playground.com/#RNASML
  23408. */
  23409. set boundingBoxSize(value: Vector3);
  23410. get boundingBoxSize(): Vector3;
  23411. /**
  23412. * In case the RTT has been created with a depth texture, get the associated
  23413. * depth texture.
  23414. * Otherwise, return null.
  23415. */
  23416. get depthStencilTexture(): Nullable<InternalTexture>;
  23417. /**
  23418. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23419. * or used a shadow, depth texture...
  23420. * @param name The friendly name of the texture
  23421. * @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)
  23422. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23423. * @param generateMipMaps True if mip maps need to be generated after render.
  23424. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23425. * @param type The type of the buffer in the RTT (int, half float, float...)
  23426. * @param isCube True if a cube texture needs to be created
  23427. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23428. * @param generateDepthBuffer True to generate a depth buffer
  23429. * @param generateStencilBuffer True to generate a stencil buffer
  23430. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23431. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23432. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23433. */
  23434. constructor(name: string, size: number | {
  23435. width: number;
  23436. height: number;
  23437. layers?: number;
  23438. } | {
  23439. ratio: number;
  23440. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23441. /**
  23442. * Creates a depth stencil texture.
  23443. * This is only available in WebGL 2 or with the depth texture extension available.
  23444. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23445. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23446. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23447. */
  23448. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23449. private _processSizeParameter;
  23450. /**
  23451. * Define the number of samples to use in case of MSAA.
  23452. * It defaults to one meaning no MSAA has been enabled.
  23453. */
  23454. get samples(): number;
  23455. set samples(value: number);
  23456. /**
  23457. * Resets the refresh counter of the texture and start bak from scratch.
  23458. * Could be useful to regenerate the texture if it is setup to render only once.
  23459. */
  23460. resetRefreshCounter(): void;
  23461. /**
  23462. * Define the refresh rate of the texture or the rendering frequency.
  23463. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23464. */
  23465. get refreshRate(): number;
  23466. set refreshRate(value: number);
  23467. /**
  23468. * Adds a post process to the render target rendering passes.
  23469. * @param postProcess define the post process to add
  23470. */
  23471. addPostProcess(postProcess: PostProcess): void;
  23472. /**
  23473. * Clear all the post processes attached to the render target
  23474. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23475. */
  23476. clearPostProcesses(dispose?: boolean): void;
  23477. /**
  23478. * Remove one of the post process from the list of attached post processes to the texture
  23479. * @param postProcess define the post process to remove from the list
  23480. */
  23481. removePostProcess(postProcess: PostProcess): void;
  23482. /** @hidden */
  23483. _shouldRender(): boolean;
  23484. /**
  23485. * Gets the actual render size of the texture.
  23486. * @returns the width of the render size
  23487. */
  23488. getRenderSize(): number;
  23489. /**
  23490. * Gets the actual render width of the texture.
  23491. * @returns the width of the render size
  23492. */
  23493. getRenderWidth(): number;
  23494. /**
  23495. * Gets the actual render height of the texture.
  23496. * @returns the height of the render size
  23497. */
  23498. getRenderHeight(): number;
  23499. /**
  23500. * Gets the actual number of layers of the texture.
  23501. * @returns the number of layers
  23502. */
  23503. getRenderLayers(): number;
  23504. /**
  23505. * Get if the texture can be rescaled or not.
  23506. */
  23507. get canRescale(): boolean;
  23508. /**
  23509. * Resize the texture using a ratio.
  23510. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23511. */
  23512. scale(ratio: number): void;
  23513. /**
  23514. * Get the texture reflection matrix used to rotate/transform the reflection.
  23515. * @returns the reflection matrix
  23516. */
  23517. getReflectionTextureMatrix(): Matrix;
  23518. /**
  23519. * Resize the texture to a new desired size.
  23520. * Be carrefull as it will recreate all the data in the new texture.
  23521. * @param size Define the new size. It can be:
  23522. * - a number for squared texture,
  23523. * - an object containing { width: number, height: number }
  23524. * - or an object containing a ratio { ratio: number }
  23525. */
  23526. resize(size: number | {
  23527. width: number;
  23528. height: number;
  23529. } | {
  23530. ratio: number;
  23531. }): void;
  23532. private _defaultRenderListPrepared;
  23533. /**
  23534. * Renders all the objects from the render list into the texture.
  23535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23537. */
  23538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23539. private _bestReflectionRenderTargetDimension;
  23540. private _prepareRenderingManager;
  23541. /**
  23542. * @hidden
  23543. * @param faceIndex face index to bind to if this is a cubetexture
  23544. * @param layer defines the index of the texture to bind in the array
  23545. */
  23546. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23547. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23548. private renderToTarget;
  23549. /**
  23550. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23551. * This allowed control for front to back rendering or reversly depending of the special needs.
  23552. *
  23553. * @param renderingGroupId The rendering group id corresponding to its index
  23554. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23555. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23556. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23557. */
  23558. 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;
  23559. /**
  23560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23561. *
  23562. * @param renderingGroupId The rendering group id corresponding to its index
  23563. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23564. */
  23565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23566. /**
  23567. * Clones the texture.
  23568. * @returns the cloned texture
  23569. */
  23570. clone(): RenderTargetTexture;
  23571. /**
  23572. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23573. * @returns The JSON representation of the texture
  23574. */
  23575. serialize(): any;
  23576. /**
  23577. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23578. */
  23579. disposeFramebufferObjects(): void;
  23580. /**
  23581. * Dispose the texture and release its associated resources.
  23582. */
  23583. dispose(): void;
  23584. /** @hidden */
  23585. _rebuild(): void;
  23586. /**
  23587. * Clear the info related to rendering groups preventing retention point in material dispose.
  23588. */
  23589. freeRenderingGroups(): void;
  23590. /**
  23591. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23592. * @returns the view count
  23593. */
  23594. getViewCount(): number;
  23595. }
  23596. }
  23597. declare module BABYLON {
  23598. /**
  23599. * Class used to manipulate GUIDs
  23600. */
  23601. export class GUID {
  23602. /**
  23603. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23604. * Be aware Math.random() could cause collisions, but:
  23605. * "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"
  23606. * @returns a pseudo random id
  23607. */
  23608. static RandomId(): string;
  23609. }
  23610. }
  23611. declare module BABYLON {
  23612. /**
  23613. * Options to be used when creating a shadow depth material
  23614. */
  23615. export interface IIOptionShadowDepthMaterial {
  23616. /** Variables in the vertex shader code that need to have their names remapped.
  23617. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23618. * "var_name" should be either: worldPos or vNormalW
  23619. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23620. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23621. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23622. */
  23623. remappedVariables?: string[];
  23624. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23625. standalone?: boolean;
  23626. }
  23627. /**
  23628. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23629. */
  23630. export class ShadowDepthWrapper {
  23631. private _scene;
  23632. private _options?;
  23633. private _baseMaterial;
  23634. private _onEffectCreatedObserver;
  23635. private _subMeshToEffect;
  23636. private _subMeshToDepthEffect;
  23637. private _meshes;
  23638. /** @hidden */
  23639. _matriceNames: any;
  23640. /** Gets the standalone status of the wrapper */
  23641. get standalone(): boolean;
  23642. /** Gets the base material the wrapper is built upon */
  23643. get baseMaterial(): Material;
  23644. /**
  23645. * Instantiate a new shadow depth wrapper.
  23646. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23647. * generate the shadow depth map. For more information, please refer to the documentation:
  23648. * https://doc.babylonjs.com/babylon101/shadows
  23649. * @param baseMaterial Material to wrap
  23650. * @param scene Define the scene the material belongs to
  23651. * @param options Options used to create the wrapper
  23652. */
  23653. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23654. /**
  23655. * Gets the effect to use to generate the depth map
  23656. * @param subMesh subMesh to get the effect for
  23657. * @param shadowGenerator shadow generator to get the effect for
  23658. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23659. */
  23660. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23661. /**
  23662. * Specifies that the submesh is ready to be used for depth rendering
  23663. * @param subMesh submesh to check
  23664. * @param defines the list of defines to take into account when checking the effect
  23665. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23666. * @param useInstances specifies that instances should be used
  23667. * @returns a boolean indicating that the submesh is ready or not
  23668. */
  23669. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23670. /**
  23671. * Disposes the resources
  23672. */
  23673. dispose(): void;
  23674. private _makeEffect;
  23675. }
  23676. }
  23677. declare module BABYLON {
  23678. interface ThinEngine {
  23679. /**
  23680. * Unbind a list of render target textures from the webGL context
  23681. * This is used only when drawBuffer extension or webGL2 are active
  23682. * @param textures defines the render target textures to unbind
  23683. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23684. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23685. */
  23686. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23687. /**
  23688. * Create a multi render target texture
  23689. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23690. * @param size defines the size of the texture
  23691. * @param options defines the creation options
  23692. * @returns the cube texture as an InternalTexture
  23693. */
  23694. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23695. /**
  23696. * Update the sample count for a given multiple render target texture
  23697. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23698. * @param textures defines the textures to update
  23699. * @param samples defines the sample count to set
  23700. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23701. */
  23702. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23703. /**
  23704. * Select a subsets of attachments to draw to.
  23705. * @param attachments gl attachments
  23706. */
  23707. bindAttachments(attachments: number[]): void;
  23708. }
  23709. }
  23710. declare module BABYLON {
  23711. /**
  23712. * Creation options of the multi render target texture.
  23713. */
  23714. export interface IMultiRenderTargetOptions {
  23715. /**
  23716. * Define if the texture needs to create mip maps after render.
  23717. */
  23718. generateMipMaps?: boolean;
  23719. /**
  23720. * Define the types of all the draw buffers we want to create
  23721. */
  23722. types?: number[];
  23723. /**
  23724. * Define the sampling modes of all the draw buffers we want to create
  23725. */
  23726. samplingModes?: number[];
  23727. /**
  23728. * Define if a depth buffer is required
  23729. */
  23730. generateDepthBuffer?: boolean;
  23731. /**
  23732. * Define if a stencil buffer is required
  23733. */
  23734. generateStencilBuffer?: boolean;
  23735. /**
  23736. * Define if a depth texture is required instead of a depth buffer
  23737. */
  23738. generateDepthTexture?: boolean;
  23739. /**
  23740. * Define the number of desired draw buffers
  23741. */
  23742. textureCount?: number;
  23743. /**
  23744. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23745. */
  23746. doNotChangeAspectRatio?: boolean;
  23747. /**
  23748. * Define the default type of the buffers we are creating
  23749. */
  23750. defaultType?: number;
  23751. }
  23752. /**
  23753. * A multi render target, like a render target provides the ability to render to a texture.
  23754. * Unlike the render target, it can render to several draw buffers in one draw.
  23755. * This is specially interesting in deferred rendering or for any effects requiring more than
  23756. * just one color from a single pass.
  23757. */
  23758. export class MultiRenderTarget extends RenderTargetTexture {
  23759. private _internalTextures;
  23760. private _textures;
  23761. private _multiRenderTargetOptions;
  23762. private _count;
  23763. /**
  23764. * Get if draw buffers are currently supported by the used hardware and browser.
  23765. */
  23766. get isSupported(): boolean;
  23767. /**
  23768. * Get the list of textures generated by the multi render target.
  23769. */
  23770. get textures(): Texture[];
  23771. /**
  23772. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23773. */
  23774. get count(): number;
  23775. /**
  23776. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23777. */
  23778. get depthTexture(): Texture;
  23779. /**
  23780. * Set the wrapping mode on U of all the textures we are rendering to.
  23781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23782. */
  23783. set wrapU(wrap: number);
  23784. /**
  23785. * Set the wrapping mode on V of all the textures we are rendering to.
  23786. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23787. */
  23788. set wrapV(wrap: number);
  23789. /**
  23790. * Instantiate a new multi render target texture.
  23791. * A multi render target, like a render target provides the ability to render to a texture.
  23792. * Unlike the render target, it can render to several draw buffers in one draw.
  23793. * This is specially interesting in deferred rendering or for any effects requiring more than
  23794. * just one color from a single pass.
  23795. * @param name Define the name of the texture
  23796. * @param size Define the size of the buffers to render to
  23797. * @param count Define the number of target we are rendering into
  23798. * @param scene Define the scene the texture belongs to
  23799. * @param options Define the options used to create the multi render target
  23800. */
  23801. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23802. /** @hidden */
  23803. _rebuild(): void;
  23804. private _createInternalTextures;
  23805. private _createTextures;
  23806. /**
  23807. * Define the number of samples used if MSAA is enabled.
  23808. */
  23809. get samples(): number;
  23810. set samples(value: number);
  23811. /**
  23812. * Resize all the textures in the multi render target.
  23813. * Be carrefull as it will recreate all the data in the new texture.
  23814. * @param size Define the new size
  23815. */
  23816. resize(size: any): void;
  23817. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23818. /**
  23819. * Dispose the render targets and their associated resources
  23820. */
  23821. dispose(): void;
  23822. /**
  23823. * Release all the underlying texture used as draw buffers.
  23824. */
  23825. releaseInternalTextures(): void;
  23826. }
  23827. }
  23828. declare module BABYLON {
  23829. /** @hidden */
  23830. export var imageProcessingPixelShader: {
  23831. name: string;
  23832. shader: string;
  23833. };
  23834. }
  23835. declare module BABYLON {
  23836. /**
  23837. * ImageProcessingPostProcess
  23838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23839. */
  23840. export class ImageProcessingPostProcess extends PostProcess {
  23841. /**
  23842. * Default configuration related to image processing available in the PBR Material.
  23843. */
  23844. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23845. /**
  23846. * Gets the image processing configuration used either in this material.
  23847. */
  23848. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23849. /**
  23850. * Sets the Default image processing configuration used either in the this material.
  23851. *
  23852. * If sets to null, the scene one is in use.
  23853. */
  23854. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23855. /**
  23856. * Keep track of the image processing observer to allow dispose and replace.
  23857. */
  23858. private _imageProcessingObserver;
  23859. /**
  23860. * Attaches a new image processing configuration to the PBR Material.
  23861. * @param configuration
  23862. */
  23863. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23864. /**
  23865. * If the post process is supported.
  23866. */
  23867. get isSupported(): boolean;
  23868. /**
  23869. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23870. */
  23871. get colorCurves(): Nullable<ColorCurves>;
  23872. /**
  23873. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23874. */
  23875. set colorCurves(value: Nullable<ColorCurves>);
  23876. /**
  23877. * Gets wether the color curves effect is enabled.
  23878. */
  23879. get colorCurvesEnabled(): boolean;
  23880. /**
  23881. * Sets wether the color curves effect is enabled.
  23882. */
  23883. set colorCurvesEnabled(value: boolean);
  23884. /**
  23885. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23886. */
  23887. get colorGradingTexture(): Nullable<BaseTexture>;
  23888. /**
  23889. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23890. */
  23891. set colorGradingTexture(value: Nullable<BaseTexture>);
  23892. /**
  23893. * Gets wether the color grading effect is enabled.
  23894. */
  23895. get colorGradingEnabled(): boolean;
  23896. /**
  23897. * Gets wether the color grading effect is enabled.
  23898. */
  23899. set colorGradingEnabled(value: boolean);
  23900. /**
  23901. * Gets exposure used in the effect.
  23902. */
  23903. get exposure(): number;
  23904. /**
  23905. * Sets exposure used in the effect.
  23906. */
  23907. set exposure(value: number);
  23908. /**
  23909. * Gets wether tonemapping is enabled or not.
  23910. */
  23911. get toneMappingEnabled(): boolean;
  23912. /**
  23913. * Sets wether tonemapping is enabled or not
  23914. */
  23915. set toneMappingEnabled(value: boolean);
  23916. /**
  23917. * Gets the type of tone mapping effect.
  23918. */
  23919. get toneMappingType(): number;
  23920. /**
  23921. * Sets the type of tone mapping effect.
  23922. */
  23923. set toneMappingType(value: number);
  23924. /**
  23925. * Gets contrast used in the effect.
  23926. */
  23927. get contrast(): number;
  23928. /**
  23929. * Sets contrast used in the effect.
  23930. */
  23931. set contrast(value: number);
  23932. /**
  23933. * Gets Vignette stretch size.
  23934. */
  23935. get vignetteStretch(): number;
  23936. /**
  23937. * Sets Vignette stretch size.
  23938. */
  23939. set vignetteStretch(value: number);
  23940. /**
  23941. * Gets Vignette centre X Offset.
  23942. */
  23943. get vignetteCentreX(): number;
  23944. /**
  23945. * Sets Vignette centre X Offset.
  23946. */
  23947. set vignetteCentreX(value: number);
  23948. /**
  23949. * Gets Vignette centre Y Offset.
  23950. */
  23951. get vignetteCentreY(): number;
  23952. /**
  23953. * Sets Vignette centre Y Offset.
  23954. */
  23955. set vignetteCentreY(value: number);
  23956. /**
  23957. * Gets Vignette weight or intensity of the vignette effect.
  23958. */
  23959. get vignetteWeight(): number;
  23960. /**
  23961. * Sets Vignette weight or intensity of the vignette effect.
  23962. */
  23963. set vignetteWeight(value: number);
  23964. /**
  23965. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23966. * if vignetteEnabled is set to true.
  23967. */
  23968. get vignetteColor(): Color4;
  23969. /**
  23970. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23971. * if vignetteEnabled is set to true.
  23972. */
  23973. set vignetteColor(value: Color4);
  23974. /**
  23975. * Gets Camera field of view used by the Vignette effect.
  23976. */
  23977. get vignetteCameraFov(): number;
  23978. /**
  23979. * Sets Camera field of view used by the Vignette effect.
  23980. */
  23981. set vignetteCameraFov(value: number);
  23982. /**
  23983. * Gets the vignette blend mode allowing different kind of effect.
  23984. */
  23985. get vignetteBlendMode(): number;
  23986. /**
  23987. * Sets the vignette blend mode allowing different kind of effect.
  23988. */
  23989. set vignetteBlendMode(value: number);
  23990. /**
  23991. * Gets wether the vignette effect is enabled.
  23992. */
  23993. get vignetteEnabled(): boolean;
  23994. /**
  23995. * Sets wether the vignette effect is enabled.
  23996. */
  23997. set vignetteEnabled(value: boolean);
  23998. private _fromLinearSpace;
  23999. /**
  24000. * Gets wether the input of the processing is in Gamma or Linear Space.
  24001. */
  24002. get fromLinearSpace(): boolean;
  24003. /**
  24004. * Sets wether the input of the processing is in Gamma or Linear Space.
  24005. */
  24006. set fromLinearSpace(value: boolean);
  24007. /**
  24008. * Defines cache preventing GC.
  24009. */
  24010. private _defines;
  24011. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24012. /**
  24013. * "ImageProcessingPostProcess"
  24014. * @returns "ImageProcessingPostProcess"
  24015. */
  24016. getClassName(): string;
  24017. /**
  24018. * @hidden
  24019. */
  24020. _updateParameters(): void;
  24021. dispose(camera?: Camera): void;
  24022. }
  24023. }
  24024. declare module BABYLON {
  24025. /** @hidden */
  24026. export var fibonacci: {
  24027. name: string;
  24028. shader: string;
  24029. };
  24030. }
  24031. declare module BABYLON {
  24032. /** @hidden */
  24033. export var subSurfaceScatteringFunctions: {
  24034. name: string;
  24035. shader: string;
  24036. };
  24037. }
  24038. declare module BABYLON {
  24039. /** @hidden */
  24040. export var diffusionProfile: {
  24041. name: string;
  24042. shader: string;
  24043. };
  24044. }
  24045. declare module BABYLON {
  24046. /** @hidden */
  24047. export var subSurfaceScatteringPixelShader: {
  24048. name: string;
  24049. shader: string;
  24050. };
  24051. }
  24052. declare module BABYLON {
  24053. /**
  24054. * Sub surface scattering post process
  24055. */
  24056. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24057. /** @hidden */
  24058. texelWidth: number;
  24059. /** @hidden */
  24060. texelHeight: number;
  24061. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24062. }
  24063. }
  24064. declare module BABYLON {
  24065. /**
  24066. * Interface for defining prepass effects in the prepass post-process pipeline
  24067. */
  24068. export interface PrePassEffectConfiguration {
  24069. /**
  24070. * Post process to attach for this effect
  24071. */
  24072. postProcess: PostProcess;
  24073. /**
  24074. * Is the effect enabled
  24075. */
  24076. enabled: boolean;
  24077. /**
  24078. * Disposes the effect configuration
  24079. */
  24080. dispose(): void;
  24081. /**
  24082. * Disposes the effect configuration
  24083. */
  24084. createPostProcess: () => PostProcess;
  24085. }
  24086. }
  24087. declare module BABYLON {
  24088. /**
  24089. * Contains all parameters needed for the prepass to perform
  24090. * screen space subsurface scattering
  24091. */
  24092. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24093. private _ssDiffusionS;
  24094. private _ssFilterRadii;
  24095. private _ssDiffusionD;
  24096. /**
  24097. * Post process to attach for screen space subsurface scattering
  24098. */
  24099. postProcess: SubSurfaceScatteringPostProcess;
  24100. /**
  24101. * Diffusion profile color for subsurface scattering
  24102. */
  24103. get ssDiffusionS(): number[];
  24104. /**
  24105. * Diffusion profile max color channel value for subsurface scattering
  24106. */
  24107. get ssDiffusionD(): number[];
  24108. /**
  24109. * Diffusion profile filter radius for subsurface scattering
  24110. */
  24111. get ssFilterRadii(): number[];
  24112. /**
  24113. * Is subsurface enabled
  24114. */
  24115. enabled: boolean;
  24116. /**
  24117. * Diffusion profile colors for subsurface scattering
  24118. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24119. * See ...
  24120. * Note that you can only store up to 5 of them
  24121. */
  24122. ssDiffusionProfileColors: Color3[];
  24123. /**
  24124. * Defines the ratio real world => scene units.
  24125. * Used for subsurface scattering
  24126. */
  24127. metersPerUnit: number;
  24128. private _scene;
  24129. /**
  24130. * Builds a subsurface configuration object
  24131. * @param scene The scene
  24132. */
  24133. constructor(scene: Scene);
  24134. /**
  24135. * Adds a new diffusion profile.
  24136. * Useful for more realistic subsurface scattering on diverse materials.
  24137. * @param color The color of the diffusion profile. Should be the average color of the material.
  24138. * @return The index of the diffusion profile for the material subsurface configuration
  24139. */
  24140. addDiffusionProfile(color: Color3): number;
  24141. /**
  24142. * Creates the sss post process
  24143. * @return The created post process
  24144. */
  24145. createPostProcess(): SubSurfaceScatteringPostProcess;
  24146. /**
  24147. * Deletes all diffusion profiles.
  24148. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24149. */
  24150. clearAllDiffusionProfiles(): void;
  24151. /**
  24152. * Disposes this object
  24153. */
  24154. dispose(): void;
  24155. /**
  24156. * @hidden
  24157. * https://zero-radiance.github.io/post/sampling-diffusion/
  24158. *
  24159. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24160. * ------------------------------------------------------------------------------------
  24161. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24162. * PDF[r, phi, s] = r * R[r, phi, s]
  24163. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24164. * ------------------------------------------------------------------------------------
  24165. * We importance sample the color channel with the widest scattering distance.
  24166. */
  24167. getDiffusionProfileParameters(color: Color3): number;
  24168. /**
  24169. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24170. * 'u' is the random number (the value of the CDF): [0, 1).
  24171. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24172. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24173. */
  24174. private _sampleBurleyDiffusionProfile;
  24175. }
  24176. }
  24177. declare module BABYLON {
  24178. /**
  24179. * Renders a pre pass of the scene
  24180. * This means every mesh in the scene will be rendered to a render target texture
  24181. * And then this texture will be composited to the rendering canvas with post processes
  24182. * It is necessary for effects like subsurface scattering or deferred shading
  24183. */
  24184. export class PrePassRenderer {
  24185. /** @hidden */
  24186. static _SceneComponentInitialization: (scene: Scene) => void;
  24187. private _scene;
  24188. private _engine;
  24189. private _isDirty;
  24190. /**
  24191. * Number of textures in the multi render target texture where the scene is directly rendered
  24192. */
  24193. readonly mrtCount: number;
  24194. /**
  24195. * The render target where the scene is directly rendered
  24196. */
  24197. prePassRT: MultiRenderTarget;
  24198. private _mrtTypes;
  24199. private _multiRenderAttachments;
  24200. private _defaultAttachments;
  24201. private _clearAttachments;
  24202. private _postProcesses;
  24203. private readonly _clearColor;
  24204. /**
  24205. * Image processing post process for composition
  24206. */
  24207. imageProcessingPostProcess: ImageProcessingPostProcess;
  24208. /**
  24209. * Configuration for sub surface scattering post process
  24210. */
  24211. subSurfaceConfiguration: SubSurfaceConfiguration;
  24212. /**
  24213. * Should materials render their geometry on the MRT
  24214. */
  24215. materialsShouldRenderGeometry: boolean;
  24216. /**
  24217. * Should materials render the irradiance information on the MRT
  24218. */
  24219. materialsShouldRenderIrradiance: boolean;
  24220. private _enabled;
  24221. /**
  24222. * Indicates if the prepass is enabled
  24223. */
  24224. get enabled(): boolean;
  24225. /**
  24226. * How many samples are used for MSAA of the scene render target
  24227. */
  24228. get samples(): number;
  24229. set samples(n: number);
  24230. /**
  24231. * Instanciates a prepass renderer
  24232. * @param scene The scene
  24233. */
  24234. constructor(scene: Scene);
  24235. private _initializeAttachments;
  24236. private _createCompositionEffect;
  24237. /**
  24238. * Indicates if rendering a prepass is supported
  24239. */
  24240. get isSupported(): boolean;
  24241. /**
  24242. * Sets the proper output textures to draw in the engine.
  24243. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24244. */
  24245. bindAttachmentsForEffect(effect: Effect): void;
  24246. /**
  24247. * @hidden
  24248. */
  24249. _beforeCameraDraw(): void;
  24250. /**
  24251. * @hidden
  24252. */
  24253. _afterCameraDraw(): void;
  24254. private _checkRTSize;
  24255. private _bindFrameBuffer;
  24256. /**
  24257. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24258. */
  24259. clear(): void;
  24260. private _setState;
  24261. private _enable;
  24262. private _disable;
  24263. private _resetPostProcessChain;
  24264. private _bindPostProcessChain;
  24265. /**
  24266. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24267. */
  24268. markAsDirty(): void;
  24269. private _update;
  24270. /**
  24271. * Disposes the prepass renderer.
  24272. */
  24273. dispose(): void;
  24274. }
  24275. }
  24276. declare module BABYLON {
  24277. /**
  24278. * Options for compiling materials.
  24279. */
  24280. export interface IMaterialCompilationOptions {
  24281. /**
  24282. * Defines whether clip planes are enabled.
  24283. */
  24284. clipPlane: boolean;
  24285. /**
  24286. * Defines whether instances are enabled.
  24287. */
  24288. useInstances: boolean;
  24289. }
  24290. /**
  24291. * Options passed when calling customShaderNameResolve
  24292. */
  24293. export interface ICustomShaderNameResolveOptions {
  24294. /**
  24295. * 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
  24296. */
  24297. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24298. }
  24299. /**
  24300. * Base class for the main features of a material in Babylon.js
  24301. */
  24302. export class Material implements IAnimatable {
  24303. /**
  24304. * Returns the triangle fill mode
  24305. */
  24306. static readonly TriangleFillMode: number;
  24307. /**
  24308. * Returns the wireframe mode
  24309. */
  24310. static readonly WireFrameFillMode: number;
  24311. /**
  24312. * Returns the point fill mode
  24313. */
  24314. static readonly PointFillMode: number;
  24315. /**
  24316. * Returns the point list draw mode
  24317. */
  24318. static readonly PointListDrawMode: number;
  24319. /**
  24320. * Returns the line list draw mode
  24321. */
  24322. static readonly LineListDrawMode: number;
  24323. /**
  24324. * Returns the line loop draw mode
  24325. */
  24326. static readonly LineLoopDrawMode: number;
  24327. /**
  24328. * Returns the line strip draw mode
  24329. */
  24330. static readonly LineStripDrawMode: number;
  24331. /**
  24332. * Returns the triangle strip draw mode
  24333. */
  24334. static readonly TriangleStripDrawMode: number;
  24335. /**
  24336. * Returns the triangle fan draw mode
  24337. */
  24338. static readonly TriangleFanDrawMode: number;
  24339. /**
  24340. * Stores the clock-wise side orientation
  24341. */
  24342. static readonly ClockWiseSideOrientation: number;
  24343. /**
  24344. * Stores the counter clock-wise side orientation
  24345. */
  24346. static readonly CounterClockWiseSideOrientation: number;
  24347. /**
  24348. * The dirty texture flag value
  24349. */
  24350. static readonly TextureDirtyFlag: number;
  24351. /**
  24352. * The dirty light flag value
  24353. */
  24354. static readonly LightDirtyFlag: number;
  24355. /**
  24356. * The dirty fresnel flag value
  24357. */
  24358. static readonly FresnelDirtyFlag: number;
  24359. /**
  24360. * The dirty attribute flag value
  24361. */
  24362. static readonly AttributesDirtyFlag: number;
  24363. /**
  24364. * The dirty misc flag value
  24365. */
  24366. static readonly MiscDirtyFlag: number;
  24367. /**
  24368. * The all dirty flag value
  24369. */
  24370. static readonly AllDirtyFlag: number;
  24371. /**
  24372. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24373. */
  24374. static readonly MATERIAL_OPAQUE: number;
  24375. /**
  24376. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24377. */
  24378. static readonly MATERIAL_ALPHATEST: number;
  24379. /**
  24380. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24381. */
  24382. static readonly MATERIAL_ALPHABLEND: number;
  24383. /**
  24384. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24385. * They are also discarded below the alpha cutoff threshold to improve performances.
  24386. */
  24387. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24388. /**
  24389. * The Whiteout method is used to blend normals.
  24390. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24391. */
  24392. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24393. /**
  24394. * The Reoriented Normal Mapping method is used to blend normals.
  24395. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24396. */
  24397. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24398. /**
  24399. * Custom callback helping to override the default shader used in the material.
  24400. */
  24401. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24402. /**
  24403. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24404. */
  24405. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24406. /**
  24407. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24408. * This means that the material can keep using a previous shader while a new one is being compiled.
  24409. * This is mostly used when shader parallel compilation is supported (true by default)
  24410. */
  24411. allowShaderHotSwapping: boolean;
  24412. /**
  24413. * The ID of the material
  24414. */
  24415. id: string;
  24416. /**
  24417. * Gets or sets the unique id of the material
  24418. */
  24419. uniqueId: number;
  24420. /**
  24421. * The name of the material
  24422. */
  24423. name: string;
  24424. /**
  24425. * Gets or sets user defined metadata
  24426. */
  24427. metadata: any;
  24428. /**
  24429. * For internal use only. Please do not use.
  24430. */
  24431. reservedDataStore: any;
  24432. /**
  24433. * Specifies if the ready state should be checked on each call
  24434. */
  24435. checkReadyOnEveryCall: boolean;
  24436. /**
  24437. * Specifies if the ready state should be checked once
  24438. */
  24439. checkReadyOnlyOnce: boolean;
  24440. /**
  24441. * The state of the material
  24442. */
  24443. state: string;
  24444. /**
  24445. * If the material can be rendered to several textures with MRT extension
  24446. */
  24447. get canRenderToMRT(): boolean;
  24448. /**
  24449. * The alpha value of the material
  24450. */
  24451. protected _alpha: number;
  24452. /**
  24453. * List of inspectable custom properties (used by the Inspector)
  24454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24455. */
  24456. inspectableCustomProperties: IInspectable[];
  24457. /**
  24458. * Sets the alpha value of the material
  24459. */
  24460. set alpha(value: number);
  24461. /**
  24462. * Gets the alpha value of the material
  24463. */
  24464. get alpha(): number;
  24465. /**
  24466. * Specifies if back face culling is enabled
  24467. */
  24468. protected _backFaceCulling: boolean;
  24469. /**
  24470. * Sets the back-face culling state
  24471. */
  24472. set backFaceCulling(value: boolean);
  24473. /**
  24474. * Gets the back-face culling state
  24475. */
  24476. get backFaceCulling(): boolean;
  24477. /**
  24478. * Stores the value for side orientation
  24479. */
  24480. sideOrientation: number;
  24481. /**
  24482. * Callback triggered when the material is compiled
  24483. */
  24484. onCompiled: Nullable<(effect: Effect) => void>;
  24485. /**
  24486. * Callback triggered when an error occurs
  24487. */
  24488. onError: Nullable<(effect: Effect, errors: string) => void>;
  24489. /**
  24490. * Callback triggered to get the render target textures
  24491. */
  24492. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24493. /**
  24494. * Gets a boolean indicating that current material needs to register RTT
  24495. */
  24496. get hasRenderTargetTextures(): boolean;
  24497. /**
  24498. * Specifies if the material should be serialized
  24499. */
  24500. doNotSerialize: boolean;
  24501. /**
  24502. * @hidden
  24503. */
  24504. _storeEffectOnSubMeshes: boolean;
  24505. /**
  24506. * Stores the animations for the material
  24507. */
  24508. animations: Nullable<Array<Animation>>;
  24509. /**
  24510. * An event triggered when the material is disposed
  24511. */
  24512. onDisposeObservable: Observable<Material>;
  24513. /**
  24514. * An observer which watches for dispose events
  24515. */
  24516. private _onDisposeObserver;
  24517. private _onUnBindObservable;
  24518. /**
  24519. * Called during a dispose event
  24520. */
  24521. set onDispose(callback: () => void);
  24522. private _onBindObservable;
  24523. /**
  24524. * An event triggered when the material is bound
  24525. */
  24526. get onBindObservable(): Observable<AbstractMesh>;
  24527. /**
  24528. * An observer which watches for bind events
  24529. */
  24530. private _onBindObserver;
  24531. /**
  24532. * Called during a bind event
  24533. */
  24534. set onBind(callback: (Mesh: AbstractMesh) => void);
  24535. /**
  24536. * An event triggered when the material is unbound
  24537. */
  24538. get onUnBindObservable(): Observable<Material>;
  24539. protected _onEffectCreatedObservable: Nullable<Observable<{
  24540. effect: Effect;
  24541. subMesh: Nullable<SubMesh>;
  24542. }>>;
  24543. /**
  24544. * An event triggered when the effect is (re)created
  24545. */
  24546. get onEffectCreatedObservable(): Observable<{
  24547. effect: Effect;
  24548. subMesh: Nullable<SubMesh>;
  24549. }>;
  24550. /**
  24551. * Stores the value of the alpha mode
  24552. */
  24553. private _alphaMode;
  24554. /**
  24555. * Sets the value of the alpha mode.
  24556. *
  24557. * | Value | Type | Description |
  24558. * | --- | --- | --- |
  24559. * | 0 | ALPHA_DISABLE | |
  24560. * | 1 | ALPHA_ADD | |
  24561. * | 2 | ALPHA_COMBINE | |
  24562. * | 3 | ALPHA_SUBTRACT | |
  24563. * | 4 | ALPHA_MULTIPLY | |
  24564. * | 5 | ALPHA_MAXIMIZED | |
  24565. * | 6 | ALPHA_ONEONE | |
  24566. * | 7 | ALPHA_PREMULTIPLIED | |
  24567. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24568. * | 9 | ALPHA_INTERPOLATE | |
  24569. * | 10 | ALPHA_SCREENMODE | |
  24570. *
  24571. */
  24572. set alphaMode(value: number);
  24573. /**
  24574. * Gets the value of the alpha mode
  24575. */
  24576. get alphaMode(): number;
  24577. /**
  24578. * Stores the state of the need depth pre-pass value
  24579. */
  24580. private _needDepthPrePass;
  24581. /**
  24582. * Sets the need depth pre-pass value
  24583. */
  24584. set needDepthPrePass(value: boolean);
  24585. /**
  24586. * Gets the depth pre-pass value
  24587. */
  24588. get needDepthPrePass(): boolean;
  24589. /**
  24590. * Specifies if depth writing should be disabled
  24591. */
  24592. disableDepthWrite: boolean;
  24593. /**
  24594. * Specifies if color writing should be disabled
  24595. */
  24596. disableColorWrite: boolean;
  24597. /**
  24598. * Specifies if depth writing should be forced
  24599. */
  24600. forceDepthWrite: boolean;
  24601. /**
  24602. * Specifies the depth function that should be used. 0 means the default engine function
  24603. */
  24604. depthFunction: number;
  24605. /**
  24606. * Specifies if there should be a separate pass for culling
  24607. */
  24608. separateCullingPass: boolean;
  24609. /**
  24610. * Stores the state specifing if fog should be enabled
  24611. */
  24612. private _fogEnabled;
  24613. /**
  24614. * Sets the state for enabling fog
  24615. */
  24616. set fogEnabled(value: boolean);
  24617. /**
  24618. * Gets the value of the fog enabled state
  24619. */
  24620. get fogEnabled(): boolean;
  24621. /**
  24622. * Stores the size of points
  24623. */
  24624. pointSize: number;
  24625. /**
  24626. * Stores the z offset value
  24627. */
  24628. zOffset: number;
  24629. get wireframe(): boolean;
  24630. /**
  24631. * Sets the state of wireframe mode
  24632. */
  24633. set wireframe(value: boolean);
  24634. /**
  24635. * Gets the value specifying if point clouds are enabled
  24636. */
  24637. get pointsCloud(): boolean;
  24638. /**
  24639. * Sets the state of point cloud mode
  24640. */
  24641. set pointsCloud(value: boolean);
  24642. /**
  24643. * Gets the material fill mode
  24644. */
  24645. get fillMode(): number;
  24646. /**
  24647. * Sets the material fill mode
  24648. */
  24649. set fillMode(value: number);
  24650. /**
  24651. * @hidden
  24652. * Stores the effects for the material
  24653. */
  24654. _effect: Nullable<Effect>;
  24655. /**
  24656. * Specifies if uniform buffers should be used
  24657. */
  24658. private _useUBO;
  24659. /**
  24660. * Stores a reference to the scene
  24661. */
  24662. private _scene;
  24663. /**
  24664. * Stores the fill mode state
  24665. */
  24666. private _fillMode;
  24667. /**
  24668. * Specifies if the depth write state should be cached
  24669. */
  24670. private _cachedDepthWriteState;
  24671. /**
  24672. * Specifies if the color write state should be cached
  24673. */
  24674. private _cachedColorWriteState;
  24675. /**
  24676. * Specifies if the depth function state should be cached
  24677. */
  24678. private _cachedDepthFunctionState;
  24679. /**
  24680. * Stores the uniform buffer
  24681. */
  24682. protected _uniformBuffer: UniformBuffer;
  24683. /** @hidden */
  24684. _indexInSceneMaterialArray: number;
  24685. /** @hidden */
  24686. meshMap: Nullable<{
  24687. [id: string]: AbstractMesh | undefined;
  24688. }>;
  24689. /**
  24690. * Creates a material instance
  24691. * @param name defines the name of the material
  24692. * @param scene defines the scene to reference
  24693. * @param doNotAdd specifies if the material should be added to the scene
  24694. */
  24695. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24696. /**
  24697. * Returns a string representation of the current material
  24698. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24699. * @returns a string with material information
  24700. */
  24701. toString(fullDetails?: boolean): string;
  24702. /**
  24703. * Gets the class name of the material
  24704. * @returns a string with the class name of the material
  24705. */
  24706. getClassName(): string;
  24707. /**
  24708. * Specifies if updates for the material been locked
  24709. */
  24710. get isFrozen(): boolean;
  24711. /**
  24712. * Locks updates for the material
  24713. */
  24714. freeze(): void;
  24715. /**
  24716. * Unlocks updates for the material
  24717. */
  24718. unfreeze(): void;
  24719. /**
  24720. * Specifies if the material is ready to be used
  24721. * @param mesh defines the mesh to check
  24722. * @param useInstances specifies if instances should be used
  24723. * @returns a boolean indicating if the material is ready to be used
  24724. */
  24725. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24726. /**
  24727. * Specifies that the submesh is ready to be used
  24728. * @param mesh defines the mesh to check
  24729. * @param subMesh defines which submesh to check
  24730. * @param useInstances specifies that instances should be used
  24731. * @returns a boolean indicating that the submesh is ready or not
  24732. */
  24733. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24734. /**
  24735. * Returns the material effect
  24736. * @returns the effect associated with the material
  24737. */
  24738. getEffect(): Nullable<Effect>;
  24739. /**
  24740. * Returns the current scene
  24741. * @returns a Scene
  24742. */
  24743. getScene(): Scene;
  24744. /**
  24745. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24746. */
  24747. protected _forceAlphaTest: boolean;
  24748. /**
  24749. * The transparency mode of the material.
  24750. */
  24751. protected _transparencyMode: Nullable<number>;
  24752. /**
  24753. * Gets the current transparency mode.
  24754. */
  24755. get transparencyMode(): Nullable<number>;
  24756. /**
  24757. * Sets the transparency mode of the material.
  24758. *
  24759. * | Value | Type | Description |
  24760. * | ----- | ----------------------------------- | ----------- |
  24761. * | 0 | OPAQUE | |
  24762. * | 1 | ALPHATEST | |
  24763. * | 2 | ALPHABLEND | |
  24764. * | 3 | ALPHATESTANDBLEND | |
  24765. *
  24766. */
  24767. set transparencyMode(value: Nullable<number>);
  24768. /**
  24769. * Returns true if alpha blending should be disabled.
  24770. */
  24771. protected get _disableAlphaBlending(): boolean;
  24772. /**
  24773. * Specifies whether or not this material should be rendered in alpha blend mode.
  24774. * @returns a boolean specifying if alpha blending is needed
  24775. */
  24776. needAlphaBlending(): boolean;
  24777. /**
  24778. * Specifies if the mesh will require alpha blending
  24779. * @param mesh defines the mesh to check
  24780. * @returns a boolean specifying if alpha blending is needed for the mesh
  24781. */
  24782. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24783. /**
  24784. * Specifies whether or not this material should be rendered in alpha test mode.
  24785. * @returns a boolean specifying if an alpha test is needed.
  24786. */
  24787. needAlphaTesting(): boolean;
  24788. /**
  24789. * Specifies if material alpha testing should be turned on for the mesh
  24790. * @param mesh defines the mesh to check
  24791. */
  24792. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24793. /**
  24794. * Gets the texture used for the alpha test
  24795. * @returns the texture to use for alpha testing
  24796. */
  24797. getAlphaTestTexture(): Nullable<BaseTexture>;
  24798. /**
  24799. * Marks the material to indicate that it needs to be re-calculated
  24800. */
  24801. markDirty(): void;
  24802. /** @hidden */
  24803. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24804. /**
  24805. * Binds the material to the mesh
  24806. * @param world defines the world transformation matrix
  24807. * @param mesh defines the mesh to bind the material to
  24808. */
  24809. bind(world: Matrix, mesh?: Mesh): void;
  24810. /**
  24811. * Binds the submesh to the material
  24812. * @param world defines the world transformation matrix
  24813. * @param mesh defines the mesh containing the submesh
  24814. * @param subMesh defines the submesh to bind the material to
  24815. */
  24816. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24817. /**
  24818. * Binds the world matrix to the material
  24819. * @param world defines the world transformation matrix
  24820. */
  24821. bindOnlyWorldMatrix(world: Matrix): void;
  24822. /**
  24823. * Binds the scene's uniform buffer to the effect.
  24824. * @param effect defines the effect to bind to the scene uniform buffer
  24825. * @param sceneUbo defines the uniform buffer storing scene data
  24826. */
  24827. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24828. /**
  24829. * Binds the view matrix to the effect
  24830. * @param effect defines the effect to bind the view matrix to
  24831. */
  24832. bindView(effect: Effect): void;
  24833. /**
  24834. * Binds the view projection matrix to the effect
  24835. * @param effect defines the effect to bind the view projection matrix to
  24836. */
  24837. bindViewProjection(effect: Effect): void;
  24838. /**
  24839. * Processes to execute after binding the material to a mesh
  24840. * @param mesh defines the rendered mesh
  24841. */
  24842. protected _afterBind(mesh?: Mesh): void;
  24843. /**
  24844. * Unbinds the material from the mesh
  24845. */
  24846. unbind(): void;
  24847. /**
  24848. * Gets the active textures from the material
  24849. * @returns an array of textures
  24850. */
  24851. getActiveTextures(): BaseTexture[];
  24852. /**
  24853. * Specifies if the material uses a texture
  24854. * @param texture defines the texture to check against the material
  24855. * @returns a boolean specifying if the material uses the texture
  24856. */
  24857. hasTexture(texture: BaseTexture): boolean;
  24858. /**
  24859. * Makes a duplicate of the material, and gives it a new name
  24860. * @param name defines the new name for the duplicated material
  24861. * @returns the cloned material
  24862. */
  24863. clone(name: string): Nullable<Material>;
  24864. /**
  24865. * Gets the meshes bound to the material
  24866. * @returns an array of meshes bound to the material
  24867. */
  24868. getBindedMeshes(): AbstractMesh[];
  24869. /**
  24870. * Force shader compilation
  24871. * @param mesh defines the mesh associated with this material
  24872. * @param onCompiled defines a function to execute once the material is compiled
  24873. * @param options defines the options to configure the compilation
  24874. * @param onError defines a function to execute if the material fails compiling
  24875. */
  24876. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24877. /**
  24878. * Force shader compilation
  24879. * @param mesh defines the mesh that will use this material
  24880. * @param options defines additional options for compiling the shaders
  24881. * @returns a promise that resolves when the compilation completes
  24882. */
  24883. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24884. private static readonly _AllDirtyCallBack;
  24885. private static readonly _ImageProcessingDirtyCallBack;
  24886. private static readonly _TextureDirtyCallBack;
  24887. private static readonly _FresnelDirtyCallBack;
  24888. private static readonly _MiscDirtyCallBack;
  24889. private static readonly _LightsDirtyCallBack;
  24890. private static readonly _AttributeDirtyCallBack;
  24891. private static _FresnelAndMiscDirtyCallBack;
  24892. private static _TextureAndMiscDirtyCallBack;
  24893. private static readonly _DirtyCallbackArray;
  24894. private static readonly _RunDirtyCallBacks;
  24895. /**
  24896. * Marks a define in the material to indicate that it needs to be re-computed
  24897. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24898. */
  24899. markAsDirty(flag: number): void;
  24900. /**
  24901. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24902. * @param func defines a function which checks material defines against the submeshes
  24903. */
  24904. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24905. /**
  24906. * Indicates that the scene should check if the rendering now needs a prepass
  24907. */
  24908. protected _markScenePrePassDirty(): void;
  24909. /**
  24910. * Indicates that we need to re-calculated for all submeshes
  24911. */
  24912. protected _markAllSubMeshesAsAllDirty(): void;
  24913. /**
  24914. * Indicates that image processing needs to be re-calculated for all submeshes
  24915. */
  24916. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24917. /**
  24918. * Indicates that textures need to be re-calculated for all submeshes
  24919. */
  24920. protected _markAllSubMeshesAsTexturesDirty(): void;
  24921. /**
  24922. * Indicates that fresnel needs to be re-calculated for all submeshes
  24923. */
  24924. protected _markAllSubMeshesAsFresnelDirty(): void;
  24925. /**
  24926. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24927. */
  24928. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24929. /**
  24930. * Indicates that lights need to be re-calculated for all submeshes
  24931. */
  24932. protected _markAllSubMeshesAsLightsDirty(): void;
  24933. /**
  24934. * Indicates that attributes need to be re-calculated for all submeshes
  24935. */
  24936. protected _markAllSubMeshesAsAttributesDirty(): void;
  24937. /**
  24938. * Indicates that misc needs to be re-calculated for all submeshes
  24939. */
  24940. protected _markAllSubMeshesAsMiscDirty(): void;
  24941. /**
  24942. * Indicates that textures and misc need to be re-calculated for all submeshes
  24943. */
  24944. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24945. /**
  24946. * Sets the required values to the prepass renderer.
  24947. * @param prePassRenderer defines the prepass renderer to setup.
  24948. * @returns true if the pre pass is needed.
  24949. */
  24950. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24951. /**
  24952. * Disposes the material
  24953. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24954. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24955. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24956. */
  24957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24958. /** @hidden */
  24959. private releaseVertexArrayObject;
  24960. /**
  24961. * Serializes this material
  24962. * @returns the serialized material object
  24963. */
  24964. serialize(): any;
  24965. /**
  24966. * Creates a material from parsed material data
  24967. * @param parsedMaterial defines parsed material data
  24968. * @param scene defines the hosting scene
  24969. * @param rootUrl defines the root URL to use to load textures
  24970. * @returns a new material
  24971. */
  24972. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24973. }
  24974. }
  24975. declare module BABYLON {
  24976. /**
  24977. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24978. * separate meshes. This can be use to improve performances.
  24979. * @see https://doc.babylonjs.com/how_to/multi_materials
  24980. */
  24981. export class MultiMaterial extends Material {
  24982. private _subMaterials;
  24983. /**
  24984. * Gets or Sets the list of Materials used within the multi material.
  24985. * They need to be ordered according to the submeshes order in the associated mesh
  24986. */
  24987. get subMaterials(): Nullable<Material>[];
  24988. set subMaterials(value: Nullable<Material>[]);
  24989. /**
  24990. * Function used to align with Node.getChildren()
  24991. * @returns the list of Materials used within the multi material
  24992. */
  24993. getChildren(): Nullable<Material>[];
  24994. /**
  24995. * Instantiates a new Multi Material
  24996. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24997. * separate meshes. This can be use to improve performances.
  24998. * @see https://doc.babylonjs.com/how_to/multi_materials
  24999. * @param name Define the name in the scene
  25000. * @param scene Define the scene the material belongs to
  25001. */
  25002. constructor(name: string, scene: Scene);
  25003. private _hookArray;
  25004. /**
  25005. * Get one of the submaterial by its index in the submaterials array
  25006. * @param index The index to look the sub material at
  25007. * @returns The Material if the index has been defined
  25008. */
  25009. getSubMaterial(index: number): Nullable<Material>;
  25010. /**
  25011. * Get the list of active textures for the whole sub materials list.
  25012. * @returns All the textures that will be used during the rendering
  25013. */
  25014. getActiveTextures(): BaseTexture[];
  25015. /**
  25016. * Gets the current class name of the material e.g. "MultiMaterial"
  25017. * Mainly use in serialization.
  25018. * @returns the class name
  25019. */
  25020. getClassName(): string;
  25021. /**
  25022. * Checks if the material is ready to render the requested sub mesh
  25023. * @param mesh Define the mesh the submesh belongs to
  25024. * @param subMesh Define the sub mesh to look readyness for
  25025. * @param useInstances Define whether or not the material is used with instances
  25026. * @returns true if ready, otherwise false
  25027. */
  25028. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25029. /**
  25030. * Clones the current material and its related sub materials
  25031. * @param name Define the name of the newly cloned material
  25032. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25033. * @returns the cloned material
  25034. */
  25035. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25036. /**
  25037. * Serializes the materials into a JSON representation.
  25038. * @returns the JSON representation
  25039. */
  25040. serialize(): any;
  25041. /**
  25042. * Dispose the material and release its associated resources
  25043. * @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)
  25044. * @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)
  25045. * @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)
  25046. */
  25047. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25048. /**
  25049. * Creates a MultiMaterial from parsed MultiMaterial data.
  25050. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25051. * @param scene defines the hosting scene
  25052. * @returns a new MultiMaterial
  25053. */
  25054. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25055. }
  25056. }
  25057. declare module BABYLON {
  25058. /**
  25059. * Defines a subdivision inside a mesh
  25060. */
  25061. export class SubMesh implements ICullable {
  25062. /** the material index to use */
  25063. materialIndex: number;
  25064. /** vertex index start */
  25065. verticesStart: number;
  25066. /** vertices count */
  25067. verticesCount: number;
  25068. /** index start */
  25069. indexStart: number;
  25070. /** indices count */
  25071. indexCount: number;
  25072. /** @hidden */
  25073. _materialDefines: Nullable<MaterialDefines>;
  25074. /** @hidden */
  25075. _materialEffect: Nullable<Effect>;
  25076. /** @hidden */
  25077. _effectOverride: Nullable<Effect>;
  25078. /**
  25079. * Gets material defines used by the effect associated to the sub mesh
  25080. */
  25081. get materialDefines(): Nullable<MaterialDefines>;
  25082. /**
  25083. * Sets material defines used by the effect associated to the sub mesh
  25084. */
  25085. set materialDefines(defines: Nullable<MaterialDefines>);
  25086. /**
  25087. * Gets associated effect
  25088. */
  25089. get effect(): Nullable<Effect>;
  25090. /**
  25091. * Sets associated effect (effect used to render this submesh)
  25092. * @param effect defines the effect to associate with
  25093. * @param defines defines the set of defines used to compile this effect
  25094. */
  25095. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25096. /** @hidden */
  25097. _linesIndexCount: number;
  25098. private _mesh;
  25099. private _renderingMesh;
  25100. private _boundingInfo;
  25101. private _linesIndexBuffer;
  25102. /** @hidden */
  25103. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25104. /** @hidden */
  25105. _trianglePlanes: Plane[];
  25106. /** @hidden */
  25107. _lastColliderTransformMatrix: Nullable<Matrix>;
  25108. /** @hidden */
  25109. _renderId: number;
  25110. /** @hidden */
  25111. _alphaIndex: number;
  25112. /** @hidden */
  25113. _distanceToCamera: number;
  25114. /** @hidden */
  25115. _id: number;
  25116. private _currentMaterial;
  25117. /**
  25118. * Add a new submesh to a mesh
  25119. * @param materialIndex defines the material index to use
  25120. * @param verticesStart defines vertex index start
  25121. * @param verticesCount defines vertices count
  25122. * @param indexStart defines index start
  25123. * @param indexCount defines indices count
  25124. * @param mesh defines the parent mesh
  25125. * @param renderingMesh defines an optional rendering mesh
  25126. * @param createBoundingBox defines if bounding box should be created for this submesh
  25127. * @returns the new submesh
  25128. */
  25129. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25130. /**
  25131. * Creates a new submesh
  25132. * @param materialIndex defines the material index to use
  25133. * @param verticesStart defines vertex index start
  25134. * @param verticesCount defines vertices count
  25135. * @param indexStart defines index start
  25136. * @param indexCount defines indices count
  25137. * @param mesh defines the parent mesh
  25138. * @param renderingMesh defines an optional rendering mesh
  25139. * @param createBoundingBox defines if bounding box should be created for this submesh
  25140. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25141. */
  25142. constructor(
  25143. /** the material index to use */
  25144. materialIndex: number,
  25145. /** vertex index start */
  25146. verticesStart: number,
  25147. /** vertices count */
  25148. verticesCount: number,
  25149. /** index start */
  25150. indexStart: number,
  25151. /** indices count */
  25152. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25153. /**
  25154. * Returns true if this submesh covers the entire parent mesh
  25155. * @ignorenaming
  25156. */
  25157. get IsGlobal(): boolean;
  25158. /**
  25159. * Returns the submesh BoudingInfo object
  25160. * @returns current bounding info (or mesh's one if the submesh is global)
  25161. */
  25162. getBoundingInfo(): BoundingInfo;
  25163. /**
  25164. * Sets the submesh BoundingInfo
  25165. * @param boundingInfo defines the new bounding info to use
  25166. * @returns the SubMesh
  25167. */
  25168. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25169. /**
  25170. * Returns the mesh of the current submesh
  25171. * @return the parent mesh
  25172. */
  25173. getMesh(): AbstractMesh;
  25174. /**
  25175. * Returns the rendering mesh of the submesh
  25176. * @returns the rendering mesh (could be different from parent mesh)
  25177. */
  25178. getRenderingMesh(): Mesh;
  25179. /**
  25180. * Returns the replacement mesh of the submesh
  25181. * @returns the replacement mesh (could be different from parent mesh)
  25182. */
  25183. getReplacementMesh(): Nullable<AbstractMesh>;
  25184. /**
  25185. * Returns the effective mesh of the submesh
  25186. * @returns the effective mesh (could be different from parent mesh)
  25187. */
  25188. getEffectiveMesh(): AbstractMesh;
  25189. /**
  25190. * Returns the submesh material
  25191. * @returns null or the current material
  25192. */
  25193. getMaterial(): Nullable<Material>;
  25194. private _IsMultiMaterial;
  25195. /**
  25196. * Sets a new updated BoundingInfo object to the submesh
  25197. * @param data defines an optional position array to use to determine the bounding info
  25198. * @returns the SubMesh
  25199. */
  25200. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25201. /** @hidden */
  25202. _checkCollision(collider: Collider): boolean;
  25203. /**
  25204. * Updates the submesh BoundingInfo
  25205. * @param world defines the world matrix to use to update the bounding info
  25206. * @returns the submesh
  25207. */
  25208. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25209. /**
  25210. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25211. * @param frustumPlanes defines the frustum planes
  25212. * @returns true if the submesh is intersecting with the frustum
  25213. */
  25214. isInFrustum(frustumPlanes: Plane[]): boolean;
  25215. /**
  25216. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25217. * @param frustumPlanes defines the frustum planes
  25218. * @returns true if the submesh is inside the frustum
  25219. */
  25220. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25221. /**
  25222. * Renders the submesh
  25223. * @param enableAlphaMode defines if alpha needs to be used
  25224. * @returns the submesh
  25225. */
  25226. render(enableAlphaMode: boolean): SubMesh;
  25227. /**
  25228. * @hidden
  25229. */
  25230. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25231. /**
  25232. * Checks if the submesh intersects with a ray
  25233. * @param ray defines the ray to test
  25234. * @returns true is the passed ray intersects the submesh bounding box
  25235. */
  25236. canIntersects(ray: Ray): boolean;
  25237. /**
  25238. * Intersects current submesh with a ray
  25239. * @param ray defines the ray to test
  25240. * @param positions defines mesh's positions array
  25241. * @param indices defines mesh's indices array
  25242. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25243. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25244. * @returns intersection info or null if no intersection
  25245. */
  25246. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25247. /** @hidden */
  25248. private _intersectLines;
  25249. /** @hidden */
  25250. private _intersectUnIndexedLines;
  25251. /** @hidden */
  25252. private _intersectTriangles;
  25253. /** @hidden */
  25254. private _intersectUnIndexedTriangles;
  25255. /** @hidden */
  25256. _rebuild(): void;
  25257. /**
  25258. * Creates a new submesh from the passed mesh
  25259. * @param newMesh defines the new hosting mesh
  25260. * @param newRenderingMesh defines an optional rendering mesh
  25261. * @returns the new submesh
  25262. */
  25263. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25264. /**
  25265. * Release associated resources
  25266. */
  25267. dispose(): void;
  25268. /**
  25269. * Gets the class name
  25270. * @returns the string "SubMesh".
  25271. */
  25272. getClassName(): string;
  25273. /**
  25274. * Creates a new submesh from indices data
  25275. * @param materialIndex the index of the main mesh material
  25276. * @param startIndex the index where to start the copy in the mesh indices array
  25277. * @param indexCount the number of indices to copy then from the startIndex
  25278. * @param mesh the main mesh to create the submesh from
  25279. * @param renderingMesh the optional rendering mesh
  25280. * @returns a new submesh
  25281. */
  25282. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25283. }
  25284. }
  25285. declare module BABYLON {
  25286. /**
  25287. * Class used to represent data loading progression
  25288. */
  25289. export class SceneLoaderFlags {
  25290. private static _ForceFullSceneLoadingForIncremental;
  25291. private static _ShowLoadingScreen;
  25292. private static _CleanBoneMatrixWeights;
  25293. private static _loggingLevel;
  25294. /**
  25295. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25296. */
  25297. static get ForceFullSceneLoadingForIncremental(): boolean;
  25298. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25299. /**
  25300. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25301. */
  25302. static get ShowLoadingScreen(): boolean;
  25303. static set ShowLoadingScreen(value: boolean);
  25304. /**
  25305. * Defines the current logging level (while loading the scene)
  25306. * @ignorenaming
  25307. */
  25308. static get loggingLevel(): number;
  25309. static set loggingLevel(value: number);
  25310. /**
  25311. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25312. */
  25313. static get CleanBoneMatrixWeights(): boolean;
  25314. static set CleanBoneMatrixWeights(value: boolean);
  25315. }
  25316. }
  25317. declare module BABYLON {
  25318. /**
  25319. * Class used to store geometry data (vertex buffers + index buffer)
  25320. */
  25321. export class Geometry implements IGetSetVerticesData {
  25322. /**
  25323. * Gets or sets the ID of the geometry
  25324. */
  25325. id: string;
  25326. /**
  25327. * Gets or sets the unique ID of the geometry
  25328. */
  25329. uniqueId: number;
  25330. /**
  25331. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25332. */
  25333. delayLoadState: number;
  25334. /**
  25335. * Gets the file containing the data to load when running in delay load state
  25336. */
  25337. delayLoadingFile: Nullable<string>;
  25338. /**
  25339. * Callback called when the geometry is updated
  25340. */
  25341. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25342. private _scene;
  25343. private _engine;
  25344. private _meshes;
  25345. private _totalVertices;
  25346. /** @hidden */
  25347. _indices: IndicesArray;
  25348. /** @hidden */
  25349. _vertexBuffers: {
  25350. [key: string]: VertexBuffer;
  25351. };
  25352. private _isDisposed;
  25353. private _extend;
  25354. private _boundingBias;
  25355. /** @hidden */
  25356. _delayInfo: Array<string>;
  25357. private _indexBuffer;
  25358. private _indexBufferIsUpdatable;
  25359. /** @hidden */
  25360. _boundingInfo: Nullable<BoundingInfo>;
  25361. /** @hidden */
  25362. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25363. /** @hidden */
  25364. _softwareSkinningFrameId: number;
  25365. private _vertexArrayObjects;
  25366. private _updatable;
  25367. /** @hidden */
  25368. _positions: Nullable<Vector3[]>;
  25369. /**
  25370. * 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
  25371. */
  25372. get boundingBias(): Vector2;
  25373. /**
  25374. * 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
  25375. */
  25376. set boundingBias(value: Vector2);
  25377. /**
  25378. * Static function used to attach a new empty geometry to a mesh
  25379. * @param mesh defines the mesh to attach the geometry to
  25380. * @returns the new Geometry
  25381. */
  25382. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25383. /** Get the list of meshes using this geometry */
  25384. get meshes(): Mesh[];
  25385. /**
  25386. * 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
  25387. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25388. */
  25389. useBoundingInfoFromGeometry: boolean;
  25390. /**
  25391. * Creates a new geometry
  25392. * @param id defines the unique ID
  25393. * @param scene defines the hosting scene
  25394. * @param vertexData defines the VertexData used to get geometry data
  25395. * @param updatable defines if geometry must be updatable (false by default)
  25396. * @param mesh defines the mesh that will be associated with the geometry
  25397. */
  25398. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25399. /**
  25400. * Gets the current extend of the geometry
  25401. */
  25402. get extend(): {
  25403. minimum: Vector3;
  25404. maximum: Vector3;
  25405. };
  25406. /**
  25407. * Gets the hosting scene
  25408. * @returns the hosting Scene
  25409. */
  25410. getScene(): Scene;
  25411. /**
  25412. * Gets the hosting engine
  25413. * @returns the hosting Engine
  25414. */
  25415. getEngine(): Engine;
  25416. /**
  25417. * Defines if the geometry is ready to use
  25418. * @returns true if the geometry is ready to be used
  25419. */
  25420. isReady(): boolean;
  25421. /**
  25422. * Gets a value indicating that the geometry should not be serialized
  25423. */
  25424. get doNotSerialize(): boolean;
  25425. /** @hidden */
  25426. _rebuild(): void;
  25427. /**
  25428. * Affects all geometry data in one call
  25429. * @param vertexData defines the geometry data
  25430. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25431. */
  25432. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25433. /**
  25434. * Set specific vertex data
  25435. * @param kind defines the data kind (Position, normal, etc...)
  25436. * @param data defines the vertex data to use
  25437. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25438. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25439. */
  25440. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25441. /**
  25442. * Removes a specific vertex data
  25443. * @param kind defines the data kind (Position, normal, etc...)
  25444. */
  25445. removeVerticesData(kind: string): void;
  25446. /**
  25447. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25448. * @param buffer defines the vertex buffer to use
  25449. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25450. */
  25451. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25452. /**
  25453. * Update a specific vertex buffer
  25454. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25455. * It will do nothing if the buffer is not updatable
  25456. * @param kind defines the data kind (Position, normal, etc...)
  25457. * @param data defines the data to use
  25458. * @param offset defines the offset in the target buffer where to store the data
  25459. * @param useBytes set to true if the offset is in bytes
  25460. */
  25461. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25462. /**
  25463. * Update a specific vertex buffer
  25464. * This function will create a new buffer if the current one is not updatable
  25465. * @param kind defines the data kind (Position, normal, etc...)
  25466. * @param data defines the data to use
  25467. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25468. */
  25469. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25470. private _updateBoundingInfo;
  25471. /** @hidden */
  25472. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25473. /**
  25474. * Gets total number of vertices
  25475. * @returns the total number of vertices
  25476. */
  25477. getTotalVertices(): number;
  25478. /**
  25479. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25480. * @param kind defines the data kind (Position, normal, etc...)
  25481. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25482. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25483. * @returns a float array containing vertex data
  25484. */
  25485. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25486. /**
  25487. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25488. * @param kind defines the data kind (Position, normal, etc...)
  25489. * @returns true if the vertex buffer with the specified kind is updatable
  25490. */
  25491. isVertexBufferUpdatable(kind: string): boolean;
  25492. /**
  25493. * Gets a specific vertex buffer
  25494. * @param kind defines the data kind (Position, normal, etc...)
  25495. * @returns a VertexBuffer
  25496. */
  25497. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25498. /**
  25499. * Returns all vertex buffers
  25500. * @return an object holding all vertex buffers indexed by kind
  25501. */
  25502. getVertexBuffers(): Nullable<{
  25503. [key: string]: VertexBuffer;
  25504. }>;
  25505. /**
  25506. * Gets a boolean indicating if specific vertex buffer is present
  25507. * @param kind defines the data kind (Position, normal, etc...)
  25508. * @returns true if data is present
  25509. */
  25510. isVerticesDataPresent(kind: string): boolean;
  25511. /**
  25512. * Gets a list of all attached data kinds (Position, normal, etc...)
  25513. * @returns a list of string containing all kinds
  25514. */
  25515. getVerticesDataKinds(): string[];
  25516. /**
  25517. * Update index buffer
  25518. * @param indices defines the indices to store in the index buffer
  25519. * @param offset defines the offset in the target buffer where to store the data
  25520. * @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)
  25521. */
  25522. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25523. /**
  25524. * Creates a new index buffer
  25525. * @param indices defines the indices to store in the index buffer
  25526. * @param totalVertices defines the total number of vertices (could be null)
  25527. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25528. */
  25529. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25530. /**
  25531. * Return the total number of indices
  25532. * @returns the total number of indices
  25533. */
  25534. getTotalIndices(): number;
  25535. /**
  25536. * Gets the index buffer array
  25537. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25538. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25539. * @returns the index buffer array
  25540. */
  25541. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25542. /**
  25543. * Gets the index buffer
  25544. * @return the index buffer
  25545. */
  25546. getIndexBuffer(): Nullable<DataBuffer>;
  25547. /** @hidden */
  25548. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25549. /**
  25550. * Release the associated resources for a specific mesh
  25551. * @param mesh defines the source mesh
  25552. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25553. */
  25554. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25555. /**
  25556. * Apply current geometry to a given mesh
  25557. * @param mesh defines the mesh to apply geometry to
  25558. */
  25559. applyToMesh(mesh: Mesh): void;
  25560. private _updateExtend;
  25561. private _applyToMesh;
  25562. private notifyUpdate;
  25563. /**
  25564. * Load the geometry if it was flagged as delay loaded
  25565. * @param scene defines the hosting scene
  25566. * @param onLoaded defines a callback called when the geometry is loaded
  25567. */
  25568. load(scene: Scene, onLoaded?: () => void): void;
  25569. private _queueLoad;
  25570. /**
  25571. * Invert the geometry to move from a right handed system to a left handed one.
  25572. */
  25573. toLeftHanded(): void;
  25574. /** @hidden */
  25575. _resetPointsArrayCache(): void;
  25576. /** @hidden */
  25577. _generatePointsArray(): boolean;
  25578. /**
  25579. * Gets a value indicating if the geometry is disposed
  25580. * @returns true if the geometry was disposed
  25581. */
  25582. isDisposed(): boolean;
  25583. private _disposeVertexArrayObjects;
  25584. /**
  25585. * Free all associated resources
  25586. */
  25587. dispose(): void;
  25588. /**
  25589. * Clone the current geometry into a new geometry
  25590. * @param id defines the unique ID of the new geometry
  25591. * @returns a new geometry object
  25592. */
  25593. copy(id: string): Geometry;
  25594. /**
  25595. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25596. * @return a JSON representation of the current geometry data (without the vertices data)
  25597. */
  25598. serialize(): any;
  25599. private toNumberArray;
  25600. /**
  25601. * Serialize all vertices data into a JSON oject
  25602. * @returns a JSON representation of the current geometry data
  25603. */
  25604. serializeVerticeData(): any;
  25605. /**
  25606. * Extracts a clone of a mesh geometry
  25607. * @param mesh defines the source mesh
  25608. * @param id defines the unique ID of the new geometry object
  25609. * @returns the new geometry object
  25610. */
  25611. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25612. /**
  25613. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25614. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25615. * Be aware Math.random() could cause collisions, but:
  25616. * "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"
  25617. * @returns a string containing a new GUID
  25618. */
  25619. static RandomId(): string;
  25620. /** @hidden */
  25621. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25622. private static _CleanMatricesWeights;
  25623. /**
  25624. * Create a new geometry from persisted data (Using .babylon file format)
  25625. * @param parsedVertexData defines the persisted data
  25626. * @param scene defines the hosting scene
  25627. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25628. * @returns the new geometry object
  25629. */
  25630. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25631. }
  25632. }
  25633. declare module BABYLON {
  25634. /**
  25635. * Define an interface for all classes that will get and set the data on vertices
  25636. */
  25637. export interface IGetSetVerticesData {
  25638. /**
  25639. * Gets a boolean indicating if specific vertex data is present
  25640. * @param kind defines the vertex data kind to use
  25641. * @returns true is data kind is present
  25642. */
  25643. isVerticesDataPresent(kind: string): boolean;
  25644. /**
  25645. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25646. * @param kind defines the data kind (Position, normal, etc...)
  25647. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25648. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25649. * @returns a float array containing vertex data
  25650. */
  25651. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25652. /**
  25653. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25654. * @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.
  25655. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25656. * @returns the indices array or an empty array if the mesh has no geometry
  25657. */
  25658. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25659. /**
  25660. * Set specific vertex data
  25661. * @param kind defines the data kind (Position, normal, etc...)
  25662. * @param data defines the vertex data to use
  25663. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25664. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25665. */
  25666. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25667. /**
  25668. * Update a specific associated vertex buffer
  25669. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25670. * - VertexBuffer.PositionKind
  25671. * - VertexBuffer.UVKind
  25672. * - VertexBuffer.UV2Kind
  25673. * - VertexBuffer.UV3Kind
  25674. * - VertexBuffer.UV4Kind
  25675. * - VertexBuffer.UV5Kind
  25676. * - VertexBuffer.UV6Kind
  25677. * - VertexBuffer.ColorKind
  25678. * - VertexBuffer.MatricesIndicesKind
  25679. * - VertexBuffer.MatricesIndicesExtraKind
  25680. * - VertexBuffer.MatricesWeightsKind
  25681. * - VertexBuffer.MatricesWeightsExtraKind
  25682. * @param data defines the data source
  25683. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25684. * @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)
  25685. */
  25686. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25687. /**
  25688. * Creates a new index buffer
  25689. * @param indices defines the indices to store in the index buffer
  25690. * @param totalVertices defines the total number of vertices (could be null)
  25691. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25692. */
  25693. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25694. }
  25695. /**
  25696. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25697. */
  25698. export class VertexData {
  25699. /**
  25700. * Mesh side orientation : usually the external or front surface
  25701. */
  25702. static readonly FRONTSIDE: number;
  25703. /**
  25704. * Mesh side orientation : usually the internal or back surface
  25705. */
  25706. static readonly BACKSIDE: number;
  25707. /**
  25708. * Mesh side orientation : both internal and external or front and back surfaces
  25709. */
  25710. static readonly DOUBLESIDE: number;
  25711. /**
  25712. * Mesh side orientation : by default, `FRONTSIDE`
  25713. */
  25714. static readonly DEFAULTSIDE: number;
  25715. /**
  25716. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25717. */
  25718. positions: Nullable<FloatArray>;
  25719. /**
  25720. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25721. */
  25722. normals: Nullable<FloatArray>;
  25723. /**
  25724. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25725. */
  25726. tangents: Nullable<FloatArray>;
  25727. /**
  25728. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25729. */
  25730. uvs: Nullable<FloatArray>;
  25731. /**
  25732. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25733. */
  25734. uvs2: Nullable<FloatArray>;
  25735. /**
  25736. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25737. */
  25738. uvs3: Nullable<FloatArray>;
  25739. /**
  25740. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25741. */
  25742. uvs4: Nullable<FloatArray>;
  25743. /**
  25744. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25745. */
  25746. uvs5: Nullable<FloatArray>;
  25747. /**
  25748. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25749. */
  25750. uvs6: Nullable<FloatArray>;
  25751. /**
  25752. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25753. */
  25754. colors: Nullable<FloatArray>;
  25755. /**
  25756. * 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).
  25757. */
  25758. matricesIndices: Nullable<FloatArray>;
  25759. /**
  25760. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25761. */
  25762. matricesWeights: Nullable<FloatArray>;
  25763. /**
  25764. * An array extending the number of possible indices
  25765. */
  25766. matricesIndicesExtra: Nullable<FloatArray>;
  25767. /**
  25768. * An array extending the number of possible weights when the number of indices is extended
  25769. */
  25770. matricesWeightsExtra: Nullable<FloatArray>;
  25771. /**
  25772. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25773. */
  25774. indices: Nullable<IndicesArray>;
  25775. /**
  25776. * Uses the passed data array to set the set the values for the specified kind of data
  25777. * @param data a linear array of floating numbers
  25778. * @param kind the type of data that is being set, eg positions, colors etc
  25779. */
  25780. set(data: FloatArray, kind: string): void;
  25781. /**
  25782. * Associates the vertexData to the passed Mesh.
  25783. * Sets it as updatable or not (default `false`)
  25784. * @param mesh the mesh the vertexData is applied to
  25785. * @param updatable when used and having the value true allows new data to update the vertexData
  25786. * @returns the VertexData
  25787. */
  25788. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25789. /**
  25790. * Associates the vertexData to the passed Geometry.
  25791. * Sets it as updatable or not (default `false`)
  25792. * @param geometry the geometry the vertexData is applied to
  25793. * @param updatable when used and having the value true allows new data to update the vertexData
  25794. * @returns VertexData
  25795. */
  25796. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25797. /**
  25798. * Updates the associated mesh
  25799. * @param mesh the mesh to be updated
  25800. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25801. * @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
  25802. * @returns VertexData
  25803. */
  25804. updateMesh(mesh: Mesh): VertexData;
  25805. /**
  25806. * Updates the associated geometry
  25807. * @param geometry the geometry to be updated
  25808. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25809. * @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
  25810. * @returns VertexData.
  25811. */
  25812. updateGeometry(geometry: Geometry): VertexData;
  25813. private _applyTo;
  25814. private _update;
  25815. /**
  25816. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25817. * @param matrix the transforming matrix
  25818. * @returns the VertexData
  25819. */
  25820. transform(matrix: Matrix): VertexData;
  25821. /**
  25822. * Merges the passed VertexData into the current one
  25823. * @param other the VertexData to be merged into the current one
  25824. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25825. * @returns the modified VertexData
  25826. */
  25827. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25828. private _mergeElement;
  25829. private _validate;
  25830. /**
  25831. * Serializes the VertexData
  25832. * @returns a serialized object
  25833. */
  25834. serialize(): any;
  25835. /**
  25836. * Extracts the vertexData from a mesh
  25837. * @param mesh the mesh from which to extract the VertexData
  25838. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25839. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25840. * @returns the object VertexData associated to the passed mesh
  25841. */
  25842. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25843. /**
  25844. * Extracts the vertexData from the geometry
  25845. * @param geometry the geometry from which to extract the VertexData
  25846. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25847. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25848. * @returns the object VertexData associated to the passed mesh
  25849. */
  25850. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25851. private static _ExtractFrom;
  25852. /**
  25853. * Creates the VertexData for a Ribbon
  25854. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25855. * * pathArray array of paths, each of which an array of successive Vector3
  25856. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25857. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25858. * * 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
  25859. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25860. * * 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)
  25861. * * 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)
  25862. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25863. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25864. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25865. * @returns the VertexData of the ribbon
  25866. */
  25867. static CreateRibbon(options: {
  25868. pathArray: Vector3[][];
  25869. closeArray?: boolean;
  25870. closePath?: boolean;
  25871. offset?: number;
  25872. sideOrientation?: number;
  25873. frontUVs?: Vector4;
  25874. backUVs?: Vector4;
  25875. invertUV?: boolean;
  25876. uvs?: Vector2[];
  25877. colors?: Color4[];
  25878. }): VertexData;
  25879. /**
  25880. * Creates the VertexData for a box
  25881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25882. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25883. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25884. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25885. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25886. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25887. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25888. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25889. * * 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)
  25890. * * 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)
  25891. * @returns the VertexData of the box
  25892. */
  25893. static CreateBox(options: {
  25894. size?: number;
  25895. width?: number;
  25896. height?: number;
  25897. depth?: number;
  25898. faceUV?: Vector4[];
  25899. faceColors?: Color4[];
  25900. sideOrientation?: number;
  25901. frontUVs?: Vector4;
  25902. backUVs?: Vector4;
  25903. }): VertexData;
  25904. /**
  25905. * Creates the VertexData for a tiled box
  25906. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25907. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25908. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25909. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25911. * @returns the VertexData of the box
  25912. */
  25913. static CreateTiledBox(options: {
  25914. pattern?: number;
  25915. width?: number;
  25916. height?: number;
  25917. depth?: number;
  25918. tileSize?: number;
  25919. tileWidth?: number;
  25920. tileHeight?: number;
  25921. alignHorizontal?: number;
  25922. alignVertical?: number;
  25923. faceUV?: Vector4[];
  25924. faceColors?: Color4[];
  25925. sideOrientation?: number;
  25926. }): VertexData;
  25927. /**
  25928. * Creates the VertexData for a tiled plane
  25929. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25930. * * pattern a limited pattern arrangement depending on the number
  25931. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25932. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25933. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25935. * * 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)
  25936. * * 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)
  25937. * @returns the VertexData of the tiled plane
  25938. */
  25939. static CreateTiledPlane(options: {
  25940. pattern?: number;
  25941. tileSize?: number;
  25942. tileWidth?: number;
  25943. tileHeight?: number;
  25944. size?: number;
  25945. width?: number;
  25946. height?: number;
  25947. alignHorizontal?: number;
  25948. alignVertical?: number;
  25949. sideOrientation?: number;
  25950. frontUVs?: Vector4;
  25951. backUVs?: Vector4;
  25952. }): VertexData;
  25953. /**
  25954. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25955. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25956. * * segments sets the number of horizontal strips optional, default 32
  25957. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25958. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25959. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25960. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25961. * * 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
  25962. * * 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
  25963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25964. * * 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)
  25965. * * 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)
  25966. * @returns the VertexData of the ellipsoid
  25967. */
  25968. static CreateSphere(options: {
  25969. segments?: number;
  25970. diameter?: number;
  25971. diameterX?: number;
  25972. diameterY?: number;
  25973. diameterZ?: number;
  25974. arc?: number;
  25975. slice?: number;
  25976. sideOrientation?: number;
  25977. frontUVs?: Vector4;
  25978. backUVs?: Vector4;
  25979. }): VertexData;
  25980. /**
  25981. * Creates the VertexData for a cylinder, cone or prism
  25982. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25983. * * height sets the height (y direction) of the cylinder, optional, default 2
  25984. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25985. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25986. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25987. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25988. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25989. * * 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
  25990. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25991. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25992. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25993. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25994. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25995. * * 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)
  25996. * * 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)
  25997. * @returns the VertexData of the cylinder, cone or prism
  25998. */
  25999. static CreateCylinder(options: {
  26000. height?: number;
  26001. diameterTop?: number;
  26002. diameterBottom?: number;
  26003. diameter?: number;
  26004. tessellation?: number;
  26005. subdivisions?: number;
  26006. arc?: number;
  26007. faceColors?: Color4[];
  26008. faceUV?: Vector4[];
  26009. hasRings?: boolean;
  26010. enclose?: boolean;
  26011. sideOrientation?: number;
  26012. frontUVs?: Vector4;
  26013. backUVs?: Vector4;
  26014. }): VertexData;
  26015. /**
  26016. * Creates the VertexData for a torus
  26017. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26018. * * diameter the diameter of the torus, optional default 1
  26019. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26020. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26022. * * 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)
  26023. * * 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)
  26024. * @returns the VertexData of the torus
  26025. */
  26026. static CreateTorus(options: {
  26027. diameter?: number;
  26028. thickness?: number;
  26029. tessellation?: number;
  26030. sideOrientation?: number;
  26031. frontUVs?: Vector4;
  26032. backUVs?: Vector4;
  26033. }): VertexData;
  26034. /**
  26035. * Creates the VertexData of the LineSystem
  26036. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26037. * - lines an array of lines, each line being an array of successive Vector3
  26038. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26039. * @returns the VertexData of the LineSystem
  26040. */
  26041. static CreateLineSystem(options: {
  26042. lines: Vector3[][];
  26043. colors?: Nullable<Color4[][]>;
  26044. }): VertexData;
  26045. /**
  26046. * Create the VertexData for a DashedLines
  26047. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26048. * - points an array successive Vector3
  26049. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26050. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26051. * - dashNb the intended total number of dashes, optional, default 200
  26052. * @returns the VertexData for the DashedLines
  26053. */
  26054. static CreateDashedLines(options: {
  26055. points: Vector3[];
  26056. dashSize?: number;
  26057. gapSize?: number;
  26058. dashNb?: number;
  26059. }): VertexData;
  26060. /**
  26061. * Creates the VertexData for a Ground
  26062. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26063. * - width the width (x direction) of the ground, optional, default 1
  26064. * - height the height (z direction) of the ground, optional, default 1
  26065. * - subdivisions the number of subdivisions per side, optional, default 1
  26066. * @returns the VertexData of the Ground
  26067. */
  26068. static CreateGround(options: {
  26069. width?: number;
  26070. height?: number;
  26071. subdivisions?: number;
  26072. subdivisionsX?: number;
  26073. subdivisionsY?: number;
  26074. }): VertexData;
  26075. /**
  26076. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26077. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26078. * * xmin the ground minimum X coordinate, optional, default -1
  26079. * * zmin the ground minimum Z coordinate, optional, default -1
  26080. * * xmax the ground maximum X coordinate, optional, default 1
  26081. * * zmax the ground maximum Z coordinate, optional, default 1
  26082. * * 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}
  26083. * * 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}
  26084. * @returns the VertexData of the TiledGround
  26085. */
  26086. static CreateTiledGround(options: {
  26087. xmin: number;
  26088. zmin: number;
  26089. xmax: number;
  26090. zmax: number;
  26091. subdivisions?: {
  26092. w: number;
  26093. h: number;
  26094. };
  26095. precision?: {
  26096. w: number;
  26097. h: number;
  26098. };
  26099. }): VertexData;
  26100. /**
  26101. * Creates the VertexData of the Ground designed from a heightmap
  26102. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26103. * * width the width (x direction) of the ground
  26104. * * height the height (z direction) of the ground
  26105. * * subdivisions the number of subdivisions per side
  26106. * * minHeight the minimum altitude on the ground, optional, default 0
  26107. * * maxHeight the maximum altitude on the ground, optional default 1
  26108. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26109. * * buffer the array holding the image color data
  26110. * * bufferWidth the width of image
  26111. * * bufferHeight the height of image
  26112. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26113. * @returns the VertexData of the Ground designed from a heightmap
  26114. */
  26115. static CreateGroundFromHeightMap(options: {
  26116. width: number;
  26117. height: number;
  26118. subdivisions: number;
  26119. minHeight: number;
  26120. maxHeight: number;
  26121. colorFilter: Color3;
  26122. buffer: Uint8Array;
  26123. bufferWidth: number;
  26124. bufferHeight: number;
  26125. alphaFilter: number;
  26126. }): VertexData;
  26127. /**
  26128. * Creates the VertexData for a Plane
  26129. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26130. * * size sets the width and height of the plane to the value of size, optional default 1
  26131. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26132. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26134. * * 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)
  26135. * * 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)
  26136. * @returns the VertexData of the box
  26137. */
  26138. static CreatePlane(options: {
  26139. size?: number;
  26140. width?: number;
  26141. height?: number;
  26142. sideOrientation?: number;
  26143. frontUVs?: Vector4;
  26144. backUVs?: Vector4;
  26145. }): VertexData;
  26146. /**
  26147. * Creates the VertexData of the Disc or regular Polygon
  26148. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26149. * * radius the radius of the disc, optional default 0.5
  26150. * * tessellation the number of polygon sides, optional, default 64
  26151. * * 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
  26152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26153. * * 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)
  26154. * * 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)
  26155. * @returns the VertexData of the box
  26156. */
  26157. static CreateDisc(options: {
  26158. radius?: number;
  26159. tessellation?: number;
  26160. arc?: number;
  26161. sideOrientation?: number;
  26162. frontUVs?: Vector4;
  26163. backUVs?: Vector4;
  26164. }): VertexData;
  26165. /**
  26166. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26167. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26168. * @param polygon a mesh built from polygonTriangulation.build()
  26169. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26170. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26171. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26172. * @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)
  26173. * @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)
  26174. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26175. * @returns the VertexData of the Polygon
  26176. */
  26177. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26178. /**
  26179. * Creates the VertexData of the IcoSphere
  26180. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26181. * * radius the radius of the IcoSphere, optional default 1
  26182. * * radiusX allows stretching in the x direction, optional, default radius
  26183. * * radiusY allows stretching in the y direction, optional, default radius
  26184. * * radiusZ allows stretching in the z direction, optional, default radius
  26185. * * flat when true creates a flat shaded mesh, optional, default true
  26186. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26188. * * 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)
  26189. * * 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)
  26190. * @returns the VertexData of the IcoSphere
  26191. */
  26192. static CreateIcoSphere(options: {
  26193. radius?: number;
  26194. radiusX?: number;
  26195. radiusY?: number;
  26196. radiusZ?: number;
  26197. flat?: boolean;
  26198. subdivisions?: number;
  26199. sideOrientation?: number;
  26200. frontUVs?: Vector4;
  26201. backUVs?: Vector4;
  26202. }): VertexData;
  26203. /**
  26204. * Creates the VertexData for a Polyhedron
  26205. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26206. * * type provided types are:
  26207. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26208. * * 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)
  26209. * * size the size of the IcoSphere, optional default 1
  26210. * * sizeX allows stretching in the x direction, optional, default size
  26211. * * sizeY allows stretching in the y direction, optional, default size
  26212. * * sizeZ allows stretching in the z direction, optional, default size
  26213. * * 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
  26214. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26215. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26216. * * flat when true creates a flat shaded mesh, optional, default true
  26217. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26219. * * 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)
  26220. * * 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)
  26221. * @returns the VertexData of the Polyhedron
  26222. */
  26223. static CreatePolyhedron(options: {
  26224. type?: number;
  26225. size?: number;
  26226. sizeX?: number;
  26227. sizeY?: number;
  26228. sizeZ?: number;
  26229. custom?: any;
  26230. faceUV?: Vector4[];
  26231. faceColors?: Color4[];
  26232. flat?: boolean;
  26233. sideOrientation?: number;
  26234. frontUVs?: Vector4;
  26235. backUVs?: Vector4;
  26236. }): VertexData;
  26237. /**
  26238. * Creates the VertexData for a TorusKnot
  26239. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26240. * * radius the radius of the torus knot, optional, default 2
  26241. * * tube the thickness of the tube, optional, default 0.5
  26242. * * radialSegments the number of sides on each tube segments, optional, default 32
  26243. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26244. * * p the number of windings around the z axis, optional, default 2
  26245. * * q the number of windings around the x axis, optional, default 3
  26246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26247. * * 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)
  26248. * * 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)
  26249. * @returns the VertexData of the Torus Knot
  26250. */
  26251. static CreateTorusKnot(options: {
  26252. radius?: number;
  26253. tube?: number;
  26254. radialSegments?: number;
  26255. tubularSegments?: number;
  26256. p?: number;
  26257. q?: number;
  26258. sideOrientation?: number;
  26259. frontUVs?: Vector4;
  26260. backUVs?: Vector4;
  26261. }): VertexData;
  26262. /**
  26263. * Compute normals for given positions and indices
  26264. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26265. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26266. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26267. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26268. * * facetNormals : optional array of facet normals (vector3)
  26269. * * facetPositions : optional array of facet positions (vector3)
  26270. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26271. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26272. * * bInfo : optional bounding info, required for facetPartitioning computation
  26273. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26274. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26275. * * useRightHandedSystem: optional boolean to for right handed system computation
  26276. * * depthSort : optional boolean to enable the facet depth sort computation
  26277. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26278. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26279. */
  26280. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26281. facetNormals?: any;
  26282. facetPositions?: any;
  26283. facetPartitioning?: any;
  26284. ratio?: number;
  26285. bInfo?: any;
  26286. bbSize?: Vector3;
  26287. subDiv?: any;
  26288. useRightHandedSystem?: boolean;
  26289. depthSort?: boolean;
  26290. distanceTo?: Vector3;
  26291. depthSortedFacets?: any;
  26292. }): void;
  26293. /** @hidden */
  26294. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26295. /**
  26296. * Applies VertexData created from the imported parameters to the geometry
  26297. * @param parsedVertexData the parsed data from an imported file
  26298. * @param geometry the geometry to apply the VertexData to
  26299. */
  26300. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26301. }
  26302. }
  26303. declare module BABYLON {
  26304. /**
  26305. * Defines a target to use with MorphTargetManager
  26306. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26307. */
  26308. export class MorphTarget implements IAnimatable {
  26309. /** defines the name of the target */
  26310. name: string;
  26311. /**
  26312. * Gets or sets the list of animations
  26313. */
  26314. animations: Animation[];
  26315. private _scene;
  26316. private _positions;
  26317. private _normals;
  26318. private _tangents;
  26319. private _uvs;
  26320. private _influence;
  26321. private _uniqueId;
  26322. /**
  26323. * Observable raised when the influence changes
  26324. */
  26325. onInfluenceChanged: Observable<boolean>;
  26326. /** @hidden */
  26327. _onDataLayoutChanged: Observable<void>;
  26328. /**
  26329. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26330. */
  26331. get influence(): number;
  26332. set influence(influence: number);
  26333. /**
  26334. * Gets or sets the id of the morph Target
  26335. */
  26336. id: string;
  26337. private _animationPropertiesOverride;
  26338. /**
  26339. * Gets or sets the animation properties override
  26340. */
  26341. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26342. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26343. /**
  26344. * Creates a new MorphTarget
  26345. * @param name defines the name of the target
  26346. * @param influence defines the influence to use
  26347. * @param scene defines the scene the morphtarget belongs to
  26348. */
  26349. constructor(
  26350. /** defines the name of the target */
  26351. name: string, influence?: number, scene?: Nullable<Scene>);
  26352. /**
  26353. * Gets the unique ID of this manager
  26354. */
  26355. get uniqueId(): number;
  26356. /**
  26357. * Gets a boolean defining if the target contains position data
  26358. */
  26359. get hasPositions(): boolean;
  26360. /**
  26361. * Gets a boolean defining if the target contains normal data
  26362. */
  26363. get hasNormals(): boolean;
  26364. /**
  26365. * Gets a boolean defining if the target contains tangent data
  26366. */
  26367. get hasTangents(): boolean;
  26368. /**
  26369. * Gets a boolean defining if the target contains texture coordinates data
  26370. */
  26371. get hasUVs(): boolean;
  26372. /**
  26373. * Affects position data to this target
  26374. * @param data defines the position data to use
  26375. */
  26376. setPositions(data: Nullable<FloatArray>): void;
  26377. /**
  26378. * Gets the position data stored in this target
  26379. * @returns a FloatArray containing the position data (or null if not present)
  26380. */
  26381. getPositions(): Nullable<FloatArray>;
  26382. /**
  26383. * Affects normal data to this target
  26384. * @param data defines the normal data to use
  26385. */
  26386. setNormals(data: Nullable<FloatArray>): void;
  26387. /**
  26388. * Gets the normal data stored in this target
  26389. * @returns a FloatArray containing the normal data (or null if not present)
  26390. */
  26391. getNormals(): Nullable<FloatArray>;
  26392. /**
  26393. * Affects tangent data to this target
  26394. * @param data defines the tangent data to use
  26395. */
  26396. setTangents(data: Nullable<FloatArray>): void;
  26397. /**
  26398. * Gets the tangent data stored in this target
  26399. * @returns a FloatArray containing the tangent data (or null if not present)
  26400. */
  26401. getTangents(): Nullable<FloatArray>;
  26402. /**
  26403. * Affects texture coordinates data to this target
  26404. * @param data defines the texture coordinates data to use
  26405. */
  26406. setUVs(data: Nullable<FloatArray>): void;
  26407. /**
  26408. * Gets the texture coordinates data stored in this target
  26409. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26410. */
  26411. getUVs(): Nullable<FloatArray>;
  26412. /**
  26413. * Clone the current target
  26414. * @returns a new MorphTarget
  26415. */
  26416. clone(): MorphTarget;
  26417. /**
  26418. * Serializes the current target into a Serialization object
  26419. * @returns the serialized object
  26420. */
  26421. serialize(): any;
  26422. /**
  26423. * Returns the string "MorphTarget"
  26424. * @returns "MorphTarget"
  26425. */
  26426. getClassName(): string;
  26427. /**
  26428. * Creates a new target from serialized data
  26429. * @param serializationObject defines the serialized data to use
  26430. * @returns a new MorphTarget
  26431. */
  26432. static Parse(serializationObject: any): MorphTarget;
  26433. /**
  26434. * Creates a MorphTarget from mesh data
  26435. * @param mesh defines the source mesh
  26436. * @param name defines the name to use for the new target
  26437. * @param influence defines the influence to attach to the target
  26438. * @returns a new MorphTarget
  26439. */
  26440. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26441. }
  26442. }
  26443. declare module BABYLON {
  26444. /**
  26445. * This class is used to deform meshes using morphing between different targets
  26446. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26447. */
  26448. export class MorphTargetManager {
  26449. private _targets;
  26450. private _targetInfluenceChangedObservers;
  26451. private _targetDataLayoutChangedObservers;
  26452. private _activeTargets;
  26453. private _scene;
  26454. private _influences;
  26455. private _supportsNormals;
  26456. private _supportsTangents;
  26457. private _supportsUVs;
  26458. private _vertexCount;
  26459. private _uniqueId;
  26460. private _tempInfluences;
  26461. /**
  26462. * Gets or sets a boolean indicating if normals must be morphed
  26463. */
  26464. enableNormalMorphing: boolean;
  26465. /**
  26466. * Gets or sets a boolean indicating if tangents must be morphed
  26467. */
  26468. enableTangentMorphing: boolean;
  26469. /**
  26470. * Gets or sets a boolean indicating if UV must be morphed
  26471. */
  26472. enableUVMorphing: boolean;
  26473. /**
  26474. * Creates a new MorphTargetManager
  26475. * @param scene defines the current scene
  26476. */
  26477. constructor(scene?: Nullable<Scene>);
  26478. /**
  26479. * Gets the unique ID of this manager
  26480. */
  26481. get uniqueId(): number;
  26482. /**
  26483. * Gets the number of vertices handled by this manager
  26484. */
  26485. get vertexCount(): number;
  26486. /**
  26487. * Gets a boolean indicating if this manager supports morphing of normals
  26488. */
  26489. get supportsNormals(): boolean;
  26490. /**
  26491. * Gets a boolean indicating if this manager supports morphing of tangents
  26492. */
  26493. get supportsTangents(): boolean;
  26494. /**
  26495. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26496. */
  26497. get supportsUVs(): boolean;
  26498. /**
  26499. * Gets the number of targets stored in this manager
  26500. */
  26501. get numTargets(): number;
  26502. /**
  26503. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26504. */
  26505. get numInfluencers(): number;
  26506. /**
  26507. * Gets the list of influences (one per target)
  26508. */
  26509. get influences(): Float32Array;
  26510. /**
  26511. * Gets the active target at specified index. An active target is a target with an influence > 0
  26512. * @param index defines the index to check
  26513. * @returns the requested target
  26514. */
  26515. getActiveTarget(index: number): MorphTarget;
  26516. /**
  26517. * Gets the target at specified index
  26518. * @param index defines the index to check
  26519. * @returns the requested target
  26520. */
  26521. getTarget(index: number): MorphTarget;
  26522. /**
  26523. * Add a new target to this manager
  26524. * @param target defines the target to add
  26525. */
  26526. addTarget(target: MorphTarget): void;
  26527. /**
  26528. * Removes a target from the manager
  26529. * @param target defines the target to remove
  26530. */
  26531. removeTarget(target: MorphTarget): void;
  26532. /**
  26533. * Clone the current manager
  26534. * @returns a new MorphTargetManager
  26535. */
  26536. clone(): MorphTargetManager;
  26537. /**
  26538. * Serializes the current manager into a Serialization object
  26539. * @returns the serialized object
  26540. */
  26541. serialize(): any;
  26542. private _syncActiveTargets;
  26543. /**
  26544. * Syncrhonize the targets with all the meshes using this morph target manager
  26545. */
  26546. synchronize(): void;
  26547. /**
  26548. * Creates a new MorphTargetManager from serialized data
  26549. * @param serializationObject defines the serialized data
  26550. * @param scene defines the hosting scene
  26551. * @returns the new MorphTargetManager
  26552. */
  26553. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26554. }
  26555. }
  26556. declare module BABYLON {
  26557. /**
  26558. * Class used to represent a specific level of detail of a mesh
  26559. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26560. */
  26561. export class MeshLODLevel {
  26562. /** Defines the distance where this level should start being displayed */
  26563. distance: number;
  26564. /** Defines the mesh to use to render this level */
  26565. mesh: Nullable<Mesh>;
  26566. /**
  26567. * Creates a new LOD level
  26568. * @param distance defines the distance where this level should star being displayed
  26569. * @param mesh defines the mesh to use to render this level
  26570. */
  26571. constructor(
  26572. /** Defines the distance where this level should start being displayed */
  26573. distance: number,
  26574. /** Defines the mesh to use to render this level */
  26575. mesh: Nullable<Mesh>);
  26576. }
  26577. }
  26578. declare module BABYLON {
  26579. /**
  26580. * Helper class used to generate a canvas to manipulate images
  26581. */
  26582. export class CanvasGenerator {
  26583. /**
  26584. * Create a new canvas (or offscreen canvas depending on the context)
  26585. * @param width defines the expected width
  26586. * @param height defines the expected height
  26587. * @return a new canvas or offscreen canvas
  26588. */
  26589. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26590. }
  26591. }
  26592. declare module BABYLON {
  26593. /**
  26594. * Mesh representing the gorund
  26595. */
  26596. export class GroundMesh extends Mesh {
  26597. /** If octree should be generated */
  26598. generateOctree: boolean;
  26599. private _heightQuads;
  26600. /** @hidden */
  26601. _subdivisionsX: number;
  26602. /** @hidden */
  26603. _subdivisionsY: number;
  26604. /** @hidden */
  26605. _width: number;
  26606. /** @hidden */
  26607. _height: number;
  26608. /** @hidden */
  26609. _minX: number;
  26610. /** @hidden */
  26611. _maxX: number;
  26612. /** @hidden */
  26613. _minZ: number;
  26614. /** @hidden */
  26615. _maxZ: number;
  26616. constructor(name: string, scene: Scene);
  26617. /**
  26618. * "GroundMesh"
  26619. * @returns "GroundMesh"
  26620. */
  26621. getClassName(): string;
  26622. /**
  26623. * The minimum of x and y subdivisions
  26624. */
  26625. get subdivisions(): number;
  26626. /**
  26627. * X subdivisions
  26628. */
  26629. get subdivisionsX(): number;
  26630. /**
  26631. * Y subdivisions
  26632. */
  26633. get subdivisionsY(): number;
  26634. /**
  26635. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26636. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26637. * @param chunksCount the number of subdivisions for x and y
  26638. * @param octreeBlocksSize (Default: 32)
  26639. */
  26640. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26641. /**
  26642. * Returns a height (y) value in the Worl system :
  26643. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26644. * @param x x coordinate
  26645. * @param z z coordinate
  26646. * @returns the ground y position if (x, z) are outside the ground surface.
  26647. */
  26648. getHeightAtCoordinates(x: number, z: number): number;
  26649. /**
  26650. * Returns a normalized vector (Vector3) orthogonal to the ground
  26651. * at the ground coordinates (x, z) expressed in the World system.
  26652. * @param x x coordinate
  26653. * @param z z coordinate
  26654. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26655. */
  26656. getNormalAtCoordinates(x: number, z: number): Vector3;
  26657. /**
  26658. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26659. * at the ground coordinates (x, z) expressed in the World system.
  26660. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26661. * @param x x coordinate
  26662. * @param z z coordinate
  26663. * @param ref vector to store the result
  26664. * @returns the GroundMesh.
  26665. */
  26666. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26667. /**
  26668. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26669. * if the ground has been updated.
  26670. * This can be used in the render loop.
  26671. * @returns the GroundMesh.
  26672. */
  26673. updateCoordinateHeights(): GroundMesh;
  26674. private _getFacetAt;
  26675. private _initHeightQuads;
  26676. private _computeHeightQuads;
  26677. /**
  26678. * Serializes this ground mesh
  26679. * @param serializationObject object to write serialization to
  26680. */
  26681. serialize(serializationObject: any): void;
  26682. /**
  26683. * Parses a serialized ground mesh
  26684. * @param parsedMesh the serialized mesh
  26685. * @param scene the scene to create the ground mesh in
  26686. * @returns the created ground mesh
  26687. */
  26688. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26689. }
  26690. }
  26691. declare module BABYLON {
  26692. /**
  26693. * Interface for Physics-Joint data
  26694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26695. */
  26696. export interface PhysicsJointData {
  26697. /**
  26698. * The main pivot of the joint
  26699. */
  26700. mainPivot?: Vector3;
  26701. /**
  26702. * The connected pivot of the joint
  26703. */
  26704. connectedPivot?: Vector3;
  26705. /**
  26706. * The main axis of the joint
  26707. */
  26708. mainAxis?: Vector3;
  26709. /**
  26710. * The connected axis of the joint
  26711. */
  26712. connectedAxis?: Vector3;
  26713. /**
  26714. * The collision of the joint
  26715. */
  26716. collision?: boolean;
  26717. /**
  26718. * Native Oimo/Cannon/Energy data
  26719. */
  26720. nativeParams?: any;
  26721. }
  26722. /**
  26723. * This is a holder class for the physics joint created by the physics plugin
  26724. * It holds a set of functions to control the underlying joint
  26725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26726. */
  26727. export class PhysicsJoint {
  26728. /**
  26729. * The type of the physics joint
  26730. */
  26731. type: number;
  26732. /**
  26733. * The data for the physics joint
  26734. */
  26735. jointData: PhysicsJointData;
  26736. private _physicsJoint;
  26737. protected _physicsPlugin: IPhysicsEnginePlugin;
  26738. /**
  26739. * Initializes the physics joint
  26740. * @param type The type of the physics joint
  26741. * @param jointData The data for the physics joint
  26742. */
  26743. constructor(
  26744. /**
  26745. * The type of the physics joint
  26746. */
  26747. type: number,
  26748. /**
  26749. * The data for the physics joint
  26750. */
  26751. jointData: PhysicsJointData);
  26752. /**
  26753. * Gets the physics joint
  26754. */
  26755. get physicsJoint(): any;
  26756. /**
  26757. * Sets the physics joint
  26758. */
  26759. set physicsJoint(newJoint: any);
  26760. /**
  26761. * Sets the physics plugin
  26762. */
  26763. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26764. /**
  26765. * Execute a function that is physics-plugin specific.
  26766. * @param {Function} func the function that will be executed.
  26767. * It accepts two parameters: the physics world and the physics joint
  26768. */
  26769. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26770. /**
  26771. * Distance-Joint type
  26772. */
  26773. static DistanceJoint: number;
  26774. /**
  26775. * Hinge-Joint type
  26776. */
  26777. static HingeJoint: number;
  26778. /**
  26779. * Ball-and-Socket joint type
  26780. */
  26781. static BallAndSocketJoint: number;
  26782. /**
  26783. * Wheel-Joint type
  26784. */
  26785. static WheelJoint: number;
  26786. /**
  26787. * Slider-Joint type
  26788. */
  26789. static SliderJoint: number;
  26790. /**
  26791. * Prismatic-Joint type
  26792. */
  26793. static PrismaticJoint: number;
  26794. /**
  26795. * Universal-Joint type
  26796. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26797. */
  26798. static UniversalJoint: number;
  26799. /**
  26800. * Hinge-Joint 2 type
  26801. */
  26802. static Hinge2Joint: number;
  26803. /**
  26804. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26805. */
  26806. static PointToPointJoint: number;
  26807. /**
  26808. * Spring-Joint type
  26809. */
  26810. static SpringJoint: number;
  26811. /**
  26812. * Lock-Joint type
  26813. */
  26814. static LockJoint: number;
  26815. }
  26816. /**
  26817. * A class representing a physics distance joint
  26818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26819. */
  26820. export class DistanceJoint extends PhysicsJoint {
  26821. /**
  26822. *
  26823. * @param jointData The data for the Distance-Joint
  26824. */
  26825. constructor(jointData: DistanceJointData);
  26826. /**
  26827. * Update the predefined distance.
  26828. * @param maxDistance The maximum preferred distance
  26829. * @param minDistance The minimum preferred distance
  26830. */
  26831. updateDistance(maxDistance: number, minDistance?: number): void;
  26832. }
  26833. /**
  26834. * Represents a Motor-Enabled Joint
  26835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26836. */
  26837. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26838. /**
  26839. * Initializes the Motor-Enabled Joint
  26840. * @param type The type of the joint
  26841. * @param jointData The physica joint data for the joint
  26842. */
  26843. constructor(type: number, jointData: PhysicsJointData);
  26844. /**
  26845. * Set the motor values.
  26846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26847. * @param force the force to apply
  26848. * @param maxForce max force for this motor.
  26849. */
  26850. setMotor(force?: number, maxForce?: number): void;
  26851. /**
  26852. * Set the motor's limits.
  26853. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26854. * @param upperLimit The upper limit of the motor
  26855. * @param lowerLimit The lower limit of the motor
  26856. */
  26857. setLimit(upperLimit: number, lowerLimit?: number): void;
  26858. }
  26859. /**
  26860. * This class represents a single physics Hinge-Joint
  26861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26862. */
  26863. export class HingeJoint extends MotorEnabledJoint {
  26864. /**
  26865. * Initializes the Hinge-Joint
  26866. * @param jointData The joint data for the Hinge-Joint
  26867. */
  26868. constructor(jointData: PhysicsJointData);
  26869. /**
  26870. * Set the motor values.
  26871. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26872. * @param {number} force the force to apply
  26873. * @param {number} maxForce max force for this motor.
  26874. */
  26875. setMotor(force?: number, maxForce?: number): void;
  26876. /**
  26877. * Set the motor's limits.
  26878. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26879. * @param upperLimit The upper limit of the motor
  26880. * @param lowerLimit The lower limit of the motor
  26881. */
  26882. setLimit(upperLimit: number, lowerLimit?: number): void;
  26883. }
  26884. /**
  26885. * This class represents a dual hinge physics joint (same as wheel joint)
  26886. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26887. */
  26888. export class Hinge2Joint extends MotorEnabledJoint {
  26889. /**
  26890. * Initializes the Hinge2-Joint
  26891. * @param jointData The joint data for the Hinge2-Joint
  26892. */
  26893. constructor(jointData: PhysicsJointData);
  26894. /**
  26895. * Set the motor values.
  26896. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26897. * @param {number} targetSpeed the speed the motor is to reach
  26898. * @param {number} maxForce max force for this motor.
  26899. * @param {motorIndex} the motor's index, 0 or 1.
  26900. */
  26901. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26902. /**
  26903. * Set the motor limits.
  26904. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26905. * @param {number} upperLimit the upper limit
  26906. * @param {number} lowerLimit lower limit
  26907. * @param {motorIndex} the motor's index, 0 or 1.
  26908. */
  26909. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26910. }
  26911. /**
  26912. * Interface for a motor enabled joint
  26913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26914. */
  26915. export interface IMotorEnabledJoint {
  26916. /**
  26917. * Physics joint
  26918. */
  26919. physicsJoint: any;
  26920. /**
  26921. * Sets the motor of the motor-enabled joint
  26922. * @param force The force of the motor
  26923. * @param maxForce The maximum force of the motor
  26924. * @param motorIndex The index of the motor
  26925. */
  26926. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26927. /**
  26928. * Sets the limit of the motor
  26929. * @param upperLimit The upper limit of the motor
  26930. * @param lowerLimit The lower limit of the motor
  26931. * @param motorIndex The index of the motor
  26932. */
  26933. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26934. }
  26935. /**
  26936. * Joint data for a Distance-Joint
  26937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26938. */
  26939. export interface DistanceJointData extends PhysicsJointData {
  26940. /**
  26941. * Max distance the 2 joint objects can be apart
  26942. */
  26943. maxDistance: number;
  26944. }
  26945. /**
  26946. * Joint data from a spring joint
  26947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26948. */
  26949. export interface SpringJointData extends PhysicsJointData {
  26950. /**
  26951. * Length of the spring
  26952. */
  26953. length: number;
  26954. /**
  26955. * Stiffness of the spring
  26956. */
  26957. stiffness: number;
  26958. /**
  26959. * Damping of the spring
  26960. */
  26961. damping: number;
  26962. /** this callback will be called when applying the force to the impostors. */
  26963. forceApplicationCallback: () => void;
  26964. }
  26965. }
  26966. declare module BABYLON {
  26967. /**
  26968. * Holds the data for the raycast result
  26969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26970. */
  26971. export class PhysicsRaycastResult {
  26972. private _hasHit;
  26973. private _hitDistance;
  26974. private _hitNormalWorld;
  26975. private _hitPointWorld;
  26976. private _rayFromWorld;
  26977. private _rayToWorld;
  26978. /**
  26979. * Gets if there was a hit
  26980. */
  26981. get hasHit(): boolean;
  26982. /**
  26983. * Gets the distance from the hit
  26984. */
  26985. get hitDistance(): number;
  26986. /**
  26987. * Gets the hit normal/direction in the world
  26988. */
  26989. get hitNormalWorld(): Vector3;
  26990. /**
  26991. * Gets the hit point in the world
  26992. */
  26993. get hitPointWorld(): Vector3;
  26994. /**
  26995. * Gets the ray "start point" of the ray in the world
  26996. */
  26997. get rayFromWorld(): Vector3;
  26998. /**
  26999. * Gets the ray "end point" of the ray in the world
  27000. */
  27001. get rayToWorld(): Vector3;
  27002. /**
  27003. * Sets the hit data (normal & point in world space)
  27004. * @param hitNormalWorld defines the normal in world space
  27005. * @param hitPointWorld defines the point in world space
  27006. */
  27007. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27008. /**
  27009. * Sets the distance from the start point to the hit point
  27010. * @param distance
  27011. */
  27012. setHitDistance(distance: number): void;
  27013. /**
  27014. * Calculates the distance manually
  27015. */
  27016. calculateHitDistance(): void;
  27017. /**
  27018. * Resets all the values to default
  27019. * @param from The from point on world space
  27020. * @param to The to point on world space
  27021. */
  27022. reset(from?: Vector3, to?: Vector3): void;
  27023. }
  27024. /**
  27025. * Interface for the size containing width and height
  27026. */
  27027. interface IXYZ {
  27028. /**
  27029. * X
  27030. */
  27031. x: number;
  27032. /**
  27033. * Y
  27034. */
  27035. y: number;
  27036. /**
  27037. * Z
  27038. */
  27039. z: number;
  27040. }
  27041. }
  27042. declare module BABYLON {
  27043. /**
  27044. * Interface used to describe a physics joint
  27045. */
  27046. export interface PhysicsImpostorJoint {
  27047. /** Defines the main impostor to which the joint is linked */
  27048. mainImpostor: PhysicsImpostor;
  27049. /** Defines the impostor that is connected to the main impostor using this joint */
  27050. connectedImpostor: PhysicsImpostor;
  27051. /** Defines the joint itself */
  27052. joint: PhysicsJoint;
  27053. }
  27054. /** @hidden */
  27055. export interface IPhysicsEnginePlugin {
  27056. world: any;
  27057. name: string;
  27058. setGravity(gravity: Vector3): void;
  27059. setTimeStep(timeStep: number): void;
  27060. getTimeStep(): number;
  27061. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27062. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27063. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27064. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27065. removePhysicsBody(impostor: PhysicsImpostor): void;
  27066. generateJoint(joint: PhysicsImpostorJoint): void;
  27067. removeJoint(joint: PhysicsImpostorJoint): void;
  27068. isSupported(): boolean;
  27069. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27070. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27071. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27072. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27073. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27074. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27075. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27076. getBodyMass(impostor: PhysicsImpostor): number;
  27077. getBodyFriction(impostor: PhysicsImpostor): number;
  27078. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27079. getBodyRestitution(impostor: PhysicsImpostor): number;
  27080. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27081. getBodyPressure?(impostor: PhysicsImpostor): number;
  27082. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27083. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27084. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27085. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27086. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27087. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27088. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27089. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27090. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27091. sleepBody(impostor: PhysicsImpostor): void;
  27092. wakeUpBody(impostor: PhysicsImpostor): void;
  27093. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27094. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27095. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27096. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27097. getRadius(impostor: PhysicsImpostor): number;
  27098. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27099. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27100. dispose(): void;
  27101. }
  27102. /**
  27103. * Interface used to define a physics engine
  27104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27105. */
  27106. export interface IPhysicsEngine {
  27107. /**
  27108. * Gets the gravity vector used by the simulation
  27109. */
  27110. gravity: Vector3;
  27111. /**
  27112. * Sets the gravity vector used by the simulation
  27113. * @param gravity defines the gravity vector to use
  27114. */
  27115. setGravity(gravity: Vector3): void;
  27116. /**
  27117. * Set the time step of the physics engine.
  27118. * Default is 1/60.
  27119. * To slow it down, enter 1/600 for example.
  27120. * To speed it up, 1/30
  27121. * @param newTimeStep the new timestep to apply to this world.
  27122. */
  27123. setTimeStep(newTimeStep: number): void;
  27124. /**
  27125. * Get the time step of the physics engine.
  27126. * @returns the current time step
  27127. */
  27128. getTimeStep(): number;
  27129. /**
  27130. * Set the sub time step of the physics engine.
  27131. * Default is 0 meaning there is no sub steps
  27132. * To increase physics resolution precision, set a small value (like 1 ms)
  27133. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27134. */
  27135. setSubTimeStep(subTimeStep: number): void;
  27136. /**
  27137. * Get the sub time step of the physics engine.
  27138. * @returns the current sub time step
  27139. */
  27140. getSubTimeStep(): number;
  27141. /**
  27142. * Release all resources
  27143. */
  27144. dispose(): void;
  27145. /**
  27146. * Gets the name of the current physics plugin
  27147. * @returns the name of the plugin
  27148. */
  27149. getPhysicsPluginName(): string;
  27150. /**
  27151. * Adding a new impostor for the impostor tracking.
  27152. * This will be done by the impostor itself.
  27153. * @param impostor the impostor to add
  27154. */
  27155. addImpostor(impostor: PhysicsImpostor): void;
  27156. /**
  27157. * Remove an impostor from the engine.
  27158. * This impostor and its mesh will not longer be updated by the physics engine.
  27159. * @param impostor the impostor to remove
  27160. */
  27161. removeImpostor(impostor: PhysicsImpostor): void;
  27162. /**
  27163. * Add a joint to the physics engine
  27164. * @param mainImpostor defines the main impostor to which the joint is added.
  27165. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27166. * @param joint defines the joint that will connect both impostors.
  27167. */
  27168. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27169. /**
  27170. * Removes a joint from the simulation
  27171. * @param mainImpostor defines the impostor used with the joint
  27172. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27173. * @param joint defines the joint to remove
  27174. */
  27175. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27176. /**
  27177. * Gets the current plugin used to run the simulation
  27178. * @returns current plugin
  27179. */
  27180. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27181. /**
  27182. * Gets the list of physic impostors
  27183. * @returns an array of PhysicsImpostor
  27184. */
  27185. getImpostors(): Array<PhysicsImpostor>;
  27186. /**
  27187. * Gets the impostor for a physics enabled object
  27188. * @param object defines the object impersonated by the impostor
  27189. * @returns the PhysicsImpostor or null if not found
  27190. */
  27191. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27192. /**
  27193. * Gets the impostor for a physics body object
  27194. * @param body defines physics body used by the impostor
  27195. * @returns the PhysicsImpostor or null if not found
  27196. */
  27197. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27198. /**
  27199. * Does a raycast in the physics world
  27200. * @param from when should the ray start?
  27201. * @param to when should the ray end?
  27202. * @returns PhysicsRaycastResult
  27203. */
  27204. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27205. /**
  27206. * Called by the scene. No need to call it.
  27207. * @param delta defines the timespam between frames
  27208. */
  27209. _step(delta: number): void;
  27210. }
  27211. }
  27212. declare module BABYLON {
  27213. /**
  27214. * The interface for the physics imposter parameters
  27215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27216. */
  27217. export interface PhysicsImpostorParameters {
  27218. /**
  27219. * The mass of the physics imposter
  27220. */
  27221. mass: number;
  27222. /**
  27223. * The friction of the physics imposter
  27224. */
  27225. friction?: number;
  27226. /**
  27227. * The coefficient of restitution of the physics imposter
  27228. */
  27229. restitution?: number;
  27230. /**
  27231. * The native options of the physics imposter
  27232. */
  27233. nativeOptions?: any;
  27234. /**
  27235. * Specifies if the parent should be ignored
  27236. */
  27237. ignoreParent?: boolean;
  27238. /**
  27239. * Specifies if bi-directional transformations should be disabled
  27240. */
  27241. disableBidirectionalTransformation?: boolean;
  27242. /**
  27243. * The pressure inside the physics imposter, soft object only
  27244. */
  27245. pressure?: number;
  27246. /**
  27247. * The stiffness the physics imposter, soft object only
  27248. */
  27249. stiffness?: number;
  27250. /**
  27251. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27252. */
  27253. velocityIterations?: number;
  27254. /**
  27255. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27256. */
  27257. positionIterations?: number;
  27258. /**
  27259. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27260. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27261. * Add to fix multiple points
  27262. */
  27263. fixedPoints?: number;
  27264. /**
  27265. * The collision margin around a soft object
  27266. */
  27267. margin?: number;
  27268. /**
  27269. * The collision margin around a soft object
  27270. */
  27271. damping?: number;
  27272. /**
  27273. * The path for a rope based on an extrusion
  27274. */
  27275. path?: any;
  27276. /**
  27277. * The shape of an extrusion used for a rope based on an extrusion
  27278. */
  27279. shape?: any;
  27280. }
  27281. /**
  27282. * Interface for a physics-enabled object
  27283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27284. */
  27285. export interface IPhysicsEnabledObject {
  27286. /**
  27287. * The position of the physics-enabled object
  27288. */
  27289. position: Vector3;
  27290. /**
  27291. * The rotation of the physics-enabled object
  27292. */
  27293. rotationQuaternion: Nullable<Quaternion>;
  27294. /**
  27295. * The scale of the physics-enabled object
  27296. */
  27297. scaling: Vector3;
  27298. /**
  27299. * The rotation of the physics-enabled object
  27300. */
  27301. rotation?: Vector3;
  27302. /**
  27303. * The parent of the physics-enabled object
  27304. */
  27305. parent?: any;
  27306. /**
  27307. * The bounding info of the physics-enabled object
  27308. * @returns The bounding info of the physics-enabled object
  27309. */
  27310. getBoundingInfo(): BoundingInfo;
  27311. /**
  27312. * Computes the world matrix
  27313. * @param force Specifies if the world matrix should be computed by force
  27314. * @returns A world matrix
  27315. */
  27316. computeWorldMatrix(force: boolean): Matrix;
  27317. /**
  27318. * Gets the world matrix
  27319. * @returns A world matrix
  27320. */
  27321. getWorldMatrix?(): Matrix;
  27322. /**
  27323. * Gets the child meshes
  27324. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27325. * @returns An array of abstract meshes
  27326. */
  27327. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27328. /**
  27329. * Gets the vertex data
  27330. * @param kind The type of vertex data
  27331. * @returns A nullable array of numbers, or a float32 array
  27332. */
  27333. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27334. /**
  27335. * Gets the indices from the mesh
  27336. * @returns A nullable array of index arrays
  27337. */
  27338. getIndices?(): Nullable<IndicesArray>;
  27339. /**
  27340. * Gets the scene from the mesh
  27341. * @returns the indices array or null
  27342. */
  27343. getScene?(): Scene;
  27344. /**
  27345. * Gets the absolute position from the mesh
  27346. * @returns the absolute position
  27347. */
  27348. getAbsolutePosition(): Vector3;
  27349. /**
  27350. * Gets the absolute pivot point from the mesh
  27351. * @returns the absolute pivot point
  27352. */
  27353. getAbsolutePivotPoint(): Vector3;
  27354. /**
  27355. * Rotates the mesh
  27356. * @param axis The axis of rotation
  27357. * @param amount The amount of rotation
  27358. * @param space The space of the rotation
  27359. * @returns The rotation transform node
  27360. */
  27361. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27362. /**
  27363. * Translates the mesh
  27364. * @param axis The axis of translation
  27365. * @param distance The distance of translation
  27366. * @param space The space of the translation
  27367. * @returns The transform node
  27368. */
  27369. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27370. /**
  27371. * Sets the absolute position of the mesh
  27372. * @param absolutePosition The absolute position of the mesh
  27373. * @returns The transform node
  27374. */
  27375. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27376. /**
  27377. * Gets the class name of the mesh
  27378. * @returns The class name
  27379. */
  27380. getClassName(): string;
  27381. }
  27382. /**
  27383. * Represents a physics imposter
  27384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27385. */
  27386. export class PhysicsImpostor {
  27387. /**
  27388. * The physics-enabled object used as the physics imposter
  27389. */
  27390. object: IPhysicsEnabledObject;
  27391. /**
  27392. * The type of the physics imposter
  27393. */
  27394. type: number;
  27395. private _options;
  27396. private _scene?;
  27397. /**
  27398. * The default object size of the imposter
  27399. */
  27400. static DEFAULT_OBJECT_SIZE: Vector3;
  27401. /**
  27402. * The identity quaternion of the imposter
  27403. */
  27404. static IDENTITY_QUATERNION: Quaternion;
  27405. /** @hidden */
  27406. _pluginData: any;
  27407. private _physicsEngine;
  27408. private _physicsBody;
  27409. private _bodyUpdateRequired;
  27410. private _onBeforePhysicsStepCallbacks;
  27411. private _onAfterPhysicsStepCallbacks;
  27412. /** @hidden */
  27413. _onPhysicsCollideCallbacks: Array<{
  27414. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27415. otherImpostors: Array<PhysicsImpostor>;
  27416. }>;
  27417. private _deltaPosition;
  27418. private _deltaRotation;
  27419. private _deltaRotationConjugated;
  27420. /** @hidden */
  27421. _isFromLine: boolean;
  27422. private _parent;
  27423. private _isDisposed;
  27424. private static _tmpVecs;
  27425. private static _tmpQuat;
  27426. /**
  27427. * Specifies if the physics imposter is disposed
  27428. */
  27429. get isDisposed(): boolean;
  27430. /**
  27431. * Gets the mass of the physics imposter
  27432. */
  27433. get mass(): number;
  27434. set mass(value: number);
  27435. /**
  27436. * Gets the coefficient of friction
  27437. */
  27438. get friction(): number;
  27439. /**
  27440. * Sets the coefficient of friction
  27441. */
  27442. set friction(value: number);
  27443. /**
  27444. * Gets the coefficient of restitution
  27445. */
  27446. get restitution(): number;
  27447. /**
  27448. * Sets the coefficient of restitution
  27449. */
  27450. set restitution(value: number);
  27451. /**
  27452. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27453. */
  27454. get pressure(): number;
  27455. /**
  27456. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27457. */
  27458. set pressure(value: number);
  27459. /**
  27460. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27461. */
  27462. get stiffness(): number;
  27463. /**
  27464. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27465. */
  27466. set stiffness(value: number);
  27467. /**
  27468. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27469. */
  27470. get velocityIterations(): number;
  27471. /**
  27472. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27473. */
  27474. set velocityIterations(value: number);
  27475. /**
  27476. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27477. */
  27478. get positionIterations(): number;
  27479. /**
  27480. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27481. */
  27482. set positionIterations(value: number);
  27483. /**
  27484. * The unique id of the physics imposter
  27485. * set by the physics engine when adding this impostor to the array
  27486. */
  27487. uniqueId: number;
  27488. /**
  27489. * @hidden
  27490. */
  27491. soft: boolean;
  27492. /**
  27493. * @hidden
  27494. */
  27495. segments: number;
  27496. private _joints;
  27497. /**
  27498. * Initializes the physics imposter
  27499. * @param object The physics-enabled object used as the physics imposter
  27500. * @param type The type of the physics imposter
  27501. * @param _options The options for the physics imposter
  27502. * @param _scene The Babylon scene
  27503. */
  27504. constructor(
  27505. /**
  27506. * The physics-enabled object used as the physics imposter
  27507. */
  27508. object: IPhysicsEnabledObject,
  27509. /**
  27510. * The type of the physics imposter
  27511. */
  27512. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27513. /**
  27514. * This function will completly initialize this impostor.
  27515. * It will create a new body - but only if this mesh has no parent.
  27516. * If it has, this impostor will not be used other than to define the impostor
  27517. * of the child mesh.
  27518. * @hidden
  27519. */
  27520. _init(): void;
  27521. private _getPhysicsParent;
  27522. /**
  27523. * Should a new body be generated.
  27524. * @returns boolean specifying if body initialization is required
  27525. */
  27526. isBodyInitRequired(): boolean;
  27527. /**
  27528. * Sets the updated scaling
  27529. * @param updated Specifies if the scaling is updated
  27530. */
  27531. setScalingUpdated(): void;
  27532. /**
  27533. * Force a regeneration of this or the parent's impostor's body.
  27534. * Use under cautious - This will remove all joints already implemented.
  27535. */
  27536. forceUpdate(): void;
  27537. /**
  27538. * Gets the body that holds this impostor. Either its own, or its parent.
  27539. */
  27540. get physicsBody(): any;
  27541. /**
  27542. * Get the parent of the physics imposter
  27543. * @returns Physics imposter or null
  27544. */
  27545. get parent(): Nullable<PhysicsImpostor>;
  27546. /**
  27547. * Sets the parent of the physics imposter
  27548. */
  27549. set parent(value: Nullable<PhysicsImpostor>);
  27550. /**
  27551. * Set the physics body. Used mainly by the physics engine/plugin
  27552. */
  27553. set physicsBody(physicsBody: any);
  27554. /**
  27555. * Resets the update flags
  27556. */
  27557. resetUpdateFlags(): void;
  27558. /**
  27559. * Gets the object extend size
  27560. * @returns the object extend size
  27561. */
  27562. getObjectExtendSize(): Vector3;
  27563. /**
  27564. * Gets the object center
  27565. * @returns The object center
  27566. */
  27567. getObjectCenter(): Vector3;
  27568. /**
  27569. * Get a specific parameter from the options parameters
  27570. * @param paramName The object parameter name
  27571. * @returns The object parameter
  27572. */
  27573. getParam(paramName: string): any;
  27574. /**
  27575. * Sets a specific parameter in the options given to the physics plugin
  27576. * @param paramName The parameter name
  27577. * @param value The value of the parameter
  27578. */
  27579. setParam(paramName: string, value: number): void;
  27580. /**
  27581. * Specifically change the body's mass option. Won't recreate the physics body object
  27582. * @param mass The mass of the physics imposter
  27583. */
  27584. setMass(mass: number): void;
  27585. /**
  27586. * Gets the linear velocity
  27587. * @returns linear velocity or null
  27588. */
  27589. getLinearVelocity(): Nullable<Vector3>;
  27590. /**
  27591. * Sets the linear velocity
  27592. * @param velocity linear velocity or null
  27593. */
  27594. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27595. /**
  27596. * Gets the angular velocity
  27597. * @returns angular velocity or null
  27598. */
  27599. getAngularVelocity(): Nullable<Vector3>;
  27600. /**
  27601. * Sets the angular velocity
  27602. * @param velocity The velocity or null
  27603. */
  27604. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27605. /**
  27606. * Execute a function with the physics plugin native code
  27607. * Provide a function the will have two variables - the world object and the physics body object
  27608. * @param func The function to execute with the physics plugin native code
  27609. */
  27610. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27611. /**
  27612. * Register a function that will be executed before the physics world is stepping forward
  27613. * @param func The function to execute before the physics world is stepped forward
  27614. */
  27615. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27616. /**
  27617. * Unregister a function that will be executed before the physics world is stepping forward
  27618. * @param func The function to execute before the physics world is stepped forward
  27619. */
  27620. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27621. /**
  27622. * Register a function that will be executed after the physics step
  27623. * @param func The function to execute after physics step
  27624. */
  27625. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27626. /**
  27627. * Unregisters a function that will be executed after the physics step
  27628. * @param func The function to execute after physics step
  27629. */
  27630. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27631. /**
  27632. * register a function that will be executed when this impostor collides against a different body
  27633. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27634. * @param func Callback that is executed on collision
  27635. */
  27636. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27637. /**
  27638. * Unregisters the physics imposter on contact
  27639. * @param collideAgainst The physics object to collide against
  27640. * @param func Callback to execute on collision
  27641. */
  27642. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27643. private _tmpQuat;
  27644. private _tmpQuat2;
  27645. /**
  27646. * Get the parent rotation
  27647. * @returns The parent rotation
  27648. */
  27649. getParentsRotation(): Quaternion;
  27650. /**
  27651. * this function is executed by the physics engine.
  27652. */
  27653. beforeStep: () => void;
  27654. /**
  27655. * this function is executed by the physics engine
  27656. */
  27657. afterStep: () => void;
  27658. /**
  27659. * Legacy collision detection event support
  27660. */
  27661. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27662. /**
  27663. * event and body object due to cannon's event-based architecture.
  27664. */
  27665. onCollide: (e: {
  27666. body: any;
  27667. }) => void;
  27668. /**
  27669. * Apply a force
  27670. * @param force The force to apply
  27671. * @param contactPoint The contact point for the force
  27672. * @returns The physics imposter
  27673. */
  27674. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27675. /**
  27676. * Apply an impulse
  27677. * @param force The impulse force
  27678. * @param contactPoint The contact point for the impulse force
  27679. * @returns The physics imposter
  27680. */
  27681. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27682. /**
  27683. * A help function to create a joint
  27684. * @param otherImpostor A physics imposter used to create a joint
  27685. * @param jointType The type of joint
  27686. * @param jointData The data for the joint
  27687. * @returns The physics imposter
  27688. */
  27689. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27690. /**
  27691. * Add a joint to this impostor with a different impostor
  27692. * @param otherImpostor A physics imposter used to add a joint
  27693. * @param joint The joint to add
  27694. * @returns The physics imposter
  27695. */
  27696. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27697. /**
  27698. * Add an anchor to a cloth impostor
  27699. * @param otherImpostor rigid impostor to anchor to
  27700. * @param width ratio across width from 0 to 1
  27701. * @param height ratio up height from 0 to 1
  27702. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27703. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27704. * @returns impostor the soft imposter
  27705. */
  27706. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27707. /**
  27708. * Add a hook to a rope impostor
  27709. * @param otherImpostor rigid impostor to anchor to
  27710. * @param length ratio across rope from 0 to 1
  27711. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27712. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27713. * @returns impostor the rope imposter
  27714. */
  27715. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27716. /**
  27717. * Will keep this body still, in a sleep mode.
  27718. * @returns the physics imposter
  27719. */
  27720. sleep(): PhysicsImpostor;
  27721. /**
  27722. * Wake the body up.
  27723. * @returns The physics imposter
  27724. */
  27725. wakeUp(): PhysicsImpostor;
  27726. /**
  27727. * Clones the physics imposter
  27728. * @param newObject The physics imposter clones to this physics-enabled object
  27729. * @returns A nullable physics imposter
  27730. */
  27731. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27732. /**
  27733. * Disposes the physics imposter
  27734. */
  27735. dispose(): void;
  27736. /**
  27737. * Sets the delta position
  27738. * @param position The delta position amount
  27739. */
  27740. setDeltaPosition(position: Vector3): void;
  27741. /**
  27742. * Sets the delta rotation
  27743. * @param rotation The delta rotation amount
  27744. */
  27745. setDeltaRotation(rotation: Quaternion): void;
  27746. /**
  27747. * Gets the box size of the physics imposter and stores the result in the input parameter
  27748. * @param result Stores the box size
  27749. * @returns The physics imposter
  27750. */
  27751. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27752. /**
  27753. * Gets the radius of the physics imposter
  27754. * @returns Radius of the physics imposter
  27755. */
  27756. getRadius(): number;
  27757. /**
  27758. * Sync a bone with this impostor
  27759. * @param bone The bone to sync to the impostor.
  27760. * @param boneMesh The mesh that the bone is influencing.
  27761. * @param jointPivot The pivot of the joint / bone in local space.
  27762. * @param distToJoint Optional distance from the impostor to the joint.
  27763. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27764. */
  27765. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27766. /**
  27767. * Sync impostor to a bone
  27768. * @param bone The bone that the impostor will be synced to.
  27769. * @param boneMesh The mesh that the bone is influencing.
  27770. * @param jointPivot The pivot of the joint / bone in local space.
  27771. * @param distToJoint Optional distance from the impostor to the joint.
  27772. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27773. * @param boneAxis Optional vector3 axis the bone is aligned with
  27774. */
  27775. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27776. /**
  27777. * No-Imposter type
  27778. */
  27779. static NoImpostor: number;
  27780. /**
  27781. * Sphere-Imposter type
  27782. */
  27783. static SphereImpostor: number;
  27784. /**
  27785. * Box-Imposter type
  27786. */
  27787. static BoxImpostor: number;
  27788. /**
  27789. * Plane-Imposter type
  27790. */
  27791. static PlaneImpostor: number;
  27792. /**
  27793. * Mesh-imposter type
  27794. */
  27795. static MeshImpostor: number;
  27796. /**
  27797. * Capsule-Impostor type (Ammo.js plugin only)
  27798. */
  27799. static CapsuleImpostor: number;
  27800. /**
  27801. * Cylinder-Imposter type
  27802. */
  27803. static CylinderImpostor: number;
  27804. /**
  27805. * Particle-Imposter type
  27806. */
  27807. static ParticleImpostor: number;
  27808. /**
  27809. * Heightmap-Imposter type
  27810. */
  27811. static HeightmapImpostor: number;
  27812. /**
  27813. * ConvexHull-Impostor type (Ammo.js plugin only)
  27814. */
  27815. static ConvexHullImpostor: number;
  27816. /**
  27817. * Custom-Imposter type (Ammo.js plugin only)
  27818. */
  27819. static CustomImpostor: number;
  27820. /**
  27821. * Rope-Imposter type
  27822. */
  27823. static RopeImpostor: number;
  27824. /**
  27825. * Cloth-Imposter type
  27826. */
  27827. static ClothImpostor: number;
  27828. /**
  27829. * Softbody-Imposter type
  27830. */
  27831. static SoftbodyImpostor: number;
  27832. }
  27833. }
  27834. declare module BABYLON {
  27835. /**
  27836. * @hidden
  27837. **/
  27838. export class _CreationDataStorage {
  27839. closePath?: boolean;
  27840. closeArray?: boolean;
  27841. idx: number[];
  27842. dashSize: number;
  27843. gapSize: number;
  27844. path3D: Path3D;
  27845. pathArray: Vector3[][];
  27846. arc: number;
  27847. radius: number;
  27848. cap: number;
  27849. tessellation: number;
  27850. }
  27851. /**
  27852. * @hidden
  27853. **/
  27854. class _InstanceDataStorage {
  27855. visibleInstances: any;
  27856. batchCache: _InstancesBatch;
  27857. instancesBufferSize: number;
  27858. instancesBuffer: Nullable<Buffer>;
  27859. instancesData: Float32Array;
  27860. overridenInstanceCount: number;
  27861. isFrozen: boolean;
  27862. previousBatch: Nullable<_InstancesBatch>;
  27863. hardwareInstancedRendering: boolean;
  27864. sideOrientation: number;
  27865. manualUpdate: boolean;
  27866. }
  27867. /**
  27868. * @hidden
  27869. **/
  27870. export class _InstancesBatch {
  27871. mustReturn: boolean;
  27872. visibleInstances: Nullable<InstancedMesh[]>[];
  27873. renderSelf: boolean[];
  27874. hardwareInstancedRendering: boolean[];
  27875. }
  27876. /**
  27877. * @hidden
  27878. **/
  27879. class _ThinInstanceDataStorage {
  27880. instancesCount: number;
  27881. matrixBuffer: Nullable<Buffer>;
  27882. matrixBufferSize: number;
  27883. matrixData: Nullable<Float32Array>;
  27884. boundingVectors: Array<Vector3>;
  27885. }
  27886. /**
  27887. * Class used to represent renderable models
  27888. */
  27889. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27890. /**
  27891. * Mesh side orientation : usually the external or front surface
  27892. */
  27893. static readonly FRONTSIDE: number;
  27894. /**
  27895. * Mesh side orientation : usually the internal or back surface
  27896. */
  27897. static readonly BACKSIDE: number;
  27898. /**
  27899. * Mesh side orientation : both internal and external or front and back surfaces
  27900. */
  27901. static readonly DOUBLESIDE: number;
  27902. /**
  27903. * Mesh side orientation : by default, `FRONTSIDE`
  27904. */
  27905. static readonly DEFAULTSIDE: number;
  27906. /**
  27907. * Mesh cap setting : no cap
  27908. */
  27909. static readonly NO_CAP: number;
  27910. /**
  27911. * Mesh cap setting : one cap at the beginning of the mesh
  27912. */
  27913. static readonly CAP_START: number;
  27914. /**
  27915. * Mesh cap setting : one cap at the end of the mesh
  27916. */
  27917. static readonly CAP_END: number;
  27918. /**
  27919. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27920. */
  27921. static readonly CAP_ALL: number;
  27922. /**
  27923. * Mesh pattern setting : no flip or rotate
  27924. */
  27925. static readonly NO_FLIP: number;
  27926. /**
  27927. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27928. */
  27929. static readonly FLIP_TILE: number;
  27930. /**
  27931. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27932. */
  27933. static readonly ROTATE_TILE: number;
  27934. /**
  27935. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27936. */
  27937. static readonly FLIP_ROW: number;
  27938. /**
  27939. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27940. */
  27941. static readonly ROTATE_ROW: number;
  27942. /**
  27943. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27944. */
  27945. static readonly FLIP_N_ROTATE_TILE: number;
  27946. /**
  27947. * Mesh pattern setting : rotate pattern and rotate
  27948. */
  27949. static readonly FLIP_N_ROTATE_ROW: number;
  27950. /**
  27951. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27952. */
  27953. static readonly CENTER: number;
  27954. /**
  27955. * Mesh tile positioning : part tiles on left
  27956. */
  27957. static readonly LEFT: number;
  27958. /**
  27959. * Mesh tile positioning : part tiles on right
  27960. */
  27961. static readonly RIGHT: number;
  27962. /**
  27963. * Mesh tile positioning : part tiles on top
  27964. */
  27965. static readonly TOP: number;
  27966. /**
  27967. * Mesh tile positioning : part tiles on bottom
  27968. */
  27969. static readonly BOTTOM: number;
  27970. /**
  27971. * Gets the default side orientation.
  27972. * @param orientation the orientation to value to attempt to get
  27973. * @returns the default orientation
  27974. * @hidden
  27975. */
  27976. static _GetDefaultSideOrientation(orientation?: number): number;
  27977. private _internalMeshDataInfo;
  27978. get computeBonesUsingShaders(): boolean;
  27979. set computeBonesUsingShaders(value: boolean);
  27980. /**
  27981. * An event triggered before rendering the mesh
  27982. */
  27983. get onBeforeRenderObservable(): Observable<Mesh>;
  27984. /**
  27985. * An event triggered before binding the mesh
  27986. */
  27987. get onBeforeBindObservable(): Observable<Mesh>;
  27988. /**
  27989. * An event triggered after rendering the mesh
  27990. */
  27991. get onAfterRenderObservable(): Observable<Mesh>;
  27992. /**
  27993. * An event triggered before drawing the mesh
  27994. */
  27995. get onBeforeDrawObservable(): Observable<Mesh>;
  27996. private _onBeforeDrawObserver;
  27997. /**
  27998. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27999. */
  28000. set onBeforeDraw(callback: () => void);
  28001. get hasInstances(): boolean;
  28002. get hasThinInstances(): boolean;
  28003. /**
  28004. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28005. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28006. */
  28007. delayLoadState: number;
  28008. /**
  28009. * Gets the list of instances created from this mesh
  28010. * it is not supposed to be modified manually.
  28011. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28012. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28013. */
  28014. instances: InstancedMesh[];
  28015. /**
  28016. * Gets the file containing delay loading data for this mesh
  28017. */
  28018. delayLoadingFile: string;
  28019. /** @hidden */
  28020. _binaryInfo: any;
  28021. /**
  28022. * User defined function used to change how LOD level selection is done
  28023. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28024. */
  28025. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28026. /**
  28027. * Gets or sets the morph target manager
  28028. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28029. */
  28030. get morphTargetManager(): Nullable<MorphTargetManager>;
  28031. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28032. /** @hidden */
  28033. _creationDataStorage: Nullable<_CreationDataStorage>;
  28034. /** @hidden */
  28035. _geometry: Nullable<Geometry>;
  28036. /** @hidden */
  28037. _delayInfo: Array<string>;
  28038. /** @hidden */
  28039. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28040. /** @hidden */
  28041. _instanceDataStorage: _InstanceDataStorage;
  28042. /** @hidden */
  28043. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28044. private _effectiveMaterial;
  28045. /** @hidden */
  28046. _shouldGenerateFlatShading: boolean;
  28047. /** @hidden */
  28048. _originalBuilderSideOrientation: number;
  28049. /**
  28050. * Use this property to change the original side orientation defined at construction time
  28051. */
  28052. overrideMaterialSideOrientation: Nullable<number>;
  28053. /**
  28054. * Gets the source mesh (the one used to clone this one from)
  28055. */
  28056. get source(): Nullable<Mesh>;
  28057. /**
  28058. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28059. */
  28060. get isUnIndexed(): boolean;
  28061. set isUnIndexed(value: boolean);
  28062. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28063. get worldMatrixInstancedBuffer(): Float32Array;
  28064. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28065. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28066. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28067. /**
  28068. * @constructor
  28069. * @param name The value used by scene.getMeshByName() to do a lookup.
  28070. * @param scene The scene to add this mesh to.
  28071. * @param parent The parent of this mesh, if it has one
  28072. * @param source An optional Mesh from which geometry is shared, cloned.
  28073. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28074. * When false, achieved by calling a clone(), also passing False.
  28075. * This will make creation of children, recursive.
  28076. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28077. */
  28078. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28079. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28080. doNotInstantiate: boolean;
  28081. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28082. /**
  28083. * Gets the class name
  28084. * @returns the string "Mesh".
  28085. */
  28086. getClassName(): string;
  28087. /** @hidden */
  28088. get _isMesh(): boolean;
  28089. /**
  28090. * Returns a description of this mesh
  28091. * @param fullDetails define if full details about this mesh must be used
  28092. * @returns a descriptive string representing this mesh
  28093. */
  28094. toString(fullDetails?: boolean): string;
  28095. /** @hidden */
  28096. _unBindEffect(): void;
  28097. /**
  28098. * Gets a boolean indicating if this mesh has LOD
  28099. */
  28100. get hasLODLevels(): boolean;
  28101. /**
  28102. * Gets the list of MeshLODLevel associated with the current mesh
  28103. * @returns an array of MeshLODLevel
  28104. */
  28105. getLODLevels(): MeshLODLevel[];
  28106. private _sortLODLevels;
  28107. /**
  28108. * Add a mesh as LOD level triggered at the given distance.
  28109. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28110. * @param distance The distance from the center of the object to show this level
  28111. * @param mesh The mesh to be added as LOD level (can be null)
  28112. * @return This mesh (for chaining)
  28113. */
  28114. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28115. /**
  28116. * Returns the LOD level mesh at the passed distance or null if not found.
  28117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28118. * @param distance The distance from the center of the object to show this level
  28119. * @returns a Mesh or `null`
  28120. */
  28121. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28122. /**
  28123. * Remove a mesh from the LOD array
  28124. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28125. * @param mesh defines the mesh to be removed
  28126. * @return This mesh (for chaining)
  28127. */
  28128. removeLODLevel(mesh: Mesh): Mesh;
  28129. /**
  28130. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28131. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28132. * @param camera defines the camera to use to compute distance
  28133. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28134. * @return This mesh (for chaining)
  28135. */
  28136. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28137. /**
  28138. * Gets the mesh internal Geometry object
  28139. */
  28140. get geometry(): Nullable<Geometry>;
  28141. /**
  28142. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28143. * @returns the total number of vertices
  28144. */
  28145. getTotalVertices(): number;
  28146. /**
  28147. * Returns the content of an associated vertex buffer
  28148. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28149. * - VertexBuffer.PositionKind
  28150. * - VertexBuffer.UVKind
  28151. * - VertexBuffer.UV2Kind
  28152. * - VertexBuffer.UV3Kind
  28153. * - VertexBuffer.UV4Kind
  28154. * - VertexBuffer.UV5Kind
  28155. * - VertexBuffer.UV6Kind
  28156. * - VertexBuffer.ColorKind
  28157. * - VertexBuffer.MatricesIndicesKind
  28158. * - VertexBuffer.MatricesIndicesExtraKind
  28159. * - VertexBuffer.MatricesWeightsKind
  28160. * - VertexBuffer.MatricesWeightsExtraKind
  28161. * @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
  28162. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28163. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28164. */
  28165. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28166. /**
  28167. * Returns the mesh VertexBuffer object from the requested `kind`
  28168. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28169. * - VertexBuffer.PositionKind
  28170. * - VertexBuffer.NormalKind
  28171. * - VertexBuffer.UVKind
  28172. * - VertexBuffer.UV2Kind
  28173. * - VertexBuffer.UV3Kind
  28174. * - VertexBuffer.UV4Kind
  28175. * - VertexBuffer.UV5Kind
  28176. * - VertexBuffer.UV6Kind
  28177. * - VertexBuffer.ColorKind
  28178. * - VertexBuffer.MatricesIndicesKind
  28179. * - VertexBuffer.MatricesIndicesExtraKind
  28180. * - VertexBuffer.MatricesWeightsKind
  28181. * - VertexBuffer.MatricesWeightsExtraKind
  28182. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28183. */
  28184. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28185. /**
  28186. * Tests if a specific vertex buffer is associated with this mesh
  28187. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28188. * - VertexBuffer.PositionKind
  28189. * - VertexBuffer.NormalKind
  28190. * - VertexBuffer.UVKind
  28191. * - VertexBuffer.UV2Kind
  28192. * - VertexBuffer.UV3Kind
  28193. * - VertexBuffer.UV4Kind
  28194. * - VertexBuffer.UV5Kind
  28195. * - VertexBuffer.UV6Kind
  28196. * - VertexBuffer.ColorKind
  28197. * - VertexBuffer.MatricesIndicesKind
  28198. * - VertexBuffer.MatricesIndicesExtraKind
  28199. * - VertexBuffer.MatricesWeightsKind
  28200. * - VertexBuffer.MatricesWeightsExtraKind
  28201. * @returns a boolean
  28202. */
  28203. isVerticesDataPresent(kind: string): boolean;
  28204. /**
  28205. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28206. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28207. * - VertexBuffer.PositionKind
  28208. * - VertexBuffer.UVKind
  28209. * - VertexBuffer.UV2Kind
  28210. * - VertexBuffer.UV3Kind
  28211. * - VertexBuffer.UV4Kind
  28212. * - VertexBuffer.UV5Kind
  28213. * - VertexBuffer.UV6Kind
  28214. * - VertexBuffer.ColorKind
  28215. * - VertexBuffer.MatricesIndicesKind
  28216. * - VertexBuffer.MatricesIndicesExtraKind
  28217. * - VertexBuffer.MatricesWeightsKind
  28218. * - VertexBuffer.MatricesWeightsExtraKind
  28219. * @returns a boolean
  28220. */
  28221. isVertexBufferUpdatable(kind: string): boolean;
  28222. /**
  28223. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28224. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28225. * - VertexBuffer.PositionKind
  28226. * - VertexBuffer.NormalKind
  28227. * - VertexBuffer.UVKind
  28228. * - VertexBuffer.UV2Kind
  28229. * - VertexBuffer.UV3Kind
  28230. * - VertexBuffer.UV4Kind
  28231. * - VertexBuffer.UV5Kind
  28232. * - VertexBuffer.UV6Kind
  28233. * - VertexBuffer.ColorKind
  28234. * - VertexBuffer.MatricesIndicesKind
  28235. * - VertexBuffer.MatricesIndicesExtraKind
  28236. * - VertexBuffer.MatricesWeightsKind
  28237. * - VertexBuffer.MatricesWeightsExtraKind
  28238. * @returns an array of strings
  28239. */
  28240. getVerticesDataKinds(): string[];
  28241. /**
  28242. * Returns a positive integer : the total number of indices in this mesh geometry.
  28243. * @returns the numner of indices or zero if the mesh has no geometry.
  28244. */
  28245. getTotalIndices(): number;
  28246. /**
  28247. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28248. * @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.
  28249. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28250. * @returns the indices array or an empty array if the mesh has no geometry
  28251. */
  28252. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28253. get isBlocked(): boolean;
  28254. /**
  28255. * Determine if the current mesh is ready to be rendered
  28256. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28257. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28258. * @returns true if all associated assets are ready (material, textures, shaders)
  28259. */
  28260. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28261. /**
  28262. * 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.
  28263. */
  28264. get areNormalsFrozen(): boolean;
  28265. /**
  28266. * 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.
  28267. * @returns the current mesh
  28268. */
  28269. freezeNormals(): Mesh;
  28270. /**
  28271. * 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
  28272. * @returns the current mesh
  28273. */
  28274. unfreezeNormals(): Mesh;
  28275. /**
  28276. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28277. */
  28278. set overridenInstanceCount(count: number);
  28279. /** @hidden */
  28280. _preActivate(): Mesh;
  28281. /** @hidden */
  28282. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28283. /** @hidden */
  28284. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28285. protected _afterComputeWorldMatrix(): void;
  28286. /** @hidden */
  28287. _postActivate(): void;
  28288. /**
  28289. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28290. * This means the mesh underlying bounding box and sphere are recomputed.
  28291. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28292. * @returns the current mesh
  28293. */
  28294. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28295. /** @hidden */
  28296. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28297. /**
  28298. * This function will subdivide the mesh into multiple submeshes
  28299. * @param count defines the expected number of submeshes
  28300. */
  28301. subdivide(count: number): void;
  28302. /**
  28303. * Copy a FloatArray into a specific associated vertex buffer
  28304. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28305. * - VertexBuffer.PositionKind
  28306. * - VertexBuffer.UVKind
  28307. * - VertexBuffer.UV2Kind
  28308. * - VertexBuffer.UV3Kind
  28309. * - VertexBuffer.UV4Kind
  28310. * - VertexBuffer.UV5Kind
  28311. * - VertexBuffer.UV6Kind
  28312. * - VertexBuffer.ColorKind
  28313. * - VertexBuffer.MatricesIndicesKind
  28314. * - VertexBuffer.MatricesIndicesExtraKind
  28315. * - VertexBuffer.MatricesWeightsKind
  28316. * - VertexBuffer.MatricesWeightsExtraKind
  28317. * @param data defines the data source
  28318. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28319. * @param stride defines the data stride size (can be null)
  28320. * @returns the current mesh
  28321. */
  28322. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28323. /**
  28324. * Delete a vertex buffer associated with this mesh
  28325. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28326. * - VertexBuffer.PositionKind
  28327. * - VertexBuffer.UVKind
  28328. * - VertexBuffer.UV2Kind
  28329. * - VertexBuffer.UV3Kind
  28330. * - VertexBuffer.UV4Kind
  28331. * - VertexBuffer.UV5Kind
  28332. * - VertexBuffer.UV6Kind
  28333. * - VertexBuffer.ColorKind
  28334. * - VertexBuffer.MatricesIndicesKind
  28335. * - VertexBuffer.MatricesIndicesExtraKind
  28336. * - VertexBuffer.MatricesWeightsKind
  28337. * - VertexBuffer.MatricesWeightsExtraKind
  28338. */
  28339. removeVerticesData(kind: string): void;
  28340. /**
  28341. * Flags an associated vertex buffer as updatable
  28342. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28343. * - VertexBuffer.PositionKind
  28344. * - VertexBuffer.UVKind
  28345. * - VertexBuffer.UV2Kind
  28346. * - VertexBuffer.UV3Kind
  28347. * - VertexBuffer.UV4Kind
  28348. * - VertexBuffer.UV5Kind
  28349. * - VertexBuffer.UV6Kind
  28350. * - VertexBuffer.ColorKind
  28351. * - VertexBuffer.MatricesIndicesKind
  28352. * - VertexBuffer.MatricesIndicesExtraKind
  28353. * - VertexBuffer.MatricesWeightsKind
  28354. * - VertexBuffer.MatricesWeightsExtraKind
  28355. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28356. */
  28357. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28358. /**
  28359. * Sets the mesh global Vertex Buffer
  28360. * @param buffer defines the buffer to use
  28361. * @returns the current mesh
  28362. */
  28363. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28364. /**
  28365. * Update a specific associated vertex buffer
  28366. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28367. * - VertexBuffer.PositionKind
  28368. * - VertexBuffer.UVKind
  28369. * - VertexBuffer.UV2Kind
  28370. * - VertexBuffer.UV3Kind
  28371. * - VertexBuffer.UV4Kind
  28372. * - VertexBuffer.UV5Kind
  28373. * - VertexBuffer.UV6Kind
  28374. * - VertexBuffer.ColorKind
  28375. * - VertexBuffer.MatricesIndicesKind
  28376. * - VertexBuffer.MatricesIndicesExtraKind
  28377. * - VertexBuffer.MatricesWeightsKind
  28378. * - VertexBuffer.MatricesWeightsExtraKind
  28379. * @param data defines the data source
  28380. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28381. * @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)
  28382. * @returns the current mesh
  28383. */
  28384. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28385. /**
  28386. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28387. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28388. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28389. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28390. * @returns the current mesh
  28391. */
  28392. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28393. /**
  28394. * Creates a un-shared specific occurence of the geometry for the mesh.
  28395. * @returns the current mesh
  28396. */
  28397. makeGeometryUnique(): Mesh;
  28398. /**
  28399. * Set the index buffer of this mesh
  28400. * @param indices defines the source data
  28401. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28402. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28403. * @returns the current mesh
  28404. */
  28405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28406. /**
  28407. * Update the current index buffer
  28408. * @param indices defines the source data
  28409. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28410. * @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)
  28411. * @returns the current mesh
  28412. */
  28413. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28414. /**
  28415. * Invert the geometry to move from a right handed system to a left handed one.
  28416. * @returns the current mesh
  28417. */
  28418. toLeftHanded(): Mesh;
  28419. /** @hidden */
  28420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28421. /** @hidden */
  28422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28423. /**
  28424. * Registers for this mesh a javascript function called just before the rendering process
  28425. * @param func defines the function to call before rendering this mesh
  28426. * @returns the current mesh
  28427. */
  28428. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28429. /**
  28430. * Disposes a previously registered javascript function called before the rendering
  28431. * @param func defines the function to remove
  28432. * @returns the current mesh
  28433. */
  28434. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28435. /**
  28436. * Registers for this mesh a javascript function called just after the rendering is complete
  28437. * @param func defines the function to call after rendering this mesh
  28438. * @returns the current mesh
  28439. */
  28440. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28441. /**
  28442. * Disposes a previously registered javascript function called after the rendering.
  28443. * @param func defines the function to remove
  28444. * @returns the current mesh
  28445. */
  28446. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28447. /** @hidden */
  28448. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28449. /** @hidden */
  28450. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28451. /** @hidden */
  28452. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28453. /** @hidden */
  28454. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28455. /** @hidden */
  28456. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28457. /** @hidden */
  28458. _rebuild(): void;
  28459. /** @hidden */
  28460. _freeze(): void;
  28461. /** @hidden */
  28462. _unFreeze(): void;
  28463. /**
  28464. * 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
  28465. * @param subMesh defines the subMesh to render
  28466. * @param enableAlphaMode defines if alpha mode can be changed
  28467. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28468. * @returns the current mesh
  28469. */
  28470. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28471. private _onBeforeDraw;
  28472. /**
  28473. * Renormalize the mesh and patch it up if there are no weights
  28474. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28475. * However in the case of zero weights then we set just a single influence to 1.
  28476. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28477. */
  28478. cleanMatrixWeights(): void;
  28479. private normalizeSkinFourWeights;
  28480. private normalizeSkinWeightsAndExtra;
  28481. /**
  28482. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28483. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28484. * the user know there was an issue with importing the mesh
  28485. * @returns a validation object with skinned, valid and report string
  28486. */
  28487. validateSkinning(): {
  28488. skinned: boolean;
  28489. valid: boolean;
  28490. report: string;
  28491. };
  28492. /** @hidden */
  28493. _checkDelayState(): Mesh;
  28494. private _queueLoad;
  28495. /**
  28496. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28497. * A mesh is in the frustum if its bounding box intersects the frustum
  28498. * @param frustumPlanes defines the frustum to test
  28499. * @returns true if the mesh is in the frustum planes
  28500. */
  28501. isInFrustum(frustumPlanes: Plane[]): boolean;
  28502. /**
  28503. * Sets the mesh material by the material or multiMaterial `id` property
  28504. * @param id is a string identifying the material or the multiMaterial
  28505. * @returns the current mesh
  28506. */
  28507. setMaterialByID(id: string): Mesh;
  28508. /**
  28509. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28510. * @returns an array of IAnimatable
  28511. */
  28512. getAnimatables(): IAnimatable[];
  28513. /**
  28514. * Modifies the mesh geometry according to the passed transformation matrix.
  28515. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28516. * The mesh normals are modified using the same transformation.
  28517. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28518. * @param transform defines the transform matrix to use
  28519. * @see https://doc.babylonjs.com/resources/baking_transformations
  28520. * @returns the current mesh
  28521. */
  28522. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28523. /**
  28524. * Modifies the mesh geometry according to its own current World Matrix.
  28525. * The mesh World Matrix is then reset.
  28526. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28527. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28528. * @see https://doc.babylonjs.com/resources/baking_transformations
  28529. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28530. * @returns the current mesh
  28531. */
  28532. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28533. /** @hidden */
  28534. get _positions(): Nullable<Vector3[]>;
  28535. /** @hidden */
  28536. _resetPointsArrayCache(): Mesh;
  28537. /** @hidden */
  28538. _generatePointsArray(): boolean;
  28539. /**
  28540. * Returns a new Mesh object generated from the current mesh properties.
  28541. * This method must not get confused with createInstance()
  28542. * @param name is a string, the name given to the new mesh
  28543. * @param newParent can be any Node object (default `null`)
  28544. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28545. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28546. * @returns a new mesh
  28547. */
  28548. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28549. /**
  28550. * Releases resources associated with this mesh.
  28551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28553. */
  28554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28555. /** @hidden */
  28556. _disposeInstanceSpecificData(): void;
  28557. /** @hidden */
  28558. _disposeThinInstanceSpecificData(): void;
  28559. /**
  28560. * Modifies the mesh geometry according to a displacement map.
  28561. * 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.
  28562. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28563. * @param url is a string, the URL from the image file is to be downloaded.
  28564. * @param minHeight is the lower limit of the displacement.
  28565. * @param maxHeight is the upper limit of the displacement.
  28566. * @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.
  28567. * @param uvOffset is an optional vector2 used to offset UV.
  28568. * @param uvScale is an optional vector2 used to scale UV.
  28569. * @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.
  28570. * @returns the Mesh.
  28571. */
  28572. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28573. /**
  28574. * Modifies the mesh geometry according to a displacementMap buffer.
  28575. * 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.
  28576. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28577. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28578. * @param heightMapWidth is the width of the buffer image.
  28579. * @param heightMapHeight is the height of the buffer image.
  28580. * @param minHeight is the lower limit of the displacement.
  28581. * @param maxHeight is the upper limit of the displacement.
  28582. * @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.
  28583. * @param uvOffset is an optional vector2 used to offset UV.
  28584. * @param uvScale is an optional vector2 used to scale UV.
  28585. * @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.
  28586. * @returns the Mesh.
  28587. */
  28588. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28589. /**
  28590. * Modify the mesh to get a flat shading rendering.
  28591. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28592. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28593. * @returns current mesh
  28594. */
  28595. convertToFlatShadedMesh(): Mesh;
  28596. /**
  28597. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28598. * In other words, more vertices, no more indices and a single bigger VBO.
  28599. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28600. * @returns current mesh
  28601. */
  28602. convertToUnIndexedMesh(): Mesh;
  28603. /**
  28604. * Inverses facet orientations.
  28605. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28606. * @param flipNormals will also inverts the normals
  28607. * @returns current mesh
  28608. */
  28609. flipFaces(flipNormals?: boolean): Mesh;
  28610. /**
  28611. * Increase the number of facets and hence vertices in a mesh
  28612. * Vertex normals are interpolated from existing vertex normals
  28613. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28614. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28615. */
  28616. increaseVertices(numberPerEdge: number): void;
  28617. /**
  28618. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28619. * This will undo any application of covertToFlatShadedMesh
  28620. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28621. */
  28622. forceSharedVertices(): void;
  28623. /** @hidden */
  28624. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28625. /** @hidden */
  28626. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28627. /**
  28628. * Creates a new InstancedMesh object from the mesh model.
  28629. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28630. * @param name defines the name of the new instance
  28631. * @returns a new InstancedMesh
  28632. */
  28633. createInstance(name: string): InstancedMesh;
  28634. /**
  28635. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28636. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28637. * @returns the current mesh
  28638. */
  28639. synchronizeInstances(): Mesh;
  28640. /**
  28641. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28642. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28643. * This should be used together with the simplification to avoid disappearing triangles.
  28644. * @param successCallback an optional success callback to be called after the optimization finished.
  28645. * @returns the current mesh
  28646. */
  28647. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28648. /**
  28649. * Serialize current mesh
  28650. * @param serializationObject defines the object which will receive the serialization data
  28651. */
  28652. serialize(serializationObject: any): void;
  28653. /** @hidden */
  28654. _syncGeometryWithMorphTargetManager(): void;
  28655. /** @hidden */
  28656. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28657. /**
  28658. * Returns a new Mesh object parsed from the source provided.
  28659. * @param parsedMesh is the source
  28660. * @param scene defines the hosting scene
  28661. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28662. * @returns a new Mesh
  28663. */
  28664. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28665. /**
  28666. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28668. * @param name defines the name of the mesh to create
  28669. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28670. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28671. * @param closePath creates a seam between the first and the last points of each path of the path array
  28672. * @param offset is taken in account only if the `pathArray` is containing a single path
  28673. * @param scene defines the hosting scene
  28674. * @param updatable defines if the mesh must be flagged as updatable
  28675. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28676. * @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)
  28677. * @returns a new Mesh
  28678. */
  28679. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28680. /**
  28681. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28682. * @param name defines the name of the mesh to create
  28683. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28684. * @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
  28685. * @param scene defines the hosting scene
  28686. * @param updatable defines if the mesh must be flagged as updatable
  28687. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28688. * @returns a new Mesh
  28689. */
  28690. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28691. /**
  28692. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28693. * @param name defines the name of the mesh to create
  28694. * @param size sets the size (float) of each box side (default 1)
  28695. * @param scene defines the hosting scene
  28696. * @param updatable defines if the mesh must be flagged as updatable
  28697. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28698. * @returns a new Mesh
  28699. */
  28700. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28701. /**
  28702. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28703. * @param name defines the name of the mesh to create
  28704. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28705. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28706. * @param scene defines the hosting scene
  28707. * @param updatable defines if the mesh must be flagged as updatable
  28708. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28709. * @returns a new Mesh
  28710. */
  28711. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28712. /**
  28713. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28714. * @param name defines the name of the mesh to create
  28715. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28716. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28717. * @param scene defines the hosting scene
  28718. * @returns a new Mesh
  28719. */
  28720. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28721. /**
  28722. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28723. * @param name defines the name of the mesh to create
  28724. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28725. * @param diameterTop set the top cap diameter (floats, default 1)
  28726. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28727. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28728. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28729. * @param scene defines the hosting scene
  28730. * @param updatable defines if the mesh must be flagged as updatable
  28731. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28732. * @returns a new Mesh
  28733. */
  28734. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28735. /**
  28736. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28737. * @param name defines the name of the mesh to create
  28738. * @param diameter sets the diameter size (float) of the torus (default 1)
  28739. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28740. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28741. * @param scene defines the hosting scene
  28742. * @param updatable defines if the mesh must be flagged as updatable
  28743. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28744. * @returns a new Mesh
  28745. */
  28746. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28747. /**
  28748. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28749. * @param name defines the name of the mesh to create
  28750. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28751. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28752. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28753. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28754. * @param p the number of windings on X axis (positive integers, default 2)
  28755. * @param q the number of windings on Y axis (positive integers, default 3)
  28756. * @param scene defines the hosting scene
  28757. * @param updatable defines if the mesh must be flagged as updatable
  28758. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28759. * @returns a new Mesh
  28760. */
  28761. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28762. /**
  28763. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28764. * @param name defines the name of the mesh to create
  28765. * @param points is an array successive Vector3
  28766. * @param scene defines the hosting scene
  28767. * @param updatable defines if the mesh must be flagged as updatable
  28768. * @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).
  28769. * @returns a new Mesh
  28770. */
  28771. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28772. /**
  28773. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28774. * @param name defines the name of the mesh to create
  28775. * @param points is an array successive Vector3
  28776. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28777. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28778. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28779. * @param scene defines the hosting scene
  28780. * @param updatable defines if the mesh must be flagged as updatable
  28781. * @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)
  28782. * @returns a new Mesh
  28783. */
  28784. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28785. /**
  28786. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28787. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28788. * 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.
  28789. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28790. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28791. * Remember you can only change the shape positions, not their number when updating a polygon.
  28792. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28793. * @param name defines the name of the mesh to create
  28794. * @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
  28795. * @param scene defines the hosting scene
  28796. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28797. * @param updatable defines if the mesh must be flagged as updatable
  28798. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28799. * @param earcutInjection can be used to inject your own earcut reference
  28800. * @returns a new Mesh
  28801. */
  28802. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28803. /**
  28804. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28806. * @param name defines the name of the mesh to create
  28807. * @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
  28808. * @param depth defines the height of extrusion
  28809. * @param scene defines the hosting scene
  28810. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28811. * @param updatable defines if the mesh must be flagged as updatable
  28812. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28813. * @param earcutInjection can be used to inject your own earcut reference
  28814. * @returns a new Mesh
  28815. */
  28816. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28817. /**
  28818. * Creates an extruded shape mesh.
  28819. * 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
  28820. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28821. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28822. * @param name defines the name of the mesh to create
  28823. * @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
  28824. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28825. * @param scale is the value to scale the shape
  28826. * @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
  28827. * @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
  28828. * @param scene defines the hosting scene
  28829. * @param updatable defines if the mesh must be flagged as updatable
  28830. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28831. * @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)
  28832. * @returns a new Mesh
  28833. */
  28834. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28835. /**
  28836. * Creates an custom extruded shape mesh.
  28837. * The custom extrusion is a parametric shape.
  28838. * It has no predefined shape. Its final shape will depend on the input parameters.
  28839. * Please consider using the same method from the MeshBuilder class instead
  28840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28841. * @param name defines the name of the mesh to create
  28842. * @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
  28843. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28844. * @param scaleFunction is a custom Javascript function called on each path point
  28845. * @param rotationFunction is a custom Javascript function called on each path point
  28846. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28847. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28848. * @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
  28849. * @param scene defines the hosting scene
  28850. * @param updatable defines if the mesh must be flagged as updatable
  28851. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28852. * @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)
  28853. * @returns a new Mesh
  28854. */
  28855. 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;
  28856. /**
  28857. * Creates lathe mesh.
  28858. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28859. * Please consider using the same method from the MeshBuilder class instead
  28860. * @param name defines the name of the mesh to create
  28861. * @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
  28862. * @param radius is the radius value of the lathe
  28863. * @param tessellation is the side number of the lathe.
  28864. * @param scene defines the hosting scene
  28865. * @param updatable defines if the mesh must be flagged as updatable
  28866. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28867. * @returns a new Mesh
  28868. */
  28869. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28870. /**
  28871. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28872. * @param name defines the name of the mesh to create
  28873. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28874. * @param scene defines the hosting scene
  28875. * @param updatable defines if the mesh must be flagged as updatable
  28876. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28877. * @returns a new Mesh
  28878. */
  28879. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28880. /**
  28881. * Creates a ground mesh.
  28882. * Please consider using the same method from the MeshBuilder class instead
  28883. * @param name defines the name of the mesh to create
  28884. * @param width set the width of the ground
  28885. * @param height set the height of the ground
  28886. * @param subdivisions sets the number of subdivisions per side
  28887. * @param scene defines the hosting scene
  28888. * @param updatable defines if the mesh must be flagged as updatable
  28889. * @returns a new Mesh
  28890. */
  28891. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28892. /**
  28893. * Creates a tiled ground mesh.
  28894. * Please consider using the same method from the MeshBuilder class instead
  28895. * @param name defines the name of the mesh to create
  28896. * @param xmin set the ground minimum X coordinate
  28897. * @param zmin set the ground minimum Y coordinate
  28898. * @param xmax set the ground maximum X coordinate
  28899. * @param zmax set the ground maximum Z coordinate
  28900. * @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
  28901. * @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
  28902. * @param scene defines the hosting scene
  28903. * @param updatable defines if the mesh must be flagged as updatable
  28904. * @returns a new Mesh
  28905. */
  28906. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28907. w: number;
  28908. h: number;
  28909. }, precision: {
  28910. w: number;
  28911. h: number;
  28912. }, scene: Scene, updatable?: boolean): Mesh;
  28913. /**
  28914. * Creates a ground mesh from a height map.
  28915. * Please consider using the same method from the MeshBuilder class instead
  28916. * @see https://doc.babylonjs.com/babylon101/height_map
  28917. * @param name defines the name of the mesh to create
  28918. * @param url sets the URL of the height map image resource
  28919. * @param width set the ground width size
  28920. * @param height set the ground height size
  28921. * @param subdivisions sets the number of subdivision per side
  28922. * @param minHeight is the minimum altitude on the ground
  28923. * @param maxHeight is the maximum altitude on the ground
  28924. * @param scene defines the hosting scene
  28925. * @param updatable defines if the mesh must be flagged as updatable
  28926. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28927. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28928. * @returns a new Mesh
  28929. */
  28930. 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;
  28931. /**
  28932. * Creates a tube mesh.
  28933. * The tube is a parametric shape.
  28934. * It has no predefined shape. Its final shape will depend on the input parameters.
  28935. * Please consider using the same method from the MeshBuilder class instead
  28936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28937. * @param name defines the name of the mesh to create
  28938. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28939. * @param radius sets the tube radius size
  28940. * @param tessellation is the number of sides on the tubular surface
  28941. * @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
  28942. * @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
  28943. * @param scene defines the hosting scene
  28944. * @param updatable defines if the mesh must be flagged as updatable
  28945. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28946. * @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)
  28947. * @returns a new Mesh
  28948. */
  28949. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28950. (i: number, distance: number): number;
  28951. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28952. /**
  28953. * Creates a polyhedron mesh.
  28954. * Please consider using the same method from the MeshBuilder class instead.
  28955. * * 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
  28956. * * The parameter `size` (positive float, default 1) sets the polygon size
  28957. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28958. * * 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`
  28959. * * 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
  28960. * * 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)`)
  28961. * * 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
  28962. * * 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
  28963. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28964. * * 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
  28965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28966. * @param name defines the name of the mesh to create
  28967. * @param options defines the options used to create the mesh
  28968. * @param scene defines the hosting scene
  28969. * @returns a new Mesh
  28970. */
  28971. static CreatePolyhedron(name: string, options: {
  28972. type?: number;
  28973. size?: number;
  28974. sizeX?: number;
  28975. sizeY?: number;
  28976. sizeZ?: number;
  28977. custom?: any;
  28978. faceUV?: Vector4[];
  28979. faceColors?: Color4[];
  28980. updatable?: boolean;
  28981. sideOrientation?: number;
  28982. }, scene: Scene): Mesh;
  28983. /**
  28984. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28985. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28986. * * 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`)
  28987. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28988. * * 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
  28989. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28990. * * 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
  28991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28992. * @param name defines the name of the mesh
  28993. * @param options defines the options used to create the mesh
  28994. * @param scene defines the hosting scene
  28995. * @returns a new Mesh
  28996. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28997. */
  28998. static CreateIcoSphere(name: string, options: {
  28999. radius?: number;
  29000. flat?: boolean;
  29001. subdivisions?: number;
  29002. sideOrientation?: number;
  29003. updatable?: boolean;
  29004. }, scene: Scene): Mesh;
  29005. /**
  29006. * Creates a decal mesh.
  29007. * Please consider using the same method from the MeshBuilder class instead.
  29008. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29009. * @param name defines the name of the mesh
  29010. * @param sourceMesh defines the mesh receiving the decal
  29011. * @param position sets the position of the decal in world coordinates
  29012. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29013. * @param size sets the decal scaling
  29014. * @param angle sets the angle to rotate the decal
  29015. * @returns a new Mesh
  29016. */
  29017. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29018. /**
  29019. * Prepare internal position array for software CPU skinning
  29020. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29021. */
  29022. setPositionsForCPUSkinning(): Float32Array;
  29023. /**
  29024. * Prepare internal normal array for software CPU skinning
  29025. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29026. */
  29027. setNormalsForCPUSkinning(): Float32Array;
  29028. /**
  29029. * Updates the vertex buffer by applying transformation from the bones
  29030. * @param skeleton defines the skeleton to apply to current mesh
  29031. * @returns the current mesh
  29032. */
  29033. applySkeleton(skeleton: Skeleton): Mesh;
  29034. /**
  29035. * 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
  29036. * @param meshes defines the list of meshes to scan
  29037. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29038. */
  29039. static MinMax(meshes: AbstractMesh[]): {
  29040. min: Vector3;
  29041. max: Vector3;
  29042. };
  29043. /**
  29044. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29045. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29046. * @returns a vector3
  29047. */
  29048. static Center(meshesOrMinMaxVector: {
  29049. min: Vector3;
  29050. max: Vector3;
  29051. } | AbstractMesh[]): Vector3;
  29052. /**
  29053. * Merge the array of meshes into a single mesh for performance reasons.
  29054. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29055. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29056. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29057. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29058. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29059. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29060. * @returns a new mesh
  29061. */
  29062. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29063. /** @hidden */
  29064. addInstance(instance: InstancedMesh): void;
  29065. /** @hidden */
  29066. removeInstance(instance: InstancedMesh): void;
  29067. }
  29068. }
  29069. declare module BABYLON {
  29070. /**
  29071. * This is the base class of all the camera used in the application.
  29072. * @see https://doc.babylonjs.com/features/cameras
  29073. */
  29074. export class Camera extends Node {
  29075. /** @hidden */
  29076. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29077. /**
  29078. * This is the default projection mode used by the cameras.
  29079. * It helps recreating a feeling of perspective and better appreciate depth.
  29080. * This is the best way to simulate real life cameras.
  29081. */
  29082. static readonly PERSPECTIVE_CAMERA: number;
  29083. /**
  29084. * This helps creating camera with an orthographic mode.
  29085. * 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.
  29086. */
  29087. static readonly ORTHOGRAPHIC_CAMERA: number;
  29088. /**
  29089. * This is the default FOV mode for perspective cameras.
  29090. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29091. */
  29092. static readonly FOVMODE_VERTICAL_FIXED: number;
  29093. /**
  29094. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29095. */
  29096. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29097. /**
  29098. * This specifies ther is no need for a camera rig.
  29099. * Basically only one eye is rendered corresponding to the camera.
  29100. */
  29101. static readonly RIG_MODE_NONE: number;
  29102. /**
  29103. * Simulates a camera Rig with one blue eye and one red eye.
  29104. * This can be use with 3d blue and red glasses.
  29105. */
  29106. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29107. /**
  29108. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29109. */
  29110. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29111. /**
  29112. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29113. */
  29114. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29115. /**
  29116. * Defines that both eyes of the camera will be rendered over under each other.
  29117. */
  29118. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29119. /**
  29120. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29121. */
  29122. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29123. /**
  29124. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29125. */
  29126. static readonly RIG_MODE_VR: number;
  29127. /**
  29128. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29129. */
  29130. static readonly RIG_MODE_WEBVR: number;
  29131. /**
  29132. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29133. */
  29134. static readonly RIG_MODE_CUSTOM: number;
  29135. /**
  29136. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29137. */
  29138. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29139. /**
  29140. * Define the input manager associated with the camera.
  29141. */
  29142. inputs: CameraInputsManager<Camera>;
  29143. /** @hidden */
  29144. _position: Vector3;
  29145. /**
  29146. * Define the current local position of the camera in the scene
  29147. */
  29148. get position(): Vector3;
  29149. set position(newPosition: Vector3);
  29150. /**
  29151. * The vector the camera should consider as up.
  29152. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29153. */
  29154. upVector: Vector3;
  29155. /**
  29156. * Define the current limit on the left side for an orthographic camera
  29157. * In scene unit
  29158. */
  29159. orthoLeft: Nullable<number>;
  29160. /**
  29161. * Define the current limit on the right side for an orthographic camera
  29162. * In scene unit
  29163. */
  29164. orthoRight: Nullable<number>;
  29165. /**
  29166. * Define the current limit on the bottom side for an orthographic camera
  29167. * In scene unit
  29168. */
  29169. orthoBottom: Nullable<number>;
  29170. /**
  29171. * Define the current limit on the top side for an orthographic camera
  29172. * In scene unit
  29173. */
  29174. orthoTop: Nullable<number>;
  29175. /**
  29176. * Field Of View is set in Radians. (default is 0.8)
  29177. */
  29178. fov: number;
  29179. /**
  29180. * Define the minimum distance the camera can see from.
  29181. * This is important to note that the depth buffer are not infinite and the closer it starts
  29182. * the more your scene might encounter depth fighting issue.
  29183. */
  29184. minZ: number;
  29185. /**
  29186. * Define the maximum distance the camera can see to.
  29187. * This is important to note that the depth buffer are not infinite and the further it end
  29188. * the more your scene might encounter depth fighting issue.
  29189. */
  29190. maxZ: number;
  29191. /**
  29192. * Define the default inertia of the camera.
  29193. * This helps giving a smooth feeling to the camera movement.
  29194. */
  29195. inertia: number;
  29196. /**
  29197. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29198. */
  29199. mode: number;
  29200. /**
  29201. * Define whether the camera is intermediate.
  29202. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29203. */
  29204. isIntermediate: boolean;
  29205. /**
  29206. * Define the viewport of the camera.
  29207. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29208. */
  29209. viewport: Viewport;
  29210. /**
  29211. * Restricts the camera to viewing objects with the same layerMask.
  29212. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29213. */
  29214. layerMask: number;
  29215. /**
  29216. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29217. */
  29218. fovMode: number;
  29219. /**
  29220. * Rig mode of the camera.
  29221. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29222. * This is normally controlled byt the camera themselves as internal use.
  29223. */
  29224. cameraRigMode: number;
  29225. /**
  29226. * Defines the distance between both "eyes" in case of a RIG
  29227. */
  29228. interaxialDistance: number;
  29229. /**
  29230. * Defines if stereoscopic rendering is done side by side or over under.
  29231. */
  29232. isStereoscopicSideBySide: boolean;
  29233. /**
  29234. * 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
  29235. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29236. * else in the scene. (Eg. security camera)
  29237. *
  29238. * 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)
  29239. */
  29240. customRenderTargets: RenderTargetTexture[];
  29241. /**
  29242. * When set, the camera will render to this render target instead of the default canvas
  29243. *
  29244. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29245. */
  29246. outputRenderTarget: Nullable<RenderTargetTexture>;
  29247. /**
  29248. * Observable triggered when the camera view matrix has changed.
  29249. */
  29250. onViewMatrixChangedObservable: Observable<Camera>;
  29251. /**
  29252. * Observable triggered when the camera Projection matrix has changed.
  29253. */
  29254. onProjectionMatrixChangedObservable: Observable<Camera>;
  29255. /**
  29256. * Observable triggered when the inputs have been processed.
  29257. */
  29258. onAfterCheckInputsObservable: Observable<Camera>;
  29259. /**
  29260. * Observable triggered when reset has been called and applied to the camera.
  29261. */
  29262. onRestoreStateObservable: Observable<Camera>;
  29263. /**
  29264. * Is this camera a part of a rig system?
  29265. */
  29266. isRigCamera: boolean;
  29267. /**
  29268. * If isRigCamera set to true this will be set with the parent camera.
  29269. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29270. */
  29271. rigParent?: Camera;
  29272. /** @hidden */
  29273. _cameraRigParams: any;
  29274. /** @hidden */
  29275. _rigCameras: Camera[];
  29276. /** @hidden */
  29277. _rigPostProcess: Nullable<PostProcess>;
  29278. protected _webvrViewMatrix: Matrix;
  29279. /** @hidden */
  29280. _skipRendering: boolean;
  29281. /** @hidden */
  29282. _projectionMatrix: Matrix;
  29283. /** @hidden */
  29284. _postProcesses: Nullable<PostProcess>[];
  29285. /** @hidden */
  29286. _activeMeshes: SmartArray<AbstractMesh>;
  29287. protected _globalPosition: Vector3;
  29288. /** @hidden */
  29289. _computedViewMatrix: Matrix;
  29290. private _doNotComputeProjectionMatrix;
  29291. private _transformMatrix;
  29292. private _frustumPlanes;
  29293. private _refreshFrustumPlanes;
  29294. private _storedFov;
  29295. private _stateStored;
  29296. /**
  29297. * Instantiates a new camera object.
  29298. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29299. * @see https://doc.babylonjs.com/features/cameras
  29300. * @param name Defines the name of the camera in the scene
  29301. * @param position Defines the position of the camera
  29302. * @param scene Defines the scene the camera belongs too
  29303. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29304. */
  29305. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29306. /**
  29307. * Store current camera state (fov, position, etc..)
  29308. * @returns the camera
  29309. */
  29310. storeState(): Camera;
  29311. /**
  29312. * Restores the camera state values if it has been stored. You must call storeState() first
  29313. */
  29314. protected _restoreStateValues(): boolean;
  29315. /**
  29316. * Restored camera state. You must call storeState() first.
  29317. * @returns true if restored and false otherwise
  29318. */
  29319. restoreState(): boolean;
  29320. /**
  29321. * Gets the class name of the camera.
  29322. * @returns the class name
  29323. */
  29324. getClassName(): string;
  29325. /** @hidden */
  29326. readonly _isCamera: boolean;
  29327. /**
  29328. * Gets a string representation of the camera useful for debug purpose.
  29329. * @param fullDetails Defines that a more verboe level of logging is required
  29330. * @returns the string representation
  29331. */
  29332. toString(fullDetails?: boolean): string;
  29333. /**
  29334. * Gets the current world space position of the camera.
  29335. */
  29336. get globalPosition(): Vector3;
  29337. /**
  29338. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29339. * @returns the active meshe list
  29340. */
  29341. getActiveMeshes(): SmartArray<AbstractMesh>;
  29342. /**
  29343. * Check whether a mesh is part of the current active mesh list of the camera
  29344. * @param mesh Defines the mesh to check
  29345. * @returns true if active, false otherwise
  29346. */
  29347. isActiveMesh(mesh: Mesh): boolean;
  29348. /**
  29349. * Is this camera ready to be used/rendered
  29350. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29351. * @return true if the camera is ready
  29352. */
  29353. isReady(completeCheck?: boolean): boolean;
  29354. /** @hidden */
  29355. _initCache(): void;
  29356. /** @hidden */
  29357. _updateCache(ignoreParentClass?: boolean): void;
  29358. /** @hidden */
  29359. _isSynchronized(): boolean;
  29360. /** @hidden */
  29361. _isSynchronizedViewMatrix(): boolean;
  29362. /** @hidden */
  29363. _isSynchronizedProjectionMatrix(): boolean;
  29364. /**
  29365. * Attach the input controls to a specific dom element to get the input from.
  29366. * @param element Defines the element the controls should be listened from
  29367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29368. */
  29369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29370. /**
  29371. * Detach the current controls from the specified dom element.
  29372. * @param element Defines the element to stop listening the inputs from
  29373. */
  29374. detachControl(element: HTMLElement): void;
  29375. /**
  29376. * Update the camera state according to the different inputs gathered during the frame.
  29377. */
  29378. update(): void;
  29379. /** @hidden */
  29380. _checkInputs(): void;
  29381. /** @hidden */
  29382. get rigCameras(): Camera[];
  29383. /**
  29384. * Gets the post process used by the rig cameras
  29385. */
  29386. get rigPostProcess(): Nullable<PostProcess>;
  29387. /**
  29388. * Internal, gets the first post proces.
  29389. * @returns the first post process to be run on this camera.
  29390. */
  29391. _getFirstPostProcess(): Nullable<PostProcess>;
  29392. private _cascadePostProcessesToRigCams;
  29393. /**
  29394. * Attach a post process to the camera.
  29395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29396. * @param postProcess The post process to attach to the camera
  29397. * @param insertAt The position of the post process in case several of them are in use in the scene
  29398. * @returns the position the post process has been inserted at
  29399. */
  29400. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29401. /**
  29402. * Detach a post process to the camera.
  29403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29404. * @param postProcess The post process to detach from the camera
  29405. */
  29406. detachPostProcess(postProcess: PostProcess): void;
  29407. /**
  29408. * Gets the current world matrix of the camera
  29409. */
  29410. getWorldMatrix(): Matrix;
  29411. /** @hidden */
  29412. _getViewMatrix(): Matrix;
  29413. /**
  29414. * Gets the current view matrix of the camera.
  29415. * @param force forces the camera to recompute the matrix without looking at the cached state
  29416. * @returns the view matrix
  29417. */
  29418. getViewMatrix(force?: boolean): Matrix;
  29419. /**
  29420. * Freeze the projection matrix.
  29421. * It will prevent the cache check of the camera projection compute and can speed up perf
  29422. * if no parameter of the camera are meant to change
  29423. * @param projection Defines manually a projection if necessary
  29424. */
  29425. freezeProjectionMatrix(projection?: Matrix): void;
  29426. /**
  29427. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29428. */
  29429. unfreezeProjectionMatrix(): void;
  29430. /**
  29431. * Gets the current projection matrix of the camera.
  29432. * @param force forces the camera to recompute the matrix without looking at the cached state
  29433. * @returns the projection matrix
  29434. */
  29435. getProjectionMatrix(force?: boolean): Matrix;
  29436. /**
  29437. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29438. * @returns a Matrix
  29439. */
  29440. getTransformationMatrix(): Matrix;
  29441. private _updateFrustumPlanes;
  29442. /**
  29443. * Checks if a cullable object (mesh...) is in the camera frustum
  29444. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29445. * @param target The object to check
  29446. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29447. * @returns true if the object is in frustum otherwise false
  29448. */
  29449. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29450. /**
  29451. * Checks if a cullable object (mesh...) is in the camera frustum
  29452. * Unlike isInFrustum this cheks the full bounding box
  29453. * @param target The object to check
  29454. * @returns true if the object is in frustum otherwise false
  29455. */
  29456. isCompletelyInFrustum(target: ICullable): boolean;
  29457. /**
  29458. * Gets a ray in the forward direction from the camera.
  29459. * @param length Defines the length of the ray to create
  29460. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29461. * @param origin Defines the start point of the ray which defaults to the camera position
  29462. * @returns the forward ray
  29463. */
  29464. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29465. /**
  29466. * Releases resources associated with this node.
  29467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29469. */
  29470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29471. /** @hidden */
  29472. _isLeftCamera: boolean;
  29473. /**
  29474. * Gets the left camera of a rig setup in case of Rigged Camera
  29475. */
  29476. get isLeftCamera(): boolean;
  29477. /** @hidden */
  29478. _isRightCamera: boolean;
  29479. /**
  29480. * Gets the right camera of a rig setup in case of Rigged Camera
  29481. */
  29482. get isRightCamera(): boolean;
  29483. /**
  29484. * Gets the left camera of a rig setup in case of Rigged Camera
  29485. */
  29486. get leftCamera(): Nullable<FreeCamera>;
  29487. /**
  29488. * Gets the right camera of a rig setup in case of Rigged Camera
  29489. */
  29490. get rightCamera(): Nullable<FreeCamera>;
  29491. /**
  29492. * Gets the left camera target of a rig setup in case of Rigged Camera
  29493. * @returns the target position
  29494. */
  29495. getLeftTarget(): Nullable<Vector3>;
  29496. /**
  29497. * Gets the right camera target of a rig setup in case of Rigged Camera
  29498. * @returns the target position
  29499. */
  29500. getRightTarget(): Nullable<Vector3>;
  29501. /**
  29502. * @hidden
  29503. */
  29504. setCameraRigMode(mode: number, rigParams: any): void;
  29505. /** @hidden */
  29506. static _setStereoscopicRigMode(camera: Camera): void;
  29507. /** @hidden */
  29508. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29509. /** @hidden */
  29510. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29511. /** @hidden */
  29512. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29513. /** @hidden */
  29514. _getVRProjectionMatrix(): Matrix;
  29515. protected _updateCameraRotationMatrix(): void;
  29516. protected _updateWebVRCameraRotationMatrix(): void;
  29517. /**
  29518. * This function MUST be overwritten by the different WebVR cameras available.
  29519. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29520. * @hidden
  29521. */
  29522. _getWebVRProjectionMatrix(): Matrix;
  29523. /**
  29524. * This function MUST be overwritten by the different WebVR cameras available.
  29525. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29526. * @hidden
  29527. */
  29528. _getWebVRViewMatrix(): Matrix;
  29529. /** @hidden */
  29530. setCameraRigParameter(name: string, value: any): void;
  29531. /**
  29532. * needs to be overridden by children so sub has required properties to be copied
  29533. * @hidden
  29534. */
  29535. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29536. /**
  29537. * May need to be overridden by children
  29538. * @hidden
  29539. */
  29540. _updateRigCameras(): void;
  29541. /** @hidden */
  29542. _setupInputs(): void;
  29543. /**
  29544. * Serialiaze the camera setup to a json represention
  29545. * @returns the JSON representation
  29546. */
  29547. serialize(): any;
  29548. /**
  29549. * Clones the current camera.
  29550. * @param name The cloned camera name
  29551. * @returns the cloned camera
  29552. */
  29553. clone(name: string): Camera;
  29554. /**
  29555. * Gets the direction of the camera relative to a given local axis.
  29556. * @param localAxis Defines the reference axis to provide a relative direction.
  29557. * @return the direction
  29558. */
  29559. getDirection(localAxis: Vector3): Vector3;
  29560. /**
  29561. * Returns the current camera absolute rotation
  29562. */
  29563. get absoluteRotation(): Quaternion;
  29564. /**
  29565. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29566. * @param localAxis Defines the reference axis to provide a relative direction.
  29567. * @param result Defines the vector to store the result in
  29568. */
  29569. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29570. /**
  29571. * Gets a camera constructor for a given camera type
  29572. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29573. * @param name The name of the camera the result will be able to instantiate
  29574. * @param scene The scene the result will construct the camera in
  29575. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29576. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29577. * @returns a factory method to construc the camera
  29578. */
  29579. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29580. /**
  29581. * Compute the world matrix of the camera.
  29582. * @returns the camera world matrix
  29583. */
  29584. computeWorldMatrix(): Matrix;
  29585. /**
  29586. * Parse a JSON and creates the camera from the parsed information
  29587. * @param parsedCamera The JSON to parse
  29588. * @param scene The scene to instantiate the camera in
  29589. * @returns the newly constructed camera
  29590. */
  29591. static Parse(parsedCamera: any, scene: Scene): Camera;
  29592. }
  29593. }
  29594. declare module BABYLON {
  29595. /**
  29596. * Class containing static functions to help procedurally build meshes
  29597. */
  29598. export class DiscBuilder {
  29599. /**
  29600. * Creates a plane polygonal mesh. By default, this is a disc
  29601. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29602. * * 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
  29603. * * 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
  29604. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29605. * * 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
  29606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29607. * @param name defines the name of the mesh
  29608. * @param options defines the options used to create the mesh
  29609. * @param scene defines the hosting scene
  29610. * @returns the plane polygonal mesh
  29611. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29612. */
  29613. static CreateDisc(name: string, options: {
  29614. radius?: number;
  29615. tessellation?: number;
  29616. arc?: number;
  29617. updatable?: boolean;
  29618. sideOrientation?: number;
  29619. frontUVs?: Vector4;
  29620. backUVs?: Vector4;
  29621. }, scene?: Nullable<Scene>): Mesh;
  29622. }
  29623. }
  29624. declare module BABYLON {
  29625. /**
  29626. * Options to be used when creating a FresnelParameters.
  29627. */
  29628. export type IFresnelParametersCreationOptions = {
  29629. /**
  29630. * Define the color used on edges (grazing angle)
  29631. */
  29632. leftColor?: Color3;
  29633. /**
  29634. * Define the color used on center
  29635. */
  29636. rightColor?: Color3;
  29637. /**
  29638. * Define bias applied to computed fresnel term
  29639. */
  29640. bias?: number;
  29641. /**
  29642. * Defined the power exponent applied to fresnel term
  29643. */
  29644. power?: number;
  29645. /**
  29646. * Define if the fresnel effect is enable or not.
  29647. */
  29648. isEnabled?: boolean;
  29649. };
  29650. /**
  29651. * Serialized format for FresnelParameters.
  29652. */
  29653. export type IFresnelParametersSerialized = {
  29654. /**
  29655. * Define the color used on edges (grazing angle) [as an array]
  29656. */
  29657. leftColor: number[];
  29658. /**
  29659. * Define the color used on center [as an array]
  29660. */
  29661. rightColor: number[];
  29662. /**
  29663. * Define bias applied to computed fresnel term
  29664. */
  29665. bias: number;
  29666. /**
  29667. * Defined the power exponent applied to fresnel term
  29668. */
  29669. power?: number;
  29670. /**
  29671. * Define if the fresnel effect is enable or not.
  29672. */
  29673. isEnabled: boolean;
  29674. };
  29675. /**
  29676. * This represents all the required information to add a fresnel effect on a material:
  29677. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29678. */
  29679. export class FresnelParameters {
  29680. private _isEnabled;
  29681. /**
  29682. * Define if the fresnel effect is enable or not.
  29683. */
  29684. get isEnabled(): boolean;
  29685. set isEnabled(value: boolean);
  29686. /**
  29687. * Define the color used on edges (grazing angle)
  29688. */
  29689. leftColor: Color3;
  29690. /**
  29691. * Define the color used on center
  29692. */
  29693. rightColor: Color3;
  29694. /**
  29695. * Define bias applied to computed fresnel term
  29696. */
  29697. bias: number;
  29698. /**
  29699. * Defined the power exponent applied to fresnel term
  29700. */
  29701. power: number;
  29702. /**
  29703. * Creates a new FresnelParameters object.
  29704. *
  29705. * @param options provide your own settings to optionally to override defaults
  29706. */
  29707. constructor(options?: IFresnelParametersCreationOptions);
  29708. /**
  29709. * Clones the current fresnel and its valuues
  29710. * @returns a clone fresnel configuration
  29711. */
  29712. clone(): FresnelParameters;
  29713. /**
  29714. * Determines equality between FresnelParameters objects
  29715. * @param otherFresnelParameters defines the second operand
  29716. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29717. */
  29718. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29719. /**
  29720. * Serializes the current fresnel parameters to a JSON representation.
  29721. * @return the JSON serialization
  29722. */
  29723. serialize(): IFresnelParametersSerialized;
  29724. /**
  29725. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29726. * @param parsedFresnelParameters Define the JSON representation
  29727. * @returns the parsed parameters
  29728. */
  29729. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29730. }
  29731. }
  29732. declare module BABYLON {
  29733. /**
  29734. * This groups all the flags used to control the materials channel.
  29735. */
  29736. export class MaterialFlags {
  29737. private static _DiffuseTextureEnabled;
  29738. /**
  29739. * Are diffuse textures enabled in the application.
  29740. */
  29741. static get DiffuseTextureEnabled(): boolean;
  29742. static set DiffuseTextureEnabled(value: boolean);
  29743. private static _DetailTextureEnabled;
  29744. /**
  29745. * Are detail textures enabled in the application.
  29746. */
  29747. static get DetailTextureEnabled(): boolean;
  29748. static set DetailTextureEnabled(value: boolean);
  29749. private static _AmbientTextureEnabled;
  29750. /**
  29751. * Are ambient textures enabled in the application.
  29752. */
  29753. static get AmbientTextureEnabled(): boolean;
  29754. static set AmbientTextureEnabled(value: boolean);
  29755. private static _OpacityTextureEnabled;
  29756. /**
  29757. * Are opacity textures enabled in the application.
  29758. */
  29759. static get OpacityTextureEnabled(): boolean;
  29760. static set OpacityTextureEnabled(value: boolean);
  29761. private static _ReflectionTextureEnabled;
  29762. /**
  29763. * Are reflection textures enabled in the application.
  29764. */
  29765. static get ReflectionTextureEnabled(): boolean;
  29766. static set ReflectionTextureEnabled(value: boolean);
  29767. private static _EmissiveTextureEnabled;
  29768. /**
  29769. * Are emissive textures enabled in the application.
  29770. */
  29771. static get EmissiveTextureEnabled(): boolean;
  29772. static set EmissiveTextureEnabled(value: boolean);
  29773. private static _SpecularTextureEnabled;
  29774. /**
  29775. * Are specular textures enabled in the application.
  29776. */
  29777. static get SpecularTextureEnabled(): boolean;
  29778. static set SpecularTextureEnabled(value: boolean);
  29779. private static _BumpTextureEnabled;
  29780. /**
  29781. * Are bump textures enabled in the application.
  29782. */
  29783. static get BumpTextureEnabled(): boolean;
  29784. static set BumpTextureEnabled(value: boolean);
  29785. private static _LightmapTextureEnabled;
  29786. /**
  29787. * Are lightmap textures enabled in the application.
  29788. */
  29789. static get LightmapTextureEnabled(): boolean;
  29790. static set LightmapTextureEnabled(value: boolean);
  29791. private static _RefractionTextureEnabled;
  29792. /**
  29793. * Are refraction textures enabled in the application.
  29794. */
  29795. static get RefractionTextureEnabled(): boolean;
  29796. static set RefractionTextureEnabled(value: boolean);
  29797. private static _ColorGradingTextureEnabled;
  29798. /**
  29799. * Are color grading textures enabled in the application.
  29800. */
  29801. static get ColorGradingTextureEnabled(): boolean;
  29802. static set ColorGradingTextureEnabled(value: boolean);
  29803. private static _FresnelEnabled;
  29804. /**
  29805. * Are fresnels enabled in the application.
  29806. */
  29807. static get FresnelEnabled(): boolean;
  29808. static set FresnelEnabled(value: boolean);
  29809. private static _ClearCoatTextureEnabled;
  29810. /**
  29811. * Are clear coat textures enabled in the application.
  29812. */
  29813. static get ClearCoatTextureEnabled(): boolean;
  29814. static set ClearCoatTextureEnabled(value: boolean);
  29815. private static _ClearCoatBumpTextureEnabled;
  29816. /**
  29817. * Are clear coat bump textures enabled in the application.
  29818. */
  29819. static get ClearCoatBumpTextureEnabled(): boolean;
  29820. static set ClearCoatBumpTextureEnabled(value: boolean);
  29821. private static _ClearCoatTintTextureEnabled;
  29822. /**
  29823. * Are clear coat tint textures enabled in the application.
  29824. */
  29825. static get ClearCoatTintTextureEnabled(): boolean;
  29826. static set ClearCoatTintTextureEnabled(value: boolean);
  29827. private static _SheenTextureEnabled;
  29828. /**
  29829. * Are sheen textures enabled in the application.
  29830. */
  29831. static get SheenTextureEnabled(): boolean;
  29832. static set SheenTextureEnabled(value: boolean);
  29833. private static _AnisotropicTextureEnabled;
  29834. /**
  29835. * Are anisotropic textures enabled in the application.
  29836. */
  29837. static get AnisotropicTextureEnabled(): boolean;
  29838. static set AnisotropicTextureEnabled(value: boolean);
  29839. private static _ThicknessTextureEnabled;
  29840. /**
  29841. * Are thickness textures enabled in the application.
  29842. */
  29843. static get ThicknessTextureEnabled(): boolean;
  29844. static set ThicknessTextureEnabled(value: boolean);
  29845. }
  29846. }
  29847. declare module BABYLON {
  29848. /** @hidden */
  29849. export var defaultFragmentDeclaration: {
  29850. name: string;
  29851. shader: string;
  29852. };
  29853. }
  29854. declare module BABYLON {
  29855. /** @hidden */
  29856. export var defaultUboDeclaration: {
  29857. name: string;
  29858. shader: string;
  29859. };
  29860. }
  29861. declare module BABYLON {
  29862. /** @hidden */
  29863. export var prePassDeclaration: {
  29864. name: string;
  29865. shader: string;
  29866. };
  29867. }
  29868. declare module BABYLON {
  29869. /** @hidden */
  29870. export var lightFragmentDeclaration: {
  29871. name: string;
  29872. shader: string;
  29873. };
  29874. }
  29875. declare module BABYLON {
  29876. /** @hidden */
  29877. export var lightUboDeclaration: {
  29878. name: string;
  29879. shader: string;
  29880. };
  29881. }
  29882. declare module BABYLON {
  29883. /** @hidden */
  29884. export var lightsFragmentFunctions: {
  29885. name: string;
  29886. shader: string;
  29887. };
  29888. }
  29889. declare module BABYLON {
  29890. /** @hidden */
  29891. export var shadowsFragmentFunctions: {
  29892. name: string;
  29893. shader: string;
  29894. };
  29895. }
  29896. declare module BABYLON {
  29897. /** @hidden */
  29898. export var fresnelFunction: {
  29899. name: string;
  29900. shader: string;
  29901. };
  29902. }
  29903. declare module BABYLON {
  29904. /** @hidden */
  29905. export var bumpFragmentMainFunctions: {
  29906. name: string;
  29907. shader: string;
  29908. };
  29909. }
  29910. declare module BABYLON {
  29911. /** @hidden */
  29912. export var bumpFragmentFunctions: {
  29913. name: string;
  29914. shader: string;
  29915. };
  29916. }
  29917. declare module BABYLON {
  29918. /** @hidden */
  29919. export var logDepthDeclaration: {
  29920. name: string;
  29921. shader: string;
  29922. };
  29923. }
  29924. declare module BABYLON {
  29925. /** @hidden */
  29926. export var bumpFragment: {
  29927. name: string;
  29928. shader: string;
  29929. };
  29930. }
  29931. declare module BABYLON {
  29932. /** @hidden */
  29933. export var depthPrePass: {
  29934. name: string;
  29935. shader: string;
  29936. };
  29937. }
  29938. declare module BABYLON {
  29939. /** @hidden */
  29940. export var lightFragment: {
  29941. name: string;
  29942. shader: string;
  29943. };
  29944. }
  29945. declare module BABYLON {
  29946. /** @hidden */
  29947. export var logDepthFragment: {
  29948. name: string;
  29949. shader: string;
  29950. };
  29951. }
  29952. declare module BABYLON {
  29953. /** @hidden */
  29954. export var defaultPixelShader: {
  29955. name: string;
  29956. shader: string;
  29957. };
  29958. }
  29959. declare module BABYLON {
  29960. /** @hidden */
  29961. export var defaultVertexDeclaration: {
  29962. name: string;
  29963. shader: string;
  29964. };
  29965. }
  29966. declare module BABYLON {
  29967. /** @hidden */
  29968. export var bumpVertexDeclaration: {
  29969. name: string;
  29970. shader: string;
  29971. };
  29972. }
  29973. declare module BABYLON {
  29974. /** @hidden */
  29975. export var bumpVertex: {
  29976. name: string;
  29977. shader: string;
  29978. };
  29979. }
  29980. declare module BABYLON {
  29981. /** @hidden */
  29982. export var fogVertex: {
  29983. name: string;
  29984. shader: string;
  29985. };
  29986. }
  29987. declare module BABYLON {
  29988. /** @hidden */
  29989. export var shadowsVertex: {
  29990. name: string;
  29991. shader: string;
  29992. };
  29993. }
  29994. declare module BABYLON {
  29995. /** @hidden */
  29996. export var pointCloudVertex: {
  29997. name: string;
  29998. shader: string;
  29999. };
  30000. }
  30001. declare module BABYLON {
  30002. /** @hidden */
  30003. export var logDepthVertex: {
  30004. name: string;
  30005. shader: string;
  30006. };
  30007. }
  30008. declare module BABYLON {
  30009. /** @hidden */
  30010. export var defaultVertexShader: {
  30011. name: string;
  30012. shader: string;
  30013. };
  30014. }
  30015. declare module BABYLON {
  30016. /**
  30017. * @hidden
  30018. */
  30019. export interface IMaterialDetailMapDefines {
  30020. DETAIL: boolean;
  30021. DETAILDIRECTUV: number;
  30022. DETAIL_NORMALBLENDMETHOD: number;
  30023. /** @hidden */
  30024. _areTexturesDirty: boolean;
  30025. }
  30026. /**
  30027. * Define the code related to the detail map parameters of a material
  30028. *
  30029. * Inspired from:
  30030. * 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
  30031. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30032. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30033. */
  30034. export class DetailMapConfiguration {
  30035. private _texture;
  30036. /**
  30037. * The detail texture of the material.
  30038. */
  30039. texture: Nullable<BaseTexture>;
  30040. /**
  30041. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30042. * Bigger values mean stronger blending
  30043. */
  30044. diffuseBlendLevel: number;
  30045. /**
  30046. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30047. * Bigger values mean stronger blending. Only used with PBR materials
  30048. */
  30049. roughnessBlendLevel: number;
  30050. /**
  30051. * Defines how strong the bump effect from the detail map is
  30052. * Bigger values mean stronger effect
  30053. */
  30054. bumpLevel: number;
  30055. private _normalBlendMethod;
  30056. /**
  30057. * The method used to blend the bump and detail normals together
  30058. */
  30059. normalBlendMethod: number;
  30060. private _isEnabled;
  30061. /**
  30062. * Enable or disable the detail map on this material
  30063. */
  30064. isEnabled: boolean;
  30065. /** @hidden */
  30066. private _internalMarkAllSubMeshesAsTexturesDirty;
  30067. /** @hidden */
  30068. _markAllSubMeshesAsTexturesDirty(): void;
  30069. /**
  30070. * Instantiate a new detail map
  30071. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30072. */
  30073. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30074. /**
  30075. * Gets whether the submesh is ready to be used or not.
  30076. * @param defines the list of "defines" to update.
  30077. * @param scene defines the scene the material belongs to.
  30078. * @returns - boolean indicating that the submesh is ready or not.
  30079. */
  30080. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30081. /**
  30082. * Update the defines for detail map usage
  30083. * @param defines the list of "defines" to update.
  30084. * @param scene defines the scene the material belongs to.
  30085. */
  30086. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30087. /**
  30088. * Binds the material data.
  30089. * @param uniformBuffer defines the Uniform buffer to fill in.
  30090. * @param scene defines the scene the material belongs to.
  30091. * @param isFrozen defines whether the material is frozen or not.
  30092. */
  30093. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30094. /**
  30095. * Checks to see if a texture is used in the material.
  30096. * @param texture - Base texture to use.
  30097. * @returns - Boolean specifying if a texture is used in the material.
  30098. */
  30099. hasTexture(texture: BaseTexture): boolean;
  30100. /**
  30101. * Returns an array of the actively used textures.
  30102. * @param activeTextures Array of BaseTextures
  30103. */
  30104. getActiveTextures(activeTextures: BaseTexture[]): void;
  30105. /**
  30106. * Returns the animatable textures.
  30107. * @param animatables Array of animatable textures.
  30108. */
  30109. getAnimatables(animatables: IAnimatable[]): void;
  30110. /**
  30111. * Disposes the resources of the material.
  30112. * @param forceDisposeTextures - Forces the disposal of all textures.
  30113. */
  30114. dispose(forceDisposeTextures?: boolean): void;
  30115. /**
  30116. * Get the current class name useful for serialization or dynamic coding.
  30117. * @returns "DetailMap"
  30118. */
  30119. getClassName(): string;
  30120. /**
  30121. * Add the required uniforms to the current list.
  30122. * @param uniforms defines the current uniform list.
  30123. */
  30124. static AddUniforms(uniforms: string[]): void;
  30125. /**
  30126. * Add the required samplers to the current list.
  30127. * @param samplers defines the current sampler list.
  30128. */
  30129. static AddSamplers(samplers: string[]): void;
  30130. /**
  30131. * Add the required uniforms to the current buffer.
  30132. * @param uniformBuffer defines the current uniform buffer.
  30133. */
  30134. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30135. /**
  30136. * Makes a duplicate of the current instance into another one.
  30137. * @param detailMap define the instance where to copy the info
  30138. */
  30139. copyTo(detailMap: DetailMapConfiguration): void;
  30140. /**
  30141. * Serializes this detail map instance
  30142. * @returns - An object with the serialized instance.
  30143. */
  30144. serialize(): any;
  30145. /**
  30146. * Parses a detail map setting from a serialized object.
  30147. * @param source - Serialized object.
  30148. * @param scene Defines the scene we are parsing for
  30149. * @param rootUrl Defines the rootUrl to load from
  30150. */
  30151. parse(source: any, scene: Scene, rootUrl: string): void;
  30152. }
  30153. }
  30154. declare module BABYLON {
  30155. /** @hidden */
  30156. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30157. MAINUV1: boolean;
  30158. MAINUV2: boolean;
  30159. DIFFUSE: boolean;
  30160. DIFFUSEDIRECTUV: number;
  30161. DETAIL: boolean;
  30162. DETAILDIRECTUV: number;
  30163. DETAIL_NORMALBLENDMETHOD: number;
  30164. AMBIENT: boolean;
  30165. AMBIENTDIRECTUV: number;
  30166. OPACITY: boolean;
  30167. OPACITYDIRECTUV: number;
  30168. OPACITYRGB: boolean;
  30169. REFLECTION: boolean;
  30170. EMISSIVE: boolean;
  30171. EMISSIVEDIRECTUV: number;
  30172. SPECULAR: boolean;
  30173. SPECULARDIRECTUV: number;
  30174. BUMP: boolean;
  30175. BUMPDIRECTUV: number;
  30176. PARALLAX: boolean;
  30177. PARALLAXOCCLUSION: boolean;
  30178. SPECULAROVERALPHA: boolean;
  30179. CLIPPLANE: boolean;
  30180. CLIPPLANE2: boolean;
  30181. CLIPPLANE3: boolean;
  30182. CLIPPLANE4: boolean;
  30183. CLIPPLANE5: boolean;
  30184. CLIPPLANE6: boolean;
  30185. ALPHATEST: boolean;
  30186. DEPTHPREPASS: boolean;
  30187. ALPHAFROMDIFFUSE: boolean;
  30188. POINTSIZE: boolean;
  30189. FOG: boolean;
  30190. SPECULARTERM: boolean;
  30191. DIFFUSEFRESNEL: boolean;
  30192. OPACITYFRESNEL: boolean;
  30193. REFLECTIONFRESNEL: boolean;
  30194. REFRACTIONFRESNEL: boolean;
  30195. EMISSIVEFRESNEL: boolean;
  30196. FRESNEL: boolean;
  30197. NORMAL: boolean;
  30198. UV1: boolean;
  30199. UV2: boolean;
  30200. VERTEXCOLOR: boolean;
  30201. VERTEXALPHA: boolean;
  30202. NUM_BONE_INFLUENCERS: number;
  30203. BonesPerMesh: number;
  30204. BONETEXTURE: boolean;
  30205. INSTANCES: boolean;
  30206. THIN_INSTANCES: boolean;
  30207. GLOSSINESS: boolean;
  30208. ROUGHNESS: boolean;
  30209. EMISSIVEASILLUMINATION: boolean;
  30210. LINKEMISSIVEWITHDIFFUSE: boolean;
  30211. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30212. LIGHTMAP: boolean;
  30213. LIGHTMAPDIRECTUV: number;
  30214. OBJECTSPACE_NORMALMAP: boolean;
  30215. USELIGHTMAPASSHADOWMAP: boolean;
  30216. REFLECTIONMAP_3D: boolean;
  30217. REFLECTIONMAP_SPHERICAL: boolean;
  30218. REFLECTIONMAP_PLANAR: boolean;
  30219. REFLECTIONMAP_CUBIC: boolean;
  30220. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30221. REFLECTIONMAP_PROJECTION: boolean;
  30222. REFLECTIONMAP_SKYBOX: boolean;
  30223. REFLECTIONMAP_EXPLICIT: boolean;
  30224. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30225. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30226. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30227. INVERTCUBICMAP: boolean;
  30228. LOGARITHMICDEPTH: boolean;
  30229. REFRACTION: boolean;
  30230. REFRACTIONMAP_3D: boolean;
  30231. REFLECTIONOVERALPHA: boolean;
  30232. TWOSIDEDLIGHTING: boolean;
  30233. SHADOWFLOAT: boolean;
  30234. MORPHTARGETS: boolean;
  30235. MORPHTARGETS_NORMAL: boolean;
  30236. MORPHTARGETS_TANGENT: boolean;
  30237. MORPHTARGETS_UV: boolean;
  30238. NUM_MORPH_INFLUENCERS: number;
  30239. NONUNIFORMSCALING: boolean;
  30240. PREMULTIPLYALPHA: boolean;
  30241. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30242. ALPHABLEND: boolean;
  30243. PREPASS: boolean;
  30244. SCENE_MRT_COUNT: number;
  30245. RGBDLIGHTMAP: boolean;
  30246. RGBDREFLECTION: boolean;
  30247. RGBDREFRACTION: boolean;
  30248. IMAGEPROCESSING: boolean;
  30249. VIGNETTE: boolean;
  30250. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30251. VIGNETTEBLENDMODEOPAQUE: boolean;
  30252. TONEMAPPING: boolean;
  30253. TONEMAPPING_ACES: boolean;
  30254. CONTRAST: boolean;
  30255. COLORCURVES: boolean;
  30256. COLORGRADING: boolean;
  30257. COLORGRADING3D: boolean;
  30258. SAMPLER3DGREENDEPTH: boolean;
  30259. SAMPLER3DBGRMAP: boolean;
  30260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30261. MULTIVIEW: boolean;
  30262. /**
  30263. * If the reflection texture on this material is in linear color space
  30264. * @hidden
  30265. */
  30266. IS_REFLECTION_LINEAR: boolean;
  30267. /**
  30268. * If the refraction texture on this material is in linear color space
  30269. * @hidden
  30270. */
  30271. IS_REFRACTION_LINEAR: boolean;
  30272. EXPOSURE: boolean;
  30273. constructor();
  30274. setReflectionMode(modeToEnable: string): void;
  30275. }
  30276. /**
  30277. * This is the default material used in Babylon. It is the best trade off between quality
  30278. * and performances.
  30279. * @see https://doc.babylonjs.com/babylon101/materials
  30280. */
  30281. export class StandardMaterial extends PushMaterial {
  30282. private _diffuseTexture;
  30283. /**
  30284. * The basic texture of the material as viewed under a light.
  30285. */
  30286. diffuseTexture: Nullable<BaseTexture>;
  30287. private _ambientTexture;
  30288. /**
  30289. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30290. */
  30291. ambientTexture: Nullable<BaseTexture>;
  30292. private _opacityTexture;
  30293. /**
  30294. * Define the transparency of the material from a texture.
  30295. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30296. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30297. */
  30298. opacityTexture: Nullable<BaseTexture>;
  30299. private _reflectionTexture;
  30300. /**
  30301. * Define the texture used to display the reflection.
  30302. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30303. */
  30304. reflectionTexture: Nullable<BaseTexture>;
  30305. private _emissiveTexture;
  30306. /**
  30307. * Define texture of the material as if self lit.
  30308. * This will be mixed in the final result even in the absence of light.
  30309. */
  30310. emissiveTexture: Nullable<BaseTexture>;
  30311. private _specularTexture;
  30312. /**
  30313. * Define how the color and intensity of the highlight given by the light in the material.
  30314. */
  30315. specularTexture: Nullable<BaseTexture>;
  30316. private _bumpTexture;
  30317. /**
  30318. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30319. * 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.
  30320. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30321. */
  30322. bumpTexture: Nullable<BaseTexture>;
  30323. private _lightmapTexture;
  30324. /**
  30325. * Complex lighting can be computationally expensive to compute at runtime.
  30326. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30327. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30328. */
  30329. lightmapTexture: Nullable<BaseTexture>;
  30330. private _refractionTexture;
  30331. /**
  30332. * Define the texture used to display the refraction.
  30333. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30334. */
  30335. refractionTexture: Nullable<BaseTexture>;
  30336. /**
  30337. * The color of the material lit by the environmental background lighting.
  30338. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30339. */
  30340. ambientColor: Color3;
  30341. /**
  30342. * The basic color of the material as viewed under a light.
  30343. */
  30344. diffuseColor: Color3;
  30345. /**
  30346. * Define how the color and intensity of the highlight given by the light in the material.
  30347. */
  30348. specularColor: Color3;
  30349. /**
  30350. * Define the color of the material as if self lit.
  30351. * This will be mixed in the final result even in the absence of light.
  30352. */
  30353. emissiveColor: Color3;
  30354. /**
  30355. * Defines how sharp are the highlights in the material.
  30356. * The bigger the value the sharper giving a more glossy feeling to the result.
  30357. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30358. */
  30359. specularPower: number;
  30360. private _useAlphaFromDiffuseTexture;
  30361. /**
  30362. * Does the transparency come from the diffuse texture alpha channel.
  30363. */
  30364. useAlphaFromDiffuseTexture: boolean;
  30365. private _useEmissiveAsIllumination;
  30366. /**
  30367. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30368. */
  30369. useEmissiveAsIllumination: boolean;
  30370. private _linkEmissiveWithDiffuse;
  30371. /**
  30372. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30373. * the emissive level when the final color is close to one.
  30374. */
  30375. linkEmissiveWithDiffuse: boolean;
  30376. private _useSpecularOverAlpha;
  30377. /**
  30378. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30379. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30380. */
  30381. useSpecularOverAlpha: boolean;
  30382. private _useReflectionOverAlpha;
  30383. /**
  30384. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30385. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30386. */
  30387. useReflectionOverAlpha: boolean;
  30388. private _disableLighting;
  30389. /**
  30390. * Does lights from the scene impacts this material.
  30391. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30392. */
  30393. disableLighting: boolean;
  30394. private _useObjectSpaceNormalMap;
  30395. /**
  30396. * Allows using an object space normal map (instead of tangent space).
  30397. */
  30398. useObjectSpaceNormalMap: boolean;
  30399. private _useParallax;
  30400. /**
  30401. * Is parallax enabled or not.
  30402. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30403. */
  30404. useParallax: boolean;
  30405. private _useParallaxOcclusion;
  30406. /**
  30407. * Is parallax occlusion enabled or not.
  30408. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30409. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30410. */
  30411. useParallaxOcclusion: boolean;
  30412. /**
  30413. * 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.
  30414. */
  30415. parallaxScaleBias: number;
  30416. private _roughness;
  30417. /**
  30418. * Helps to define how blurry the reflections should appears in the material.
  30419. */
  30420. roughness: number;
  30421. /**
  30422. * In case of refraction, define the value of the index of refraction.
  30423. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30424. */
  30425. indexOfRefraction: number;
  30426. /**
  30427. * Invert the refraction texture alongside the y axis.
  30428. * It can be useful with procedural textures or probe for instance.
  30429. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30430. */
  30431. invertRefractionY: boolean;
  30432. /**
  30433. * Defines the alpha limits in alpha test mode.
  30434. */
  30435. alphaCutOff: number;
  30436. private _useLightmapAsShadowmap;
  30437. /**
  30438. * In case of light mapping, define whether the map contains light or shadow informations.
  30439. */
  30440. useLightmapAsShadowmap: boolean;
  30441. private _diffuseFresnelParameters;
  30442. /**
  30443. * Define the diffuse fresnel parameters of the material.
  30444. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30445. */
  30446. diffuseFresnelParameters: FresnelParameters;
  30447. private _opacityFresnelParameters;
  30448. /**
  30449. * Define the opacity fresnel parameters of the material.
  30450. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30451. */
  30452. opacityFresnelParameters: FresnelParameters;
  30453. private _reflectionFresnelParameters;
  30454. /**
  30455. * Define the reflection fresnel parameters of the material.
  30456. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30457. */
  30458. reflectionFresnelParameters: FresnelParameters;
  30459. private _refractionFresnelParameters;
  30460. /**
  30461. * Define the refraction fresnel parameters of the material.
  30462. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30463. */
  30464. refractionFresnelParameters: FresnelParameters;
  30465. private _emissiveFresnelParameters;
  30466. /**
  30467. * Define the emissive fresnel parameters of the material.
  30468. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30469. */
  30470. emissiveFresnelParameters: FresnelParameters;
  30471. private _useReflectionFresnelFromSpecular;
  30472. /**
  30473. * If true automatically deducts the fresnels values from the material specularity.
  30474. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30475. */
  30476. useReflectionFresnelFromSpecular: boolean;
  30477. private _useGlossinessFromSpecularMapAlpha;
  30478. /**
  30479. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30480. */
  30481. useGlossinessFromSpecularMapAlpha: boolean;
  30482. private _maxSimultaneousLights;
  30483. /**
  30484. * Defines the maximum number of lights that can be used in the material
  30485. */
  30486. maxSimultaneousLights: number;
  30487. private _invertNormalMapX;
  30488. /**
  30489. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30490. */
  30491. invertNormalMapX: boolean;
  30492. private _invertNormalMapY;
  30493. /**
  30494. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30495. */
  30496. invertNormalMapY: boolean;
  30497. private _twoSidedLighting;
  30498. /**
  30499. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30500. */
  30501. twoSidedLighting: boolean;
  30502. /**
  30503. * Default configuration related to image processing available in the standard Material.
  30504. */
  30505. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30506. /**
  30507. * Gets the image processing configuration used either in this material.
  30508. */
  30509. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30510. /**
  30511. * Sets the Default image processing configuration used either in the this material.
  30512. *
  30513. * If sets to null, the scene one is in use.
  30514. */
  30515. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30516. /**
  30517. * Keep track of the image processing observer to allow dispose and replace.
  30518. */
  30519. private _imageProcessingObserver;
  30520. /**
  30521. * Attaches a new image processing configuration to the Standard Material.
  30522. * @param configuration
  30523. */
  30524. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30525. /**
  30526. * Gets wether the color curves effect is enabled.
  30527. */
  30528. get cameraColorCurvesEnabled(): boolean;
  30529. /**
  30530. * Sets wether the color curves effect is enabled.
  30531. */
  30532. set cameraColorCurvesEnabled(value: boolean);
  30533. /**
  30534. * Gets wether the color grading effect is enabled.
  30535. */
  30536. get cameraColorGradingEnabled(): boolean;
  30537. /**
  30538. * Gets wether the color grading effect is enabled.
  30539. */
  30540. set cameraColorGradingEnabled(value: boolean);
  30541. /**
  30542. * Gets wether tonemapping is enabled or not.
  30543. */
  30544. get cameraToneMappingEnabled(): boolean;
  30545. /**
  30546. * Sets wether tonemapping is enabled or not
  30547. */
  30548. set cameraToneMappingEnabled(value: boolean);
  30549. /**
  30550. * The camera exposure used on this material.
  30551. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30552. * This corresponds to a photographic exposure.
  30553. */
  30554. get cameraExposure(): number;
  30555. /**
  30556. * The camera exposure used on this material.
  30557. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30558. * This corresponds to a photographic exposure.
  30559. */
  30560. set cameraExposure(value: number);
  30561. /**
  30562. * Gets The camera contrast used on this material.
  30563. */
  30564. get cameraContrast(): number;
  30565. /**
  30566. * Sets The camera contrast used on this material.
  30567. */
  30568. set cameraContrast(value: number);
  30569. /**
  30570. * Gets the Color Grading 2D Lookup Texture.
  30571. */
  30572. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30573. /**
  30574. * Sets the Color Grading 2D Lookup Texture.
  30575. */
  30576. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30577. /**
  30578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30580. * 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;
  30581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30582. */
  30583. get cameraColorCurves(): Nullable<ColorCurves>;
  30584. /**
  30585. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30586. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30587. * 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;
  30588. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30589. */
  30590. set cameraColorCurves(value: Nullable<ColorCurves>);
  30591. /**
  30592. * Can this material render to several textures at once
  30593. */
  30594. get canRenderToMRT(): boolean;
  30595. /**
  30596. * Defines the detail map parameters for the material.
  30597. */
  30598. readonly detailMap: DetailMapConfiguration;
  30599. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30600. protected _worldViewProjectionMatrix: Matrix;
  30601. protected _globalAmbientColor: Color3;
  30602. protected _useLogarithmicDepth: boolean;
  30603. protected _rebuildInParallel: boolean;
  30604. /**
  30605. * Instantiates a new standard material.
  30606. * This is the default material used in Babylon. It is the best trade off between quality
  30607. * and performances.
  30608. * @see https://doc.babylonjs.com/babylon101/materials
  30609. * @param name Define the name of the material in the scene
  30610. * @param scene Define the scene the material belong to
  30611. */
  30612. constructor(name: string, scene: Scene);
  30613. /**
  30614. * Gets a boolean indicating that current material needs to register RTT
  30615. */
  30616. get hasRenderTargetTextures(): boolean;
  30617. /**
  30618. * Gets the current class name of the material e.g. "StandardMaterial"
  30619. * Mainly use in serialization.
  30620. * @returns the class name
  30621. */
  30622. getClassName(): string;
  30623. /**
  30624. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30625. * You can try switching to logarithmic depth.
  30626. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30627. */
  30628. get useLogarithmicDepth(): boolean;
  30629. set useLogarithmicDepth(value: boolean);
  30630. /**
  30631. * Specifies if the material will require alpha blending
  30632. * @returns a boolean specifying if alpha blending is needed
  30633. */
  30634. needAlphaBlending(): boolean;
  30635. /**
  30636. * Specifies if this material should be rendered in alpha test mode
  30637. * @returns a boolean specifying if an alpha test is needed.
  30638. */
  30639. needAlphaTesting(): boolean;
  30640. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30641. /**
  30642. * Get the texture used for alpha test purpose.
  30643. * @returns the diffuse texture in case of the standard material.
  30644. */
  30645. getAlphaTestTexture(): Nullable<BaseTexture>;
  30646. /**
  30647. * Get if the submesh is ready to be used and all its information available.
  30648. * Child classes can use it to update shaders
  30649. * @param mesh defines the mesh to check
  30650. * @param subMesh defines which submesh to check
  30651. * @param useInstances specifies that instances should be used
  30652. * @returns a boolean indicating that the submesh is ready or not
  30653. */
  30654. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30655. /**
  30656. * Builds the material UBO layouts.
  30657. * Used internally during the effect preparation.
  30658. */
  30659. buildUniformLayout(): void;
  30660. /**
  30661. * Unbinds the material from the mesh
  30662. */
  30663. unbind(): void;
  30664. /**
  30665. * Binds the submesh to this material by preparing the effect and shader to draw
  30666. * @param world defines the world transformation matrix
  30667. * @param mesh defines the mesh containing the submesh
  30668. * @param subMesh defines the submesh to bind the material to
  30669. */
  30670. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30671. /**
  30672. * Get the list of animatables in the material.
  30673. * @returns the list of animatables object used in the material
  30674. */
  30675. getAnimatables(): IAnimatable[];
  30676. /**
  30677. * Gets the active textures from the material
  30678. * @returns an array of textures
  30679. */
  30680. getActiveTextures(): BaseTexture[];
  30681. /**
  30682. * Specifies if the material uses a texture
  30683. * @param texture defines the texture to check against the material
  30684. * @returns a boolean specifying if the material uses the texture
  30685. */
  30686. hasTexture(texture: BaseTexture): boolean;
  30687. /**
  30688. * Disposes the material
  30689. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30690. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30691. */
  30692. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30693. /**
  30694. * Makes a duplicate of the material, and gives it a new name
  30695. * @param name defines the new name for the duplicated material
  30696. * @returns the cloned material
  30697. */
  30698. clone(name: string): StandardMaterial;
  30699. /**
  30700. * Serializes this material in a JSON representation
  30701. * @returns the serialized material object
  30702. */
  30703. serialize(): any;
  30704. /**
  30705. * Creates a standard material from parsed material data
  30706. * @param source defines the JSON representation of the material
  30707. * @param scene defines the hosting scene
  30708. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30709. * @returns a new standard material
  30710. */
  30711. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30712. /**
  30713. * Are diffuse textures enabled in the application.
  30714. */
  30715. static get DiffuseTextureEnabled(): boolean;
  30716. static set DiffuseTextureEnabled(value: boolean);
  30717. /**
  30718. * Are detail textures enabled in the application.
  30719. */
  30720. static get DetailTextureEnabled(): boolean;
  30721. static set DetailTextureEnabled(value: boolean);
  30722. /**
  30723. * Are ambient textures enabled in the application.
  30724. */
  30725. static get AmbientTextureEnabled(): boolean;
  30726. static set AmbientTextureEnabled(value: boolean);
  30727. /**
  30728. * Are opacity textures enabled in the application.
  30729. */
  30730. static get OpacityTextureEnabled(): boolean;
  30731. static set OpacityTextureEnabled(value: boolean);
  30732. /**
  30733. * Are reflection textures enabled in the application.
  30734. */
  30735. static get ReflectionTextureEnabled(): boolean;
  30736. static set ReflectionTextureEnabled(value: boolean);
  30737. /**
  30738. * Are emissive textures enabled in the application.
  30739. */
  30740. static get EmissiveTextureEnabled(): boolean;
  30741. static set EmissiveTextureEnabled(value: boolean);
  30742. /**
  30743. * Are specular textures enabled in the application.
  30744. */
  30745. static get SpecularTextureEnabled(): boolean;
  30746. static set SpecularTextureEnabled(value: boolean);
  30747. /**
  30748. * Are bump textures enabled in the application.
  30749. */
  30750. static get BumpTextureEnabled(): boolean;
  30751. static set BumpTextureEnabled(value: boolean);
  30752. /**
  30753. * Are lightmap textures enabled in the application.
  30754. */
  30755. static get LightmapTextureEnabled(): boolean;
  30756. static set LightmapTextureEnabled(value: boolean);
  30757. /**
  30758. * Are refraction textures enabled in the application.
  30759. */
  30760. static get RefractionTextureEnabled(): boolean;
  30761. static set RefractionTextureEnabled(value: boolean);
  30762. /**
  30763. * Are color grading textures enabled in the application.
  30764. */
  30765. static get ColorGradingTextureEnabled(): boolean;
  30766. static set ColorGradingTextureEnabled(value: boolean);
  30767. /**
  30768. * Are fresnels enabled in the application.
  30769. */
  30770. static get FresnelEnabled(): boolean;
  30771. static set FresnelEnabled(value: boolean);
  30772. }
  30773. }
  30774. declare module BABYLON {
  30775. /**
  30776. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30777. *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.
  30778. * The SPS is also a particle system. It provides some methods to manage the particles.
  30779. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30780. *
  30781. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30782. */
  30783. export class SolidParticleSystem implements IDisposable {
  30784. /**
  30785. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30786. * Example : var p = SPS.particles[i];
  30787. */
  30788. particles: SolidParticle[];
  30789. /**
  30790. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30791. */
  30792. nbParticles: number;
  30793. /**
  30794. * If the particles must ever face the camera (default false). Useful for planar particles.
  30795. */
  30796. billboard: boolean;
  30797. /**
  30798. * Recompute normals when adding a shape
  30799. */
  30800. recomputeNormals: boolean;
  30801. /**
  30802. * This a counter ofr your own usage. It's not set by any SPS functions.
  30803. */
  30804. counter: number;
  30805. /**
  30806. * The SPS name. This name is also given to the underlying mesh.
  30807. */
  30808. name: string;
  30809. /**
  30810. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30811. */
  30812. mesh: Mesh;
  30813. /**
  30814. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30815. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30816. */
  30817. vars: any;
  30818. /**
  30819. * This array is populated when the SPS is set as 'pickable'.
  30820. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30821. * Each element of this array is an object `{idx: int, faceId: int}`.
  30822. * `idx` is the picked particle index in the `SPS.particles` array
  30823. * `faceId` is the picked face index counted within this particle.
  30824. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30825. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30826. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30827. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30828. */
  30829. pickedParticles: {
  30830. idx: number;
  30831. faceId: number;
  30832. }[];
  30833. /**
  30834. * This array is populated when the SPS is set as 'pickable'
  30835. * Each key of this array is a submesh index.
  30836. * Each element of this array is a second array defined like this :
  30837. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30838. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30839. * `idx` is the picked particle index in the `SPS.particles` array
  30840. * `faceId` is the picked face index counted within this particle.
  30841. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30842. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30843. */
  30844. pickedBySubMesh: {
  30845. idx: number;
  30846. faceId: number;
  30847. }[][];
  30848. /**
  30849. * This array is populated when `enableDepthSort` is set to true.
  30850. * Each element of this array is an instance of the class DepthSortedParticle.
  30851. */
  30852. depthSortedParticles: DepthSortedParticle[];
  30853. /**
  30854. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30855. * @hidden
  30856. */
  30857. _bSphereOnly: boolean;
  30858. /**
  30859. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30860. * @hidden
  30861. */
  30862. _bSphereRadiusFactor: number;
  30863. private _scene;
  30864. private _positions;
  30865. private _indices;
  30866. private _normals;
  30867. private _colors;
  30868. private _uvs;
  30869. private _indices32;
  30870. private _positions32;
  30871. private _normals32;
  30872. private _fixedNormal32;
  30873. private _colors32;
  30874. private _uvs32;
  30875. private _index;
  30876. private _updatable;
  30877. private _pickable;
  30878. private _isVisibilityBoxLocked;
  30879. private _alwaysVisible;
  30880. private _depthSort;
  30881. private _expandable;
  30882. private _shapeCounter;
  30883. private _copy;
  30884. private _color;
  30885. private _computeParticleColor;
  30886. private _computeParticleTexture;
  30887. private _computeParticleRotation;
  30888. private _computeParticleVertex;
  30889. private _computeBoundingBox;
  30890. private _depthSortParticles;
  30891. private _camera;
  30892. private _mustUnrotateFixedNormals;
  30893. private _particlesIntersect;
  30894. private _needs32Bits;
  30895. private _isNotBuilt;
  30896. private _lastParticleId;
  30897. private _idxOfId;
  30898. private _multimaterialEnabled;
  30899. private _useModelMaterial;
  30900. private _indicesByMaterial;
  30901. private _materialIndexes;
  30902. private _depthSortFunction;
  30903. private _materialSortFunction;
  30904. private _materials;
  30905. private _multimaterial;
  30906. private _materialIndexesById;
  30907. private _defaultMaterial;
  30908. private _autoUpdateSubMeshes;
  30909. private _tmpVertex;
  30910. /**
  30911. * Creates a SPS (Solid Particle System) object.
  30912. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30913. * @param scene (Scene) is the scene in which the SPS is added.
  30914. * @param options defines the options of the sps e.g.
  30915. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30916. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30917. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30918. * * 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.
  30919. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30920. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30921. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30922. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30923. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30924. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30925. */
  30926. constructor(name: string, scene: Scene, options?: {
  30927. updatable?: boolean;
  30928. isPickable?: boolean;
  30929. enableDepthSort?: boolean;
  30930. particleIntersection?: boolean;
  30931. boundingSphereOnly?: boolean;
  30932. bSphereRadiusFactor?: number;
  30933. expandable?: boolean;
  30934. useModelMaterial?: boolean;
  30935. enableMultiMaterial?: boolean;
  30936. });
  30937. /**
  30938. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30939. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30940. * @returns the created mesh
  30941. */
  30942. buildMesh(): Mesh;
  30943. /**
  30944. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30945. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30946. * Thus the particles generated from `digest()` have their property `position` set yet.
  30947. * @param mesh ( Mesh ) is the mesh to be digested
  30948. * @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
  30949. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30950. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30951. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30952. * @returns the current SPS
  30953. */
  30954. digest(mesh: Mesh, options?: {
  30955. facetNb?: number;
  30956. number?: number;
  30957. delta?: number;
  30958. storage?: [];
  30959. }): SolidParticleSystem;
  30960. /**
  30961. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30962. * @hidden
  30963. */
  30964. private _unrotateFixedNormals;
  30965. /**
  30966. * Resets the temporary working copy particle
  30967. * @hidden
  30968. */
  30969. private _resetCopy;
  30970. /**
  30971. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30972. * @param p the current index in the positions array to be updated
  30973. * @param ind the current index in the indices array
  30974. * @param shape a Vector3 array, the shape geometry
  30975. * @param positions the positions array to be updated
  30976. * @param meshInd the shape indices array
  30977. * @param indices the indices array to be updated
  30978. * @param meshUV the shape uv array
  30979. * @param uvs the uv array to be updated
  30980. * @param meshCol the shape color array
  30981. * @param colors the color array to be updated
  30982. * @param meshNor the shape normals array
  30983. * @param normals the normals array to be updated
  30984. * @param idx the particle index
  30985. * @param idxInShape the particle index in its shape
  30986. * @param options the addShape() method passed options
  30987. * @model the particle model
  30988. * @hidden
  30989. */
  30990. private _meshBuilder;
  30991. /**
  30992. * Returns a shape Vector3 array from positions float array
  30993. * @param positions float array
  30994. * @returns a vector3 array
  30995. * @hidden
  30996. */
  30997. private _posToShape;
  30998. /**
  30999. * Returns a shapeUV array from a float uvs (array deep copy)
  31000. * @param uvs as a float array
  31001. * @returns a shapeUV array
  31002. * @hidden
  31003. */
  31004. private _uvsToShapeUV;
  31005. /**
  31006. * Adds a new particle object in the particles array
  31007. * @param idx particle index in particles array
  31008. * @param id particle id
  31009. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31010. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31011. * @param model particle ModelShape object
  31012. * @param shapeId model shape identifier
  31013. * @param idxInShape index of the particle in the current model
  31014. * @param bInfo model bounding info object
  31015. * @param storage target storage array, if any
  31016. * @hidden
  31017. */
  31018. private _addParticle;
  31019. /**
  31020. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31021. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31022. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31023. * @param nb (positive integer) the number of particles to be created from this model
  31024. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31025. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31026. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31027. * @returns the number of shapes in the system
  31028. */
  31029. addShape(mesh: Mesh, nb: number, options?: {
  31030. positionFunction?: any;
  31031. vertexFunction?: any;
  31032. storage?: [];
  31033. }): number;
  31034. /**
  31035. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31036. * @hidden
  31037. */
  31038. private _rebuildParticle;
  31039. /**
  31040. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31041. * @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.
  31042. * @returns the SPS.
  31043. */
  31044. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31045. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31046. * Returns an array with the removed particles.
  31047. * 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.
  31048. * The SPS can't be empty so at least one particle needs to remain in place.
  31049. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31050. * @param start index of the first particle to remove
  31051. * @param end index of the last particle to remove (included)
  31052. * @returns an array populated with the removed particles
  31053. */
  31054. removeParticles(start: number, end: number): SolidParticle[];
  31055. /**
  31056. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31057. * @param solidParticleArray an array populated with Solid Particles objects
  31058. * @returns the SPS
  31059. */
  31060. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31061. /**
  31062. * Creates a new particle and modifies the SPS mesh geometry :
  31063. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31064. * - calls _addParticle() to populate the particle array
  31065. * factorized code from addShape() and insertParticlesFromArray()
  31066. * @param idx particle index in the particles array
  31067. * @param i particle index in its shape
  31068. * @param modelShape particle ModelShape object
  31069. * @param shape shape vertex array
  31070. * @param meshInd shape indices array
  31071. * @param meshUV shape uv array
  31072. * @param meshCol shape color array
  31073. * @param meshNor shape normals array
  31074. * @param bbInfo shape bounding info
  31075. * @param storage target particle storage
  31076. * @options addShape() passed options
  31077. * @hidden
  31078. */
  31079. private _insertNewParticle;
  31080. /**
  31081. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31082. * This method calls `updateParticle()` for each particle of the SPS.
  31083. * For an animated SPS, it is usually called within the render loop.
  31084. * 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.
  31085. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31086. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31087. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31088. * @returns the SPS.
  31089. */
  31090. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31091. /**
  31092. * Disposes the SPS.
  31093. */
  31094. dispose(): void;
  31095. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31096. * idx is the particle index in the SPS
  31097. * faceId is the picked face index counted within this particle.
  31098. * Returns null if the pickInfo can't identify a picked particle.
  31099. * @param pickingInfo (PickingInfo object)
  31100. * @returns {idx: number, faceId: number} or null
  31101. */
  31102. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31103. idx: number;
  31104. faceId: number;
  31105. }>;
  31106. /**
  31107. * Returns a SolidParticle object from its identifier : particle.id
  31108. * @param id (integer) the particle Id
  31109. * @returns the searched particle or null if not found in the SPS.
  31110. */
  31111. getParticleById(id: number): Nullable<SolidParticle>;
  31112. /**
  31113. * Returns a new array populated with the particles having the passed shapeId.
  31114. * @param shapeId (integer) the shape identifier
  31115. * @returns a new solid particle array
  31116. */
  31117. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31118. /**
  31119. * Populates the passed array "ref" with the particles having the passed shapeId.
  31120. * @param shapeId the shape identifier
  31121. * @returns the SPS
  31122. * @param ref
  31123. */
  31124. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31125. /**
  31126. * Computes the required SubMeshes according the materials assigned to the particles.
  31127. * @returns the solid particle system.
  31128. * Does nothing if called before the SPS mesh is built.
  31129. */
  31130. computeSubMeshes(): SolidParticleSystem;
  31131. /**
  31132. * Sorts the solid particles by material when MultiMaterial is enabled.
  31133. * Updates the indices32 array.
  31134. * Updates the indicesByMaterial array.
  31135. * Updates the mesh indices array.
  31136. * @returns the SPS
  31137. * @hidden
  31138. */
  31139. private _sortParticlesByMaterial;
  31140. /**
  31141. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31142. * @hidden
  31143. */
  31144. private _setMaterialIndexesById;
  31145. /**
  31146. * Returns an array with unique values of Materials from the passed array
  31147. * @param array the material array to be checked and filtered
  31148. * @hidden
  31149. */
  31150. private _filterUniqueMaterialId;
  31151. /**
  31152. * Sets a new Standard Material as _defaultMaterial if not already set.
  31153. * @hidden
  31154. */
  31155. private _setDefaultMaterial;
  31156. /**
  31157. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31158. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31159. * @returns the SPS.
  31160. */
  31161. refreshVisibleSize(): SolidParticleSystem;
  31162. /**
  31163. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31164. * @param size the size (float) of the visibility box
  31165. * note : this doesn't lock the SPS mesh bounding box.
  31166. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31167. */
  31168. setVisibilityBox(size: number): void;
  31169. /**
  31170. * Gets whether the SPS as always visible or not
  31171. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31172. */
  31173. get isAlwaysVisible(): boolean;
  31174. /**
  31175. * Sets the SPS as always visible or not
  31176. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31177. */
  31178. set isAlwaysVisible(val: boolean);
  31179. /**
  31180. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31181. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31182. */
  31183. set isVisibilityBoxLocked(val: boolean);
  31184. /**
  31185. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31186. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31187. */
  31188. get isVisibilityBoxLocked(): boolean;
  31189. /**
  31190. * Tells to `setParticles()` to compute the particle rotations or not.
  31191. * Default value : true. The SPS is faster when it's set to false.
  31192. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31193. */
  31194. set computeParticleRotation(val: boolean);
  31195. /**
  31196. * Tells to `setParticles()` to compute the particle colors or not.
  31197. * Default value : true. The SPS is faster when it's set to false.
  31198. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31199. */
  31200. set computeParticleColor(val: boolean);
  31201. set computeParticleTexture(val: boolean);
  31202. /**
  31203. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31204. * Default value : false. The SPS is faster when it's set to false.
  31205. * Note : the particle custom vertex positions aren't stored values.
  31206. */
  31207. set computeParticleVertex(val: boolean);
  31208. /**
  31209. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31210. */
  31211. set computeBoundingBox(val: boolean);
  31212. /**
  31213. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31214. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31215. * Default : `true`
  31216. */
  31217. set depthSortParticles(val: boolean);
  31218. /**
  31219. * Gets if `setParticles()` computes the particle rotations or not.
  31220. * Default value : true. The SPS is faster when it's set to false.
  31221. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31222. */
  31223. get computeParticleRotation(): boolean;
  31224. /**
  31225. * Gets if `setParticles()` computes the particle colors or not.
  31226. * Default value : true. The SPS is faster when it's set to false.
  31227. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31228. */
  31229. get computeParticleColor(): boolean;
  31230. /**
  31231. * Gets if `setParticles()` computes the particle textures or not.
  31232. * Default value : true. The SPS is faster when it's set to false.
  31233. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31234. */
  31235. get computeParticleTexture(): boolean;
  31236. /**
  31237. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31238. * Default value : false. The SPS is faster when it's set to false.
  31239. * Note : the particle custom vertex positions aren't stored values.
  31240. */
  31241. get computeParticleVertex(): boolean;
  31242. /**
  31243. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31244. */
  31245. get computeBoundingBox(): boolean;
  31246. /**
  31247. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31248. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31249. * Default : `true`
  31250. */
  31251. get depthSortParticles(): boolean;
  31252. /**
  31253. * Gets if the SPS is created as expandable at construction time.
  31254. * Default : `false`
  31255. */
  31256. get expandable(): boolean;
  31257. /**
  31258. * Gets if the SPS supports the Multi Materials
  31259. */
  31260. get multimaterialEnabled(): boolean;
  31261. /**
  31262. * Gets if the SPS uses the model materials for its own multimaterial.
  31263. */
  31264. get useModelMaterial(): boolean;
  31265. /**
  31266. * The SPS used material array.
  31267. */
  31268. get materials(): Material[];
  31269. /**
  31270. * Sets the SPS MultiMaterial from the passed materials.
  31271. * Note : the passed array is internally copied and not used then by reference.
  31272. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31273. */
  31274. setMultiMaterial(materials: Material[]): void;
  31275. /**
  31276. * The SPS computed multimaterial object
  31277. */
  31278. get multimaterial(): MultiMaterial;
  31279. set multimaterial(mm: MultiMaterial);
  31280. /**
  31281. * If the subMeshes must be updated on the next call to setParticles()
  31282. */
  31283. get autoUpdateSubMeshes(): boolean;
  31284. set autoUpdateSubMeshes(val: boolean);
  31285. /**
  31286. * This function does nothing. It may be overwritten to set all the particle first values.
  31287. * The SPS doesn't call this function, you may have to call it by your own.
  31288. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31289. */
  31290. initParticles(): void;
  31291. /**
  31292. * This function does nothing. It may be overwritten to recycle a particle.
  31293. * The SPS doesn't call this function, you may have to call it by your own.
  31294. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31295. * @param particle The particle to recycle
  31296. * @returns the recycled particle
  31297. */
  31298. recycleParticle(particle: SolidParticle): SolidParticle;
  31299. /**
  31300. * Updates a particle : this function should be overwritten by the user.
  31301. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31302. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31303. * @example : just set a particle position or velocity and recycle conditions
  31304. * @param particle The particle to update
  31305. * @returns the updated particle
  31306. */
  31307. updateParticle(particle: SolidParticle): SolidParticle;
  31308. /**
  31309. * Updates a vertex of a particle : it can be overwritten by the user.
  31310. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31311. * @param particle the current particle
  31312. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31313. * @param pt the index of the current vertex in the particle shape
  31314. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31315. * @example : just set a vertex particle position or color
  31316. * @returns the sps
  31317. */
  31318. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31319. /**
  31320. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31321. * This does nothing and may be overwritten by the user.
  31322. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31323. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31324. * @param update the boolean update value actually passed to setParticles()
  31325. */
  31326. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31327. /**
  31328. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31329. * This will be passed three parameters.
  31330. * This does nothing and may be overwritten by the user.
  31331. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31332. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31333. * @param update the boolean update value actually passed to setParticles()
  31334. */
  31335. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31336. }
  31337. }
  31338. declare module BABYLON {
  31339. /**
  31340. * Represents one particle of a solid particle system.
  31341. */
  31342. export class SolidParticle {
  31343. /**
  31344. * particle global index
  31345. */
  31346. idx: number;
  31347. /**
  31348. * particle identifier
  31349. */
  31350. id: number;
  31351. /**
  31352. * The color of the particle
  31353. */
  31354. color: Nullable<Color4>;
  31355. /**
  31356. * The world space position of the particle.
  31357. */
  31358. position: Vector3;
  31359. /**
  31360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31361. */
  31362. rotation: Vector3;
  31363. /**
  31364. * The world space rotation quaternion of the particle.
  31365. */
  31366. rotationQuaternion: Nullable<Quaternion>;
  31367. /**
  31368. * The scaling of the particle.
  31369. */
  31370. scaling: Vector3;
  31371. /**
  31372. * The uvs of the particle.
  31373. */
  31374. uvs: Vector4;
  31375. /**
  31376. * The current speed of the particle.
  31377. */
  31378. velocity: Vector3;
  31379. /**
  31380. * The pivot point in the particle local space.
  31381. */
  31382. pivot: Vector3;
  31383. /**
  31384. * Must the particle be translated from its pivot point in its local space ?
  31385. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31386. * Default : false
  31387. */
  31388. translateFromPivot: boolean;
  31389. /**
  31390. * Is the particle active or not ?
  31391. */
  31392. alive: boolean;
  31393. /**
  31394. * Is the particle visible or not ?
  31395. */
  31396. isVisible: boolean;
  31397. /**
  31398. * Index of this particle in the global "positions" array (Internal use)
  31399. * @hidden
  31400. */
  31401. _pos: number;
  31402. /**
  31403. * @hidden Index of this particle in the global "indices" array (Internal use)
  31404. */
  31405. _ind: number;
  31406. /**
  31407. * @hidden ModelShape of this particle (Internal use)
  31408. */
  31409. _model: ModelShape;
  31410. /**
  31411. * ModelShape id of this particle
  31412. */
  31413. shapeId: number;
  31414. /**
  31415. * Index of the particle in its shape id
  31416. */
  31417. idxInShape: number;
  31418. /**
  31419. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31420. */
  31421. _modelBoundingInfo: BoundingInfo;
  31422. /**
  31423. * @hidden Particle BoundingInfo object (Internal use)
  31424. */
  31425. _boundingInfo: BoundingInfo;
  31426. /**
  31427. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31428. */
  31429. _sps: SolidParticleSystem;
  31430. /**
  31431. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31432. */
  31433. _stillInvisible: boolean;
  31434. /**
  31435. * @hidden Last computed particle rotation matrix
  31436. */
  31437. _rotationMatrix: number[];
  31438. /**
  31439. * Parent particle Id, if any.
  31440. * Default null.
  31441. */
  31442. parentId: Nullable<number>;
  31443. /**
  31444. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31445. */
  31446. materialIndex: Nullable<number>;
  31447. /**
  31448. * Custom object or properties.
  31449. */
  31450. props: Nullable<any>;
  31451. /**
  31452. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31453. * The possible values are :
  31454. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31455. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31456. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31457. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31458. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31459. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31460. * */
  31461. cullingStrategy: number;
  31462. /**
  31463. * @hidden Internal global position in the SPS.
  31464. */
  31465. _globalPosition: Vector3;
  31466. /**
  31467. * Creates a Solid Particle object.
  31468. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31469. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31470. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31471. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31472. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31473. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31474. * @param shapeId (integer) is the model shape identifier in the SPS.
  31475. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31476. * @param sps defines the sps it is associated to
  31477. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31478. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31479. */
  31480. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31481. /**
  31482. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31483. * @param target the particle target
  31484. * @returns the current particle
  31485. */
  31486. copyToRef(target: SolidParticle): SolidParticle;
  31487. /**
  31488. * Legacy support, changed scale to scaling
  31489. */
  31490. get scale(): Vector3;
  31491. /**
  31492. * Legacy support, changed scale to scaling
  31493. */
  31494. set scale(scale: Vector3);
  31495. /**
  31496. * Legacy support, changed quaternion to rotationQuaternion
  31497. */
  31498. get quaternion(): Nullable<Quaternion>;
  31499. /**
  31500. * Legacy support, changed quaternion to rotationQuaternion
  31501. */
  31502. set quaternion(q: Nullable<Quaternion>);
  31503. /**
  31504. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31505. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31506. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31507. * @returns true if it intersects
  31508. */
  31509. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31510. /**
  31511. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31512. * A particle is in the frustum if its bounding box intersects the frustum
  31513. * @param frustumPlanes defines the frustum to test
  31514. * @returns true if the particle is in the frustum planes
  31515. */
  31516. isInFrustum(frustumPlanes: Plane[]): boolean;
  31517. /**
  31518. * get the rotation matrix of the particle
  31519. * @hidden
  31520. */
  31521. getRotationMatrix(m: Matrix): void;
  31522. }
  31523. /**
  31524. * Represents the shape of the model used by one particle of a solid particle system.
  31525. * SPS internal tool, don't use it manually.
  31526. */
  31527. export class ModelShape {
  31528. /**
  31529. * The shape id
  31530. * @hidden
  31531. */
  31532. shapeID: number;
  31533. /**
  31534. * flat array of model positions (internal use)
  31535. * @hidden
  31536. */
  31537. _shape: Vector3[];
  31538. /**
  31539. * flat array of model UVs (internal use)
  31540. * @hidden
  31541. */
  31542. _shapeUV: number[];
  31543. /**
  31544. * color array of the model
  31545. * @hidden
  31546. */
  31547. _shapeColors: number[];
  31548. /**
  31549. * indices array of the model
  31550. * @hidden
  31551. */
  31552. _indices: number[];
  31553. /**
  31554. * normals array of the model
  31555. * @hidden
  31556. */
  31557. _normals: number[];
  31558. /**
  31559. * length of the shape in the model indices array (internal use)
  31560. * @hidden
  31561. */
  31562. _indicesLength: number;
  31563. /**
  31564. * Custom position function (internal use)
  31565. * @hidden
  31566. */
  31567. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31568. /**
  31569. * Custom vertex function (internal use)
  31570. * @hidden
  31571. */
  31572. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31573. /**
  31574. * Model material (internal use)
  31575. * @hidden
  31576. */
  31577. _material: Nullable<Material>;
  31578. /**
  31579. * 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.
  31580. * SPS internal tool, don't use it manually.
  31581. * @hidden
  31582. */
  31583. 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>);
  31584. }
  31585. /**
  31586. * Represents a Depth Sorted Particle in the solid particle system.
  31587. * @hidden
  31588. */
  31589. export class DepthSortedParticle {
  31590. /**
  31591. * Particle index
  31592. */
  31593. idx: number;
  31594. /**
  31595. * Index of the particle in the "indices" array
  31596. */
  31597. ind: number;
  31598. /**
  31599. * Length of the particle shape in the "indices" array
  31600. */
  31601. indicesLength: number;
  31602. /**
  31603. * Squared distance from the particle to the camera
  31604. */
  31605. sqDistance: number;
  31606. /**
  31607. * Material index when used with MultiMaterials
  31608. */
  31609. materialIndex: number;
  31610. /**
  31611. * Creates a new sorted particle
  31612. * @param materialIndex
  31613. */
  31614. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31615. }
  31616. /**
  31617. * Represents a solid particle vertex
  31618. */
  31619. export class SolidParticleVertex {
  31620. /**
  31621. * Vertex position
  31622. */
  31623. position: Vector3;
  31624. /**
  31625. * Vertex color
  31626. */
  31627. color: Color4;
  31628. /**
  31629. * Vertex UV
  31630. */
  31631. uv: Vector2;
  31632. /**
  31633. * Creates a new solid particle vertex
  31634. */
  31635. constructor();
  31636. /** Vertex x coordinate */
  31637. get x(): number;
  31638. set x(val: number);
  31639. /** Vertex y coordinate */
  31640. get y(): number;
  31641. set y(val: number);
  31642. /** Vertex z coordinate */
  31643. get z(): number;
  31644. set z(val: number);
  31645. }
  31646. }
  31647. declare module BABYLON {
  31648. /**
  31649. * @hidden
  31650. */
  31651. export class _MeshCollisionData {
  31652. _checkCollisions: boolean;
  31653. _collisionMask: number;
  31654. _collisionGroup: number;
  31655. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31656. _collider: Nullable<Collider>;
  31657. _oldPositionForCollisions: Vector3;
  31658. _diffPositionForCollisions: Vector3;
  31659. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31660. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31661. }
  31662. }
  31663. declare module BABYLON {
  31664. /** @hidden */
  31665. class _FacetDataStorage {
  31666. facetPositions: Vector3[];
  31667. facetNormals: Vector3[];
  31668. facetPartitioning: number[][];
  31669. facetNb: number;
  31670. partitioningSubdivisions: number;
  31671. partitioningBBoxRatio: number;
  31672. facetDataEnabled: boolean;
  31673. facetParameters: any;
  31674. bbSize: Vector3;
  31675. subDiv: {
  31676. max: number;
  31677. X: number;
  31678. Y: number;
  31679. Z: number;
  31680. };
  31681. facetDepthSort: boolean;
  31682. facetDepthSortEnabled: boolean;
  31683. depthSortedIndices: IndicesArray;
  31684. depthSortedFacets: {
  31685. ind: number;
  31686. sqDistance: number;
  31687. }[];
  31688. facetDepthSortFunction: (f1: {
  31689. ind: number;
  31690. sqDistance: number;
  31691. }, f2: {
  31692. ind: number;
  31693. sqDistance: number;
  31694. }) => number;
  31695. facetDepthSortFrom: Vector3;
  31696. facetDepthSortOrigin: Vector3;
  31697. invertedMatrix: Matrix;
  31698. }
  31699. /**
  31700. * @hidden
  31701. **/
  31702. class _InternalAbstractMeshDataInfo {
  31703. _hasVertexAlpha: boolean;
  31704. _useVertexColors: boolean;
  31705. _numBoneInfluencers: number;
  31706. _applyFog: boolean;
  31707. _receiveShadows: boolean;
  31708. _facetData: _FacetDataStorage;
  31709. _visibility: number;
  31710. _skeleton: Nullable<Skeleton>;
  31711. _layerMask: number;
  31712. _computeBonesUsingShaders: boolean;
  31713. _isActive: boolean;
  31714. _onlyForInstances: boolean;
  31715. _isActiveIntermediate: boolean;
  31716. _onlyForInstancesIntermediate: boolean;
  31717. _actAsRegularMesh: boolean;
  31718. }
  31719. /**
  31720. * Class used to store all common mesh properties
  31721. */
  31722. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31723. /** No occlusion */
  31724. static OCCLUSION_TYPE_NONE: number;
  31725. /** Occlusion set to optimisitic */
  31726. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31727. /** Occlusion set to strict */
  31728. static OCCLUSION_TYPE_STRICT: number;
  31729. /** Use an accurante occlusion algorithm */
  31730. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31731. /** Use a conservative occlusion algorithm */
  31732. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31733. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31734. * Test order :
  31735. * Is the bounding sphere outside the frustum ?
  31736. * If not, are the bounding box vertices outside the frustum ?
  31737. * It not, then the cullable object is in the frustum.
  31738. */
  31739. static readonly CULLINGSTRATEGY_STANDARD: number;
  31740. /** Culling strategy : Bounding Sphere Only.
  31741. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31742. * It's also less accurate than the standard because some not visible objects can still be selected.
  31743. * Test : is the bounding sphere outside the frustum ?
  31744. * If not, then the cullable object is in the frustum.
  31745. */
  31746. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31747. /** Culling strategy : Optimistic Inclusion.
  31748. * This in an inclusion test first, then the standard exclusion test.
  31749. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31750. * 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.
  31751. * Anyway, it's as accurate as the standard strategy.
  31752. * Test :
  31753. * Is the cullable object bounding sphere center in the frustum ?
  31754. * If not, apply the default culling strategy.
  31755. */
  31756. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31757. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31758. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31759. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31760. * 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.
  31761. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31762. * Test :
  31763. * Is the cullable object bounding sphere center in the frustum ?
  31764. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31765. */
  31766. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31767. /**
  31768. * No billboard
  31769. */
  31770. static get BILLBOARDMODE_NONE(): number;
  31771. /** Billboard on X axis */
  31772. static get BILLBOARDMODE_X(): number;
  31773. /** Billboard on Y axis */
  31774. static get BILLBOARDMODE_Y(): number;
  31775. /** Billboard on Z axis */
  31776. static get BILLBOARDMODE_Z(): number;
  31777. /** Billboard on all axes */
  31778. static get BILLBOARDMODE_ALL(): number;
  31779. /** Billboard on using position instead of orientation */
  31780. static get BILLBOARDMODE_USE_POSITION(): number;
  31781. /** @hidden */
  31782. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31783. /**
  31784. * The culling strategy to use to check whether the mesh must be rendered or not.
  31785. * This value can be changed at any time and will be used on the next render mesh selection.
  31786. * The possible values are :
  31787. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31788. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31789. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31790. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31791. * Please read each static variable documentation to get details about the culling process.
  31792. * */
  31793. cullingStrategy: number;
  31794. /**
  31795. * Gets the number of facets in the mesh
  31796. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31797. */
  31798. get facetNb(): number;
  31799. /**
  31800. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31801. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31802. */
  31803. get partitioningSubdivisions(): number;
  31804. set partitioningSubdivisions(nb: number);
  31805. /**
  31806. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31807. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31808. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31809. */
  31810. get partitioningBBoxRatio(): number;
  31811. set partitioningBBoxRatio(ratio: number);
  31812. /**
  31813. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31814. * Works only for updatable meshes.
  31815. * Doesn't work with multi-materials
  31816. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31817. */
  31818. get mustDepthSortFacets(): boolean;
  31819. set mustDepthSortFacets(sort: boolean);
  31820. /**
  31821. * The location (Vector3) where the facet depth sort must be computed from.
  31822. * By default, the active camera position.
  31823. * Used only when facet depth sort is enabled
  31824. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31825. */
  31826. get facetDepthSortFrom(): Vector3;
  31827. set facetDepthSortFrom(location: Vector3);
  31828. /**
  31829. * gets a boolean indicating if facetData is enabled
  31830. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31831. */
  31832. get isFacetDataEnabled(): boolean;
  31833. /** @hidden */
  31834. _updateNonUniformScalingState(value: boolean): boolean;
  31835. /**
  31836. * An event triggered when this mesh collides with another one
  31837. */
  31838. onCollideObservable: Observable<AbstractMesh>;
  31839. /** Set a function to call when this mesh collides with another one */
  31840. set onCollide(callback: () => void);
  31841. /**
  31842. * An event triggered when the collision's position changes
  31843. */
  31844. onCollisionPositionChangeObservable: Observable<Vector3>;
  31845. /** Set a function to call when the collision's position changes */
  31846. set onCollisionPositionChange(callback: () => void);
  31847. /**
  31848. * An event triggered when material is changed
  31849. */
  31850. onMaterialChangedObservable: Observable<AbstractMesh>;
  31851. /**
  31852. * Gets or sets the orientation for POV movement & rotation
  31853. */
  31854. definedFacingForward: boolean;
  31855. /** @hidden */
  31856. _occlusionQuery: Nullable<WebGLQuery>;
  31857. /** @hidden */
  31858. _renderingGroup: Nullable<RenderingGroup>;
  31859. /**
  31860. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31861. */
  31862. get visibility(): number;
  31863. /**
  31864. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31865. */
  31866. set visibility(value: number);
  31867. /** Gets or sets the alpha index used to sort transparent meshes
  31868. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31869. */
  31870. alphaIndex: number;
  31871. /**
  31872. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31873. */
  31874. isVisible: boolean;
  31875. /**
  31876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31877. */
  31878. isPickable: boolean;
  31879. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31880. showSubMeshesBoundingBox: boolean;
  31881. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31882. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31883. */
  31884. isBlocker: boolean;
  31885. /**
  31886. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31887. */
  31888. enablePointerMoveEvents: boolean;
  31889. /**
  31890. * Specifies the rendering group id for this mesh (0 by default)
  31891. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31892. */
  31893. renderingGroupId: number;
  31894. private _material;
  31895. /** Gets or sets current material */
  31896. get material(): Nullable<Material>;
  31897. set material(value: Nullable<Material>);
  31898. /**
  31899. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31900. * @see https://doc.babylonjs.com/babylon101/shadows
  31901. */
  31902. get receiveShadows(): boolean;
  31903. set receiveShadows(value: boolean);
  31904. /** Defines color to use when rendering outline */
  31905. outlineColor: Color3;
  31906. /** Define width to use when rendering outline */
  31907. outlineWidth: number;
  31908. /** Defines color to use when rendering overlay */
  31909. overlayColor: Color3;
  31910. /** Defines alpha to use when rendering overlay */
  31911. overlayAlpha: number;
  31912. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31913. get hasVertexAlpha(): boolean;
  31914. set hasVertexAlpha(value: boolean);
  31915. /** 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) */
  31916. get useVertexColors(): boolean;
  31917. set useVertexColors(value: boolean);
  31918. /**
  31919. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31920. */
  31921. get computeBonesUsingShaders(): boolean;
  31922. set computeBonesUsingShaders(value: boolean);
  31923. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31924. get numBoneInfluencers(): number;
  31925. set numBoneInfluencers(value: number);
  31926. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31927. get applyFog(): boolean;
  31928. set applyFog(value: boolean);
  31929. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31930. useOctreeForRenderingSelection: boolean;
  31931. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31932. useOctreeForPicking: boolean;
  31933. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31934. useOctreeForCollisions: boolean;
  31935. /**
  31936. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31937. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31938. */
  31939. get layerMask(): number;
  31940. set layerMask(value: number);
  31941. /**
  31942. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31943. */
  31944. alwaysSelectAsActiveMesh: boolean;
  31945. /**
  31946. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31947. */
  31948. doNotSyncBoundingInfo: boolean;
  31949. /**
  31950. * Gets or sets the current action manager
  31951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31952. */
  31953. actionManager: Nullable<AbstractActionManager>;
  31954. private _meshCollisionData;
  31955. /**
  31956. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31957. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31958. */
  31959. ellipsoid: Vector3;
  31960. /**
  31961. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31962. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31963. */
  31964. ellipsoidOffset: Vector3;
  31965. /**
  31966. * Gets or sets a collision mask used to mask collisions (default is -1).
  31967. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31968. */
  31969. get collisionMask(): number;
  31970. set collisionMask(mask: number);
  31971. /**
  31972. * Gets or sets the current collision group mask (-1 by default).
  31973. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31974. */
  31975. get collisionGroup(): number;
  31976. set collisionGroup(mask: number);
  31977. /**
  31978. * Gets or sets current surrounding meshes (null by default).
  31979. *
  31980. * By default collision detection is tested against every mesh in the scene.
  31981. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31982. * meshes will be tested for the collision.
  31983. *
  31984. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31985. */
  31986. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31987. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31988. /**
  31989. * Defines edge width used when edgesRenderer is enabled
  31990. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31991. */
  31992. edgesWidth: number;
  31993. /**
  31994. * Defines edge color used when edgesRenderer is enabled
  31995. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31996. */
  31997. edgesColor: Color4;
  31998. /** @hidden */
  31999. _edgesRenderer: Nullable<IEdgesRenderer>;
  32000. /** @hidden */
  32001. _masterMesh: Nullable<AbstractMesh>;
  32002. /** @hidden */
  32003. _boundingInfo: Nullable<BoundingInfo>;
  32004. /** @hidden */
  32005. _renderId: number;
  32006. /**
  32007. * Gets or sets the list of subMeshes
  32008. * @see https://doc.babylonjs.com/how_to/multi_materials
  32009. */
  32010. subMeshes: SubMesh[];
  32011. /** @hidden */
  32012. _intersectionsInProgress: AbstractMesh[];
  32013. /** @hidden */
  32014. _unIndexed: boolean;
  32015. /** @hidden */
  32016. _lightSources: Light[];
  32017. /** Gets the list of lights affecting that mesh */
  32018. get lightSources(): Light[];
  32019. /** @hidden */
  32020. get _positions(): Nullable<Vector3[]>;
  32021. /** @hidden */
  32022. _waitingData: {
  32023. lods: Nullable<any>;
  32024. actions: Nullable<any>;
  32025. freezeWorldMatrix: Nullable<boolean>;
  32026. };
  32027. /** @hidden */
  32028. _bonesTransformMatrices: Nullable<Float32Array>;
  32029. /** @hidden */
  32030. _transformMatrixTexture: Nullable<RawTexture>;
  32031. /**
  32032. * Gets or sets a skeleton to apply skining transformations
  32033. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32034. */
  32035. set skeleton(value: Nullable<Skeleton>);
  32036. get skeleton(): Nullable<Skeleton>;
  32037. /**
  32038. * An event triggered when the mesh is rebuilt.
  32039. */
  32040. onRebuildObservable: Observable<AbstractMesh>;
  32041. /**
  32042. * Creates a new AbstractMesh
  32043. * @param name defines the name of the mesh
  32044. * @param scene defines the hosting scene
  32045. */
  32046. constructor(name: string, scene?: Nullable<Scene>);
  32047. /**
  32048. * Returns the string "AbstractMesh"
  32049. * @returns "AbstractMesh"
  32050. */
  32051. getClassName(): string;
  32052. /**
  32053. * Gets a string representation of the current mesh
  32054. * @param fullDetails defines a boolean indicating if full details must be included
  32055. * @returns a string representation of the current mesh
  32056. */
  32057. toString(fullDetails?: boolean): string;
  32058. /**
  32059. * @hidden
  32060. */
  32061. protected _getEffectiveParent(): Nullable<Node>;
  32062. /** @hidden */
  32063. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32064. /** @hidden */
  32065. _rebuild(): void;
  32066. /** @hidden */
  32067. _resyncLightSources(): void;
  32068. /** @hidden */
  32069. _resyncLightSource(light: Light): void;
  32070. /** @hidden */
  32071. _unBindEffect(): void;
  32072. /** @hidden */
  32073. _removeLightSource(light: Light, dispose: boolean): void;
  32074. private _markSubMeshesAsDirty;
  32075. /** @hidden */
  32076. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32077. /** @hidden */
  32078. _markSubMeshesAsAttributesDirty(): void;
  32079. /** @hidden */
  32080. _markSubMeshesAsMiscDirty(): void;
  32081. /**
  32082. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32083. */
  32084. get scaling(): Vector3;
  32085. set scaling(newScaling: Vector3);
  32086. /**
  32087. * Returns true if the mesh is blocked. Implemented by child classes
  32088. */
  32089. get isBlocked(): boolean;
  32090. /**
  32091. * Returns the mesh itself by default. Implemented by child classes
  32092. * @param camera defines the camera to use to pick the right LOD level
  32093. * @returns the currentAbstractMesh
  32094. */
  32095. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32096. /**
  32097. * Returns 0 by default. Implemented by child classes
  32098. * @returns an integer
  32099. */
  32100. getTotalVertices(): number;
  32101. /**
  32102. * Returns a positive integer : the total number of indices in this mesh geometry.
  32103. * @returns the numner of indices or zero if the mesh has no geometry.
  32104. */
  32105. getTotalIndices(): number;
  32106. /**
  32107. * Returns null by default. Implemented by child classes
  32108. * @returns null
  32109. */
  32110. getIndices(): Nullable<IndicesArray>;
  32111. /**
  32112. * Returns the array of the requested vertex data kind. Implemented by child classes
  32113. * @param kind defines the vertex data kind to use
  32114. * @returns null
  32115. */
  32116. getVerticesData(kind: string): Nullable<FloatArray>;
  32117. /**
  32118. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32119. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32120. * Note that a new underlying VertexBuffer object is created each call.
  32121. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32122. * @param kind defines vertex data kind:
  32123. * * VertexBuffer.PositionKind
  32124. * * VertexBuffer.UVKind
  32125. * * VertexBuffer.UV2Kind
  32126. * * VertexBuffer.UV3Kind
  32127. * * VertexBuffer.UV4Kind
  32128. * * VertexBuffer.UV5Kind
  32129. * * VertexBuffer.UV6Kind
  32130. * * VertexBuffer.ColorKind
  32131. * * VertexBuffer.MatricesIndicesKind
  32132. * * VertexBuffer.MatricesIndicesExtraKind
  32133. * * VertexBuffer.MatricesWeightsKind
  32134. * * VertexBuffer.MatricesWeightsExtraKind
  32135. * @param data defines the data source
  32136. * @param updatable defines if the data must be flagged as updatable (or static)
  32137. * @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
  32138. * @returns the current mesh
  32139. */
  32140. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32141. /**
  32142. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32143. * If the mesh has no geometry, it is simply returned as it is.
  32144. * @param kind defines vertex data kind:
  32145. * * VertexBuffer.PositionKind
  32146. * * VertexBuffer.UVKind
  32147. * * VertexBuffer.UV2Kind
  32148. * * VertexBuffer.UV3Kind
  32149. * * VertexBuffer.UV4Kind
  32150. * * VertexBuffer.UV5Kind
  32151. * * VertexBuffer.UV6Kind
  32152. * * VertexBuffer.ColorKind
  32153. * * VertexBuffer.MatricesIndicesKind
  32154. * * VertexBuffer.MatricesIndicesExtraKind
  32155. * * VertexBuffer.MatricesWeightsKind
  32156. * * VertexBuffer.MatricesWeightsExtraKind
  32157. * @param data defines the data source
  32158. * @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
  32159. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32160. * @returns the current mesh
  32161. */
  32162. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32163. /**
  32164. * Sets the mesh indices,
  32165. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32166. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32167. * @param totalVertices Defines the total number of vertices
  32168. * @returns the current mesh
  32169. */
  32170. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32171. /**
  32172. * Gets a boolean indicating if specific vertex data is present
  32173. * @param kind defines the vertex data kind to use
  32174. * @returns true is data kind is present
  32175. */
  32176. isVerticesDataPresent(kind: string): boolean;
  32177. /**
  32178. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32179. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32180. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32181. * @returns a BoundingInfo
  32182. */
  32183. getBoundingInfo(): BoundingInfo;
  32184. /**
  32185. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32186. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32187. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32188. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32189. * @returns the current mesh
  32190. */
  32191. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32192. /**
  32193. * Overwrite the current bounding info
  32194. * @param boundingInfo defines the new bounding info
  32195. * @returns the current mesh
  32196. */
  32197. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32198. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32199. get useBones(): boolean;
  32200. /** @hidden */
  32201. _preActivate(): void;
  32202. /** @hidden */
  32203. _preActivateForIntermediateRendering(renderId: number): void;
  32204. /** @hidden */
  32205. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32206. /** @hidden */
  32207. _postActivate(): void;
  32208. /** @hidden */
  32209. _freeze(): void;
  32210. /** @hidden */
  32211. _unFreeze(): void;
  32212. /**
  32213. * Gets the current world matrix
  32214. * @returns a Matrix
  32215. */
  32216. getWorldMatrix(): Matrix;
  32217. /** @hidden */
  32218. _getWorldMatrixDeterminant(): number;
  32219. /**
  32220. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32221. */
  32222. get isAnInstance(): boolean;
  32223. /**
  32224. * Gets a boolean indicating if this mesh has instances
  32225. */
  32226. get hasInstances(): boolean;
  32227. /**
  32228. * Gets a boolean indicating if this mesh has thin instances
  32229. */
  32230. get hasThinInstances(): boolean;
  32231. /**
  32232. * Perform relative position change from the point of view of behind the front of the mesh.
  32233. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32234. * Supports definition of mesh facing forward or backward
  32235. * @param amountRight defines the distance on the right axis
  32236. * @param amountUp defines the distance on the up axis
  32237. * @param amountForward defines the distance on the forward axis
  32238. * @returns the current mesh
  32239. */
  32240. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32241. /**
  32242. * Calculate relative position change from the point of view of behind the front of the mesh.
  32243. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32244. * Supports definition of mesh facing forward or backward
  32245. * @param amountRight defines the distance on the right axis
  32246. * @param amountUp defines the distance on the up axis
  32247. * @param amountForward defines the distance on the forward axis
  32248. * @returns the new displacement vector
  32249. */
  32250. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32251. /**
  32252. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32253. * Supports definition of mesh facing forward or backward
  32254. * @param flipBack defines the flip
  32255. * @param twirlClockwise defines the twirl
  32256. * @param tiltRight defines the tilt
  32257. * @returns the current mesh
  32258. */
  32259. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32260. /**
  32261. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32262. * Supports definition of mesh facing forward or backward.
  32263. * @param flipBack defines the flip
  32264. * @param twirlClockwise defines the twirl
  32265. * @param tiltRight defines the tilt
  32266. * @returns the new rotation vector
  32267. */
  32268. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32269. /**
  32270. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32271. * This means the mesh underlying bounding box and sphere are recomputed.
  32272. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32273. * @returns the current mesh
  32274. */
  32275. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32276. /** @hidden */
  32277. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32278. /** @hidden */
  32279. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32280. /** @hidden */
  32281. _updateBoundingInfo(): AbstractMesh;
  32282. /** @hidden */
  32283. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32284. /** @hidden */
  32285. protected _afterComputeWorldMatrix(): void;
  32286. /** @hidden */
  32287. get _effectiveMesh(): AbstractMesh;
  32288. /**
  32289. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32290. * A mesh is in the frustum if its bounding box intersects the frustum
  32291. * @param frustumPlanes defines the frustum to test
  32292. * @returns true if the mesh is in the frustum planes
  32293. */
  32294. isInFrustum(frustumPlanes: Plane[]): boolean;
  32295. /**
  32296. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32297. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32298. * @param frustumPlanes defines the frustum to test
  32299. * @returns true if the mesh is completely in the frustum planes
  32300. */
  32301. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32302. /**
  32303. * True if the mesh intersects another mesh or a SolidParticle object
  32304. * @param mesh defines a target mesh or SolidParticle to test
  32305. * @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)
  32306. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32307. * @returns true if there is an intersection
  32308. */
  32309. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32310. /**
  32311. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32312. * @param point defines the point to test
  32313. * @returns true if there is an intersection
  32314. */
  32315. intersectsPoint(point: Vector3): boolean;
  32316. /**
  32317. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32318. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32319. */
  32320. get checkCollisions(): boolean;
  32321. set checkCollisions(collisionEnabled: boolean);
  32322. /**
  32323. * Gets Collider object used to compute collisions (not physics)
  32324. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32325. */
  32326. get collider(): Nullable<Collider>;
  32327. /**
  32328. * Move the mesh using collision engine
  32329. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32330. * @param displacement defines the requested displacement vector
  32331. * @returns the current mesh
  32332. */
  32333. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32334. private _onCollisionPositionChange;
  32335. /** @hidden */
  32336. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32337. /** @hidden */
  32338. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32339. /** @hidden */
  32340. _checkCollision(collider: Collider): AbstractMesh;
  32341. /** @hidden */
  32342. _generatePointsArray(): boolean;
  32343. /**
  32344. * Checks if the passed Ray intersects with the mesh
  32345. * @param ray defines the ray to use
  32346. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32347. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32348. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32349. * @returns the picking info
  32350. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32351. */
  32352. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32353. /**
  32354. * Clones the current mesh
  32355. * @param name defines the mesh name
  32356. * @param newParent defines the new mesh parent
  32357. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32358. * @returns the new mesh
  32359. */
  32360. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32361. /**
  32362. * Disposes all the submeshes of the current meshnp
  32363. * @returns the current mesh
  32364. */
  32365. releaseSubMeshes(): AbstractMesh;
  32366. /**
  32367. * Releases resources associated with this abstract mesh.
  32368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32370. */
  32371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32372. /**
  32373. * Adds the passed mesh as a child to the current mesh
  32374. * @param mesh defines the child mesh
  32375. * @returns the current mesh
  32376. */
  32377. addChild(mesh: AbstractMesh): AbstractMesh;
  32378. /**
  32379. * Removes the passed mesh from the current mesh children list
  32380. * @param mesh defines the child mesh
  32381. * @returns the current mesh
  32382. */
  32383. removeChild(mesh: AbstractMesh): AbstractMesh;
  32384. /** @hidden */
  32385. private _initFacetData;
  32386. /**
  32387. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32388. * This method can be called within the render loop.
  32389. * 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
  32390. * @returns the current mesh
  32391. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32392. */
  32393. updateFacetData(): AbstractMesh;
  32394. /**
  32395. * Returns the facetLocalNormals array.
  32396. * The normals are expressed in the mesh local spac
  32397. * @returns an array of Vector3
  32398. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32399. */
  32400. getFacetLocalNormals(): Vector3[];
  32401. /**
  32402. * Returns the facetLocalPositions array.
  32403. * The facet positions are expressed in the mesh local space
  32404. * @returns an array of Vector3
  32405. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32406. */
  32407. getFacetLocalPositions(): Vector3[];
  32408. /**
  32409. * Returns the facetLocalPartioning array
  32410. * @returns an array of array of numbers
  32411. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32412. */
  32413. getFacetLocalPartitioning(): number[][];
  32414. /**
  32415. * Returns the i-th facet position in the world system.
  32416. * This method allocates a new Vector3 per call
  32417. * @param i defines the facet index
  32418. * @returns a new Vector3
  32419. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32420. */
  32421. getFacetPosition(i: number): Vector3;
  32422. /**
  32423. * Sets the reference Vector3 with the i-th facet position in the world system
  32424. * @param i defines the facet index
  32425. * @param ref defines the target vector
  32426. * @returns the current mesh
  32427. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32428. */
  32429. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32430. /**
  32431. * Returns the i-th facet normal in the world system.
  32432. * This method allocates a new Vector3 per call
  32433. * @param i defines the facet index
  32434. * @returns a new Vector3
  32435. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32436. */
  32437. getFacetNormal(i: number): Vector3;
  32438. /**
  32439. * Sets the reference Vector3 with the i-th facet normal in the world system
  32440. * @param i defines the facet index
  32441. * @param ref defines the target vector
  32442. * @returns the current mesh
  32443. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32444. */
  32445. getFacetNormalToRef(i: number, ref: Vector3): this;
  32446. /**
  32447. * 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)
  32448. * @param x defines x coordinate
  32449. * @param y defines y coordinate
  32450. * @param z defines z coordinate
  32451. * @returns the array of facet indexes
  32452. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32453. */
  32454. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32455. /**
  32456. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32457. * @param projected sets as the (x,y,z) world projection on the facet
  32458. * @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
  32459. * @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
  32460. * @param x defines x coordinate
  32461. * @param y defines y coordinate
  32462. * @param z defines z coordinate
  32463. * @returns the face index if found (or null instead)
  32464. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32465. */
  32466. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32467. /**
  32468. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32469. * @param projected sets as the (x,y,z) local projection on the facet
  32470. * @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
  32471. * @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
  32472. * @param x defines x coordinate
  32473. * @param y defines y coordinate
  32474. * @param z defines z coordinate
  32475. * @returns the face index if found (or null instead)
  32476. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32477. */
  32478. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32479. /**
  32480. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32481. * @returns the parameters
  32482. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32483. */
  32484. getFacetDataParameters(): any;
  32485. /**
  32486. * Disables the feature FacetData and frees the related memory
  32487. * @returns the current mesh
  32488. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32489. */
  32490. disableFacetData(): AbstractMesh;
  32491. /**
  32492. * Updates the AbstractMesh indices array
  32493. * @param indices defines the data source
  32494. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32495. * @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)
  32496. * @returns the current mesh
  32497. */
  32498. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32499. /**
  32500. * Creates new normals data for the mesh
  32501. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32502. * @returns the current mesh
  32503. */
  32504. createNormals(updatable: boolean): AbstractMesh;
  32505. /**
  32506. * Align the mesh with a normal
  32507. * @param normal defines the normal to use
  32508. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32509. * @returns the current mesh
  32510. */
  32511. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32512. /** @hidden */
  32513. _checkOcclusionQuery(): boolean;
  32514. /**
  32515. * Disables the mesh edge rendering mode
  32516. * @returns the currentAbstractMesh
  32517. */
  32518. disableEdgesRendering(): AbstractMesh;
  32519. /**
  32520. * Enables the edge rendering mode on the mesh.
  32521. * This mode makes the mesh edges visible
  32522. * @param epsilon defines the maximal distance between two angles to detect a face
  32523. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32524. * @returns the currentAbstractMesh
  32525. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32526. */
  32527. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32528. /**
  32529. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32530. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32531. */
  32532. getConnectedParticleSystems(): IParticleSystem[];
  32533. }
  32534. }
  32535. declare module BABYLON {
  32536. /**
  32537. * Interface used to define ActionEvent
  32538. */
  32539. export interface IActionEvent {
  32540. /** The mesh or sprite that triggered the action */
  32541. source: any;
  32542. /** The X mouse cursor position at the time of the event */
  32543. pointerX: number;
  32544. /** The Y mouse cursor position at the time of the event */
  32545. pointerY: number;
  32546. /** The mesh that is currently pointed at (can be null) */
  32547. meshUnderPointer: Nullable<AbstractMesh>;
  32548. /** the original (browser) event that triggered the ActionEvent */
  32549. sourceEvent?: any;
  32550. /** additional data for the event */
  32551. additionalData?: any;
  32552. }
  32553. /**
  32554. * ActionEvent is the event being sent when an action is triggered.
  32555. */
  32556. export class ActionEvent implements IActionEvent {
  32557. /** The mesh or sprite that triggered the action */
  32558. source: any;
  32559. /** The X mouse cursor position at the time of the event */
  32560. pointerX: number;
  32561. /** The Y mouse cursor position at the time of the event */
  32562. pointerY: number;
  32563. /** The mesh that is currently pointed at (can be null) */
  32564. meshUnderPointer: Nullable<AbstractMesh>;
  32565. /** the original (browser) event that triggered the ActionEvent */
  32566. sourceEvent?: any;
  32567. /** additional data for the event */
  32568. additionalData?: any;
  32569. /**
  32570. * Creates a new ActionEvent
  32571. * @param source The mesh or sprite that triggered the action
  32572. * @param pointerX The X mouse cursor position at the time of the event
  32573. * @param pointerY The Y mouse cursor position at the time of the event
  32574. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32575. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32576. * @param additionalData additional data for the event
  32577. */
  32578. constructor(
  32579. /** The mesh or sprite that triggered the action */
  32580. source: any,
  32581. /** The X mouse cursor position at the time of the event */
  32582. pointerX: number,
  32583. /** The Y mouse cursor position at the time of the event */
  32584. pointerY: number,
  32585. /** The mesh that is currently pointed at (can be null) */
  32586. meshUnderPointer: Nullable<AbstractMesh>,
  32587. /** the original (browser) event that triggered the ActionEvent */
  32588. sourceEvent?: any,
  32589. /** additional data for the event */
  32590. additionalData?: any);
  32591. /**
  32592. * Helper function to auto-create an ActionEvent from a source mesh.
  32593. * @param source The source mesh that triggered the event
  32594. * @param evt The original (browser) event
  32595. * @param additionalData additional data for the event
  32596. * @returns the new ActionEvent
  32597. */
  32598. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32599. /**
  32600. * Helper function to auto-create an ActionEvent from a source sprite
  32601. * @param source The source sprite that triggered the event
  32602. * @param scene Scene associated with the sprite
  32603. * @param evt The original (browser) event
  32604. * @param additionalData additional data for the event
  32605. * @returns the new ActionEvent
  32606. */
  32607. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32608. /**
  32609. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32610. * @param scene the scene where the event occurred
  32611. * @param evt The original (browser) event
  32612. * @returns the new ActionEvent
  32613. */
  32614. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32615. /**
  32616. * Helper function to auto-create an ActionEvent from a primitive
  32617. * @param prim defines the target primitive
  32618. * @param pointerPos defines the pointer position
  32619. * @param evt The original (browser) event
  32620. * @param additionalData additional data for the event
  32621. * @returns the new ActionEvent
  32622. */
  32623. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32624. }
  32625. }
  32626. declare module BABYLON {
  32627. /**
  32628. * Abstract class used to decouple action Manager from scene and meshes.
  32629. * Do not instantiate.
  32630. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32631. */
  32632. export abstract class AbstractActionManager implements IDisposable {
  32633. /** Gets the list of active triggers */
  32634. static Triggers: {
  32635. [key: string]: number;
  32636. };
  32637. /** Gets the cursor to use when hovering items */
  32638. hoverCursor: string;
  32639. /** Gets the list of actions */
  32640. actions: IAction[];
  32641. /**
  32642. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32643. */
  32644. isRecursive: boolean;
  32645. /**
  32646. * Releases all associated resources
  32647. */
  32648. abstract dispose(): void;
  32649. /**
  32650. * Does this action manager has pointer triggers
  32651. */
  32652. abstract get hasPointerTriggers(): boolean;
  32653. /**
  32654. * Does this action manager has pick triggers
  32655. */
  32656. abstract get hasPickTriggers(): boolean;
  32657. /**
  32658. * Process a specific trigger
  32659. * @param trigger defines the trigger to process
  32660. * @param evt defines the event details to be processed
  32661. */
  32662. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32663. /**
  32664. * Does this action manager handles actions of any of the given triggers
  32665. * @param triggers defines the triggers to be tested
  32666. * @return a boolean indicating whether one (or more) of the triggers is handled
  32667. */
  32668. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32669. /**
  32670. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32671. * speed.
  32672. * @param triggerA defines the trigger to be tested
  32673. * @param triggerB defines the trigger to be tested
  32674. * @return a boolean indicating whether one (or more) of the triggers is handled
  32675. */
  32676. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32677. /**
  32678. * Does this action manager handles actions of a given trigger
  32679. * @param trigger defines the trigger to be tested
  32680. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32681. * @return whether the trigger is handled
  32682. */
  32683. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32684. /**
  32685. * Serialize this manager to a JSON object
  32686. * @param name defines the property name to store this manager
  32687. * @returns a JSON representation of this manager
  32688. */
  32689. abstract serialize(name: string): any;
  32690. /**
  32691. * Registers an action to this action manager
  32692. * @param action defines the action to be registered
  32693. * @return the action amended (prepared) after registration
  32694. */
  32695. abstract registerAction(action: IAction): Nullable<IAction>;
  32696. /**
  32697. * Unregisters an action to this action manager
  32698. * @param action defines the action to be unregistered
  32699. * @return a boolean indicating whether the action has been unregistered
  32700. */
  32701. abstract unregisterAction(action: IAction): Boolean;
  32702. /**
  32703. * Does exist one action manager with at least one trigger
  32704. **/
  32705. static get HasTriggers(): boolean;
  32706. /**
  32707. * Does exist one action manager with at least one pick trigger
  32708. **/
  32709. static get HasPickTriggers(): boolean;
  32710. /**
  32711. * Does exist one action manager that handles actions of a given trigger
  32712. * @param trigger defines the trigger to be tested
  32713. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32714. **/
  32715. static HasSpecificTrigger(trigger: number): boolean;
  32716. }
  32717. }
  32718. declare module BABYLON {
  32719. /**
  32720. * Defines how a node can be built from a string name.
  32721. */
  32722. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32723. /**
  32724. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32725. */
  32726. export class Node implements IBehaviorAware<Node> {
  32727. /** @hidden */
  32728. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32729. private static _NodeConstructors;
  32730. /**
  32731. * Add a new node constructor
  32732. * @param type defines the type name of the node to construct
  32733. * @param constructorFunc defines the constructor function
  32734. */
  32735. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32736. /**
  32737. * Returns a node constructor based on type name
  32738. * @param type defines the type name
  32739. * @param name defines the new node name
  32740. * @param scene defines the hosting scene
  32741. * @param options defines optional options to transmit to constructors
  32742. * @returns the new constructor or null
  32743. */
  32744. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32745. /**
  32746. * Gets or sets the name of the node
  32747. */
  32748. name: string;
  32749. /**
  32750. * Gets or sets the id of the node
  32751. */
  32752. id: string;
  32753. /**
  32754. * Gets or sets the unique id of the node
  32755. */
  32756. uniqueId: number;
  32757. /**
  32758. * Gets or sets a string used to store user defined state for the node
  32759. */
  32760. state: string;
  32761. /**
  32762. * Gets or sets an object used to store user defined information for the node
  32763. */
  32764. metadata: any;
  32765. /**
  32766. * For internal use only. Please do not use.
  32767. */
  32768. reservedDataStore: any;
  32769. /**
  32770. * List of inspectable custom properties (used by the Inspector)
  32771. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32772. */
  32773. inspectableCustomProperties: IInspectable[];
  32774. private _doNotSerialize;
  32775. /**
  32776. * Gets or sets a boolean used to define if the node must be serialized
  32777. */
  32778. get doNotSerialize(): boolean;
  32779. set doNotSerialize(value: boolean);
  32780. /** @hidden */
  32781. _isDisposed: boolean;
  32782. /**
  32783. * Gets a list of Animations associated with the node
  32784. */
  32785. animations: Animation[];
  32786. protected _ranges: {
  32787. [name: string]: Nullable<AnimationRange>;
  32788. };
  32789. /**
  32790. * Callback raised when the node is ready to be used
  32791. */
  32792. onReady: Nullable<(node: Node) => void>;
  32793. private _isEnabled;
  32794. private _isParentEnabled;
  32795. private _isReady;
  32796. /** @hidden */
  32797. _currentRenderId: number;
  32798. private _parentUpdateId;
  32799. /** @hidden */
  32800. _childUpdateId: number;
  32801. /** @hidden */
  32802. _waitingParentId: Nullable<string>;
  32803. /** @hidden */
  32804. _scene: Scene;
  32805. /** @hidden */
  32806. _cache: any;
  32807. private _parentNode;
  32808. private _children;
  32809. /** @hidden */
  32810. _worldMatrix: Matrix;
  32811. /** @hidden */
  32812. _worldMatrixDeterminant: number;
  32813. /** @hidden */
  32814. _worldMatrixDeterminantIsDirty: boolean;
  32815. /** @hidden */
  32816. private _sceneRootNodesIndex;
  32817. /**
  32818. * Gets a boolean indicating if the node has been disposed
  32819. * @returns true if the node was disposed
  32820. */
  32821. isDisposed(): boolean;
  32822. /**
  32823. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32824. * @see https://doc.babylonjs.com/how_to/parenting
  32825. */
  32826. set parent(parent: Nullable<Node>);
  32827. get parent(): Nullable<Node>;
  32828. /** @hidden */
  32829. _addToSceneRootNodes(): void;
  32830. /** @hidden */
  32831. _removeFromSceneRootNodes(): void;
  32832. private _animationPropertiesOverride;
  32833. /**
  32834. * Gets or sets the animation properties override
  32835. */
  32836. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32837. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32838. /**
  32839. * Gets a string idenfifying the name of the class
  32840. * @returns "Node" string
  32841. */
  32842. getClassName(): string;
  32843. /** @hidden */
  32844. readonly _isNode: boolean;
  32845. /**
  32846. * An event triggered when the mesh is disposed
  32847. */
  32848. onDisposeObservable: Observable<Node>;
  32849. private _onDisposeObserver;
  32850. /**
  32851. * Sets a callback that will be raised when the node will be disposed
  32852. */
  32853. set onDispose(callback: () => void);
  32854. /**
  32855. * Creates a new Node
  32856. * @param name the name and id to be given to this node
  32857. * @param scene the scene this node will be added to
  32858. */
  32859. constructor(name: string, scene?: Nullable<Scene>);
  32860. /**
  32861. * Gets the scene of the node
  32862. * @returns a scene
  32863. */
  32864. getScene(): Scene;
  32865. /**
  32866. * Gets the engine of the node
  32867. * @returns a Engine
  32868. */
  32869. getEngine(): Engine;
  32870. private _behaviors;
  32871. /**
  32872. * Attach a behavior to the node
  32873. * @see https://doc.babylonjs.com/features/behaviour
  32874. * @param behavior defines the behavior to attach
  32875. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32876. * @returns the current Node
  32877. */
  32878. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32879. /**
  32880. * Remove an attached behavior
  32881. * @see https://doc.babylonjs.com/features/behaviour
  32882. * @param behavior defines the behavior to attach
  32883. * @returns the current Node
  32884. */
  32885. removeBehavior(behavior: Behavior<Node>): Node;
  32886. /**
  32887. * Gets the list of attached behaviors
  32888. * @see https://doc.babylonjs.com/features/behaviour
  32889. */
  32890. get behaviors(): Behavior<Node>[];
  32891. /**
  32892. * Gets an attached behavior by name
  32893. * @param name defines the name of the behavior to look for
  32894. * @see https://doc.babylonjs.com/features/behaviour
  32895. * @returns null if behavior was not found else the requested behavior
  32896. */
  32897. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32898. /**
  32899. * Returns the latest update of the World matrix
  32900. * @returns a Matrix
  32901. */
  32902. getWorldMatrix(): Matrix;
  32903. /** @hidden */
  32904. _getWorldMatrixDeterminant(): number;
  32905. /**
  32906. * Returns directly the latest state of the mesh World matrix.
  32907. * A Matrix is returned.
  32908. */
  32909. get worldMatrixFromCache(): Matrix;
  32910. /** @hidden */
  32911. _initCache(): void;
  32912. /** @hidden */
  32913. updateCache(force?: boolean): void;
  32914. /** @hidden */
  32915. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32916. /** @hidden */
  32917. _updateCache(ignoreParentClass?: boolean): void;
  32918. /** @hidden */
  32919. _isSynchronized(): boolean;
  32920. /** @hidden */
  32921. _markSyncedWithParent(): void;
  32922. /** @hidden */
  32923. isSynchronizedWithParent(): boolean;
  32924. /** @hidden */
  32925. isSynchronized(): boolean;
  32926. /**
  32927. * Is this node ready to be used/rendered
  32928. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32929. * @return true if the node is ready
  32930. */
  32931. isReady(completeCheck?: boolean): boolean;
  32932. /**
  32933. * Is this node enabled?
  32934. * 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
  32935. * @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
  32936. * @return whether this node (and its parent) is enabled
  32937. */
  32938. isEnabled(checkAncestors?: boolean): boolean;
  32939. /** @hidden */
  32940. protected _syncParentEnabledState(): void;
  32941. /**
  32942. * Set the enabled state of this node
  32943. * @param value defines the new enabled state
  32944. */
  32945. setEnabled(value: boolean): void;
  32946. /**
  32947. * Is this node a descendant of the given node?
  32948. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32949. * @param ancestor defines the parent node to inspect
  32950. * @returns a boolean indicating if this node is a descendant of the given node
  32951. */
  32952. isDescendantOf(ancestor: Node): boolean;
  32953. /** @hidden */
  32954. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32955. /**
  32956. * Will return all nodes that have this node as ascendant
  32957. * @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
  32958. * @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
  32959. * @return all children nodes of all types
  32960. */
  32961. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32962. /**
  32963. * Get all child-meshes of this node
  32964. * @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)
  32965. * @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
  32966. * @returns an array of AbstractMesh
  32967. */
  32968. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32969. /**
  32970. * Get all direct children of this node
  32971. * @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
  32972. * @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)
  32973. * @returns an array of Node
  32974. */
  32975. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32976. /** @hidden */
  32977. _setReady(state: boolean): void;
  32978. /**
  32979. * Get an animation by name
  32980. * @param name defines the name of the animation to look for
  32981. * @returns null if not found else the requested animation
  32982. */
  32983. getAnimationByName(name: string): Nullable<Animation>;
  32984. /**
  32985. * Creates an animation range for this node
  32986. * @param name defines the name of the range
  32987. * @param from defines the starting key
  32988. * @param to defines the end key
  32989. */
  32990. createAnimationRange(name: string, from: number, to: number): void;
  32991. /**
  32992. * Delete a specific animation range
  32993. * @param name defines the name of the range to delete
  32994. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32995. */
  32996. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32997. /**
  32998. * Get an animation range by name
  32999. * @param name defines the name of the animation range to look for
  33000. * @returns null if not found else the requested animation range
  33001. */
  33002. getAnimationRange(name: string): Nullable<AnimationRange>;
  33003. /**
  33004. * Gets the list of all animation ranges defined on this node
  33005. * @returns an array
  33006. */
  33007. getAnimationRanges(): Nullable<AnimationRange>[];
  33008. /**
  33009. * Will start the animation sequence
  33010. * @param name defines the range frames for animation sequence
  33011. * @param loop defines if the animation should loop (false by default)
  33012. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33013. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33014. * @returns the object created for this animation. If range does not exist, it will return null
  33015. */
  33016. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33017. /**
  33018. * Serialize animation ranges into a JSON compatible object
  33019. * @returns serialization object
  33020. */
  33021. serializeAnimationRanges(): any;
  33022. /**
  33023. * Computes the world matrix of the node
  33024. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33025. * @returns the world matrix
  33026. */
  33027. computeWorldMatrix(force?: boolean): Matrix;
  33028. /**
  33029. * Releases resources associated with this node.
  33030. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33031. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33032. */
  33033. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33034. /**
  33035. * Parse animation range data from a serialization object and store them into a given node
  33036. * @param node defines where to store the animation ranges
  33037. * @param parsedNode defines the serialization object to read data from
  33038. * @param scene defines the hosting scene
  33039. */
  33040. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33041. /**
  33042. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33043. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33044. * @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
  33045. * @returns the new bounding vectors
  33046. */
  33047. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33048. min: Vector3;
  33049. max: Vector3;
  33050. };
  33051. }
  33052. }
  33053. declare module BABYLON {
  33054. /**
  33055. * @hidden
  33056. */
  33057. export class _IAnimationState {
  33058. key: number;
  33059. repeatCount: number;
  33060. workValue?: any;
  33061. loopMode?: number;
  33062. offsetValue?: any;
  33063. highLimitValue?: any;
  33064. }
  33065. /**
  33066. * Class used to store any kind of animation
  33067. */
  33068. export class Animation {
  33069. /**Name of the animation */
  33070. name: string;
  33071. /**Property to animate */
  33072. targetProperty: string;
  33073. /**The frames per second of the animation */
  33074. framePerSecond: number;
  33075. /**The data type of the animation */
  33076. dataType: number;
  33077. /**The loop mode of the animation */
  33078. loopMode?: number | undefined;
  33079. /**Specifies if blending should be enabled */
  33080. enableBlending?: boolean | undefined;
  33081. /**
  33082. * Use matrix interpolation instead of using direct key value when animating matrices
  33083. */
  33084. static AllowMatricesInterpolation: boolean;
  33085. /**
  33086. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33087. */
  33088. static AllowMatrixDecomposeForInterpolation: boolean;
  33089. /** Define the Url to load snippets */
  33090. static SnippetUrl: string;
  33091. /** Snippet ID if the animation was created from the snippet server */
  33092. snippetId: string;
  33093. /**
  33094. * Stores the key frames of the animation
  33095. */
  33096. private _keys;
  33097. /**
  33098. * Stores the easing function of the animation
  33099. */
  33100. private _easingFunction;
  33101. /**
  33102. * @hidden Internal use only
  33103. */
  33104. _runtimeAnimations: RuntimeAnimation[];
  33105. /**
  33106. * The set of event that will be linked to this animation
  33107. */
  33108. private _events;
  33109. /**
  33110. * Stores an array of target property paths
  33111. */
  33112. targetPropertyPath: string[];
  33113. /**
  33114. * Stores the blending speed of the animation
  33115. */
  33116. blendingSpeed: number;
  33117. /**
  33118. * Stores the animation ranges for the animation
  33119. */
  33120. private _ranges;
  33121. /**
  33122. * @hidden Internal use
  33123. */
  33124. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33125. /**
  33126. * Sets up an animation
  33127. * @param property The property to animate
  33128. * @param animationType The animation type to apply
  33129. * @param framePerSecond The frames per second of the animation
  33130. * @param easingFunction The easing function used in the animation
  33131. * @returns The created animation
  33132. */
  33133. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33134. /**
  33135. * Create and start an animation on a node
  33136. * @param name defines the name of the global animation that will be run on all nodes
  33137. * @param node defines the root node where the animation will take place
  33138. * @param targetProperty defines property to animate
  33139. * @param framePerSecond defines the number of frame per second yo use
  33140. * @param totalFrame defines the number of frames in total
  33141. * @param from defines the initial value
  33142. * @param to defines the final value
  33143. * @param loopMode defines which loop mode you want to use (off by default)
  33144. * @param easingFunction defines the easing function to use (linear by default)
  33145. * @param onAnimationEnd defines the callback to call when animation end
  33146. * @returns the animatable created for this animation
  33147. */
  33148. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33149. /**
  33150. * Create and start an animation on a node and its descendants
  33151. * @param name defines the name of the global animation that will be run on all nodes
  33152. * @param node defines the root node where the animation will take place
  33153. * @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
  33154. * @param targetProperty defines property to animate
  33155. * @param framePerSecond defines the number of frame per second to use
  33156. * @param totalFrame defines the number of frames in total
  33157. * @param from defines the initial value
  33158. * @param to defines the final value
  33159. * @param loopMode defines which loop mode you want to use (off by default)
  33160. * @param easingFunction defines the easing function to use (linear by default)
  33161. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33162. * @returns the list of animatables created for all nodes
  33163. * @example https://www.babylonjs-playground.com/#MH0VLI
  33164. */
  33165. 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[]>;
  33166. /**
  33167. * Creates a new animation, merges it with the existing animations and starts it
  33168. * @param name Name of the animation
  33169. * @param node Node which contains the scene that begins the animations
  33170. * @param targetProperty Specifies which property to animate
  33171. * @param framePerSecond The frames per second of the animation
  33172. * @param totalFrame The total number of frames
  33173. * @param from The frame at the beginning of the animation
  33174. * @param to The frame at the end of the animation
  33175. * @param loopMode Specifies the loop mode of the animation
  33176. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33177. * @param onAnimationEnd Callback to run once the animation is complete
  33178. * @returns Nullable animation
  33179. */
  33180. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33181. /**
  33182. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33183. * @param sourceAnimation defines the Animation containing keyframes to convert
  33184. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33185. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33186. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33187. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33188. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33189. */
  33190. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33191. /**
  33192. * Transition property of an host to the target Value
  33193. * @param property The property to transition
  33194. * @param targetValue The target Value of the property
  33195. * @param host The object where the property to animate belongs
  33196. * @param scene Scene used to run the animation
  33197. * @param frameRate Framerate (in frame/s) to use
  33198. * @param transition The transition type we want to use
  33199. * @param duration The duration of the animation, in milliseconds
  33200. * @param onAnimationEnd Callback trigger at the end of the animation
  33201. * @returns Nullable animation
  33202. */
  33203. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33204. /**
  33205. * Return the array of runtime animations currently using this animation
  33206. */
  33207. get runtimeAnimations(): RuntimeAnimation[];
  33208. /**
  33209. * Specifies if any of the runtime animations are currently running
  33210. */
  33211. get hasRunningRuntimeAnimations(): boolean;
  33212. /**
  33213. * Initializes the animation
  33214. * @param name Name of the animation
  33215. * @param targetProperty Property to animate
  33216. * @param framePerSecond The frames per second of the animation
  33217. * @param dataType The data type of the animation
  33218. * @param loopMode The loop mode of the animation
  33219. * @param enableBlending Specifies if blending should be enabled
  33220. */
  33221. constructor(
  33222. /**Name of the animation */
  33223. name: string,
  33224. /**Property to animate */
  33225. targetProperty: string,
  33226. /**The frames per second of the animation */
  33227. framePerSecond: number,
  33228. /**The data type of the animation */
  33229. dataType: number,
  33230. /**The loop mode of the animation */
  33231. loopMode?: number | undefined,
  33232. /**Specifies if blending should be enabled */
  33233. enableBlending?: boolean | undefined);
  33234. /**
  33235. * Converts the animation to a string
  33236. * @param fullDetails support for multiple levels of logging within scene loading
  33237. * @returns String form of the animation
  33238. */
  33239. toString(fullDetails?: boolean): string;
  33240. /**
  33241. * Add an event to this animation
  33242. * @param event Event to add
  33243. */
  33244. addEvent(event: AnimationEvent): void;
  33245. /**
  33246. * Remove all events found at the given frame
  33247. * @param frame The frame to remove events from
  33248. */
  33249. removeEvents(frame: number): void;
  33250. /**
  33251. * Retrieves all the events from the animation
  33252. * @returns Events from the animation
  33253. */
  33254. getEvents(): AnimationEvent[];
  33255. /**
  33256. * Creates an animation range
  33257. * @param name Name of the animation range
  33258. * @param from Starting frame of the animation range
  33259. * @param to Ending frame of the animation
  33260. */
  33261. createRange(name: string, from: number, to: number): void;
  33262. /**
  33263. * Deletes an animation range by name
  33264. * @param name Name of the animation range to delete
  33265. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33266. */
  33267. deleteRange(name: string, deleteFrames?: boolean): void;
  33268. /**
  33269. * Gets the animation range by name, or null if not defined
  33270. * @param name Name of the animation range
  33271. * @returns Nullable animation range
  33272. */
  33273. getRange(name: string): Nullable<AnimationRange>;
  33274. /**
  33275. * Gets the key frames from the animation
  33276. * @returns The key frames of the animation
  33277. */
  33278. getKeys(): Array<IAnimationKey>;
  33279. /**
  33280. * Gets the highest frame rate of the animation
  33281. * @returns Highest frame rate of the animation
  33282. */
  33283. getHighestFrame(): number;
  33284. /**
  33285. * Gets the easing function of the animation
  33286. * @returns Easing function of the animation
  33287. */
  33288. getEasingFunction(): IEasingFunction;
  33289. /**
  33290. * Sets the easing function of the animation
  33291. * @param easingFunction A custom mathematical formula for animation
  33292. */
  33293. setEasingFunction(easingFunction: EasingFunction): void;
  33294. /**
  33295. * Interpolates a scalar linearly
  33296. * @param startValue Start value of the animation curve
  33297. * @param endValue End value of the animation curve
  33298. * @param gradient Scalar amount to interpolate
  33299. * @returns Interpolated scalar value
  33300. */
  33301. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33302. /**
  33303. * Interpolates a scalar cubically
  33304. * @param startValue Start value of the animation curve
  33305. * @param outTangent End tangent of the animation
  33306. * @param endValue End value of the animation curve
  33307. * @param inTangent Start tangent of the animation curve
  33308. * @param gradient Scalar amount to interpolate
  33309. * @returns Interpolated scalar value
  33310. */
  33311. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33312. /**
  33313. * Interpolates a quaternion using a spherical linear interpolation
  33314. * @param startValue Start value of the animation curve
  33315. * @param endValue End value of the animation curve
  33316. * @param gradient Scalar amount to interpolate
  33317. * @returns Interpolated quaternion value
  33318. */
  33319. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33320. /**
  33321. * Interpolates a quaternion cubically
  33322. * @param startValue Start value of the animation curve
  33323. * @param outTangent End tangent of the animation curve
  33324. * @param endValue End value of the animation curve
  33325. * @param inTangent Start tangent of the animation curve
  33326. * @param gradient Scalar amount to interpolate
  33327. * @returns Interpolated quaternion value
  33328. */
  33329. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33330. /**
  33331. * Interpolates a Vector3 linearl
  33332. * @param startValue Start value of the animation curve
  33333. * @param endValue End value of the animation curve
  33334. * @param gradient Scalar amount to interpolate
  33335. * @returns Interpolated scalar value
  33336. */
  33337. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33338. /**
  33339. * Interpolates a Vector3 cubically
  33340. * @param startValue Start value of the animation curve
  33341. * @param outTangent End tangent of the animation
  33342. * @param endValue End value of the animation curve
  33343. * @param inTangent Start tangent of the animation curve
  33344. * @param gradient Scalar amount to interpolate
  33345. * @returns InterpolatedVector3 value
  33346. */
  33347. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33348. /**
  33349. * Interpolates a Vector2 linearly
  33350. * @param startValue Start value of the animation curve
  33351. * @param endValue End value of the animation curve
  33352. * @param gradient Scalar amount to interpolate
  33353. * @returns Interpolated Vector2 value
  33354. */
  33355. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33356. /**
  33357. * Interpolates a Vector2 cubically
  33358. * @param startValue Start value of the animation curve
  33359. * @param outTangent End tangent of the animation
  33360. * @param endValue End value of the animation curve
  33361. * @param inTangent Start tangent of the animation curve
  33362. * @param gradient Scalar amount to interpolate
  33363. * @returns Interpolated Vector2 value
  33364. */
  33365. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33366. /**
  33367. * Interpolates a size linearly
  33368. * @param startValue Start value of the animation curve
  33369. * @param endValue End value of the animation curve
  33370. * @param gradient Scalar amount to interpolate
  33371. * @returns Interpolated Size value
  33372. */
  33373. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33374. /**
  33375. * Interpolates a Color3 linearly
  33376. * @param startValue Start value of the animation curve
  33377. * @param endValue End value of the animation curve
  33378. * @param gradient Scalar amount to interpolate
  33379. * @returns Interpolated Color3 value
  33380. */
  33381. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33382. /**
  33383. * Interpolates a Color4 linearly
  33384. * @param startValue Start value of the animation curve
  33385. * @param endValue End value of the animation curve
  33386. * @param gradient Scalar amount to interpolate
  33387. * @returns Interpolated Color3 value
  33388. */
  33389. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33390. /**
  33391. * @hidden Internal use only
  33392. */
  33393. _getKeyValue(value: any): any;
  33394. /**
  33395. * @hidden Internal use only
  33396. */
  33397. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33398. /**
  33399. * Defines the function to use to interpolate matrices
  33400. * @param startValue defines the start matrix
  33401. * @param endValue defines the end matrix
  33402. * @param gradient defines the gradient between both matrices
  33403. * @param result defines an optional target matrix where to store the interpolation
  33404. * @returns the interpolated matrix
  33405. */
  33406. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33407. /**
  33408. * Makes a copy of the animation
  33409. * @returns Cloned animation
  33410. */
  33411. clone(): Animation;
  33412. /**
  33413. * Sets the key frames of the animation
  33414. * @param values The animation key frames to set
  33415. */
  33416. setKeys(values: Array<IAnimationKey>): void;
  33417. /**
  33418. * Serializes the animation to an object
  33419. * @returns Serialized object
  33420. */
  33421. serialize(): any;
  33422. /**
  33423. * Float animation type
  33424. */
  33425. static readonly ANIMATIONTYPE_FLOAT: number;
  33426. /**
  33427. * Vector3 animation type
  33428. */
  33429. static readonly ANIMATIONTYPE_VECTOR3: number;
  33430. /**
  33431. * Quaternion animation type
  33432. */
  33433. static readonly ANIMATIONTYPE_QUATERNION: number;
  33434. /**
  33435. * Matrix animation type
  33436. */
  33437. static readonly ANIMATIONTYPE_MATRIX: number;
  33438. /**
  33439. * Color3 animation type
  33440. */
  33441. static readonly ANIMATIONTYPE_COLOR3: number;
  33442. /**
  33443. * Color3 animation type
  33444. */
  33445. static readonly ANIMATIONTYPE_COLOR4: number;
  33446. /**
  33447. * Vector2 animation type
  33448. */
  33449. static readonly ANIMATIONTYPE_VECTOR2: number;
  33450. /**
  33451. * Size animation type
  33452. */
  33453. static readonly ANIMATIONTYPE_SIZE: number;
  33454. /**
  33455. * Relative Loop Mode
  33456. */
  33457. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33458. /**
  33459. * Cycle Loop Mode
  33460. */
  33461. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33462. /**
  33463. * Constant Loop Mode
  33464. */
  33465. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33466. /** @hidden */
  33467. static _UniversalLerp(left: any, right: any, amount: number): any;
  33468. /**
  33469. * Parses an animation object and creates an animation
  33470. * @param parsedAnimation Parsed animation object
  33471. * @returns Animation object
  33472. */
  33473. static Parse(parsedAnimation: any): Animation;
  33474. /**
  33475. * Appends the serialized animations from the source animations
  33476. * @param source Source containing the animations
  33477. * @param destination Target to store the animations
  33478. */
  33479. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33480. /**
  33481. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33482. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33483. * @param url defines the url to load from
  33484. * @returns a promise that will resolve to the new animation or an array of animations
  33485. */
  33486. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33487. /**
  33488. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33489. * @param snippetId defines the snippet to load
  33490. * @returns a promise that will resolve to the new animation or a new array of animations
  33491. */
  33492. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33493. }
  33494. }
  33495. declare module BABYLON {
  33496. /**
  33497. * Interface containing an array of animations
  33498. */
  33499. export interface IAnimatable {
  33500. /**
  33501. * Array of animations
  33502. */
  33503. animations: Nullable<Array<Animation>>;
  33504. }
  33505. }
  33506. declare module BABYLON {
  33507. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33508. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33509. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33510. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33511. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33512. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33513. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33514. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33515. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33516. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33517. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33518. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33519. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33520. /**
  33521. * Decorator used to define property that can be serialized as reference to a camera
  33522. * @param sourceName defines the name of the property to decorate
  33523. */
  33524. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33525. /**
  33526. * Class used to help serialization objects
  33527. */
  33528. export class SerializationHelper {
  33529. /** @hidden */
  33530. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33531. /** @hidden */
  33532. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33533. /** @hidden */
  33534. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33535. /** @hidden */
  33536. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33537. /**
  33538. * Appends the serialized animations from the source animations
  33539. * @param source Source containing the animations
  33540. * @param destination Target to store the animations
  33541. */
  33542. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33543. /**
  33544. * Static function used to serialized a specific entity
  33545. * @param entity defines the entity to serialize
  33546. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33547. * @returns a JSON compatible object representing the serialization of the entity
  33548. */
  33549. static Serialize<T>(entity: T, serializationObject?: any): any;
  33550. /**
  33551. * Creates a new entity from a serialization data object
  33552. * @param creationFunction defines a function used to instanciated the new entity
  33553. * @param source defines the source serialization data
  33554. * @param scene defines the hosting scene
  33555. * @param rootUrl defines the root url for resources
  33556. * @returns a new entity
  33557. */
  33558. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33559. /**
  33560. * Clones an object
  33561. * @param creationFunction defines the function used to instanciate the new object
  33562. * @param source defines the source object
  33563. * @returns the cloned object
  33564. */
  33565. static Clone<T>(creationFunction: () => T, source: T): T;
  33566. /**
  33567. * Instanciates a new object based on a source one (some data will be shared between both object)
  33568. * @param creationFunction defines the function used to instanciate the new object
  33569. * @param source defines the source object
  33570. * @returns the new object
  33571. */
  33572. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33573. }
  33574. }
  33575. declare module BABYLON {
  33576. /**
  33577. * Base class of all the textures in babylon.
  33578. * It groups all the common properties the materials, post process, lights... might need
  33579. * in order to make a correct use of the texture.
  33580. */
  33581. export class BaseTexture implements IAnimatable {
  33582. /**
  33583. * Default anisotropic filtering level for the application.
  33584. * It is set to 4 as a good tradeoff between perf and quality.
  33585. */
  33586. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33587. /**
  33588. * Gets or sets the unique id of the texture
  33589. */
  33590. uniqueId: number;
  33591. /**
  33592. * Define the name of the texture.
  33593. */
  33594. name: string;
  33595. /**
  33596. * Gets or sets an object used to store user defined information.
  33597. */
  33598. metadata: any;
  33599. /**
  33600. * For internal use only. Please do not use.
  33601. */
  33602. reservedDataStore: any;
  33603. private _hasAlpha;
  33604. /**
  33605. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33606. */
  33607. set hasAlpha(value: boolean);
  33608. get hasAlpha(): boolean;
  33609. /**
  33610. * Defines if the alpha value should be determined via the rgb values.
  33611. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33612. */
  33613. getAlphaFromRGB: boolean;
  33614. /**
  33615. * Intensity or strength of the texture.
  33616. * It is commonly used by materials to fine tune the intensity of the texture
  33617. */
  33618. level: number;
  33619. /**
  33620. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33621. * This is part of the texture as textures usually maps to one uv set.
  33622. */
  33623. coordinatesIndex: number;
  33624. private _coordinatesMode;
  33625. /**
  33626. * How a texture is mapped.
  33627. *
  33628. * | Value | Type | Description |
  33629. * | ----- | ----------------------------------- | ----------- |
  33630. * | 0 | EXPLICIT_MODE | |
  33631. * | 1 | SPHERICAL_MODE | |
  33632. * | 2 | PLANAR_MODE | |
  33633. * | 3 | CUBIC_MODE | |
  33634. * | 4 | PROJECTION_MODE | |
  33635. * | 5 | SKYBOX_MODE | |
  33636. * | 6 | INVCUBIC_MODE | |
  33637. * | 7 | EQUIRECTANGULAR_MODE | |
  33638. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33639. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33640. */
  33641. set coordinatesMode(value: number);
  33642. get coordinatesMode(): number;
  33643. /**
  33644. * | Value | Type | Description |
  33645. * | ----- | ------------------ | ----------- |
  33646. * | 0 | CLAMP_ADDRESSMODE | |
  33647. * | 1 | WRAP_ADDRESSMODE | |
  33648. * | 2 | MIRROR_ADDRESSMODE | |
  33649. */
  33650. wrapU: number;
  33651. /**
  33652. * | Value | Type | Description |
  33653. * | ----- | ------------------ | ----------- |
  33654. * | 0 | CLAMP_ADDRESSMODE | |
  33655. * | 1 | WRAP_ADDRESSMODE | |
  33656. * | 2 | MIRROR_ADDRESSMODE | |
  33657. */
  33658. wrapV: number;
  33659. /**
  33660. * | Value | Type | Description |
  33661. * | ----- | ------------------ | ----------- |
  33662. * | 0 | CLAMP_ADDRESSMODE | |
  33663. * | 1 | WRAP_ADDRESSMODE | |
  33664. * | 2 | MIRROR_ADDRESSMODE | |
  33665. */
  33666. wrapR: number;
  33667. /**
  33668. * With compliant hardware and browser (supporting anisotropic filtering)
  33669. * this defines the level of anisotropic filtering in the texture.
  33670. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33671. */
  33672. anisotropicFilteringLevel: number;
  33673. /**
  33674. * Define if the texture is a cube texture or if false a 2d texture.
  33675. */
  33676. get isCube(): boolean;
  33677. set isCube(value: boolean);
  33678. /**
  33679. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33680. */
  33681. get is3D(): boolean;
  33682. set is3D(value: boolean);
  33683. /**
  33684. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33685. */
  33686. get is2DArray(): boolean;
  33687. set is2DArray(value: boolean);
  33688. /**
  33689. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33690. * HDR texture are usually stored in linear space.
  33691. * This only impacts the PBR and Background materials
  33692. */
  33693. gammaSpace: boolean;
  33694. /**
  33695. * Gets or sets whether or not the texture contains RGBD data.
  33696. */
  33697. get isRGBD(): boolean;
  33698. set isRGBD(value: boolean);
  33699. /**
  33700. * Is Z inverted in the texture (useful in a cube texture).
  33701. */
  33702. invertZ: boolean;
  33703. /**
  33704. * Are mip maps generated for this texture or not.
  33705. */
  33706. get noMipmap(): boolean;
  33707. /**
  33708. * @hidden
  33709. */
  33710. lodLevelInAlpha: boolean;
  33711. /**
  33712. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33713. */
  33714. get lodGenerationOffset(): number;
  33715. set lodGenerationOffset(value: number);
  33716. /**
  33717. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33718. */
  33719. get lodGenerationScale(): number;
  33720. set lodGenerationScale(value: number);
  33721. /**
  33722. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33723. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33724. * average roughness values.
  33725. */
  33726. get linearSpecularLOD(): boolean;
  33727. set linearSpecularLOD(value: boolean);
  33728. /**
  33729. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33730. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33731. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33732. */
  33733. get irradianceTexture(): Nullable<BaseTexture>;
  33734. set irradianceTexture(value: Nullable<BaseTexture>);
  33735. /**
  33736. * Define if the texture is a render target.
  33737. */
  33738. isRenderTarget: boolean;
  33739. /**
  33740. * Define the unique id of the texture in the scene.
  33741. */
  33742. get uid(): string;
  33743. /** @hidden */
  33744. _prefiltered: boolean;
  33745. /**
  33746. * Return a string representation of the texture.
  33747. * @returns the texture as a string
  33748. */
  33749. toString(): string;
  33750. /**
  33751. * Get the class name of the texture.
  33752. * @returns "BaseTexture"
  33753. */
  33754. getClassName(): string;
  33755. /**
  33756. * Define the list of animation attached to the texture.
  33757. */
  33758. animations: Animation[];
  33759. /**
  33760. * An event triggered when the texture is disposed.
  33761. */
  33762. onDisposeObservable: Observable<BaseTexture>;
  33763. private _onDisposeObserver;
  33764. /**
  33765. * Callback triggered when the texture has been disposed.
  33766. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33767. */
  33768. set onDispose(callback: () => void);
  33769. /**
  33770. * Define the current state of the loading sequence when in delayed load mode.
  33771. */
  33772. delayLoadState: number;
  33773. private _scene;
  33774. private _engine;
  33775. /** @hidden */
  33776. _texture: Nullable<InternalTexture>;
  33777. private _uid;
  33778. /**
  33779. * Define if the texture is preventinga material to render or not.
  33780. * If not and the texture is not ready, the engine will use a default black texture instead.
  33781. */
  33782. get isBlocking(): boolean;
  33783. /**
  33784. * Instantiates a new BaseTexture.
  33785. * Base class of all the textures in babylon.
  33786. * It groups all the common properties the materials, post process, lights... might need
  33787. * in order to make a correct use of the texture.
  33788. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33789. */
  33790. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33791. /**
  33792. * Get the scene the texture belongs to.
  33793. * @returns the scene or null if undefined
  33794. */
  33795. getScene(): Nullable<Scene>;
  33796. /** @hidden */
  33797. protected _getEngine(): Nullable<ThinEngine>;
  33798. /**
  33799. * Get the texture transform matrix used to offset tile the texture for istance.
  33800. * @returns the transformation matrix
  33801. */
  33802. getTextureMatrix(): Matrix;
  33803. /**
  33804. * Get the texture reflection matrix used to rotate/transform the reflection.
  33805. * @returns the reflection matrix
  33806. */
  33807. getReflectionTextureMatrix(): Matrix;
  33808. /**
  33809. * Get the underlying lower level texture from Babylon.
  33810. * @returns the insternal texture
  33811. */
  33812. getInternalTexture(): Nullable<InternalTexture>;
  33813. /**
  33814. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33815. * @returns true if ready or not blocking
  33816. */
  33817. isReadyOrNotBlocking(): boolean;
  33818. /**
  33819. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33820. * @returns true if fully ready
  33821. */
  33822. isReady(): boolean;
  33823. private _cachedSize;
  33824. /**
  33825. * Get the size of the texture.
  33826. * @returns the texture size.
  33827. */
  33828. getSize(): ISize;
  33829. /**
  33830. * Get the base size of the texture.
  33831. * It can be different from the size if the texture has been resized for POT for instance
  33832. * @returns the base size
  33833. */
  33834. getBaseSize(): ISize;
  33835. /**
  33836. * Update the sampling mode of the texture.
  33837. * Default is Trilinear mode.
  33838. *
  33839. * | Value | Type | Description |
  33840. * | ----- | ------------------ | ----------- |
  33841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33847. * | 7 | NEAREST_LINEAR | |
  33848. * | 8 | NEAREST_NEAREST | |
  33849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33851. * | 11 | LINEAR_LINEAR | |
  33852. * | 12 | LINEAR_NEAREST | |
  33853. *
  33854. * > _mag_: magnification filter (close to the viewer)
  33855. * > _min_: minification filter (far from the viewer)
  33856. * > _mip_: filter used between mip map levels
  33857. *@param samplingMode Define the new sampling mode of the texture
  33858. */
  33859. updateSamplingMode(samplingMode: number): void;
  33860. /**
  33861. * Scales the texture if is `canRescale()`
  33862. * @param ratio the resize factor we want to use to rescale
  33863. */
  33864. scale(ratio: number): void;
  33865. /**
  33866. * Get if the texture can rescale.
  33867. */
  33868. get canRescale(): boolean;
  33869. /** @hidden */
  33870. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33871. /** @hidden */
  33872. _rebuild(): void;
  33873. /**
  33874. * Triggers the load sequence in delayed load mode.
  33875. */
  33876. delayLoad(): void;
  33877. /**
  33878. * Clones the texture.
  33879. * @returns the cloned texture
  33880. */
  33881. clone(): Nullable<BaseTexture>;
  33882. /**
  33883. * Get the texture underlying type (INT, FLOAT...)
  33884. */
  33885. get textureType(): number;
  33886. /**
  33887. * Get the texture underlying format (RGB, RGBA...)
  33888. */
  33889. get textureFormat(): number;
  33890. /**
  33891. * Indicates that textures need to be re-calculated for all materials
  33892. */
  33893. protected _markAllSubMeshesAsTexturesDirty(): void;
  33894. /**
  33895. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33896. * This will returns an RGBA array buffer containing either in values (0-255) or
  33897. * float values (0-1) depending of the underlying buffer type.
  33898. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33899. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33900. * @param buffer defines a user defined buffer to fill with data (can be null)
  33901. * @returns The Array buffer containing the pixels data.
  33902. */
  33903. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33904. /**
  33905. * Release and destroy the underlying lower level texture aka internalTexture.
  33906. */
  33907. releaseInternalTexture(): void;
  33908. /** @hidden */
  33909. get _lodTextureHigh(): Nullable<BaseTexture>;
  33910. /** @hidden */
  33911. get _lodTextureMid(): Nullable<BaseTexture>;
  33912. /** @hidden */
  33913. get _lodTextureLow(): Nullable<BaseTexture>;
  33914. /**
  33915. * Dispose the texture and release its associated resources.
  33916. */
  33917. dispose(): void;
  33918. /**
  33919. * Serialize the texture into a JSON representation that can be parsed later on.
  33920. * @returns the JSON representation of the texture
  33921. */
  33922. serialize(): any;
  33923. /**
  33924. * Helper function to be called back once a list of texture contains only ready textures.
  33925. * @param textures Define the list of textures to wait for
  33926. * @param callback Define the callback triggered once the entire list will be ready
  33927. */
  33928. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33929. private static _isScene;
  33930. }
  33931. }
  33932. declare module BABYLON {
  33933. /**
  33934. * Options to be used when creating an effect.
  33935. */
  33936. export interface IEffectCreationOptions {
  33937. /**
  33938. * Atrributes that will be used in the shader.
  33939. */
  33940. attributes: string[];
  33941. /**
  33942. * Uniform varible names that will be set in the shader.
  33943. */
  33944. uniformsNames: string[];
  33945. /**
  33946. * Uniform buffer variable names that will be set in the shader.
  33947. */
  33948. uniformBuffersNames: string[];
  33949. /**
  33950. * Sampler texture variable names that will be set in the shader.
  33951. */
  33952. samplers: string[];
  33953. /**
  33954. * Define statements that will be set in the shader.
  33955. */
  33956. defines: any;
  33957. /**
  33958. * Possible fallbacks for this effect to improve performance when needed.
  33959. */
  33960. fallbacks: Nullable<IEffectFallbacks>;
  33961. /**
  33962. * Callback that will be called when the shader is compiled.
  33963. */
  33964. onCompiled: Nullable<(effect: Effect) => void>;
  33965. /**
  33966. * Callback that will be called if an error occurs during shader compilation.
  33967. */
  33968. onError: Nullable<(effect: Effect, errors: string) => void>;
  33969. /**
  33970. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33971. */
  33972. indexParameters?: any;
  33973. /**
  33974. * Max number of lights that can be used in the shader.
  33975. */
  33976. maxSimultaneousLights?: number;
  33977. /**
  33978. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33979. */
  33980. transformFeedbackVaryings?: Nullable<string[]>;
  33981. /**
  33982. * 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
  33983. */
  33984. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33985. /**
  33986. * Is this effect rendering to several color attachments ?
  33987. */
  33988. multiTarget?: boolean;
  33989. }
  33990. /**
  33991. * Effect containing vertex and fragment shader that can be executed on an object.
  33992. */
  33993. export class Effect implements IDisposable {
  33994. /**
  33995. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33996. */
  33997. static ShadersRepository: string;
  33998. /**
  33999. * Enable logging of the shader code when a compilation error occurs
  34000. */
  34001. static LogShaderCodeOnCompilationError: boolean;
  34002. /**
  34003. * Name of the effect.
  34004. */
  34005. name: any;
  34006. /**
  34007. * String container all the define statements that should be set on the shader.
  34008. */
  34009. defines: string;
  34010. /**
  34011. * Callback that will be called when the shader is compiled.
  34012. */
  34013. onCompiled: Nullable<(effect: Effect) => void>;
  34014. /**
  34015. * Callback that will be called if an error occurs during shader compilation.
  34016. */
  34017. onError: Nullable<(effect: Effect, errors: string) => void>;
  34018. /**
  34019. * Callback that will be called when effect is bound.
  34020. */
  34021. onBind: Nullable<(effect: Effect) => void>;
  34022. /**
  34023. * Unique ID of the effect.
  34024. */
  34025. uniqueId: number;
  34026. /**
  34027. * Observable that will be called when the shader is compiled.
  34028. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34029. */
  34030. onCompileObservable: Observable<Effect>;
  34031. /**
  34032. * Observable that will be called if an error occurs during shader compilation.
  34033. */
  34034. onErrorObservable: Observable<Effect>;
  34035. /** @hidden */
  34036. _onBindObservable: Nullable<Observable<Effect>>;
  34037. /**
  34038. * @hidden
  34039. * Specifies if the effect was previously ready
  34040. */
  34041. _wasPreviouslyReady: boolean;
  34042. /**
  34043. * Observable that will be called when effect is bound.
  34044. */
  34045. get onBindObservable(): Observable<Effect>;
  34046. /** @hidden */
  34047. _bonesComputationForcedToCPU: boolean;
  34048. /** @hidden */
  34049. _multiTarget: boolean;
  34050. private static _uniqueIdSeed;
  34051. private _engine;
  34052. private _uniformBuffersNames;
  34053. private _uniformBuffersNamesList;
  34054. private _uniformsNames;
  34055. private _samplerList;
  34056. private _samplers;
  34057. private _isReady;
  34058. private _compilationError;
  34059. private _allFallbacksProcessed;
  34060. private _attributesNames;
  34061. private _attributes;
  34062. private _attributeLocationByName;
  34063. private _uniforms;
  34064. /**
  34065. * Key for the effect.
  34066. * @hidden
  34067. */
  34068. _key: string;
  34069. private _indexParameters;
  34070. private _fallbacks;
  34071. private _vertexSourceCode;
  34072. private _fragmentSourceCode;
  34073. private _vertexSourceCodeOverride;
  34074. private _fragmentSourceCodeOverride;
  34075. private _transformFeedbackVaryings;
  34076. /**
  34077. * Compiled shader to webGL program.
  34078. * @hidden
  34079. */
  34080. _pipelineContext: Nullable<IPipelineContext>;
  34081. private _valueCache;
  34082. private static _baseCache;
  34083. /**
  34084. * Instantiates an effect.
  34085. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34086. * @param baseName Name of the effect.
  34087. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34088. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34089. * @param samplers List of sampler variables that will be passed to the shader.
  34090. * @param engine Engine to be used to render the effect
  34091. * @param defines Define statements to be added to the shader.
  34092. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34093. * @param onCompiled Callback that will be called when the shader is compiled.
  34094. * @param onError Callback that will be called if an error occurs during shader compilation.
  34095. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34096. */
  34097. 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);
  34098. private _useFinalCode;
  34099. /**
  34100. * Unique key for this effect
  34101. */
  34102. get key(): string;
  34103. /**
  34104. * If the effect has been compiled and prepared.
  34105. * @returns if the effect is compiled and prepared.
  34106. */
  34107. isReady(): boolean;
  34108. private _isReadyInternal;
  34109. /**
  34110. * The engine the effect was initialized with.
  34111. * @returns the engine.
  34112. */
  34113. getEngine(): Engine;
  34114. /**
  34115. * The pipeline context for this effect
  34116. * @returns the associated pipeline context
  34117. */
  34118. getPipelineContext(): Nullable<IPipelineContext>;
  34119. /**
  34120. * The set of names of attribute variables for the shader.
  34121. * @returns An array of attribute names.
  34122. */
  34123. getAttributesNames(): string[];
  34124. /**
  34125. * Returns the attribute at the given index.
  34126. * @param index The index of the attribute.
  34127. * @returns The location of the attribute.
  34128. */
  34129. getAttributeLocation(index: number): number;
  34130. /**
  34131. * Returns the attribute based on the name of the variable.
  34132. * @param name of the attribute to look up.
  34133. * @returns the attribute location.
  34134. */
  34135. getAttributeLocationByName(name: string): number;
  34136. /**
  34137. * The number of attributes.
  34138. * @returns the numnber of attributes.
  34139. */
  34140. getAttributesCount(): number;
  34141. /**
  34142. * Gets the index of a uniform variable.
  34143. * @param uniformName of the uniform to look up.
  34144. * @returns the index.
  34145. */
  34146. getUniformIndex(uniformName: string): number;
  34147. /**
  34148. * Returns the attribute based on the name of the variable.
  34149. * @param uniformName of the uniform to look up.
  34150. * @returns the location of the uniform.
  34151. */
  34152. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34153. /**
  34154. * Returns an array of sampler variable names
  34155. * @returns The array of sampler variable names.
  34156. */
  34157. getSamplers(): string[];
  34158. /**
  34159. * Returns an array of uniform variable names
  34160. * @returns The array of uniform variable names.
  34161. */
  34162. getUniformNames(): string[];
  34163. /**
  34164. * Returns an array of uniform buffer variable names
  34165. * @returns The array of uniform buffer variable names.
  34166. */
  34167. getUniformBuffersNames(): string[];
  34168. /**
  34169. * Returns the index parameters used to create the effect
  34170. * @returns The index parameters object
  34171. */
  34172. getIndexParameters(): any;
  34173. /**
  34174. * The error from the last compilation.
  34175. * @returns the error string.
  34176. */
  34177. getCompilationError(): string;
  34178. /**
  34179. * Gets a boolean indicating that all fallbacks were used during compilation
  34180. * @returns true if all fallbacks were used
  34181. */
  34182. allFallbacksProcessed(): boolean;
  34183. /**
  34184. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34185. * @param func The callback to be used.
  34186. */
  34187. executeWhenCompiled(func: (effect: Effect) => void): void;
  34188. private _checkIsReady;
  34189. private _loadShader;
  34190. /**
  34191. * Gets the vertex shader source code of this effect
  34192. */
  34193. get vertexSourceCode(): string;
  34194. /**
  34195. * Gets the fragment shader source code of this effect
  34196. */
  34197. get fragmentSourceCode(): string;
  34198. /**
  34199. * Recompiles the webGL program
  34200. * @param vertexSourceCode The source code for the vertex shader.
  34201. * @param fragmentSourceCode The source code for the fragment shader.
  34202. * @param onCompiled Callback called when completed.
  34203. * @param onError Callback called on error.
  34204. * @hidden
  34205. */
  34206. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34207. /**
  34208. * Prepares the effect
  34209. * @hidden
  34210. */
  34211. _prepareEffect(): void;
  34212. private _getShaderCodeAndErrorLine;
  34213. private _processCompilationErrors;
  34214. /**
  34215. * Checks if the effect is supported. (Must be called after compilation)
  34216. */
  34217. get isSupported(): boolean;
  34218. /**
  34219. * Binds a texture to the engine to be used as output of the shader.
  34220. * @param channel Name of the output variable.
  34221. * @param texture Texture to bind.
  34222. * @hidden
  34223. */
  34224. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34225. /**
  34226. * Sets a texture on the engine to be used in the shader.
  34227. * @param channel Name of the sampler variable.
  34228. * @param texture Texture to set.
  34229. */
  34230. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34231. /**
  34232. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34233. * @param channel Name of the sampler variable.
  34234. * @param texture Texture to set.
  34235. */
  34236. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34237. /**
  34238. * Sets an array of textures on the engine to be used in the shader.
  34239. * @param channel Name of the variable.
  34240. * @param textures Textures to set.
  34241. */
  34242. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34243. /**
  34244. * 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)
  34245. * @param channel Name of the sampler variable.
  34246. * @param postProcess Post process to get the input texture from.
  34247. */
  34248. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34249. /**
  34250. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34251. * 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)
  34252. * @param channel Name of the sampler variable.
  34253. * @param postProcess Post process to get the output texture from.
  34254. */
  34255. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34256. /** @hidden */
  34257. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34258. /** @hidden */
  34259. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34260. /** @hidden */
  34261. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34262. /** @hidden */
  34263. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34264. /**
  34265. * Binds a buffer to a uniform.
  34266. * @param buffer Buffer to bind.
  34267. * @param name Name of the uniform variable to bind to.
  34268. */
  34269. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34270. /**
  34271. * Binds block to a uniform.
  34272. * @param blockName Name of the block to bind.
  34273. * @param index Index to bind.
  34274. */
  34275. bindUniformBlock(blockName: string, index: number): void;
  34276. /**
  34277. * Sets an interger value on a uniform variable.
  34278. * @param uniformName Name of the variable.
  34279. * @param value Value to be set.
  34280. * @returns this effect.
  34281. */
  34282. setInt(uniformName: string, value: number): Effect;
  34283. /**
  34284. * Sets an int array on a uniform variable.
  34285. * @param uniformName Name of the variable.
  34286. * @param array array to be set.
  34287. * @returns this effect.
  34288. */
  34289. setIntArray(uniformName: string, array: Int32Array): Effect;
  34290. /**
  34291. * 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)
  34292. * @param uniformName Name of the variable.
  34293. * @param array array to be set.
  34294. * @returns this effect.
  34295. */
  34296. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34297. /**
  34298. * 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)
  34299. * @param uniformName Name of the variable.
  34300. * @param array array to be set.
  34301. * @returns this effect.
  34302. */
  34303. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34304. /**
  34305. * 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)
  34306. * @param uniformName Name of the variable.
  34307. * @param array array to be set.
  34308. * @returns this effect.
  34309. */
  34310. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34311. /**
  34312. * Sets an float array on a uniform variable.
  34313. * @param uniformName Name of the variable.
  34314. * @param array array to be set.
  34315. * @returns this effect.
  34316. */
  34317. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34318. /**
  34319. * 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)
  34320. * @param uniformName Name of the variable.
  34321. * @param array array to be set.
  34322. * @returns this effect.
  34323. */
  34324. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34325. /**
  34326. * 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)
  34327. * @param uniformName Name of the variable.
  34328. * @param array array to be set.
  34329. * @returns this effect.
  34330. */
  34331. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34332. /**
  34333. * 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)
  34334. * @param uniformName Name of the variable.
  34335. * @param array array to be set.
  34336. * @returns this effect.
  34337. */
  34338. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34339. /**
  34340. * Sets an array on a uniform variable.
  34341. * @param uniformName Name of the variable.
  34342. * @param array array to be set.
  34343. * @returns this effect.
  34344. */
  34345. setArray(uniformName: string, array: number[]): Effect;
  34346. /**
  34347. * 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)
  34348. * @param uniformName Name of the variable.
  34349. * @param array array to be set.
  34350. * @returns this effect.
  34351. */
  34352. setArray2(uniformName: string, array: number[]): Effect;
  34353. /**
  34354. * 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)
  34355. * @param uniformName Name of the variable.
  34356. * @param array array to be set.
  34357. * @returns this effect.
  34358. */
  34359. setArray3(uniformName: string, array: number[]): Effect;
  34360. /**
  34361. * 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)
  34362. * @param uniformName Name of the variable.
  34363. * @param array array to be set.
  34364. * @returns this effect.
  34365. */
  34366. setArray4(uniformName: string, array: number[]): Effect;
  34367. /**
  34368. * Sets matrices on a uniform variable.
  34369. * @param uniformName Name of the variable.
  34370. * @param matrices matrices to be set.
  34371. * @returns this effect.
  34372. */
  34373. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34374. /**
  34375. * Sets matrix on a uniform variable.
  34376. * @param uniformName Name of the variable.
  34377. * @param matrix matrix to be set.
  34378. * @returns this effect.
  34379. */
  34380. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34381. /**
  34382. * 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)
  34383. * @param uniformName Name of the variable.
  34384. * @param matrix matrix to be set.
  34385. * @returns this effect.
  34386. */
  34387. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34388. /**
  34389. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34390. * @param uniformName Name of the variable.
  34391. * @param matrix matrix to be set.
  34392. * @returns this effect.
  34393. */
  34394. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34395. /**
  34396. * Sets a float on a uniform variable.
  34397. * @param uniformName Name of the variable.
  34398. * @param value value to be set.
  34399. * @returns this effect.
  34400. */
  34401. setFloat(uniformName: string, value: number): Effect;
  34402. /**
  34403. * Sets a boolean on a uniform variable.
  34404. * @param uniformName Name of the variable.
  34405. * @param bool value to be set.
  34406. * @returns this effect.
  34407. */
  34408. setBool(uniformName: string, bool: boolean): Effect;
  34409. /**
  34410. * Sets a Vector2 on a uniform variable.
  34411. * @param uniformName Name of the variable.
  34412. * @param vector2 vector2 to be set.
  34413. * @returns this effect.
  34414. */
  34415. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34416. /**
  34417. * Sets a float2 on a uniform variable.
  34418. * @param uniformName Name of the variable.
  34419. * @param x First float in float2.
  34420. * @param y Second float in float2.
  34421. * @returns this effect.
  34422. */
  34423. setFloat2(uniformName: string, x: number, y: number): Effect;
  34424. /**
  34425. * Sets a Vector3 on a uniform variable.
  34426. * @param uniformName Name of the variable.
  34427. * @param vector3 Value to be set.
  34428. * @returns this effect.
  34429. */
  34430. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34431. /**
  34432. * Sets a float3 on a uniform variable.
  34433. * @param uniformName Name of the variable.
  34434. * @param x First float in float3.
  34435. * @param y Second float in float3.
  34436. * @param z Third float in float3.
  34437. * @returns this effect.
  34438. */
  34439. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34440. /**
  34441. * Sets a Vector4 on a uniform variable.
  34442. * @param uniformName Name of the variable.
  34443. * @param vector4 Value to be set.
  34444. * @returns this effect.
  34445. */
  34446. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34447. /**
  34448. * Sets a float4 on a uniform variable.
  34449. * @param uniformName Name of the variable.
  34450. * @param x First float in float4.
  34451. * @param y Second float in float4.
  34452. * @param z Third float in float4.
  34453. * @param w Fourth float in float4.
  34454. * @returns this effect.
  34455. */
  34456. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34457. /**
  34458. * Sets a Color3 on a uniform variable.
  34459. * @param uniformName Name of the variable.
  34460. * @param color3 Value to be set.
  34461. * @returns this effect.
  34462. */
  34463. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34464. /**
  34465. * Sets a Color4 on a uniform variable.
  34466. * @param uniformName Name of the variable.
  34467. * @param color3 Value to be set.
  34468. * @param alpha Alpha value to be set.
  34469. * @returns this effect.
  34470. */
  34471. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34472. /**
  34473. * Sets a Color4 on a uniform variable
  34474. * @param uniformName defines the name of the variable
  34475. * @param color4 defines the value to be set
  34476. * @returns this effect.
  34477. */
  34478. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34479. /** Release all associated resources */
  34480. dispose(): void;
  34481. /**
  34482. * This function will add a new shader to the shader store
  34483. * @param name the name of the shader
  34484. * @param pixelShader optional pixel shader content
  34485. * @param vertexShader optional vertex shader content
  34486. */
  34487. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34488. /**
  34489. * Store of each shader (The can be looked up using effect.key)
  34490. */
  34491. static ShadersStore: {
  34492. [key: string]: string;
  34493. };
  34494. /**
  34495. * Store of each included file for a shader (The can be looked up using effect.key)
  34496. */
  34497. static IncludesShadersStore: {
  34498. [key: string]: string;
  34499. };
  34500. /**
  34501. * Resets the cache of effects.
  34502. */
  34503. static ResetCache(): void;
  34504. }
  34505. }
  34506. declare module BABYLON {
  34507. /**
  34508. * Interface used to describe the capabilities of the engine relatively to the current browser
  34509. */
  34510. export interface EngineCapabilities {
  34511. /** Maximum textures units per fragment shader */
  34512. maxTexturesImageUnits: number;
  34513. /** Maximum texture units per vertex shader */
  34514. maxVertexTextureImageUnits: number;
  34515. /** Maximum textures units in the entire pipeline */
  34516. maxCombinedTexturesImageUnits: number;
  34517. /** Maximum texture size */
  34518. maxTextureSize: number;
  34519. /** Maximum texture samples */
  34520. maxSamples?: number;
  34521. /** Maximum cube texture size */
  34522. maxCubemapTextureSize: number;
  34523. /** Maximum render texture size */
  34524. maxRenderTextureSize: number;
  34525. /** Maximum number of vertex attributes */
  34526. maxVertexAttribs: number;
  34527. /** Maximum number of varyings */
  34528. maxVaryingVectors: number;
  34529. /** Maximum number of uniforms per vertex shader */
  34530. maxVertexUniformVectors: number;
  34531. /** Maximum number of uniforms per fragment shader */
  34532. maxFragmentUniformVectors: number;
  34533. /** Defines if standard derivates (dx/dy) are supported */
  34534. standardDerivatives: boolean;
  34535. /** Defines if s3tc texture compression is supported */
  34536. s3tc?: WEBGL_compressed_texture_s3tc;
  34537. /** Defines if pvrtc texture compression is supported */
  34538. pvrtc: any;
  34539. /** Defines if etc1 texture compression is supported */
  34540. etc1: any;
  34541. /** Defines if etc2 texture compression is supported */
  34542. etc2: any;
  34543. /** Defines if astc texture compression is supported */
  34544. astc: any;
  34545. /** Defines if float textures are supported */
  34546. textureFloat: boolean;
  34547. /** Defines if vertex array objects are supported */
  34548. vertexArrayObject: boolean;
  34549. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34550. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34551. /** Gets the maximum level of anisotropy supported */
  34552. maxAnisotropy: number;
  34553. /** Defines if instancing is supported */
  34554. instancedArrays: boolean;
  34555. /** Defines if 32 bits indices are supported */
  34556. uintIndices: boolean;
  34557. /** Defines if high precision shaders are supported */
  34558. highPrecisionShaderSupported: boolean;
  34559. /** Defines if depth reading in the fragment shader is supported */
  34560. fragmentDepthSupported: boolean;
  34561. /** Defines if float texture linear filtering is supported*/
  34562. textureFloatLinearFiltering: boolean;
  34563. /** Defines if rendering to float textures is supported */
  34564. textureFloatRender: boolean;
  34565. /** Defines if half float textures are supported*/
  34566. textureHalfFloat: boolean;
  34567. /** Defines if half float texture linear filtering is supported*/
  34568. textureHalfFloatLinearFiltering: boolean;
  34569. /** Defines if rendering to half float textures is supported */
  34570. textureHalfFloatRender: boolean;
  34571. /** Defines if textureLOD shader command is supported */
  34572. textureLOD: boolean;
  34573. /** Defines if draw buffers extension is supported */
  34574. drawBuffersExtension: boolean;
  34575. /** Defines if depth textures are supported */
  34576. depthTextureExtension: boolean;
  34577. /** Defines if float color buffer are supported */
  34578. colorBufferFloat: boolean;
  34579. /** Gets disjoint timer query extension (null if not supported) */
  34580. timerQuery?: EXT_disjoint_timer_query;
  34581. /** Defines if timestamp can be used with timer query */
  34582. canUseTimestampForTimerQuery: boolean;
  34583. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34584. multiview?: any;
  34585. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34586. oculusMultiview?: any;
  34587. /** Function used to let the system compiles shaders in background */
  34588. parallelShaderCompile?: {
  34589. COMPLETION_STATUS_KHR: number;
  34590. };
  34591. /** Max number of texture samples for MSAA */
  34592. maxMSAASamples: number;
  34593. /** Defines if the blend min max extension is supported */
  34594. blendMinMax: boolean;
  34595. }
  34596. }
  34597. declare module BABYLON {
  34598. /**
  34599. * @hidden
  34600. **/
  34601. export class DepthCullingState {
  34602. private _isDepthTestDirty;
  34603. private _isDepthMaskDirty;
  34604. private _isDepthFuncDirty;
  34605. private _isCullFaceDirty;
  34606. private _isCullDirty;
  34607. private _isZOffsetDirty;
  34608. private _isFrontFaceDirty;
  34609. private _depthTest;
  34610. private _depthMask;
  34611. private _depthFunc;
  34612. private _cull;
  34613. private _cullFace;
  34614. private _zOffset;
  34615. private _frontFace;
  34616. /**
  34617. * Initializes the state.
  34618. */
  34619. constructor();
  34620. get isDirty(): boolean;
  34621. get zOffset(): number;
  34622. set zOffset(value: number);
  34623. get cullFace(): Nullable<number>;
  34624. set cullFace(value: Nullable<number>);
  34625. get cull(): Nullable<boolean>;
  34626. set cull(value: Nullable<boolean>);
  34627. get depthFunc(): Nullable<number>;
  34628. set depthFunc(value: Nullable<number>);
  34629. get depthMask(): boolean;
  34630. set depthMask(value: boolean);
  34631. get depthTest(): boolean;
  34632. set depthTest(value: boolean);
  34633. get frontFace(): Nullable<number>;
  34634. set frontFace(value: Nullable<number>);
  34635. reset(): void;
  34636. apply(gl: WebGLRenderingContext): void;
  34637. }
  34638. }
  34639. declare module BABYLON {
  34640. /**
  34641. * @hidden
  34642. **/
  34643. export class StencilState {
  34644. /** 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 */
  34645. static readonly ALWAYS: number;
  34646. /** Passed to stencilOperation to specify that stencil value must be kept */
  34647. static readonly KEEP: number;
  34648. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34649. static readonly REPLACE: number;
  34650. private _isStencilTestDirty;
  34651. private _isStencilMaskDirty;
  34652. private _isStencilFuncDirty;
  34653. private _isStencilOpDirty;
  34654. private _stencilTest;
  34655. private _stencilMask;
  34656. private _stencilFunc;
  34657. private _stencilFuncRef;
  34658. private _stencilFuncMask;
  34659. private _stencilOpStencilFail;
  34660. private _stencilOpDepthFail;
  34661. private _stencilOpStencilDepthPass;
  34662. get isDirty(): boolean;
  34663. get stencilFunc(): number;
  34664. set stencilFunc(value: number);
  34665. get stencilFuncRef(): number;
  34666. set stencilFuncRef(value: number);
  34667. get stencilFuncMask(): number;
  34668. set stencilFuncMask(value: number);
  34669. get stencilOpStencilFail(): number;
  34670. set stencilOpStencilFail(value: number);
  34671. get stencilOpDepthFail(): number;
  34672. set stencilOpDepthFail(value: number);
  34673. get stencilOpStencilDepthPass(): number;
  34674. set stencilOpStencilDepthPass(value: number);
  34675. get stencilMask(): number;
  34676. set stencilMask(value: number);
  34677. get stencilTest(): boolean;
  34678. set stencilTest(value: boolean);
  34679. constructor();
  34680. reset(): void;
  34681. apply(gl: WebGLRenderingContext): void;
  34682. }
  34683. }
  34684. declare module BABYLON {
  34685. /**
  34686. * @hidden
  34687. **/
  34688. export class AlphaState {
  34689. private _isAlphaBlendDirty;
  34690. private _isBlendFunctionParametersDirty;
  34691. private _isBlendEquationParametersDirty;
  34692. private _isBlendConstantsDirty;
  34693. private _alphaBlend;
  34694. private _blendFunctionParameters;
  34695. private _blendEquationParameters;
  34696. private _blendConstants;
  34697. /**
  34698. * Initializes the state.
  34699. */
  34700. constructor();
  34701. get isDirty(): boolean;
  34702. get alphaBlend(): boolean;
  34703. set alphaBlend(value: boolean);
  34704. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34705. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34706. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34707. reset(): void;
  34708. apply(gl: WebGLRenderingContext): void;
  34709. }
  34710. }
  34711. declare module BABYLON {
  34712. /** @hidden */
  34713. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34714. attributeProcessor(attribute: string): string;
  34715. varyingProcessor(varying: string, isFragment: boolean): string;
  34716. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34717. }
  34718. }
  34719. declare module BABYLON {
  34720. /**
  34721. * Interface for attribute information associated with buffer instanciation
  34722. */
  34723. export interface InstancingAttributeInfo {
  34724. /**
  34725. * Name of the GLSL attribute
  34726. * if attribute index is not specified, this is used to retrieve the index from the effect
  34727. */
  34728. attributeName: string;
  34729. /**
  34730. * Index/offset of the attribute in the vertex shader
  34731. * if not specified, this will be computes from the name.
  34732. */
  34733. index?: number;
  34734. /**
  34735. * size of the attribute, 1, 2, 3 or 4
  34736. */
  34737. attributeSize: number;
  34738. /**
  34739. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34740. */
  34741. offset: number;
  34742. /**
  34743. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34744. * default to 1
  34745. */
  34746. divisor?: number;
  34747. /**
  34748. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34749. * default is FLOAT
  34750. */
  34751. attributeType?: number;
  34752. /**
  34753. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34754. */
  34755. normalized?: boolean;
  34756. }
  34757. }
  34758. declare module BABYLON {
  34759. interface ThinEngine {
  34760. /**
  34761. * Update a video texture
  34762. * @param texture defines the texture to update
  34763. * @param video defines the video element to use
  34764. * @param invertY defines if data must be stored with Y axis inverted
  34765. */
  34766. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34767. }
  34768. }
  34769. declare module BABYLON {
  34770. interface ThinEngine {
  34771. /**
  34772. * Creates a dynamic texture
  34773. * @param width defines the width of the texture
  34774. * @param height defines the height of the texture
  34775. * @param generateMipMaps defines if the engine should generate the mip levels
  34776. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34777. * @returns the dynamic texture inside an InternalTexture
  34778. */
  34779. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34780. /**
  34781. * Update the content of a dynamic texture
  34782. * @param texture defines the texture to update
  34783. * @param canvas defines the canvas containing the source
  34784. * @param invertY defines if data must be stored with Y axis inverted
  34785. * @param premulAlpha defines if alpha is stored as premultiplied
  34786. * @param format defines the format of the data
  34787. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34788. */
  34789. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34790. }
  34791. }
  34792. declare module BABYLON {
  34793. /**
  34794. * Settings for finer control over video usage
  34795. */
  34796. export interface VideoTextureSettings {
  34797. /**
  34798. * Applies `autoplay` to video, if specified
  34799. */
  34800. autoPlay?: boolean;
  34801. /**
  34802. * Applies `loop` to video, if specified
  34803. */
  34804. loop?: boolean;
  34805. /**
  34806. * Automatically updates internal texture from video at every frame in the render loop
  34807. */
  34808. autoUpdateTexture: boolean;
  34809. /**
  34810. * Image src displayed during the video loading or until the user interacts with the video.
  34811. */
  34812. poster?: string;
  34813. }
  34814. /**
  34815. * If you want to display a video in your scene, this is the special texture for that.
  34816. * This special texture works similar to other textures, with the exception of a few parameters.
  34817. * @see https://doc.babylonjs.com/how_to/video_texture
  34818. */
  34819. export class VideoTexture extends Texture {
  34820. /**
  34821. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34822. */
  34823. readonly autoUpdateTexture: boolean;
  34824. /**
  34825. * The video instance used by the texture internally
  34826. */
  34827. readonly video: HTMLVideoElement;
  34828. private _onUserActionRequestedObservable;
  34829. /**
  34830. * Event triggerd when a dom action is required by the user to play the video.
  34831. * This happens due to recent changes in browser policies preventing video to auto start.
  34832. */
  34833. get onUserActionRequestedObservable(): Observable<Texture>;
  34834. private _generateMipMaps;
  34835. private _stillImageCaptured;
  34836. private _displayingPosterTexture;
  34837. private _settings;
  34838. private _createInternalTextureOnEvent;
  34839. private _frameId;
  34840. private _currentSrc;
  34841. /**
  34842. * Creates a video texture.
  34843. * If you want to display a video in your scene, this is the special texture for that.
  34844. * This special texture works similar to other textures, with the exception of a few parameters.
  34845. * @see https://doc.babylonjs.com/how_to/video_texture
  34846. * @param name optional name, will detect from video source, if not defined
  34847. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34848. * @param scene is obviously the current scene.
  34849. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34850. * @param invertY is false by default but can be used to invert video on Y axis
  34851. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34852. * @param settings allows finer control over video usage
  34853. */
  34854. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34855. private _getName;
  34856. private _getVideo;
  34857. private _createInternalTexture;
  34858. private reset;
  34859. /**
  34860. * @hidden Internal method to initiate `update`.
  34861. */
  34862. _rebuild(): void;
  34863. /**
  34864. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34865. */
  34866. update(): void;
  34867. /**
  34868. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34869. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34870. */
  34871. updateTexture(isVisible: boolean): void;
  34872. protected _updateInternalTexture: () => void;
  34873. /**
  34874. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34875. * @param url New url.
  34876. */
  34877. updateURL(url: string): void;
  34878. /**
  34879. * Clones the texture.
  34880. * @returns the cloned texture
  34881. */
  34882. clone(): VideoTexture;
  34883. /**
  34884. * Dispose the texture and release its associated resources.
  34885. */
  34886. dispose(): void;
  34887. /**
  34888. * Creates a video texture straight from a stream.
  34889. * @param scene Define the scene the texture should be created in
  34890. * @param stream Define the stream the texture should be created from
  34891. * @returns The created video texture as a promise
  34892. */
  34893. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34894. /**
  34895. * Creates a video texture straight from your WebCam video feed.
  34896. * @param scene Define the scene the texture should be created in
  34897. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34898. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34899. * @returns The created video texture as a promise
  34900. */
  34901. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34902. minWidth: number;
  34903. maxWidth: number;
  34904. minHeight: number;
  34905. maxHeight: number;
  34906. deviceId: string;
  34907. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34908. /**
  34909. * Creates a video texture straight from your WebCam video feed.
  34910. * @param scene Define the scene the texture should be created in
  34911. * @param onReady Define a callback to triggered once the texture will be ready
  34912. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34913. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34914. */
  34915. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34916. minWidth: number;
  34917. maxWidth: number;
  34918. minHeight: number;
  34919. maxHeight: number;
  34920. deviceId: string;
  34921. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34922. }
  34923. }
  34924. declare module BABYLON {
  34925. /**
  34926. * Defines the interface used by objects working like Scene
  34927. * @hidden
  34928. */
  34929. export interface ISceneLike {
  34930. _addPendingData(data: any): void;
  34931. _removePendingData(data: any): void;
  34932. offlineProvider: IOfflineProvider;
  34933. }
  34934. /** Interface defining initialization parameters for Engine class */
  34935. export interface EngineOptions extends WebGLContextAttributes {
  34936. /**
  34937. * Defines if the engine should no exceed a specified device ratio
  34938. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34939. */
  34940. limitDeviceRatio?: number;
  34941. /**
  34942. * Defines if webvr should be enabled automatically
  34943. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34944. */
  34945. autoEnableWebVR?: boolean;
  34946. /**
  34947. * Defines if webgl2 should be turned off even if supported
  34948. * @see https://doc.babylonjs.com/features/webgl2
  34949. */
  34950. disableWebGL2Support?: boolean;
  34951. /**
  34952. * Defines if webaudio should be initialized as well
  34953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34954. */
  34955. audioEngine?: boolean;
  34956. /**
  34957. * Defines if animations should run using a deterministic lock step
  34958. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34959. */
  34960. deterministicLockstep?: boolean;
  34961. /** Defines the maximum steps to use with deterministic lock step mode */
  34962. lockstepMaxSteps?: number;
  34963. /** Defines the seconds between each deterministic lock step */
  34964. timeStep?: number;
  34965. /**
  34966. * Defines that engine should ignore context lost events
  34967. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34968. */
  34969. doNotHandleContextLost?: boolean;
  34970. /**
  34971. * Defines that engine should ignore modifying touch action attribute and style
  34972. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34973. */
  34974. doNotHandleTouchAction?: boolean;
  34975. /**
  34976. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34977. */
  34978. useHighPrecisionFloats?: boolean;
  34979. /**
  34980. * Make the canvas XR Compatible for XR sessions
  34981. */
  34982. xrCompatible?: boolean;
  34983. /**
  34984. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  34985. */
  34986. useHighPrecisionMatrix?: boolean;
  34987. }
  34988. /**
  34989. * The base engine class (root of all engines)
  34990. */
  34991. export class ThinEngine {
  34992. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34993. static ExceptionList: ({
  34994. key: string;
  34995. capture: string;
  34996. captureConstraint: number;
  34997. targets: string[];
  34998. } | {
  34999. key: string;
  35000. capture: null;
  35001. captureConstraint: null;
  35002. targets: string[];
  35003. })[];
  35004. /** @hidden */
  35005. static _TextureLoaders: IInternalTextureLoader[];
  35006. /**
  35007. * Returns the current npm package of the sdk
  35008. */
  35009. static get NpmPackage(): string;
  35010. /**
  35011. * Returns the current version of the framework
  35012. */
  35013. static get Version(): string;
  35014. /**
  35015. * Returns a string describing the current engine
  35016. */
  35017. get description(): string;
  35018. /**
  35019. * Gets or sets the epsilon value used by collision engine
  35020. */
  35021. static CollisionsEpsilon: number;
  35022. /**
  35023. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35024. */
  35025. static get ShadersRepository(): string;
  35026. static set ShadersRepository(value: string);
  35027. /** @hidden */
  35028. _shaderProcessor: IShaderProcessor;
  35029. /**
  35030. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35031. */
  35032. forcePOTTextures: boolean;
  35033. /**
  35034. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35035. */
  35036. isFullscreen: boolean;
  35037. /**
  35038. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35039. */
  35040. cullBackFaces: boolean;
  35041. /**
  35042. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35043. */
  35044. renderEvenInBackground: boolean;
  35045. /**
  35046. * Gets or sets a boolean indicating that cache can be kept between frames
  35047. */
  35048. preventCacheWipeBetweenFrames: boolean;
  35049. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35050. validateShaderPrograms: boolean;
  35051. /**
  35052. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35053. * This can provide greater z depth for distant objects.
  35054. */
  35055. useReverseDepthBuffer: boolean;
  35056. /**
  35057. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35058. */
  35059. disableUniformBuffers: boolean;
  35060. /** @hidden */
  35061. _uniformBuffers: UniformBuffer[];
  35062. /**
  35063. * Gets a boolean indicating that the engine supports uniform buffers
  35064. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35065. */
  35066. get supportsUniformBuffers(): boolean;
  35067. /** @hidden */
  35068. _gl: WebGLRenderingContext;
  35069. /** @hidden */
  35070. _webGLVersion: number;
  35071. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35072. protected _windowIsBackground: boolean;
  35073. protected _creationOptions: EngineOptions;
  35074. protected _highPrecisionShadersAllowed: boolean;
  35075. /** @hidden */
  35076. get _shouldUseHighPrecisionShader(): boolean;
  35077. /**
  35078. * Gets a boolean indicating that only power of 2 textures are supported
  35079. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35080. */
  35081. get needPOTTextures(): boolean;
  35082. /** @hidden */
  35083. _badOS: boolean;
  35084. /** @hidden */
  35085. _badDesktopOS: boolean;
  35086. private _hardwareScalingLevel;
  35087. /** @hidden */
  35088. _caps: EngineCapabilities;
  35089. private _isStencilEnable;
  35090. private _glVersion;
  35091. private _glRenderer;
  35092. private _glVendor;
  35093. /** @hidden */
  35094. _videoTextureSupported: boolean;
  35095. protected _renderingQueueLaunched: boolean;
  35096. protected _activeRenderLoops: (() => void)[];
  35097. /**
  35098. * Observable signaled when a context lost event is raised
  35099. */
  35100. onContextLostObservable: Observable<ThinEngine>;
  35101. /**
  35102. * Observable signaled when a context restored event is raised
  35103. */
  35104. onContextRestoredObservable: Observable<ThinEngine>;
  35105. private _onContextLost;
  35106. private _onContextRestored;
  35107. protected _contextWasLost: boolean;
  35108. /** @hidden */
  35109. _doNotHandleContextLost: boolean;
  35110. /**
  35111. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35112. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35113. */
  35114. get doNotHandleContextLost(): boolean;
  35115. set doNotHandleContextLost(value: boolean);
  35116. /**
  35117. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35118. */
  35119. disableVertexArrayObjects: boolean;
  35120. /** @hidden */
  35121. protected _colorWrite: boolean;
  35122. /** @hidden */
  35123. protected _colorWriteChanged: boolean;
  35124. /** @hidden */
  35125. protected _depthCullingState: DepthCullingState;
  35126. /** @hidden */
  35127. protected _stencilState: StencilState;
  35128. /** @hidden */
  35129. _alphaState: AlphaState;
  35130. /** @hidden */
  35131. _alphaMode: number;
  35132. /** @hidden */
  35133. _alphaEquation: number;
  35134. /** @hidden */
  35135. _internalTexturesCache: InternalTexture[];
  35136. /** @hidden */
  35137. protected _activeChannel: number;
  35138. private _currentTextureChannel;
  35139. /** @hidden */
  35140. protected _boundTexturesCache: {
  35141. [key: string]: Nullable<InternalTexture>;
  35142. };
  35143. /** @hidden */
  35144. protected _currentEffect: Nullable<Effect>;
  35145. /** @hidden */
  35146. protected _currentProgram: Nullable<WebGLProgram>;
  35147. private _compiledEffects;
  35148. private _vertexAttribArraysEnabled;
  35149. /** @hidden */
  35150. protected _cachedViewport: Nullable<IViewportLike>;
  35151. private _cachedVertexArrayObject;
  35152. /** @hidden */
  35153. protected _cachedVertexBuffers: any;
  35154. /** @hidden */
  35155. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35156. /** @hidden */
  35157. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35158. /** @hidden */
  35159. _currentRenderTarget: Nullable<InternalTexture>;
  35160. private _uintIndicesCurrentlySet;
  35161. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35162. /** @hidden */
  35163. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35164. /** @hidden */
  35165. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35166. private _currentBufferPointers;
  35167. private _currentInstanceLocations;
  35168. private _currentInstanceBuffers;
  35169. private _textureUnits;
  35170. /** @hidden */
  35171. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35172. /** @hidden */
  35173. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35174. /** @hidden */
  35175. _boundRenderFunction: any;
  35176. private _vaoRecordInProgress;
  35177. private _mustWipeVertexAttributes;
  35178. private _emptyTexture;
  35179. private _emptyCubeTexture;
  35180. private _emptyTexture3D;
  35181. private _emptyTexture2DArray;
  35182. /** @hidden */
  35183. _frameHandler: number;
  35184. private _nextFreeTextureSlots;
  35185. private _maxSimultaneousTextures;
  35186. private _activeRequests;
  35187. /** @hidden */
  35188. _transformTextureUrl: Nullable<(url: string) => string>;
  35189. protected get _supportsHardwareTextureRescaling(): boolean;
  35190. private _framebufferDimensionsObject;
  35191. /**
  35192. * sets the object from which width and height will be taken from when getting render width and height
  35193. * Will fallback to the gl object
  35194. * @param dimensions the framebuffer width and height that will be used.
  35195. */
  35196. set framebufferDimensionsObject(dimensions: Nullable<{
  35197. framebufferWidth: number;
  35198. framebufferHeight: number;
  35199. }>);
  35200. /**
  35201. * Gets the current viewport
  35202. */
  35203. get currentViewport(): Nullable<IViewportLike>;
  35204. /**
  35205. * Gets the default empty texture
  35206. */
  35207. get emptyTexture(): InternalTexture;
  35208. /**
  35209. * Gets the default empty 3D texture
  35210. */
  35211. get emptyTexture3D(): InternalTexture;
  35212. /**
  35213. * Gets the default empty 2D array texture
  35214. */
  35215. get emptyTexture2DArray(): InternalTexture;
  35216. /**
  35217. * Gets the default empty cube texture
  35218. */
  35219. get emptyCubeTexture(): InternalTexture;
  35220. /**
  35221. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35222. */
  35223. readonly premultipliedAlpha: boolean;
  35224. /**
  35225. * Observable event triggered before each texture is initialized
  35226. */
  35227. onBeforeTextureInitObservable: Observable<Texture>;
  35228. /**
  35229. * Creates a new engine
  35230. * @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
  35231. * @param antialias defines enable antialiasing (default: false)
  35232. * @param options defines further options to be sent to the getContext() function
  35233. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35234. */
  35235. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35236. private _rebuildInternalTextures;
  35237. private _rebuildEffects;
  35238. /**
  35239. * Gets a boolean indicating if all created effects are ready
  35240. * @returns true if all effects are ready
  35241. */
  35242. areAllEffectsReady(): boolean;
  35243. protected _rebuildBuffers(): void;
  35244. protected _initGLContext(): void;
  35245. /**
  35246. * Gets version of the current webGL context
  35247. */
  35248. get webGLVersion(): number;
  35249. /**
  35250. * Gets a string idenfifying the name of the class
  35251. * @returns "Engine" string
  35252. */
  35253. getClassName(): string;
  35254. /**
  35255. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35256. */
  35257. get isStencilEnable(): boolean;
  35258. /** @hidden */
  35259. _prepareWorkingCanvas(): void;
  35260. /**
  35261. * Reset the texture cache to empty state
  35262. */
  35263. resetTextureCache(): void;
  35264. /**
  35265. * Gets an object containing information about the current webGL context
  35266. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35267. */
  35268. getGlInfo(): {
  35269. vendor: string;
  35270. renderer: string;
  35271. version: string;
  35272. };
  35273. /**
  35274. * Defines the hardware scaling level.
  35275. * By default the hardware scaling level is computed from the window device ratio.
  35276. * 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.
  35277. * @param level defines the level to use
  35278. */
  35279. setHardwareScalingLevel(level: number): void;
  35280. /**
  35281. * Gets the current hardware scaling level.
  35282. * By default the hardware scaling level is computed from the window device ratio.
  35283. * 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.
  35284. * @returns a number indicating the current hardware scaling level
  35285. */
  35286. getHardwareScalingLevel(): number;
  35287. /**
  35288. * Gets the list of loaded textures
  35289. * @returns an array containing all loaded textures
  35290. */
  35291. getLoadedTexturesCache(): InternalTexture[];
  35292. /**
  35293. * Gets the object containing all engine capabilities
  35294. * @returns the EngineCapabilities object
  35295. */
  35296. getCaps(): EngineCapabilities;
  35297. /**
  35298. * stop executing a render loop function and remove it from the execution array
  35299. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35300. */
  35301. stopRenderLoop(renderFunction?: () => void): void;
  35302. /** @hidden */
  35303. _renderLoop(): void;
  35304. /**
  35305. * Gets the HTML canvas attached with the current webGL context
  35306. * @returns a HTML canvas
  35307. */
  35308. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35309. /**
  35310. * Gets host window
  35311. * @returns the host window object
  35312. */
  35313. getHostWindow(): Nullable<Window>;
  35314. /**
  35315. * Gets the current render width
  35316. * @param useScreen defines if screen size must be used (or the current render target if any)
  35317. * @returns a number defining the current render width
  35318. */
  35319. getRenderWidth(useScreen?: boolean): number;
  35320. /**
  35321. * Gets the current render height
  35322. * @param useScreen defines if screen size must be used (or the current render target if any)
  35323. * @returns a number defining the current render height
  35324. */
  35325. getRenderHeight(useScreen?: boolean): number;
  35326. /**
  35327. * Can be used to override the current requestAnimationFrame requester.
  35328. * @hidden
  35329. */
  35330. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35331. /**
  35332. * Register and execute a render loop. The engine can have more than one render function
  35333. * @param renderFunction defines the function to continuously execute
  35334. */
  35335. runRenderLoop(renderFunction: () => void): void;
  35336. /**
  35337. * Clear the current render buffer or the current render target (if any is set up)
  35338. * @param color defines the color to use
  35339. * @param backBuffer defines if the back buffer must be cleared
  35340. * @param depth defines if the depth buffer must be cleared
  35341. * @param stencil defines if the stencil buffer must be cleared
  35342. */
  35343. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35344. private _viewportCached;
  35345. /** @hidden */
  35346. _viewport(x: number, y: number, width: number, height: number): void;
  35347. /**
  35348. * Set the WebGL's viewport
  35349. * @param viewport defines the viewport element to be used
  35350. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35351. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35352. */
  35353. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35354. /**
  35355. * Begin a new frame
  35356. */
  35357. beginFrame(): void;
  35358. /**
  35359. * Enf the current frame
  35360. */
  35361. endFrame(): void;
  35362. /**
  35363. * Resize the view according to the canvas' size
  35364. */
  35365. resize(): void;
  35366. /**
  35367. * Force a specific size of the canvas
  35368. * @param width defines the new canvas' width
  35369. * @param height defines the new canvas' height
  35370. * @returns true if the size was changed
  35371. */
  35372. setSize(width: number, height: number): boolean;
  35373. /**
  35374. * Binds the frame buffer to the specified texture.
  35375. * @param texture The texture to render to or null for the default canvas
  35376. * @param faceIndex The face of the texture to render to in case of cube texture
  35377. * @param requiredWidth The width of the target to render to
  35378. * @param requiredHeight The height of the target to render to
  35379. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35380. * @param lodLevel defines the lod level to bind to the frame buffer
  35381. * @param layer defines the 2d array index to bind to frame buffer to
  35382. */
  35383. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35384. /** @hidden */
  35385. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35386. /**
  35387. * Unbind the current render target texture from the webGL context
  35388. * @param texture defines the render target texture to unbind
  35389. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35390. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35391. */
  35392. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35393. /**
  35394. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35395. */
  35396. flushFramebuffer(): void;
  35397. /**
  35398. * Unbind the current render target and bind the default framebuffer
  35399. */
  35400. restoreDefaultFramebuffer(): void;
  35401. /** @hidden */
  35402. protected _resetVertexBufferBinding(): void;
  35403. /**
  35404. * Creates a vertex buffer
  35405. * @param data the data for the vertex buffer
  35406. * @returns the new WebGL static buffer
  35407. */
  35408. createVertexBuffer(data: DataArray): DataBuffer;
  35409. private _createVertexBuffer;
  35410. /**
  35411. * Creates a dynamic vertex buffer
  35412. * @param data the data for the dynamic vertex buffer
  35413. * @returns the new WebGL dynamic buffer
  35414. */
  35415. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35416. protected _resetIndexBufferBinding(): void;
  35417. /**
  35418. * Creates a new index buffer
  35419. * @param indices defines the content of the index buffer
  35420. * @param updatable defines if the index buffer must be updatable
  35421. * @returns a new webGL buffer
  35422. */
  35423. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35424. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35425. /**
  35426. * Bind a webGL buffer to the webGL context
  35427. * @param buffer defines the buffer to bind
  35428. */
  35429. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35430. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35431. private bindBuffer;
  35432. /**
  35433. * update the bound buffer with the given data
  35434. * @param data defines the data to update
  35435. */
  35436. updateArrayBuffer(data: Float32Array): void;
  35437. private _vertexAttribPointer;
  35438. /** @hidden */
  35439. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35440. private _bindVertexBuffersAttributes;
  35441. /**
  35442. * Records a vertex array object
  35443. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35444. * @param vertexBuffers defines the list of vertex buffers to store
  35445. * @param indexBuffer defines the index buffer to store
  35446. * @param effect defines the effect to store
  35447. * @returns the new vertex array object
  35448. */
  35449. recordVertexArrayObject(vertexBuffers: {
  35450. [key: string]: VertexBuffer;
  35451. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35452. /**
  35453. * Bind a specific vertex array object
  35454. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35455. * @param vertexArrayObject defines the vertex array object to bind
  35456. * @param indexBuffer defines the index buffer to bind
  35457. */
  35458. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35459. /**
  35460. * Bind webGl buffers directly to the webGL context
  35461. * @param vertexBuffer defines the vertex buffer to bind
  35462. * @param indexBuffer defines the index buffer to bind
  35463. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35464. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35465. * @param effect defines the effect associated with the vertex buffer
  35466. */
  35467. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35468. private _unbindVertexArrayObject;
  35469. /**
  35470. * Bind a list of vertex buffers to the webGL context
  35471. * @param vertexBuffers defines the list of vertex buffers to bind
  35472. * @param indexBuffer defines the index buffer to bind
  35473. * @param effect defines the effect associated with the vertex buffers
  35474. */
  35475. bindBuffers(vertexBuffers: {
  35476. [key: string]: Nullable<VertexBuffer>;
  35477. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35478. /**
  35479. * Unbind all instance attributes
  35480. */
  35481. unbindInstanceAttributes(): void;
  35482. /**
  35483. * Release and free the memory of a vertex array object
  35484. * @param vao defines the vertex array object to delete
  35485. */
  35486. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35487. /** @hidden */
  35488. _releaseBuffer(buffer: DataBuffer): boolean;
  35489. protected _deleteBuffer(buffer: DataBuffer): void;
  35490. /**
  35491. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35492. * @param instancesBuffer defines the webGL buffer to update and bind
  35493. * @param data defines the data to store in the buffer
  35494. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35495. */
  35496. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35497. /**
  35498. * Bind the content of a webGL buffer used with instantiation
  35499. * @param instancesBuffer defines the webGL buffer to bind
  35500. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35501. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35502. */
  35503. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35504. /**
  35505. * Disable the instance attribute corresponding to the name in parameter
  35506. * @param name defines the name of the attribute to disable
  35507. */
  35508. disableInstanceAttributeByName(name: string): void;
  35509. /**
  35510. * Disable the instance attribute corresponding to the location in parameter
  35511. * @param attributeLocation defines the attribute location of the attribute to disable
  35512. */
  35513. disableInstanceAttribute(attributeLocation: number): void;
  35514. /**
  35515. * Disable the attribute corresponding to the location in parameter
  35516. * @param attributeLocation defines the attribute location of the attribute to disable
  35517. */
  35518. disableAttributeByIndex(attributeLocation: number): void;
  35519. /**
  35520. * Send a draw order
  35521. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35522. * @param indexStart defines the starting index
  35523. * @param indexCount defines the number of index to draw
  35524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35525. */
  35526. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35527. /**
  35528. * Draw a list of points
  35529. * @param verticesStart defines the index of first vertex to draw
  35530. * @param verticesCount defines the count of vertices to draw
  35531. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35532. */
  35533. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35534. /**
  35535. * Draw a list of unindexed primitives
  35536. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35537. * @param verticesStart defines the index of first vertex to draw
  35538. * @param verticesCount defines the count of vertices to draw
  35539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35540. */
  35541. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35542. /**
  35543. * Draw a list of indexed primitives
  35544. * @param fillMode defines the primitive to use
  35545. * @param indexStart defines the starting index
  35546. * @param indexCount defines the number of index to draw
  35547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35548. */
  35549. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35550. /**
  35551. * Draw a list of unindexed primitives
  35552. * @param fillMode defines the primitive to use
  35553. * @param verticesStart defines the index of first vertex to draw
  35554. * @param verticesCount defines the count of vertices to draw
  35555. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35556. */
  35557. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35558. private _drawMode;
  35559. /** @hidden */
  35560. protected _reportDrawCall(): void;
  35561. /** @hidden */
  35562. _releaseEffect(effect: Effect): void;
  35563. /** @hidden */
  35564. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35565. /**
  35566. * Create a new effect (used to store vertex/fragment shaders)
  35567. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35568. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35569. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35570. * @param samplers defines an array of string used to represent textures
  35571. * @param defines defines the string containing the defines to use to compile the shaders
  35572. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35573. * @param onCompiled defines a function to call when the effect creation is successful
  35574. * @param onError defines a function to call when the effect creation has failed
  35575. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35576. * @returns the new Effect
  35577. */
  35578. 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;
  35579. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35580. private _compileShader;
  35581. private _compileRawShader;
  35582. /** @hidden */
  35583. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35584. /**
  35585. * Directly creates a webGL program
  35586. * @param pipelineContext defines the pipeline context to attach to
  35587. * @param vertexCode defines the vertex shader code to use
  35588. * @param fragmentCode defines the fragment shader code to use
  35589. * @param context defines the webGL context to use (if not set, the current one will be used)
  35590. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35591. * @returns the new webGL program
  35592. */
  35593. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35594. /**
  35595. * Creates a webGL program
  35596. * @param pipelineContext defines the pipeline context to attach to
  35597. * @param vertexCode defines the vertex shader code to use
  35598. * @param fragmentCode defines the fragment shader code to use
  35599. * @param defines defines the string containing the defines to use to compile the shaders
  35600. * @param context defines the webGL context to use (if not set, the current one will be used)
  35601. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35602. * @returns the new webGL program
  35603. */
  35604. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35605. /**
  35606. * Creates a new pipeline context
  35607. * @returns the new pipeline
  35608. */
  35609. createPipelineContext(): IPipelineContext;
  35610. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35611. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35612. /** @hidden */
  35613. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35614. /** @hidden */
  35615. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35616. /** @hidden */
  35617. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35618. /**
  35619. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35620. * @param pipelineContext defines the pipeline context to use
  35621. * @param uniformsNames defines the list of uniform names
  35622. * @returns an array of webGL uniform locations
  35623. */
  35624. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35625. /**
  35626. * Gets the lsit of active attributes for a given webGL program
  35627. * @param pipelineContext defines the pipeline context to use
  35628. * @param attributesNames defines the list of attribute names to get
  35629. * @returns an array of indices indicating the offset of each attribute
  35630. */
  35631. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35632. /**
  35633. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35634. * @param effect defines the effect to activate
  35635. */
  35636. enableEffect(effect: Nullable<Effect>): void;
  35637. /**
  35638. * Set the value of an uniform to a number (int)
  35639. * @param uniform defines the webGL uniform location where to store the value
  35640. * @param value defines the int number to store
  35641. */
  35642. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35643. /**
  35644. * Set the value of an uniform to an array of int32
  35645. * @param uniform defines the webGL uniform location where to store the value
  35646. * @param array defines the array of int32 to store
  35647. */
  35648. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35649. /**
  35650. * Set the value of an uniform to an array of int32 (stored as vec2)
  35651. * @param uniform defines the webGL uniform location where to store the value
  35652. * @param array defines the array of int32 to store
  35653. */
  35654. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35655. /**
  35656. * Set the value of an uniform to an array of int32 (stored as vec3)
  35657. * @param uniform defines the webGL uniform location where to store the value
  35658. * @param array defines the array of int32 to store
  35659. */
  35660. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35661. /**
  35662. * Set the value of an uniform to an array of int32 (stored as vec4)
  35663. * @param uniform defines the webGL uniform location where to store the value
  35664. * @param array defines the array of int32 to store
  35665. */
  35666. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35667. /**
  35668. * Set the value of an uniform to an array of number
  35669. * @param uniform defines the webGL uniform location where to store the value
  35670. * @param array defines the array of number to store
  35671. */
  35672. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35673. /**
  35674. * Set the value of an uniform to an array of number (stored as vec2)
  35675. * @param uniform defines the webGL uniform location where to store the value
  35676. * @param array defines the array of number to store
  35677. */
  35678. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35679. /**
  35680. * Set the value of an uniform to an array of number (stored as vec3)
  35681. * @param uniform defines the webGL uniform location where to store the value
  35682. * @param array defines the array of number to store
  35683. */
  35684. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35685. /**
  35686. * Set the value of an uniform to an array of number (stored as vec4)
  35687. * @param uniform defines the webGL uniform location where to store the value
  35688. * @param array defines the array of number to store
  35689. */
  35690. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35691. /**
  35692. * Set the value of an uniform to an array of float32 (stored as matrices)
  35693. * @param uniform defines the webGL uniform location where to store the value
  35694. * @param matrices defines the array of float32 to store
  35695. */
  35696. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35697. /**
  35698. * Set the value of an uniform to a matrix (3x3)
  35699. * @param uniform defines the webGL uniform location where to store the value
  35700. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35701. */
  35702. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35703. /**
  35704. * Set the value of an uniform to a matrix (2x2)
  35705. * @param uniform defines the webGL uniform location where to store the value
  35706. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35707. */
  35708. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35709. /**
  35710. * Set the value of an uniform to a number (float)
  35711. * @param uniform defines the webGL uniform location where to store the value
  35712. * @param value defines the float number to store
  35713. */
  35714. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35715. /**
  35716. * Set the value of an uniform to a vec2
  35717. * @param uniform defines the webGL uniform location where to store the value
  35718. * @param x defines the 1st component of the value
  35719. * @param y defines the 2nd component of the value
  35720. */
  35721. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35722. /**
  35723. * Set the value of an uniform to a vec3
  35724. * @param uniform defines the webGL uniform location where to store the value
  35725. * @param x defines the 1st component of the value
  35726. * @param y defines the 2nd component of the value
  35727. * @param z defines the 3rd component of the value
  35728. */
  35729. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35730. /**
  35731. * Set the value of an uniform to a vec4
  35732. * @param uniform defines the webGL uniform location where to store the value
  35733. * @param x defines the 1st component of the value
  35734. * @param y defines the 2nd component of the value
  35735. * @param z defines the 3rd component of the value
  35736. * @param w defines the 4th component of the value
  35737. */
  35738. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35739. /**
  35740. * Apply all cached states (depth, culling, stencil and alpha)
  35741. */
  35742. applyStates(): void;
  35743. /**
  35744. * Enable or disable color writing
  35745. * @param enable defines the state to set
  35746. */
  35747. setColorWrite(enable: boolean): void;
  35748. /**
  35749. * Gets a boolean indicating if color writing is enabled
  35750. * @returns the current color writing state
  35751. */
  35752. getColorWrite(): boolean;
  35753. /**
  35754. * Gets the depth culling state manager
  35755. */
  35756. get depthCullingState(): DepthCullingState;
  35757. /**
  35758. * Gets the alpha state manager
  35759. */
  35760. get alphaState(): AlphaState;
  35761. /**
  35762. * Gets the stencil state manager
  35763. */
  35764. get stencilState(): StencilState;
  35765. /**
  35766. * Clears the list of texture accessible through engine.
  35767. * This can help preventing texture load conflict due to name collision.
  35768. */
  35769. clearInternalTexturesCache(): void;
  35770. /**
  35771. * Force the entire cache to be cleared
  35772. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35773. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35774. */
  35775. wipeCaches(bruteForce?: boolean): void;
  35776. /** @hidden */
  35777. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35778. min: number;
  35779. mag: number;
  35780. };
  35781. /** @hidden */
  35782. _createTexture(): WebGLTexture;
  35783. /**
  35784. * Usually called from Texture.ts.
  35785. * Passed information to create a WebGLTexture
  35786. * @param url defines a value which contains one of the following:
  35787. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35788. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35789. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35790. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35791. * @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)
  35792. * @param scene needed for loading to the correct scene
  35793. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35794. * @param onLoad optional callback to be called upon successful completion
  35795. * @param onError optional callback to be called upon failure
  35796. * @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
  35797. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35798. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35799. * @param forcedExtension defines the extension to use to pick the right loader
  35800. * @param mimeType defines an optional mime type
  35801. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35802. */
  35803. 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;
  35804. /**
  35805. * Loads an image as an HTMLImageElement.
  35806. * @param input url string, ArrayBuffer, or Blob to load
  35807. * @param onLoad callback called when the image successfully loads
  35808. * @param onError callback called when the image fails to load
  35809. * @param offlineProvider offline provider for caching
  35810. * @param mimeType optional mime type
  35811. * @returns the HTMLImageElement of the loaded image
  35812. * @hidden
  35813. */
  35814. 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>;
  35815. /**
  35816. * @hidden
  35817. */
  35818. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35819. private _unpackFlipYCached;
  35820. /**
  35821. * In case you are sharing the context with other applications, it might
  35822. * be interested to not cache the unpack flip y state to ensure a consistent
  35823. * value would be set.
  35824. */
  35825. enableUnpackFlipYCached: boolean;
  35826. /** @hidden */
  35827. _unpackFlipY(value: boolean): void;
  35828. /** @hidden */
  35829. _getUnpackAlignement(): number;
  35830. private _getTextureTarget;
  35831. /**
  35832. * Update the sampling mode of a given texture
  35833. * @param samplingMode defines the required sampling mode
  35834. * @param texture defines the texture to update
  35835. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35836. */
  35837. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35838. /**
  35839. * Update the sampling mode of a given texture
  35840. * @param texture defines the texture to update
  35841. * @param wrapU defines the texture wrap mode of the u coordinates
  35842. * @param wrapV defines the texture wrap mode of the v coordinates
  35843. * @param wrapR defines the texture wrap mode of the r coordinates
  35844. */
  35845. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35846. /** @hidden */
  35847. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35848. width: number;
  35849. height: number;
  35850. layers?: number;
  35851. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35852. /** @hidden */
  35853. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35854. /** @hidden */
  35855. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35856. /**
  35857. * Update a portion of an internal texture
  35858. * @param texture defines the texture to update
  35859. * @param imageData defines the data to store into the texture
  35860. * @param xOffset defines the x coordinates of the update rectangle
  35861. * @param yOffset defines the y coordinates of the update rectangle
  35862. * @param width defines the width of the update rectangle
  35863. * @param height defines the height of the update rectangle
  35864. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35865. * @param lod defines the lod level to update (0 by default)
  35866. */
  35867. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35868. /** @hidden */
  35869. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35870. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35871. private _prepareWebGLTexture;
  35872. /** @hidden */
  35873. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35874. private _getDepthStencilBuffer;
  35875. /** @hidden */
  35876. _releaseFramebufferObjects(texture: InternalTexture): void;
  35877. /** @hidden */
  35878. _releaseTexture(texture: InternalTexture): void;
  35879. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35880. protected _setProgram(program: WebGLProgram): void;
  35881. protected _boundUniforms: {
  35882. [key: number]: WebGLUniformLocation;
  35883. };
  35884. /**
  35885. * Binds an effect to the webGL context
  35886. * @param effect defines the effect to bind
  35887. */
  35888. bindSamplers(effect: Effect): void;
  35889. private _activateCurrentTexture;
  35890. /** @hidden */
  35891. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35892. /** @hidden */
  35893. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35894. /**
  35895. * Unbind all textures from the webGL context
  35896. */
  35897. unbindAllTextures(): void;
  35898. /**
  35899. * Sets a texture to the according uniform.
  35900. * @param channel The texture channel
  35901. * @param uniform The uniform to set
  35902. * @param texture The texture to apply
  35903. */
  35904. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35905. private _bindSamplerUniformToChannel;
  35906. private _getTextureWrapMode;
  35907. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35908. /**
  35909. * Sets an array of texture to the webGL context
  35910. * @param channel defines the channel where the texture array must be set
  35911. * @param uniform defines the associated uniform location
  35912. * @param textures defines the array of textures to bind
  35913. */
  35914. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35915. /** @hidden */
  35916. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35917. private _setTextureParameterFloat;
  35918. private _setTextureParameterInteger;
  35919. /**
  35920. * Unbind all vertex attributes from the webGL context
  35921. */
  35922. unbindAllAttributes(): void;
  35923. /**
  35924. * 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
  35925. */
  35926. releaseEffects(): void;
  35927. /**
  35928. * Dispose and release all associated resources
  35929. */
  35930. dispose(): void;
  35931. /**
  35932. * Attach a new callback raised when context lost event is fired
  35933. * @param callback defines the callback to call
  35934. */
  35935. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35936. /**
  35937. * Attach a new callback raised when context restored event is fired
  35938. * @param callback defines the callback to call
  35939. */
  35940. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35941. /**
  35942. * Get the current error code of the webGL context
  35943. * @returns the error code
  35944. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35945. */
  35946. getError(): number;
  35947. private _canRenderToFloatFramebuffer;
  35948. private _canRenderToHalfFloatFramebuffer;
  35949. private _canRenderToFramebuffer;
  35950. /** @hidden */
  35951. _getWebGLTextureType(type: number): number;
  35952. /** @hidden */
  35953. _getInternalFormat(format: number): number;
  35954. /** @hidden */
  35955. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35956. /** @hidden */
  35957. _getRGBAMultiSampleBufferFormat(type: number): number;
  35958. /** @hidden */
  35959. _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;
  35960. /**
  35961. * Loads a file from a url
  35962. * @param url url to load
  35963. * @param onSuccess callback called when the file successfully loads
  35964. * @param onProgress callback called while file is loading (if the server supports this mode)
  35965. * @param offlineProvider defines the offline provider for caching
  35966. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35967. * @param onError callback called when the file fails to load
  35968. * @returns a file request object
  35969. * @hidden
  35970. */
  35971. 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;
  35972. /**
  35973. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35974. * @param x defines the x coordinate of the rectangle where pixels must be read
  35975. * @param y defines the y coordinate of the rectangle where pixels must be read
  35976. * @param width defines the width of the rectangle where pixels must be read
  35977. * @param height defines the height of the rectangle where pixels must be read
  35978. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35979. * @returns a Uint8Array containing RGBA colors
  35980. */
  35981. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35982. private static _isSupported;
  35983. /**
  35984. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35985. * @returns true if the engine can be created
  35986. * @ignorenaming
  35987. */
  35988. static isSupported(): boolean;
  35989. /**
  35990. * Find the next highest power of two.
  35991. * @param x Number to start search from.
  35992. * @return Next highest power of two.
  35993. */
  35994. static CeilingPOT(x: number): number;
  35995. /**
  35996. * Find the next lowest power of two.
  35997. * @param x Number to start search from.
  35998. * @return Next lowest power of two.
  35999. */
  36000. static FloorPOT(x: number): number;
  36001. /**
  36002. * Find the nearest power of two.
  36003. * @param x Number to start search from.
  36004. * @return Next nearest power of two.
  36005. */
  36006. static NearestPOT(x: number): number;
  36007. /**
  36008. * Get the closest exponent of two
  36009. * @param value defines the value to approximate
  36010. * @param max defines the maximum value to return
  36011. * @param mode defines how to define the closest value
  36012. * @returns closest exponent of two of the given value
  36013. */
  36014. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36015. /**
  36016. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36017. * @param func - the function to be called
  36018. * @param requester - the object that will request the next frame. Falls back to window.
  36019. * @returns frame number
  36020. */
  36021. static QueueNewFrame(func: () => void, requester?: any): number;
  36022. /**
  36023. * Gets host document
  36024. * @returns the host document object
  36025. */
  36026. getHostDocument(): Nullable<Document>;
  36027. }
  36028. }
  36029. declare module BABYLON {
  36030. /**
  36031. * Class representing spherical harmonics coefficients to the 3rd degree
  36032. */
  36033. export class SphericalHarmonics {
  36034. /**
  36035. * Defines whether or not the harmonics have been prescaled for rendering.
  36036. */
  36037. preScaled: boolean;
  36038. /**
  36039. * The l0,0 coefficients of the spherical harmonics
  36040. */
  36041. l00: Vector3;
  36042. /**
  36043. * The l1,-1 coefficients of the spherical harmonics
  36044. */
  36045. l1_1: Vector3;
  36046. /**
  36047. * The l1,0 coefficients of the spherical harmonics
  36048. */
  36049. l10: Vector3;
  36050. /**
  36051. * The l1,1 coefficients of the spherical harmonics
  36052. */
  36053. l11: Vector3;
  36054. /**
  36055. * The l2,-2 coefficients of the spherical harmonics
  36056. */
  36057. l2_2: Vector3;
  36058. /**
  36059. * The l2,-1 coefficients of the spherical harmonics
  36060. */
  36061. l2_1: Vector3;
  36062. /**
  36063. * The l2,0 coefficients of the spherical harmonics
  36064. */
  36065. l20: Vector3;
  36066. /**
  36067. * The l2,1 coefficients of the spherical harmonics
  36068. */
  36069. l21: Vector3;
  36070. /**
  36071. * The l2,2 coefficients of the spherical harmonics
  36072. */
  36073. l22: Vector3;
  36074. /**
  36075. * Adds a light to the spherical harmonics
  36076. * @param direction the direction of the light
  36077. * @param color the color of the light
  36078. * @param deltaSolidAngle the delta solid angle of the light
  36079. */
  36080. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36081. /**
  36082. * Scales the spherical harmonics by the given amount
  36083. * @param scale the amount to scale
  36084. */
  36085. scaleInPlace(scale: number): void;
  36086. /**
  36087. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36088. *
  36089. * ```
  36090. * E_lm = A_l * L_lm
  36091. * ```
  36092. *
  36093. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36094. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36095. * the scaling factors are given in equation 9.
  36096. */
  36097. convertIncidentRadianceToIrradiance(): void;
  36098. /**
  36099. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36100. *
  36101. * ```
  36102. * L = (1/pi) * E * rho
  36103. * ```
  36104. *
  36105. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36106. */
  36107. convertIrradianceToLambertianRadiance(): void;
  36108. /**
  36109. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36110. * required operations at run time.
  36111. *
  36112. * This is simply done by scaling back the SH with Ylm constants parameter.
  36113. * The trigonometric part being applied by the shader at run time.
  36114. */
  36115. preScaleForRendering(): void;
  36116. /**
  36117. * Constructs a spherical harmonics from an array.
  36118. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36119. * @returns the spherical harmonics
  36120. */
  36121. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36122. /**
  36123. * Gets the spherical harmonics from polynomial
  36124. * @param polynomial the spherical polynomial
  36125. * @returns the spherical harmonics
  36126. */
  36127. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36128. }
  36129. /**
  36130. * Class representing spherical polynomial coefficients to the 3rd degree
  36131. */
  36132. export class SphericalPolynomial {
  36133. private _harmonics;
  36134. /**
  36135. * The spherical harmonics used to create the polynomials.
  36136. */
  36137. get preScaledHarmonics(): SphericalHarmonics;
  36138. /**
  36139. * The x coefficients of the spherical polynomial
  36140. */
  36141. x: Vector3;
  36142. /**
  36143. * The y coefficients of the spherical polynomial
  36144. */
  36145. y: Vector3;
  36146. /**
  36147. * The z coefficients of the spherical polynomial
  36148. */
  36149. z: Vector3;
  36150. /**
  36151. * The xx coefficients of the spherical polynomial
  36152. */
  36153. xx: Vector3;
  36154. /**
  36155. * The yy coefficients of the spherical polynomial
  36156. */
  36157. yy: Vector3;
  36158. /**
  36159. * The zz coefficients of the spherical polynomial
  36160. */
  36161. zz: Vector3;
  36162. /**
  36163. * The xy coefficients of the spherical polynomial
  36164. */
  36165. xy: Vector3;
  36166. /**
  36167. * The yz coefficients of the spherical polynomial
  36168. */
  36169. yz: Vector3;
  36170. /**
  36171. * The zx coefficients of the spherical polynomial
  36172. */
  36173. zx: Vector3;
  36174. /**
  36175. * Adds an ambient color to the spherical polynomial
  36176. * @param color the color to add
  36177. */
  36178. addAmbient(color: Color3): void;
  36179. /**
  36180. * Scales the spherical polynomial by the given amount
  36181. * @param scale the amount to scale
  36182. */
  36183. scaleInPlace(scale: number): void;
  36184. /**
  36185. * Gets the spherical polynomial from harmonics
  36186. * @param harmonics the spherical harmonics
  36187. * @returns the spherical polynomial
  36188. */
  36189. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36190. /**
  36191. * Constructs a spherical polynomial from an array.
  36192. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36193. * @returns the spherical polynomial
  36194. */
  36195. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36196. }
  36197. }
  36198. declare module BABYLON {
  36199. /**
  36200. * Defines the source of the internal texture
  36201. */
  36202. export enum InternalTextureSource {
  36203. /**
  36204. * The source of the texture data is unknown
  36205. */
  36206. Unknown = 0,
  36207. /**
  36208. * Texture data comes from an URL
  36209. */
  36210. Url = 1,
  36211. /**
  36212. * Texture data is only used for temporary storage
  36213. */
  36214. Temp = 2,
  36215. /**
  36216. * Texture data comes from raw data (ArrayBuffer)
  36217. */
  36218. Raw = 3,
  36219. /**
  36220. * Texture content is dynamic (video or dynamic texture)
  36221. */
  36222. Dynamic = 4,
  36223. /**
  36224. * Texture content is generated by rendering to it
  36225. */
  36226. RenderTarget = 5,
  36227. /**
  36228. * Texture content is part of a multi render target process
  36229. */
  36230. MultiRenderTarget = 6,
  36231. /**
  36232. * Texture data comes from a cube data file
  36233. */
  36234. Cube = 7,
  36235. /**
  36236. * Texture data comes from a raw cube data
  36237. */
  36238. CubeRaw = 8,
  36239. /**
  36240. * Texture data come from a prefiltered cube data file
  36241. */
  36242. CubePrefiltered = 9,
  36243. /**
  36244. * Texture content is raw 3D data
  36245. */
  36246. Raw3D = 10,
  36247. /**
  36248. * Texture content is raw 2D array data
  36249. */
  36250. Raw2DArray = 11,
  36251. /**
  36252. * Texture content is a depth texture
  36253. */
  36254. Depth = 12,
  36255. /**
  36256. * Texture data comes from a raw cube data encoded with RGBD
  36257. */
  36258. CubeRawRGBD = 13
  36259. }
  36260. /**
  36261. * Class used to store data associated with WebGL texture data for the engine
  36262. * This class should not be used directly
  36263. */
  36264. export class InternalTexture {
  36265. /** @hidden */
  36266. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36267. /**
  36268. * Defines if the texture is ready
  36269. */
  36270. isReady: boolean;
  36271. /**
  36272. * Defines if the texture is a cube texture
  36273. */
  36274. isCube: boolean;
  36275. /**
  36276. * Defines if the texture contains 3D data
  36277. */
  36278. is3D: boolean;
  36279. /**
  36280. * Defines if the texture contains 2D array data
  36281. */
  36282. is2DArray: boolean;
  36283. /**
  36284. * Defines if the texture contains multiview data
  36285. */
  36286. isMultiview: boolean;
  36287. /**
  36288. * Gets the URL used to load this texture
  36289. */
  36290. url: string;
  36291. /**
  36292. * Gets the sampling mode of the texture
  36293. */
  36294. samplingMode: number;
  36295. /**
  36296. * Gets a boolean indicating if the texture needs mipmaps generation
  36297. */
  36298. generateMipMaps: boolean;
  36299. /**
  36300. * Gets the number of samples used by the texture (WebGL2+ only)
  36301. */
  36302. samples: number;
  36303. /**
  36304. * Gets the type of the texture (int, float...)
  36305. */
  36306. type: number;
  36307. /**
  36308. * Gets the format of the texture (RGB, RGBA...)
  36309. */
  36310. format: number;
  36311. /**
  36312. * Observable called when the texture is loaded
  36313. */
  36314. onLoadedObservable: Observable<InternalTexture>;
  36315. /**
  36316. * Gets the width of the texture
  36317. */
  36318. width: number;
  36319. /**
  36320. * Gets the height of the texture
  36321. */
  36322. height: number;
  36323. /**
  36324. * Gets the depth of the texture
  36325. */
  36326. depth: number;
  36327. /**
  36328. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36329. */
  36330. baseWidth: number;
  36331. /**
  36332. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36333. */
  36334. baseHeight: number;
  36335. /**
  36336. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36337. */
  36338. baseDepth: number;
  36339. /**
  36340. * Gets a boolean indicating if the texture is inverted on Y axis
  36341. */
  36342. invertY: boolean;
  36343. /** @hidden */
  36344. _invertVScale: boolean;
  36345. /** @hidden */
  36346. _associatedChannel: number;
  36347. /** @hidden */
  36348. _source: InternalTextureSource;
  36349. /** @hidden */
  36350. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36351. /** @hidden */
  36352. _bufferView: Nullable<ArrayBufferView>;
  36353. /** @hidden */
  36354. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36355. /** @hidden */
  36356. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36357. /** @hidden */
  36358. _size: number;
  36359. /** @hidden */
  36360. _extension: string;
  36361. /** @hidden */
  36362. _files: Nullable<string[]>;
  36363. /** @hidden */
  36364. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36365. /** @hidden */
  36366. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36367. /** @hidden */
  36368. _framebuffer: Nullable<WebGLFramebuffer>;
  36369. /** @hidden */
  36370. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36371. /** @hidden */
  36372. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36373. /** @hidden */
  36374. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36375. /** @hidden */
  36376. _attachments: Nullable<number[]>;
  36377. /** @hidden */
  36378. _textureArray: Nullable<InternalTexture[]>;
  36379. /** @hidden */
  36380. _cachedCoordinatesMode: Nullable<number>;
  36381. /** @hidden */
  36382. _cachedWrapU: Nullable<number>;
  36383. /** @hidden */
  36384. _cachedWrapV: Nullable<number>;
  36385. /** @hidden */
  36386. _cachedWrapR: Nullable<number>;
  36387. /** @hidden */
  36388. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36389. /** @hidden */
  36390. _isDisabled: boolean;
  36391. /** @hidden */
  36392. _compression: Nullable<string>;
  36393. /** @hidden */
  36394. _generateStencilBuffer: boolean;
  36395. /** @hidden */
  36396. _generateDepthBuffer: boolean;
  36397. /** @hidden */
  36398. _comparisonFunction: number;
  36399. /** @hidden */
  36400. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36401. /** @hidden */
  36402. _lodGenerationScale: number;
  36403. /** @hidden */
  36404. _lodGenerationOffset: number;
  36405. /** @hidden */
  36406. _depthStencilTexture: Nullable<InternalTexture>;
  36407. /** @hidden */
  36408. _colorTextureArray: Nullable<WebGLTexture>;
  36409. /** @hidden */
  36410. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36411. /** @hidden */
  36412. _lodTextureHigh: Nullable<BaseTexture>;
  36413. /** @hidden */
  36414. _lodTextureMid: Nullable<BaseTexture>;
  36415. /** @hidden */
  36416. _lodTextureLow: Nullable<BaseTexture>;
  36417. /** @hidden */
  36418. _isRGBD: boolean;
  36419. /** @hidden */
  36420. _linearSpecularLOD: boolean;
  36421. /** @hidden */
  36422. _irradianceTexture: Nullable<BaseTexture>;
  36423. /** @hidden */
  36424. _webGLTexture: Nullable<WebGLTexture>;
  36425. /** @hidden */
  36426. _references: number;
  36427. private _engine;
  36428. /**
  36429. * Gets the Engine the texture belongs to.
  36430. * @returns The babylon engine
  36431. */
  36432. getEngine(): ThinEngine;
  36433. /**
  36434. * Gets the data source type of the texture
  36435. */
  36436. get source(): InternalTextureSource;
  36437. /**
  36438. * Creates a new InternalTexture
  36439. * @param engine defines the engine to use
  36440. * @param source defines the type of data that will be used
  36441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36442. */
  36443. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36444. /**
  36445. * Increments the number of references (ie. the number of Texture that point to it)
  36446. */
  36447. incrementReferences(): void;
  36448. /**
  36449. * Change the size of the texture (not the size of the content)
  36450. * @param width defines the new width
  36451. * @param height defines the new height
  36452. * @param depth defines the new depth (1 by default)
  36453. */
  36454. updateSize(width: int, height: int, depth?: int): void;
  36455. /** @hidden */
  36456. _rebuild(): void;
  36457. /** @hidden */
  36458. _swapAndDie(target: InternalTexture): void;
  36459. /**
  36460. * Dispose the current allocated resources
  36461. */
  36462. dispose(): void;
  36463. }
  36464. }
  36465. declare module BABYLON {
  36466. /**
  36467. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36468. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36469. */
  36470. export class Analyser {
  36471. /**
  36472. * Gets or sets the smoothing
  36473. * @ignorenaming
  36474. */
  36475. SMOOTHING: number;
  36476. /**
  36477. * Gets or sets the FFT table size
  36478. * @ignorenaming
  36479. */
  36480. FFT_SIZE: number;
  36481. /**
  36482. * Gets or sets the bar graph amplitude
  36483. * @ignorenaming
  36484. */
  36485. BARGRAPHAMPLITUDE: number;
  36486. /**
  36487. * Gets or sets the position of the debug canvas
  36488. * @ignorenaming
  36489. */
  36490. DEBUGCANVASPOS: {
  36491. x: number;
  36492. y: number;
  36493. };
  36494. /**
  36495. * Gets or sets the debug canvas size
  36496. * @ignorenaming
  36497. */
  36498. DEBUGCANVASSIZE: {
  36499. width: number;
  36500. height: number;
  36501. };
  36502. private _byteFreqs;
  36503. private _byteTime;
  36504. private _floatFreqs;
  36505. private _webAudioAnalyser;
  36506. private _debugCanvas;
  36507. private _debugCanvasContext;
  36508. private _scene;
  36509. private _registerFunc;
  36510. private _audioEngine;
  36511. /**
  36512. * Creates a new analyser
  36513. * @param scene defines hosting scene
  36514. */
  36515. constructor(scene: Scene);
  36516. /**
  36517. * Get the number of data values you will have to play with for the visualization
  36518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36519. * @returns a number
  36520. */
  36521. getFrequencyBinCount(): number;
  36522. /**
  36523. * Gets the current frequency data as a byte array
  36524. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36525. * @returns a Uint8Array
  36526. */
  36527. getByteFrequencyData(): Uint8Array;
  36528. /**
  36529. * Gets the current waveform as a byte array
  36530. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36531. * @returns a Uint8Array
  36532. */
  36533. getByteTimeDomainData(): Uint8Array;
  36534. /**
  36535. * Gets the current frequency data as a float array
  36536. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36537. * @returns a Float32Array
  36538. */
  36539. getFloatFrequencyData(): Float32Array;
  36540. /**
  36541. * Renders the debug canvas
  36542. */
  36543. drawDebugCanvas(): void;
  36544. /**
  36545. * Stops rendering the debug canvas and removes it
  36546. */
  36547. stopDebugCanvas(): void;
  36548. /**
  36549. * Connects two audio nodes
  36550. * @param inputAudioNode defines first node to connect
  36551. * @param outputAudioNode defines second node to connect
  36552. */
  36553. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36554. /**
  36555. * Releases all associated resources
  36556. */
  36557. dispose(): void;
  36558. }
  36559. }
  36560. declare module BABYLON {
  36561. /**
  36562. * This represents an audio engine and it is responsible
  36563. * to play, synchronize and analyse sounds throughout the application.
  36564. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36565. */
  36566. export interface IAudioEngine extends IDisposable {
  36567. /**
  36568. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36569. */
  36570. readonly canUseWebAudio: boolean;
  36571. /**
  36572. * Gets the current AudioContext if available.
  36573. */
  36574. readonly audioContext: Nullable<AudioContext>;
  36575. /**
  36576. * The master gain node defines the global audio volume of your audio engine.
  36577. */
  36578. readonly masterGain: GainNode;
  36579. /**
  36580. * Gets whether or not mp3 are supported by your browser.
  36581. */
  36582. readonly isMP3supported: boolean;
  36583. /**
  36584. * Gets whether or not ogg are supported by your browser.
  36585. */
  36586. readonly isOGGsupported: boolean;
  36587. /**
  36588. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36589. * @ignoreNaming
  36590. */
  36591. WarnedWebAudioUnsupported: boolean;
  36592. /**
  36593. * Defines if the audio engine relies on a custom unlocked button.
  36594. * In this case, the embedded button will not be displayed.
  36595. */
  36596. useCustomUnlockedButton: boolean;
  36597. /**
  36598. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36599. */
  36600. readonly unlocked: boolean;
  36601. /**
  36602. * Event raised when audio has been unlocked on the browser.
  36603. */
  36604. onAudioUnlockedObservable: Observable<AudioEngine>;
  36605. /**
  36606. * Event raised when audio has been locked on the browser.
  36607. */
  36608. onAudioLockedObservable: Observable<AudioEngine>;
  36609. /**
  36610. * Flags the audio engine in Locked state.
  36611. * This happens due to new browser policies preventing audio to autoplay.
  36612. */
  36613. lock(): void;
  36614. /**
  36615. * Unlocks the audio engine once a user action has been done on the dom.
  36616. * This is helpful to resume play once browser policies have been satisfied.
  36617. */
  36618. unlock(): void;
  36619. /**
  36620. * Gets the global volume sets on the master gain.
  36621. * @returns the global volume if set or -1 otherwise
  36622. */
  36623. getGlobalVolume(): number;
  36624. /**
  36625. * Sets the global volume of your experience (sets on the master gain).
  36626. * @param newVolume Defines the new global volume of the application
  36627. */
  36628. setGlobalVolume(newVolume: number): void;
  36629. /**
  36630. * Connect the audio engine to an audio analyser allowing some amazing
  36631. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36633. * @param analyser The analyser to connect to the engine
  36634. */
  36635. connectToAnalyser(analyser: Analyser): void;
  36636. }
  36637. /**
  36638. * This represents the default audio engine used in babylon.
  36639. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36641. */
  36642. export class AudioEngine implements IAudioEngine {
  36643. private _audioContext;
  36644. private _audioContextInitialized;
  36645. private _muteButton;
  36646. private _hostElement;
  36647. /**
  36648. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36649. */
  36650. canUseWebAudio: boolean;
  36651. /**
  36652. * The master gain node defines the global audio volume of your audio engine.
  36653. */
  36654. masterGain: GainNode;
  36655. /**
  36656. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36657. * @ignoreNaming
  36658. */
  36659. WarnedWebAudioUnsupported: boolean;
  36660. /**
  36661. * Gets whether or not mp3 are supported by your browser.
  36662. */
  36663. isMP3supported: boolean;
  36664. /**
  36665. * Gets whether or not ogg are supported by your browser.
  36666. */
  36667. isOGGsupported: boolean;
  36668. /**
  36669. * Gets whether audio has been unlocked on the device.
  36670. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36671. * a user interaction has happened.
  36672. */
  36673. unlocked: boolean;
  36674. /**
  36675. * Defines if the audio engine relies on a custom unlocked button.
  36676. * In this case, the embedded button will not be displayed.
  36677. */
  36678. useCustomUnlockedButton: boolean;
  36679. /**
  36680. * Event raised when audio has been unlocked on the browser.
  36681. */
  36682. onAudioUnlockedObservable: Observable<AudioEngine>;
  36683. /**
  36684. * Event raised when audio has been locked on the browser.
  36685. */
  36686. onAudioLockedObservable: Observable<AudioEngine>;
  36687. /**
  36688. * Gets the current AudioContext if available.
  36689. */
  36690. get audioContext(): Nullable<AudioContext>;
  36691. private _connectedAnalyser;
  36692. /**
  36693. * Instantiates a new audio engine.
  36694. *
  36695. * There should be only one per page as some browsers restrict the number
  36696. * of audio contexts you can create.
  36697. * @param hostElement defines the host element where to display the mute icon if necessary
  36698. */
  36699. constructor(hostElement?: Nullable<HTMLElement>);
  36700. /**
  36701. * Flags the audio engine in Locked state.
  36702. * This happens due to new browser policies preventing audio to autoplay.
  36703. */
  36704. lock(): void;
  36705. /**
  36706. * Unlocks the audio engine once a user action has been done on the dom.
  36707. * This is helpful to resume play once browser policies have been satisfied.
  36708. */
  36709. unlock(): void;
  36710. private _resumeAudioContext;
  36711. private _initializeAudioContext;
  36712. private _tryToRun;
  36713. private _triggerRunningState;
  36714. private _triggerSuspendedState;
  36715. private _displayMuteButton;
  36716. private _moveButtonToTopLeft;
  36717. private _onResize;
  36718. private _hideMuteButton;
  36719. /**
  36720. * Destroy and release the resources associated with the audio ccontext.
  36721. */
  36722. dispose(): void;
  36723. /**
  36724. * Gets the global volume sets on the master gain.
  36725. * @returns the global volume if set or -1 otherwise
  36726. */
  36727. getGlobalVolume(): number;
  36728. /**
  36729. * Sets the global volume of your experience (sets on the master gain).
  36730. * @param newVolume Defines the new global volume of the application
  36731. */
  36732. setGlobalVolume(newVolume: number): void;
  36733. /**
  36734. * Connect the audio engine to an audio analyser allowing some amazing
  36735. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36736. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36737. * @param analyser The analyser to connect to the engine
  36738. */
  36739. connectToAnalyser(analyser: Analyser): void;
  36740. }
  36741. }
  36742. declare module BABYLON {
  36743. /**
  36744. * Interface used to present a loading screen while loading a scene
  36745. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36746. */
  36747. export interface ILoadingScreen {
  36748. /**
  36749. * Function called to display the loading screen
  36750. */
  36751. displayLoadingUI: () => void;
  36752. /**
  36753. * Function called to hide the loading screen
  36754. */
  36755. hideLoadingUI: () => void;
  36756. /**
  36757. * Gets or sets the color to use for the background
  36758. */
  36759. loadingUIBackgroundColor: string;
  36760. /**
  36761. * Gets or sets the text to display while loading
  36762. */
  36763. loadingUIText: string;
  36764. }
  36765. /**
  36766. * Class used for the default loading screen
  36767. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36768. */
  36769. export class DefaultLoadingScreen implements ILoadingScreen {
  36770. private _renderingCanvas;
  36771. private _loadingText;
  36772. private _loadingDivBackgroundColor;
  36773. private _loadingDiv;
  36774. private _loadingTextDiv;
  36775. /** Gets or sets the logo url to use for the default loading screen */
  36776. static DefaultLogoUrl: string;
  36777. /** Gets or sets the spinner url to use for the default loading screen */
  36778. static DefaultSpinnerUrl: string;
  36779. /**
  36780. * Creates a new default loading screen
  36781. * @param _renderingCanvas defines the canvas used to render the scene
  36782. * @param _loadingText defines the default text to display
  36783. * @param _loadingDivBackgroundColor defines the default background color
  36784. */
  36785. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36786. /**
  36787. * Function called to display the loading screen
  36788. */
  36789. displayLoadingUI(): void;
  36790. /**
  36791. * Function called to hide the loading screen
  36792. */
  36793. hideLoadingUI(): void;
  36794. /**
  36795. * Gets or sets the text to display while loading
  36796. */
  36797. set loadingUIText(text: string);
  36798. get loadingUIText(): string;
  36799. /**
  36800. * Gets or sets the color to use for the background
  36801. */
  36802. get loadingUIBackgroundColor(): string;
  36803. set loadingUIBackgroundColor(color: string);
  36804. private _resizeLoadingUI;
  36805. }
  36806. }
  36807. declare module BABYLON {
  36808. /**
  36809. * Interface for any object that can request an animation frame
  36810. */
  36811. export interface ICustomAnimationFrameRequester {
  36812. /**
  36813. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36814. */
  36815. renderFunction?: Function;
  36816. /**
  36817. * Called to request the next frame to render to
  36818. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36819. */
  36820. requestAnimationFrame: Function;
  36821. /**
  36822. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36823. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36824. */
  36825. requestID?: number;
  36826. }
  36827. }
  36828. declare module BABYLON {
  36829. /**
  36830. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36831. */
  36832. export class PerformanceMonitor {
  36833. private _enabled;
  36834. private _rollingFrameTime;
  36835. private _lastFrameTimeMs;
  36836. /**
  36837. * constructor
  36838. * @param frameSampleSize The number of samples required to saturate the sliding window
  36839. */
  36840. constructor(frameSampleSize?: number);
  36841. /**
  36842. * Samples current frame
  36843. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36844. */
  36845. sampleFrame(timeMs?: number): void;
  36846. /**
  36847. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36848. */
  36849. get averageFrameTime(): number;
  36850. /**
  36851. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36852. */
  36853. get averageFrameTimeVariance(): number;
  36854. /**
  36855. * Returns the frame time of the most recent frame
  36856. */
  36857. get instantaneousFrameTime(): number;
  36858. /**
  36859. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36860. */
  36861. get averageFPS(): number;
  36862. /**
  36863. * Returns the average framerate in frames per second using the most recent frame time
  36864. */
  36865. get instantaneousFPS(): number;
  36866. /**
  36867. * Returns true if enough samples have been taken to completely fill the sliding window
  36868. */
  36869. get isSaturated(): boolean;
  36870. /**
  36871. * Enables contributions to the sliding window sample set
  36872. */
  36873. enable(): void;
  36874. /**
  36875. * Disables contributions to the sliding window sample set
  36876. * Samples will not be interpolated over the disabled period
  36877. */
  36878. disable(): void;
  36879. /**
  36880. * Returns true if sampling is enabled
  36881. */
  36882. get isEnabled(): boolean;
  36883. /**
  36884. * Resets performance monitor
  36885. */
  36886. reset(): void;
  36887. }
  36888. /**
  36889. * RollingAverage
  36890. *
  36891. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36892. */
  36893. export class RollingAverage {
  36894. /**
  36895. * Current average
  36896. */
  36897. average: number;
  36898. /**
  36899. * Current variance
  36900. */
  36901. variance: number;
  36902. protected _samples: Array<number>;
  36903. protected _sampleCount: number;
  36904. protected _pos: number;
  36905. protected _m2: number;
  36906. /**
  36907. * constructor
  36908. * @param length The number of samples required to saturate the sliding window
  36909. */
  36910. constructor(length: number);
  36911. /**
  36912. * Adds a sample to the sample set
  36913. * @param v The sample value
  36914. */
  36915. add(v: number): void;
  36916. /**
  36917. * Returns previously added values or null if outside of history or outside the sliding window domain
  36918. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36919. * @return Value previously recorded with add() or null if outside of range
  36920. */
  36921. history(i: number): number;
  36922. /**
  36923. * Returns true if enough samples have been taken to completely fill the sliding window
  36924. * @return true if sample-set saturated
  36925. */
  36926. isSaturated(): boolean;
  36927. /**
  36928. * Resets the rolling average (equivalent to 0 samples taken so far)
  36929. */
  36930. reset(): void;
  36931. /**
  36932. * Wraps a value around the sample range boundaries
  36933. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36934. * @return Wrapped position in sample range
  36935. */
  36936. protected _wrapPosition(i: number): number;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * This class is used to track a performance counter which is number based.
  36942. * The user has access to many properties which give statistics of different nature.
  36943. *
  36944. * The implementer can track two kinds of Performance Counter: time and count.
  36945. * 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.
  36946. * 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.
  36947. */
  36948. export class PerfCounter {
  36949. /**
  36950. * Gets or sets a global boolean to turn on and off all the counters
  36951. */
  36952. static Enabled: boolean;
  36953. /**
  36954. * Returns the smallest value ever
  36955. */
  36956. get min(): number;
  36957. /**
  36958. * Returns the biggest value ever
  36959. */
  36960. get max(): number;
  36961. /**
  36962. * Returns the average value since the performance counter is running
  36963. */
  36964. get average(): number;
  36965. /**
  36966. * Returns the average value of the last second the counter was monitored
  36967. */
  36968. get lastSecAverage(): number;
  36969. /**
  36970. * Returns the current value
  36971. */
  36972. get current(): number;
  36973. /**
  36974. * Gets the accumulated total
  36975. */
  36976. get total(): number;
  36977. /**
  36978. * Gets the total value count
  36979. */
  36980. get count(): number;
  36981. /**
  36982. * Creates a new counter
  36983. */
  36984. constructor();
  36985. /**
  36986. * Call this method to start monitoring a new frame.
  36987. * 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.
  36988. */
  36989. fetchNewFrame(): void;
  36990. /**
  36991. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36992. * @param newCount the count value to add to the monitored count
  36993. * @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.
  36994. */
  36995. addCount(newCount: number, fetchResult: boolean): void;
  36996. /**
  36997. * Start monitoring this performance counter
  36998. */
  36999. beginMonitoring(): void;
  37000. /**
  37001. * Compute the time lapsed since the previous beginMonitoring() call.
  37002. * @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
  37003. */
  37004. endMonitoring(newFrame?: boolean): void;
  37005. private _fetchResult;
  37006. private _startMonitoringTime;
  37007. private _min;
  37008. private _max;
  37009. private _average;
  37010. private _current;
  37011. private _totalValueCount;
  37012. private _totalAccumulated;
  37013. private _lastSecAverage;
  37014. private _lastSecAccumulated;
  37015. private _lastSecTime;
  37016. private _lastSecValueCount;
  37017. }
  37018. }
  37019. declare module BABYLON {
  37020. interface ThinEngine {
  37021. /**
  37022. * Sets alpha constants used by some alpha blending modes
  37023. * @param r defines the red component
  37024. * @param g defines the green component
  37025. * @param b defines the blue component
  37026. * @param a defines the alpha component
  37027. */
  37028. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37029. /**
  37030. * Sets the current alpha mode
  37031. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37032. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37033. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37034. */
  37035. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37036. /**
  37037. * Gets the current alpha mode
  37038. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37039. * @returns the current alpha mode
  37040. */
  37041. getAlphaMode(): number;
  37042. /**
  37043. * Sets the current alpha equation
  37044. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37045. */
  37046. setAlphaEquation(equation: number): void;
  37047. /**
  37048. * Gets the current alpha equation.
  37049. * @returns the current alpha equation
  37050. */
  37051. getAlphaEquation(): number;
  37052. }
  37053. }
  37054. declare module BABYLON {
  37055. interface ThinEngine {
  37056. /** @hidden */
  37057. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37058. }
  37059. }
  37060. declare module BABYLON {
  37061. /**
  37062. * Defines the interface used by display changed events
  37063. */
  37064. export interface IDisplayChangedEventArgs {
  37065. /** Gets the vrDisplay object (if any) */
  37066. vrDisplay: Nullable<any>;
  37067. /** Gets a boolean indicating if webVR is supported */
  37068. vrSupported: boolean;
  37069. }
  37070. /**
  37071. * Defines the interface used by objects containing a viewport (like a camera)
  37072. */
  37073. interface IViewportOwnerLike {
  37074. /**
  37075. * Gets or sets the viewport
  37076. */
  37077. viewport: IViewportLike;
  37078. }
  37079. /**
  37080. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37081. */
  37082. export class Engine extends ThinEngine {
  37083. /** Defines that alpha blending is disabled */
  37084. static readonly ALPHA_DISABLE: number;
  37085. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37086. static readonly ALPHA_ADD: number;
  37087. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37088. static readonly ALPHA_COMBINE: number;
  37089. /** Defines that alpha blending to DEST - SRC * DEST */
  37090. static readonly ALPHA_SUBTRACT: number;
  37091. /** Defines that alpha blending to SRC * DEST */
  37092. static readonly ALPHA_MULTIPLY: number;
  37093. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37094. static readonly ALPHA_MAXIMIZED: number;
  37095. /** Defines that alpha blending to SRC + DEST */
  37096. static readonly ALPHA_ONEONE: number;
  37097. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37098. static readonly ALPHA_PREMULTIPLIED: number;
  37099. /**
  37100. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37101. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37102. */
  37103. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37104. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37105. static readonly ALPHA_INTERPOLATE: number;
  37106. /**
  37107. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37108. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37109. */
  37110. static readonly ALPHA_SCREENMODE: number;
  37111. /** Defines that the ressource is not delayed*/
  37112. static readonly DELAYLOADSTATE_NONE: number;
  37113. /** Defines that the ressource was successfully delay loaded */
  37114. static readonly DELAYLOADSTATE_LOADED: number;
  37115. /** Defines that the ressource is currently delay loading */
  37116. static readonly DELAYLOADSTATE_LOADING: number;
  37117. /** Defines that the ressource is delayed and has not started loading */
  37118. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37119. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37120. static readonly NEVER: number;
  37121. /** 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 */
  37122. static readonly ALWAYS: number;
  37123. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37124. static readonly LESS: number;
  37125. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37126. static readonly EQUAL: number;
  37127. /** 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 */
  37128. static readonly LEQUAL: number;
  37129. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37130. static readonly GREATER: number;
  37131. /** 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 */
  37132. static readonly GEQUAL: number;
  37133. /** 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 */
  37134. static readonly NOTEQUAL: number;
  37135. /** Passed to stencilOperation to specify that stencil value must be kept */
  37136. static readonly KEEP: number;
  37137. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37138. static readonly REPLACE: number;
  37139. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37140. static readonly INCR: number;
  37141. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37142. static readonly DECR: number;
  37143. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37144. static readonly INVERT: number;
  37145. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37146. static readonly INCR_WRAP: number;
  37147. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37148. static readonly DECR_WRAP: number;
  37149. /** Texture is not repeating outside of 0..1 UVs */
  37150. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37151. /** Texture is repeating outside of 0..1 UVs */
  37152. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37153. /** Texture is repeating and mirrored */
  37154. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37155. /** ALPHA */
  37156. static readonly TEXTUREFORMAT_ALPHA: number;
  37157. /** LUMINANCE */
  37158. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37159. /** LUMINANCE_ALPHA */
  37160. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37161. /** RGB */
  37162. static readonly TEXTUREFORMAT_RGB: number;
  37163. /** RGBA */
  37164. static readonly TEXTUREFORMAT_RGBA: number;
  37165. /** RED */
  37166. static readonly TEXTUREFORMAT_RED: number;
  37167. /** RED (2nd reference) */
  37168. static readonly TEXTUREFORMAT_R: number;
  37169. /** RG */
  37170. static readonly TEXTUREFORMAT_RG: number;
  37171. /** RED_INTEGER */
  37172. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37173. /** RED_INTEGER (2nd reference) */
  37174. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37175. /** RG_INTEGER */
  37176. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37177. /** RGB_INTEGER */
  37178. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37179. /** RGBA_INTEGER */
  37180. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37181. /** UNSIGNED_BYTE */
  37182. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37183. /** UNSIGNED_BYTE (2nd reference) */
  37184. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37185. /** FLOAT */
  37186. static readonly TEXTURETYPE_FLOAT: number;
  37187. /** HALF_FLOAT */
  37188. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37189. /** BYTE */
  37190. static readonly TEXTURETYPE_BYTE: number;
  37191. /** SHORT */
  37192. static readonly TEXTURETYPE_SHORT: number;
  37193. /** UNSIGNED_SHORT */
  37194. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37195. /** INT */
  37196. static readonly TEXTURETYPE_INT: number;
  37197. /** UNSIGNED_INT */
  37198. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37199. /** UNSIGNED_SHORT_4_4_4_4 */
  37200. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37201. /** UNSIGNED_SHORT_5_5_5_1 */
  37202. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37203. /** UNSIGNED_SHORT_5_6_5 */
  37204. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37205. /** UNSIGNED_INT_2_10_10_10_REV */
  37206. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37207. /** UNSIGNED_INT_24_8 */
  37208. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37209. /** UNSIGNED_INT_10F_11F_11F_REV */
  37210. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37211. /** UNSIGNED_INT_5_9_9_9_REV */
  37212. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37213. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37214. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37215. /** nearest is mag = nearest and min = nearest and mip = linear */
  37216. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37217. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37218. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37219. /** Trilinear is mag = linear and min = linear and mip = linear */
  37220. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37221. /** nearest is mag = nearest and min = nearest and mip = linear */
  37222. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37223. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37224. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37225. /** Trilinear is mag = linear and min = linear and mip = linear */
  37226. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37227. /** mag = nearest and min = nearest and mip = nearest */
  37228. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37229. /** mag = nearest and min = linear and mip = nearest */
  37230. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37231. /** mag = nearest and min = linear and mip = linear */
  37232. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37233. /** mag = nearest and min = linear and mip = none */
  37234. static readonly TEXTURE_NEAREST_LINEAR: number;
  37235. /** mag = nearest and min = nearest and mip = none */
  37236. static readonly TEXTURE_NEAREST_NEAREST: number;
  37237. /** mag = linear and min = nearest and mip = nearest */
  37238. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37239. /** mag = linear and min = nearest and mip = linear */
  37240. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37241. /** mag = linear and min = linear and mip = none */
  37242. static readonly TEXTURE_LINEAR_LINEAR: number;
  37243. /** mag = linear and min = nearest and mip = none */
  37244. static readonly TEXTURE_LINEAR_NEAREST: number;
  37245. /** Explicit coordinates mode */
  37246. static readonly TEXTURE_EXPLICIT_MODE: number;
  37247. /** Spherical coordinates mode */
  37248. static readonly TEXTURE_SPHERICAL_MODE: number;
  37249. /** Planar coordinates mode */
  37250. static readonly TEXTURE_PLANAR_MODE: number;
  37251. /** Cubic coordinates mode */
  37252. static readonly TEXTURE_CUBIC_MODE: number;
  37253. /** Projection coordinates mode */
  37254. static readonly TEXTURE_PROJECTION_MODE: number;
  37255. /** Skybox coordinates mode */
  37256. static readonly TEXTURE_SKYBOX_MODE: number;
  37257. /** Inverse Cubic coordinates mode */
  37258. static readonly TEXTURE_INVCUBIC_MODE: number;
  37259. /** Equirectangular coordinates mode */
  37260. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37261. /** Equirectangular Fixed coordinates mode */
  37262. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37263. /** Equirectangular Fixed Mirrored coordinates mode */
  37264. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37265. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37266. static readonly SCALEMODE_FLOOR: number;
  37267. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37268. static readonly SCALEMODE_NEAREST: number;
  37269. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37270. static readonly SCALEMODE_CEILING: number;
  37271. /**
  37272. * Returns the current npm package of the sdk
  37273. */
  37274. static get NpmPackage(): string;
  37275. /**
  37276. * Returns the current version of the framework
  37277. */
  37278. static get Version(): string;
  37279. /** Gets the list of created engines */
  37280. static get Instances(): Engine[];
  37281. /**
  37282. * Gets the latest created engine
  37283. */
  37284. static get LastCreatedEngine(): Nullable<Engine>;
  37285. /**
  37286. * Gets the latest created scene
  37287. */
  37288. static get LastCreatedScene(): Nullable<Scene>;
  37289. /**
  37290. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37291. * @param flag defines which part of the materials must be marked as dirty
  37292. * @param predicate defines a predicate used to filter which materials should be affected
  37293. */
  37294. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37295. /**
  37296. * Method called to create the default loading screen.
  37297. * This can be overriden in your own app.
  37298. * @param canvas The rendering canvas element
  37299. * @returns The loading screen
  37300. */
  37301. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37302. /**
  37303. * Method called to create the default rescale post process on each engine.
  37304. */
  37305. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37306. /**
  37307. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37308. **/
  37309. enableOfflineSupport: boolean;
  37310. /**
  37311. * 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)
  37312. **/
  37313. disableManifestCheck: boolean;
  37314. /**
  37315. * Gets the list of created scenes
  37316. */
  37317. scenes: Scene[];
  37318. /**
  37319. * Event raised when a new scene is created
  37320. */
  37321. onNewSceneAddedObservable: Observable<Scene>;
  37322. /**
  37323. * Gets the list of created postprocesses
  37324. */
  37325. postProcesses: PostProcess[];
  37326. /**
  37327. * Gets a boolean indicating if the pointer is currently locked
  37328. */
  37329. isPointerLock: boolean;
  37330. /**
  37331. * Observable event triggered each time the rendering canvas is resized
  37332. */
  37333. onResizeObservable: Observable<Engine>;
  37334. /**
  37335. * Observable event triggered each time the canvas loses focus
  37336. */
  37337. onCanvasBlurObservable: Observable<Engine>;
  37338. /**
  37339. * Observable event triggered each time the canvas gains focus
  37340. */
  37341. onCanvasFocusObservable: Observable<Engine>;
  37342. /**
  37343. * Observable event triggered each time the canvas receives pointerout event
  37344. */
  37345. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37346. /**
  37347. * Observable raised when the engine begins a new frame
  37348. */
  37349. onBeginFrameObservable: Observable<Engine>;
  37350. /**
  37351. * If set, will be used to request the next animation frame for the render loop
  37352. */
  37353. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37354. /**
  37355. * Observable raised when the engine ends the current frame
  37356. */
  37357. onEndFrameObservable: Observable<Engine>;
  37358. /**
  37359. * Observable raised when the engine is about to compile a shader
  37360. */
  37361. onBeforeShaderCompilationObservable: Observable<Engine>;
  37362. /**
  37363. * Observable raised when the engine has jsut compiled a shader
  37364. */
  37365. onAfterShaderCompilationObservable: Observable<Engine>;
  37366. /**
  37367. * Gets the audio engine
  37368. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37369. * @ignorenaming
  37370. */
  37371. static audioEngine: IAudioEngine;
  37372. /**
  37373. * Default AudioEngine factory responsible of creating the Audio Engine.
  37374. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37375. */
  37376. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37377. /**
  37378. * Default offline support factory responsible of creating a tool used to store data locally.
  37379. * By default, this will create a Database object if the workload has been embedded.
  37380. */
  37381. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37382. private _loadingScreen;
  37383. private _pointerLockRequested;
  37384. private _rescalePostProcess;
  37385. private _deterministicLockstep;
  37386. private _lockstepMaxSteps;
  37387. private _timeStep;
  37388. protected get _supportsHardwareTextureRescaling(): boolean;
  37389. private _fps;
  37390. private _deltaTime;
  37391. /** @hidden */
  37392. _drawCalls: PerfCounter;
  37393. /** 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 */
  37394. canvasTabIndex: number;
  37395. /**
  37396. * Turn this value on if you want to pause FPS computation when in background
  37397. */
  37398. disablePerformanceMonitorInBackground: boolean;
  37399. private _performanceMonitor;
  37400. /**
  37401. * Gets the performance monitor attached to this engine
  37402. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37403. */
  37404. get performanceMonitor(): PerformanceMonitor;
  37405. private _onFocus;
  37406. private _onBlur;
  37407. private _onCanvasPointerOut;
  37408. private _onCanvasBlur;
  37409. private _onCanvasFocus;
  37410. private _onFullscreenChange;
  37411. private _onPointerLockChange;
  37412. /**
  37413. * Gets the HTML element used to attach event listeners
  37414. * @returns a HTML element
  37415. */
  37416. getInputElement(): Nullable<HTMLElement>;
  37417. /**
  37418. * Creates a new engine
  37419. * @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
  37420. * @param antialias defines enable antialiasing (default: false)
  37421. * @param options defines further options to be sent to the getContext() function
  37422. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37423. */
  37424. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37425. /**
  37426. * Gets current aspect ratio
  37427. * @param viewportOwner defines the camera to use to get the aspect ratio
  37428. * @param useScreen defines if screen size must be used (or the current render target if any)
  37429. * @returns a number defining the aspect ratio
  37430. */
  37431. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37432. /**
  37433. * Gets current screen aspect ratio
  37434. * @returns a number defining the aspect ratio
  37435. */
  37436. getScreenAspectRatio(): number;
  37437. /**
  37438. * Gets the client rect of the HTML canvas attached with the current webGL context
  37439. * @returns a client rectanglee
  37440. */
  37441. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37442. /**
  37443. * Gets the client rect of the HTML element used for events
  37444. * @returns a client rectanglee
  37445. */
  37446. getInputElementClientRect(): Nullable<ClientRect>;
  37447. /**
  37448. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37449. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37450. * @returns true if engine is in deterministic lock step mode
  37451. */
  37452. isDeterministicLockStep(): boolean;
  37453. /**
  37454. * Gets the max steps when engine is running in deterministic lock step
  37455. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37456. * @returns the max steps
  37457. */
  37458. getLockstepMaxSteps(): number;
  37459. /**
  37460. * Returns the time in ms between steps when using deterministic lock step.
  37461. * @returns time step in (ms)
  37462. */
  37463. getTimeStep(): number;
  37464. /**
  37465. * Force the mipmap generation for the given render target texture
  37466. * @param texture defines the render target texture to use
  37467. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37468. */
  37469. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37470. /** States */
  37471. /**
  37472. * Set various states to the webGL context
  37473. * @param culling defines backface culling state
  37474. * @param zOffset defines the value to apply to zOffset (0 by default)
  37475. * @param force defines if states must be applied even if cache is up to date
  37476. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37477. */
  37478. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37479. /**
  37480. * Set the z offset to apply to current rendering
  37481. * @param value defines the offset to apply
  37482. */
  37483. setZOffset(value: number): void;
  37484. /**
  37485. * Gets the current value of the zOffset
  37486. * @returns the current zOffset state
  37487. */
  37488. getZOffset(): number;
  37489. /**
  37490. * Enable or disable depth buffering
  37491. * @param enable defines the state to set
  37492. */
  37493. setDepthBuffer(enable: boolean): void;
  37494. /**
  37495. * Gets a boolean indicating if depth writing is enabled
  37496. * @returns the current depth writing state
  37497. */
  37498. getDepthWrite(): boolean;
  37499. /**
  37500. * Enable or disable depth writing
  37501. * @param enable defines the state to set
  37502. */
  37503. setDepthWrite(enable: boolean): void;
  37504. /**
  37505. * Gets a boolean indicating if stencil buffer is enabled
  37506. * @returns the current stencil buffer state
  37507. */
  37508. getStencilBuffer(): boolean;
  37509. /**
  37510. * Enable or disable the stencil buffer
  37511. * @param enable defines if the stencil buffer must be enabled or disabled
  37512. */
  37513. setStencilBuffer(enable: boolean): void;
  37514. /**
  37515. * Gets the current stencil mask
  37516. * @returns a number defining the new stencil mask to use
  37517. */
  37518. getStencilMask(): number;
  37519. /**
  37520. * Sets the current stencil mask
  37521. * @param mask defines the new stencil mask to use
  37522. */
  37523. setStencilMask(mask: number): void;
  37524. /**
  37525. * Gets the current stencil function
  37526. * @returns a number defining the stencil function to use
  37527. */
  37528. getStencilFunction(): number;
  37529. /**
  37530. * Gets the current stencil reference value
  37531. * @returns a number defining the stencil reference value to use
  37532. */
  37533. getStencilFunctionReference(): number;
  37534. /**
  37535. * Gets the current stencil mask
  37536. * @returns a number defining the stencil mask to use
  37537. */
  37538. getStencilFunctionMask(): number;
  37539. /**
  37540. * Sets the current stencil function
  37541. * @param stencilFunc defines the new stencil function to use
  37542. */
  37543. setStencilFunction(stencilFunc: number): void;
  37544. /**
  37545. * Sets the current stencil reference
  37546. * @param reference defines the new stencil reference to use
  37547. */
  37548. setStencilFunctionReference(reference: number): void;
  37549. /**
  37550. * Sets the current stencil mask
  37551. * @param mask defines the new stencil mask to use
  37552. */
  37553. setStencilFunctionMask(mask: number): void;
  37554. /**
  37555. * Gets the current stencil operation when stencil fails
  37556. * @returns a number defining stencil operation to use when stencil fails
  37557. */
  37558. getStencilOperationFail(): number;
  37559. /**
  37560. * Gets the current stencil operation when depth fails
  37561. * @returns a number defining stencil operation to use when depth fails
  37562. */
  37563. getStencilOperationDepthFail(): number;
  37564. /**
  37565. * Gets the current stencil operation when stencil passes
  37566. * @returns a number defining stencil operation to use when stencil passes
  37567. */
  37568. getStencilOperationPass(): number;
  37569. /**
  37570. * Sets the stencil operation to use when stencil fails
  37571. * @param operation defines the stencil operation to use when stencil fails
  37572. */
  37573. setStencilOperationFail(operation: number): void;
  37574. /**
  37575. * Sets the stencil operation to use when depth fails
  37576. * @param operation defines the stencil operation to use when depth fails
  37577. */
  37578. setStencilOperationDepthFail(operation: number): void;
  37579. /**
  37580. * Sets the stencil operation to use when stencil passes
  37581. * @param operation defines the stencil operation to use when stencil passes
  37582. */
  37583. setStencilOperationPass(operation: number): void;
  37584. /**
  37585. * Sets a boolean indicating if the dithering state is enabled or disabled
  37586. * @param value defines the dithering state
  37587. */
  37588. setDitheringState(value: boolean): void;
  37589. /**
  37590. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37591. * @param value defines the rasterizer state
  37592. */
  37593. setRasterizerState(value: boolean): void;
  37594. /**
  37595. * Gets the current depth function
  37596. * @returns a number defining the depth function
  37597. */
  37598. getDepthFunction(): Nullable<number>;
  37599. /**
  37600. * Sets the current depth function
  37601. * @param depthFunc defines the function to use
  37602. */
  37603. setDepthFunction(depthFunc: number): void;
  37604. /**
  37605. * Sets the current depth function to GREATER
  37606. */
  37607. setDepthFunctionToGreater(): void;
  37608. /**
  37609. * Sets the current depth function to GEQUAL
  37610. */
  37611. setDepthFunctionToGreaterOrEqual(): void;
  37612. /**
  37613. * Sets the current depth function to LESS
  37614. */
  37615. setDepthFunctionToLess(): void;
  37616. /**
  37617. * Sets the current depth function to LEQUAL
  37618. */
  37619. setDepthFunctionToLessOrEqual(): void;
  37620. private _cachedStencilBuffer;
  37621. private _cachedStencilFunction;
  37622. private _cachedStencilMask;
  37623. private _cachedStencilOperationPass;
  37624. private _cachedStencilOperationFail;
  37625. private _cachedStencilOperationDepthFail;
  37626. private _cachedStencilReference;
  37627. /**
  37628. * Caches the the state of the stencil buffer
  37629. */
  37630. cacheStencilState(): void;
  37631. /**
  37632. * Restores the state of the stencil buffer
  37633. */
  37634. restoreStencilState(): void;
  37635. /**
  37636. * Directly set the WebGL Viewport
  37637. * @param x defines the x coordinate of the viewport (in screen space)
  37638. * @param y defines the y coordinate of the viewport (in screen space)
  37639. * @param width defines the width of the viewport (in screen space)
  37640. * @param height defines the height of the viewport (in screen space)
  37641. * @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
  37642. */
  37643. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37644. /**
  37645. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37646. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37647. * @param y defines the y-coordinate of the corner of the clear rectangle
  37648. * @param width defines the width of the clear rectangle
  37649. * @param height defines the height of the clear rectangle
  37650. * @param clearColor defines the clear color
  37651. */
  37652. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37653. /**
  37654. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37655. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37656. * @param y defines the y-coordinate of the corner of the clear rectangle
  37657. * @param width defines the width of the clear rectangle
  37658. * @param height defines the height of the clear rectangle
  37659. */
  37660. enableScissor(x: number, y: number, width: number, height: number): void;
  37661. /**
  37662. * Disable previously set scissor test rectangle
  37663. */
  37664. disableScissor(): void;
  37665. protected _reportDrawCall(): void;
  37666. /**
  37667. * Initializes a webVR display and starts listening to display change events
  37668. * The onVRDisplayChangedObservable will be notified upon these changes
  37669. * @returns The onVRDisplayChangedObservable
  37670. */
  37671. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37672. /** @hidden */
  37673. _prepareVRComponent(): void;
  37674. /** @hidden */
  37675. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37676. /** @hidden */
  37677. _submitVRFrame(): void;
  37678. /**
  37679. * Call this function to leave webVR mode
  37680. * Will do nothing if webVR is not supported or if there is no webVR device
  37681. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37682. */
  37683. disableVR(): void;
  37684. /**
  37685. * Gets a boolean indicating that the system is in VR mode and is presenting
  37686. * @returns true if VR mode is engaged
  37687. */
  37688. isVRPresenting(): boolean;
  37689. /** @hidden */
  37690. _requestVRFrame(): void;
  37691. /** @hidden */
  37692. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37693. /**
  37694. * Gets the source code of the vertex shader associated with a specific webGL program
  37695. * @param program defines the program to use
  37696. * @returns a string containing the source code of the vertex shader associated with the program
  37697. */
  37698. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37699. /**
  37700. * Gets the source code of the fragment shader associated with a specific webGL program
  37701. * @param program defines the program to use
  37702. * @returns a string containing the source code of the fragment shader associated with the program
  37703. */
  37704. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37705. /**
  37706. * Sets a depth stencil texture from a render target to the according uniform.
  37707. * @param channel The texture channel
  37708. * @param uniform The uniform to set
  37709. * @param texture The render target texture containing the depth stencil texture to apply
  37710. */
  37711. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37712. /**
  37713. * Sets a texture to the webGL context from a postprocess
  37714. * @param channel defines the channel to use
  37715. * @param postProcess defines the source postprocess
  37716. */
  37717. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37718. /**
  37719. * Binds the output of the passed in post process to the texture channel specified
  37720. * @param channel The channel the texture should be bound to
  37721. * @param postProcess The post process which's output should be bound
  37722. */
  37723. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37724. protected _rebuildBuffers(): void;
  37725. /** @hidden */
  37726. _renderFrame(): void;
  37727. _renderLoop(): void;
  37728. /** @hidden */
  37729. _renderViews(): boolean;
  37730. /**
  37731. * Toggle full screen mode
  37732. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37733. */
  37734. switchFullscreen(requestPointerLock: boolean): void;
  37735. /**
  37736. * Enters full screen mode
  37737. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37738. */
  37739. enterFullscreen(requestPointerLock: boolean): void;
  37740. /**
  37741. * Exits full screen mode
  37742. */
  37743. exitFullscreen(): void;
  37744. /**
  37745. * Enters Pointerlock mode
  37746. */
  37747. enterPointerlock(): void;
  37748. /**
  37749. * Exits Pointerlock mode
  37750. */
  37751. exitPointerlock(): void;
  37752. /**
  37753. * Begin a new frame
  37754. */
  37755. beginFrame(): void;
  37756. /**
  37757. * Enf the current frame
  37758. */
  37759. endFrame(): void;
  37760. resize(): void;
  37761. /**
  37762. * Force a specific size of the canvas
  37763. * @param width defines the new canvas' width
  37764. * @param height defines the new canvas' height
  37765. * @returns true if the size was changed
  37766. */
  37767. setSize(width: number, height: number): boolean;
  37768. /**
  37769. * Updates a dynamic vertex buffer.
  37770. * @param vertexBuffer the vertex buffer to update
  37771. * @param data the data used to update the vertex buffer
  37772. * @param byteOffset the byte offset of the data
  37773. * @param byteLength the byte length of the data
  37774. */
  37775. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37776. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37777. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37778. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37779. _releaseTexture(texture: InternalTexture): void;
  37780. /**
  37781. * @hidden
  37782. * Rescales a texture
  37783. * @param source input texutre
  37784. * @param destination destination texture
  37785. * @param scene scene to use to render the resize
  37786. * @param internalFormat format to use when resizing
  37787. * @param onComplete callback to be called when resize has completed
  37788. */
  37789. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37790. /**
  37791. * Gets the current framerate
  37792. * @returns a number representing the framerate
  37793. */
  37794. getFps(): number;
  37795. /**
  37796. * Gets the time spent between current and previous frame
  37797. * @returns a number representing the delta time in ms
  37798. */
  37799. getDeltaTime(): number;
  37800. private _measureFps;
  37801. /** @hidden */
  37802. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37803. /**
  37804. * Update a dynamic index buffer
  37805. * @param indexBuffer defines the target index buffer
  37806. * @param indices defines the data to update
  37807. * @param offset defines the offset in the target index buffer where update should start
  37808. */
  37809. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37810. /**
  37811. * Updates the sample count of a render target texture
  37812. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37813. * @param texture defines the texture to update
  37814. * @param samples defines the sample count to set
  37815. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37816. */
  37817. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37818. /**
  37819. * Updates a depth texture Comparison Mode and Function.
  37820. * If the comparison Function is equal to 0, the mode will be set to none.
  37821. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37822. * @param texture The texture to set the comparison function for
  37823. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37824. */
  37825. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37826. /**
  37827. * Creates a webGL buffer to use with instanciation
  37828. * @param capacity defines the size of the buffer
  37829. * @returns the webGL buffer
  37830. */
  37831. createInstancesBuffer(capacity: number): DataBuffer;
  37832. /**
  37833. * Delete a webGL buffer used with instanciation
  37834. * @param buffer defines the webGL buffer to delete
  37835. */
  37836. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37837. private _clientWaitAsync;
  37838. /** @hidden */
  37839. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37840. dispose(): void;
  37841. private _disableTouchAction;
  37842. /**
  37843. * Display the loading screen
  37844. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37845. */
  37846. displayLoadingUI(): void;
  37847. /**
  37848. * Hide the loading screen
  37849. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37850. */
  37851. hideLoadingUI(): void;
  37852. /**
  37853. * Gets the current loading screen object
  37854. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37855. */
  37856. get loadingScreen(): ILoadingScreen;
  37857. /**
  37858. * Sets the current loading screen object
  37859. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37860. */
  37861. set loadingScreen(loadingScreen: ILoadingScreen);
  37862. /**
  37863. * Sets the current loading screen text
  37864. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37865. */
  37866. set loadingUIText(text: string);
  37867. /**
  37868. * Sets the current loading screen background color
  37869. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37870. */
  37871. set loadingUIBackgroundColor(color: string);
  37872. /** Pointerlock and fullscreen */
  37873. /**
  37874. * Ask the browser to promote the current element to pointerlock mode
  37875. * @param element defines the DOM element to promote
  37876. */
  37877. static _RequestPointerlock(element: HTMLElement): void;
  37878. /**
  37879. * Asks the browser to exit pointerlock mode
  37880. */
  37881. static _ExitPointerlock(): void;
  37882. /**
  37883. * Ask the browser to promote the current element to fullscreen rendering mode
  37884. * @param element defines the DOM element to promote
  37885. */
  37886. static _RequestFullscreen(element: HTMLElement): void;
  37887. /**
  37888. * Asks the browser to exit fullscreen mode
  37889. */
  37890. static _ExitFullscreen(): void;
  37891. }
  37892. }
  37893. declare module BABYLON {
  37894. /**
  37895. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37896. * during the life time of the application.
  37897. */
  37898. export class EngineStore {
  37899. /** Gets the list of created engines */
  37900. static Instances: Engine[];
  37901. /** @hidden */
  37902. static _LastCreatedScene: Nullable<Scene>;
  37903. /**
  37904. * Gets the latest created engine
  37905. */
  37906. static get LastCreatedEngine(): Nullable<Engine>;
  37907. /**
  37908. * Gets the latest created scene
  37909. */
  37910. static get LastCreatedScene(): Nullable<Scene>;
  37911. /**
  37912. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37913. * @ignorenaming
  37914. */
  37915. static UseFallbackTexture: boolean;
  37916. /**
  37917. * Texture content used if a texture cannot loaded
  37918. * @ignorenaming
  37919. */
  37920. static FallbackTexture: string;
  37921. }
  37922. }
  37923. declare module BABYLON {
  37924. /**
  37925. * Helper class that provides a small promise polyfill
  37926. */
  37927. export class PromisePolyfill {
  37928. /**
  37929. * Static function used to check if the polyfill is required
  37930. * If this is the case then the function will inject the polyfill to window.Promise
  37931. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37932. */
  37933. static Apply(force?: boolean): void;
  37934. }
  37935. }
  37936. declare module BABYLON {
  37937. /**
  37938. * Interface for screenshot methods with describe argument called `size` as object with options
  37939. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37940. */
  37941. export interface IScreenshotSize {
  37942. /**
  37943. * number in pixels for canvas height
  37944. */
  37945. height?: number;
  37946. /**
  37947. * multiplier allowing render at a higher or lower resolution
  37948. * If value is defined then height and width will be ignored and taken from camera
  37949. */
  37950. precision?: number;
  37951. /**
  37952. * number in pixels for canvas width
  37953. */
  37954. width?: number;
  37955. }
  37956. }
  37957. declare module BABYLON {
  37958. interface IColor4Like {
  37959. r: float;
  37960. g: float;
  37961. b: float;
  37962. a: float;
  37963. }
  37964. /**
  37965. * Class containing a set of static utilities functions
  37966. */
  37967. export class Tools {
  37968. /**
  37969. * Gets or sets the base URL to use to load assets
  37970. */
  37971. static get BaseUrl(): string;
  37972. static set BaseUrl(value: string);
  37973. /**
  37974. * Enable/Disable Custom HTTP Request Headers globally.
  37975. * default = false
  37976. * @see CustomRequestHeaders
  37977. */
  37978. static UseCustomRequestHeaders: boolean;
  37979. /**
  37980. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37981. * i.e. when loading files, where the server/service expects an Authorization header
  37982. */
  37983. static CustomRequestHeaders: {
  37984. [key: string]: string;
  37985. };
  37986. /**
  37987. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37988. */
  37989. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37990. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37991. /**
  37992. * Default behaviour for cors in the application.
  37993. * It can be a string if the expected behavior is identical in the entire app.
  37994. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37995. */
  37996. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37997. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37998. /**
  37999. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38000. * @ignorenaming
  38001. */
  38002. static get UseFallbackTexture(): boolean;
  38003. static set UseFallbackTexture(value: boolean);
  38004. /**
  38005. * Use this object to register external classes like custom textures or material
  38006. * to allow the laoders to instantiate them
  38007. */
  38008. static get RegisteredExternalClasses(): {
  38009. [key: string]: Object;
  38010. };
  38011. static set RegisteredExternalClasses(classes: {
  38012. [key: string]: Object;
  38013. });
  38014. /**
  38015. * Texture content used if a texture cannot loaded
  38016. * @ignorenaming
  38017. */
  38018. static get fallbackTexture(): string;
  38019. static set fallbackTexture(value: string);
  38020. /**
  38021. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38022. * @param u defines the coordinate on X axis
  38023. * @param v defines the coordinate on Y axis
  38024. * @param width defines the width of the source data
  38025. * @param height defines the height of the source data
  38026. * @param pixels defines the source byte array
  38027. * @param color defines the output color
  38028. */
  38029. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38030. /**
  38031. * Interpolates between a and b via alpha
  38032. * @param a The lower value (returned when alpha = 0)
  38033. * @param b The upper value (returned when alpha = 1)
  38034. * @param alpha The interpolation-factor
  38035. * @return The mixed value
  38036. */
  38037. static Mix(a: number, b: number, alpha: number): number;
  38038. /**
  38039. * Tries to instantiate a new object from a given class name
  38040. * @param className defines the class name to instantiate
  38041. * @returns the new object or null if the system was not able to do the instantiation
  38042. */
  38043. static Instantiate(className: string): any;
  38044. /**
  38045. * Provides a slice function that will work even on IE
  38046. * @param data defines the array to slice
  38047. * @param start defines the start of the data (optional)
  38048. * @param end defines the end of the data (optional)
  38049. * @returns the new sliced array
  38050. */
  38051. static Slice<T>(data: T, start?: number, end?: number): T;
  38052. /**
  38053. * Polyfill for setImmediate
  38054. * @param action defines the action to execute after the current execution block
  38055. */
  38056. static SetImmediate(action: () => void): void;
  38057. /**
  38058. * Function indicating if a number is an exponent of 2
  38059. * @param value defines the value to test
  38060. * @returns true if the value is an exponent of 2
  38061. */
  38062. static IsExponentOfTwo(value: number): boolean;
  38063. private static _tmpFloatArray;
  38064. /**
  38065. * Returns the nearest 32-bit single precision float representation of a Number
  38066. * @param value A Number. If the parameter is of a different type, it will get converted
  38067. * to a number or to NaN if it cannot be converted
  38068. * @returns number
  38069. */
  38070. static FloatRound(value: number): number;
  38071. /**
  38072. * Extracts the filename from a path
  38073. * @param path defines the path to use
  38074. * @returns the filename
  38075. */
  38076. static GetFilename(path: string): string;
  38077. /**
  38078. * Extracts the "folder" part of a path (everything before the filename).
  38079. * @param uri The URI to extract the info from
  38080. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38081. * @returns The "folder" part of the path
  38082. */
  38083. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38084. /**
  38085. * Extracts text content from a DOM element hierarchy
  38086. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38087. */
  38088. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38089. /**
  38090. * Convert an angle in radians to degrees
  38091. * @param angle defines the angle to convert
  38092. * @returns the angle in degrees
  38093. */
  38094. static ToDegrees(angle: number): number;
  38095. /**
  38096. * Convert an angle in degrees to radians
  38097. * @param angle defines the angle to convert
  38098. * @returns the angle in radians
  38099. */
  38100. static ToRadians(angle: number): number;
  38101. /**
  38102. * Returns an array if obj is not an array
  38103. * @param obj defines the object to evaluate as an array
  38104. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38105. * @returns either obj directly if obj is an array or a new array containing obj
  38106. */
  38107. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38108. /**
  38109. * Gets the pointer prefix to use
  38110. * @param engine defines the engine we are finding the prefix for
  38111. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38112. */
  38113. static GetPointerPrefix(engine: Engine): string;
  38114. /**
  38115. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38116. * @param url define the url we are trying
  38117. * @param element define the dom element where to configure the cors policy
  38118. */
  38119. static SetCorsBehavior(url: string | string[], element: {
  38120. crossOrigin: string | null;
  38121. }): void;
  38122. /**
  38123. * Removes unwanted characters from an url
  38124. * @param url defines the url to clean
  38125. * @returns the cleaned url
  38126. */
  38127. static CleanUrl(url: string): string;
  38128. /**
  38129. * Gets or sets a function used to pre-process url before using them to load assets
  38130. */
  38131. static get PreprocessUrl(): (url: string) => string;
  38132. static set PreprocessUrl(processor: (url: string) => string);
  38133. /**
  38134. * Loads an image as an HTMLImageElement.
  38135. * @param input url string, ArrayBuffer, or Blob to load
  38136. * @param onLoad callback called when the image successfully loads
  38137. * @param onError callback called when the image fails to load
  38138. * @param offlineProvider offline provider for caching
  38139. * @param mimeType optional mime type
  38140. * @returns the HTMLImageElement of the loaded image
  38141. */
  38142. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38143. /**
  38144. * Loads a file from a url
  38145. * @param url url string, ArrayBuffer, or Blob to load
  38146. * @param onSuccess callback called when the file successfully loads
  38147. * @param onProgress callback called while file is loading (if the server supports this mode)
  38148. * @param offlineProvider defines the offline provider for caching
  38149. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38150. * @param onError callback called when the file fails to load
  38151. * @returns a file request object
  38152. */
  38153. 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;
  38154. /**
  38155. * Loads a file from a url
  38156. * @param url the file url to load
  38157. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38158. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38159. */
  38160. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38161. /**
  38162. * Load a script (identified by an url). When the url returns, the
  38163. * content of this file is added into a new script element, attached to the DOM (body element)
  38164. * @param scriptUrl defines the url of the script to laod
  38165. * @param onSuccess defines the callback called when the script is loaded
  38166. * @param onError defines the callback to call if an error occurs
  38167. * @param scriptId defines the id of the script element
  38168. */
  38169. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38170. /**
  38171. * Load an asynchronous script (identified by an url). When the url returns, the
  38172. * content of this file is added into a new script element, attached to the DOM (body element)
  38173. * @param scriptUrl defines the url of the script to laod
  38174. * @param scriptId defines the id of the script element
  38175. * @returns a promise request object
  38176. */
  38177. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38178. /**
  38179. * Loads a file from a blob
  38180. * @param fileToLoad defines the blob to use
  38181. * @param callback defines the callback to call when data is loaded
  38182. * @param progressCallback defines the callback to call during loading process
  38183. * @returns a file request object
  38184. */
  38185. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38186. /**
  38187. * Reads a file from a File object
  38188. * @param file defines the file to load
  38189. * @param onSuccess defines the callback to call when data is loaded
  38190. * @param onProgress defines the callback to call during loading process
  38191. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38192. * @param onError defines the callback to call when an error occurs
  38193. * @returns a file request object
  38194. */
  38195. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38196. /**
  38197. * Creates a data url from a given string content
  38198. * @param content defines the content to convert
  38199. * @returns the new data url link
  38200. */
  38201. static FileAsURL(content: string): string;
  38202. /**
  38203. * Format the given number to a specific decimal format
  38204. * @param value defines the number to format
  38205. * @param decimals defines the number of decimals to use
  38206. * @returns the formatted string
  38207. */
  38208. static Format(value: number, decimals?: number): string;
  38209. /**
  38210. * Tries to copy an object by duplicating every property
  38211. * @param source defines the source object
  38212. * @param destination defines the target object
  38213. * @param doNotCopyList defines a list of properties to avoid
  38214. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38215. */
  38216. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38217. /**
  38218. * Gets a boolean indicating if the given object has no own property
  38219. * @param obj defines the object to test
  38220. * @returns true if object has no own property
  38221. */
  38222. static IsEmpty(obj: any): boolean;
  38223. /**
  38224. * Function used to register events at window level
  38225. * @param windowElement defines the Window object to use
  38226. * @param events defines the events to register
  38227. */
  38228. static RegisterTopRootEvents(windowElement: Window, events: {
  38229. name: string;
  38230. handler: Nullable<(e: FocusEvent) => any>;
  38231. }[]): void;
  38232. /**
  38233. * Function used to unregister events from window level
  38234. * @param windowElement defines the Window object to use
  38235. * @param events defines the events to unregister
  38236. */
  38237. static UnregisterTopRootEvents(windowElement: Window, events: {
  38238. name: string;
  38239. handler: Nullable<(e: FocusEvent) => any>;
  38240. }[]): void;
  38241. /**
  38242. * @ignore
  38243. */
  38244. static _ScreenshotCanvas: HTMLCanvasElement;
  38245. /**
  38246. * Dumps the current bound framebuffer
  38247. * @param width defines the rendering width
  38248. * @param height defines the rendering height
  38249. * @param engine defines the hosting engine
  38250. * @param successCallback defines the callback triggered once the data are available
  38251. * @param mimeType defines the mime type of the result
  38252. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38253. */
  38254. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38255. /**
  38256. * Converts the canvas data to blob.
  38257. * This acts as a polyfill for browsers not supporting the to blob function.
  38258. * @param canvas Defines the canvas to extract the data from
  38259. * @param successCallback Defines the callback triggered once the data are available
  38260. * @param mimeType Defines the mime type of the result
  38261. */
  38262. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38263. /**
  38264. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38265. * @param successCallback defines the callback triggered once the data are available
  38266. * @param mimeType defines the mime type of the result
  38267. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38268. */
  38269. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38270. /**
  38271. * Downloads a blob in the browser
  38272. * @param blob defines the blob to download
  38273. * @param fileName defines the name of the downloaded file
  38274. */
  38275. static Download(blob: Blob, fileName: string): void;
  38276. /**
  38277. * Captures a screenshot of the current rendering
  38278. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38279. * @param engine defines the rendering engine
  38280. * @param camera defines the source camera
  38281. * @param size This parameter can be set to a single number or to an object with the
  38282. * following (optional) properties: precision, width, height. If a single number is passed,
  38283. * it will be used for both width and height. If an object is passed, the screenshot size
  38284. * will be derived from the parameters. The precision property is a multiplier allowing
  38285. * rendering at a higher or lower resolution
  38286. * @param successCallback defines the callback receives a single parameter which contains the
  38287. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38288. * src parameter of an <img> to display it
  38289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38290. * Check your browser for supported MIME types
  38291. */
  38292. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38293. /**
  38294. * Captures a screenshot of the current rendering
  38295. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38296. * @param engine defines the rendering engine
  38297. * @param camera defines the source camera
  38298. * @param size This parameter can be set to a single number or to an object with the
  38299. * following (optional) properties: precision, width, height. If a single number is passed,
  38300. * it will be used for both width and height. If an object is passed, the screenshot size
  38301. * will be derived from the parameters. The precision property is a multiplier allowing
  38302. * rendering at a higher or lower resolution
  38303. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38304. * Check your browser for supported MIME types
  38305. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38306. * to the src parameter of an <img> to display it
  38307. */
  38308. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38309. /**
  38310. * Generates an image screenshot from the specified camera.
  38311. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38312. * @param engine The engine to use for rendering
  38313. * @param camera The camera to use for rendering
  38314. * @param size This parameter can be set to a single number or to an object with the
  38315. * following (optional) properties: precision, width, height. If a single number is passed,
  38316. * it will be used for both width and height. If an object is passed, the screenshot size
  38317. * will be derived from the parameters. The precision property is a multiplier allowing
  38318. * rendering at a higher or lower resolution
  38319. * @param successCallback The callback receives a single parameter which contains the
  38320. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38321. * src parameter of an <img> to display it
  38322. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38323. * Check your browser for supported MIME types
  38324. * @param samples Texture samples (default: 1)
  38325. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38326. * @param fileName A name for for the downloaded file.
  38327. */
  38328. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38329. /**
  38330. * Generates an image screenshot from the specified camera.
  38331. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38332. * @param engine The engine to use for rendering
  38333. * @param camera The camera to use for rendering
  38334. * @param size This parameter can be set to a single number or to an object with the
  38335. * following (optional) properties: precision, width, height. If a single number is passed,
  38336. * it will be used for both width and height. If an object is passed, the screenshot size
  38337. * will be derived from the parameters. The precision property is a multiplier allowing
  38338. * rendering at a higher or lower resolution
  38339. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38340. * Check your browser for supported MIME types
  38341. * @param samples Texture samples (default: 1)
  38342. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38343. * @param fileName A name for for the downloaded file.
  38344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38345. * to the src parameter of an <img> to display it
  38346. */
  38347. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38348. /**
  38349. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38350. * Be aware Math.random() could cause collisions, but:
  38351. * "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"
  38352. * @returns a pseudo random id
  38353. */
  38354. static RandomId(): string;
  38355. /**
  38356. * Test if the given uri is a base64 string
  38357. * @param uri The uri to test
  38358. * @return True if the uri is a base64 string or false otherwise
  38359. */
  38360. static IsBase64(uri: string): boolean;
  38361. /**
  38362. * Decode the given base64 uri.
  38363. * @param uri The uri to decode
  38364. * @return The decoded base64 data.
  38365. */
  38366. static DecodeBase64(uri: string): ArrayBuffer;
  38367. /**
  38368. * Gets the absolute url.
  38369. * @param url the input url
  38370. * @return the absolute url
  38371. */
  38372. static GetAbsoluteUrl(url: string): string;
  38373. /**
  38374. * No log
  38375. */
  38376. static readonly NoneLogLevel: number;
  38377. /**
  38378. * Only message logs
  38379. */
  38380. static readonly MessageLogLevel: number;
  38381. /**
  38382. * Only warning logs
  38383. */
  38384. static readonly WarningLogLevel: number;
  38385. /**
  38386. * Only error logs
  38387. */
  38388. static readonly ErrorLogLevel: number;
  38389. /**
  38390. * All logs
  38391. */
  38392. static readonly AllLogLevel: number;
  38393. /**
  38394. * Gets a value indicating the number of loading errors
  38395. * @ignorenaming
  38396. */
  38397. static get errorsCount(): number;
  38398. /**
  38399. * Callback called when a new log is added
  38400. */
  38401. static OnNewCacheEntry: (entry: string) => void;
  38402. /**
  38403. * Log a message to the console
  38404. * @param message defines the message to log
  38405. */
  38406. static Log(message: string): void;
  38407. /**
  38408. * Write a warning message to the console
  38409. * @param message defines the message to log
  38410. */
  38411. static Warn(message: string): void;
  38412. /**
  38413. * Write an error message to the console
  38414. * @param message defines the message to log
  38415. */
  38416. static Error(message: string): void;
  38417. /**
  38418. * Gets current log cache (list of logs)
  38419. */
  38420. static get LogCache(): string;
  38421. /**
  38422. * Clears the log cache
  38423. */
  38424. static ClearLogCache(): void;
  38425. /**
  38426. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38427. */
  38428. static set LogLevels(level: number);
  38429. /**
  38430. * Checks if the window object exists
  38431. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38432. */
  38433. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38434. /**
  38435. * No performance log
  38436. */
  38437. static readonly PerformanceNoneLogLevel: number;
  38438. /**
  38439. * Use user marks to log performance
  38440. */
  38441. static readonly PerformanceUserMarkLogLevel: number;
  38442. /**
  38443. * Log performance to the console
  38444. */
  38445. static readonly PerformanceConsoleLogLevel: number;
  38446. private static _performance;
  38447. /**
  38448. * Sets the current performance log level
  38449. */
  38450. static set PerformanceLogLevel(level: number);
  38451. private static _StartPerformanceCounterDisabled;
  38452. private static _EndPerformanceCounterDisabled;
  38453. private static _StartUserMark;
  38454. private static _EndUserMark;
  38455. private static _StartPerformanceConsole;
  38456. private static _EndPerformanceConsole;
  38457. /**
  38458. * Starts a performance counter
  38459. */
  38460. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38461. /**
  38462. * Ends a specific performance coutner
  38463. */
  38464. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38465. /**
  38466. * Gets either window.performance.now() if supported or Date.now() else
  38467. */
  38468. static get Now(): number;
  38469. /**
  38470. * This method will return the name of the class used to create the instance of the given object.
  38471. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38472. * @param object the object to get the class name from
  38473. * @param isType defines if the object is actually a type
  38474. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38475. */
  38476. static GetClassName(object: any, isType?: boolean): string;
  38477. /**
  38478. * Gets the first element of an array satisfying a given predicate
  38479. * @param array defines the array to browse
  38480. * @param predicate defines the predicate to use
  38481. * @returns null if not found or the element
  38482. */
  38483. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38484. /**
  38485. * This method will return the name of the full name of the class, including its owning module (if any).
  38486. * 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).
  38487. * @param object the object to get the class name from
  38488. * @param isType defines if the object is actually a type
  38489. * @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.
  38490. * @ignorenaming
  38491. */
  38492. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38493. /**
  38494. * Returns a promise that resolves after the given amount of time.
  38495. * @param delay Number of milliseconds to delay
  38496. * @returns Promise that resolves after the given amount of time
  38497. */
  38498. static DelayAsync(delay: number): Promise<void>;
  38499. /**
  38500. * Utility function to detect if the current user agent is Safari
  38501. * @returns whether or not the current user agent is safari
  38502. */
  38503. static IsSafari(): boolean;
  38504. }
  38505. /**
  38506. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38507. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38508. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38509. * @param name The name of the class, case should be preserved
  38510. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38511. */
  38512. export function className(name: string, module?: string): (target: Object) => void;
  38513. /**
  38514. * An implementation of a loop for asynchronous functions.
  38515. */
  38516. export class AsyncLoop {
  38517. /**
  38518. * Defines the number of iterations for the loop
  38519. */
  38520. iterations: number;
  38521. /**
  38522. * Defines the current index of the loop.
  38523. */
  38524. index: number;
  38525. private _done;
  38526. private _fn;
  38527. private _successCallback;
  38528. /**
  38529. * Constructor.
  38530. * @param iterations the number of iterations.
  38531. * @param func the function to run each iteration
  38532. * @param successCallback the callback that will be called upon succesful execution
  38533. * @param offset starting offset.
  38534. */
  38535. constructor(
  38536. /**
  38537. * Defines the number of iterations for the loop
  38538. */
  38539. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38540. /**
  38541. * Execute the next iteration. Must be called after the last iteration was finished.
  38542. */
  38543. executeNext(): void;
  38544. /**
  38545. * Break the loop and run the success callback.
  38546. */
  38547. breakLoop(): void;
  38548. /**
  38549. * Create and run an async loop.
  38550. * @param iterations the number of iterations.
  38551. * @param fn the function to run each iteration
  38552. * @param successCallback the callback that will be called upon succesful execution
  38553. * @param offset starting offset.
  38554. * @returns the created async loop object
  38555. */
  38556. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38557. /**
  38558. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38559. * @param iterations total number of iterations
  38560. * @param syncedIterations number of synchronous iterations in each async iteration.
  38561. * @param fn the function to call each iteration.
  38562. * @param callback a success call back that will be called when iterating stops.
  38563. * @param breakFunction a break condition (optional)
  38564. * @param timeout timeout settings for the setTimeout function. default - 0.
  38565. * @returns the created async loop object
  38566. */
  38567. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38568. }
  38569. }
  38570. declare module BABYLON {
  38571. /**
  38572. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38573. * The underlying implementation relies on an associative array to ensure the best performances.
  38574. * The value can be anything including 'null' but except 'undefined'
  38575. */
  38576. export class StringDictionary<T> {
  38577. /**
  38578. * This will clear this dictionary and copy the content from the 'source' one.
  38579. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38580. * @param source the dictionary to take the content from and copy to this dictionary
  38581. */
  38582. copyFrom(source: StringDictionary<T>): void;
  38583. /**
  38584. * Get a value based from its key
  38585. * @param key the given key to get the matching value from
  38586. * @return the value if found, otherwise undefined is returned
  38587. */
  38588. get(key: string): T | undefined;
  38589. /**
  38590. * Get a value from its key or add it if it doesn't exist.
  38591. * This method will ensure you that a given key/data will be present in the dictionary.
  38592. * @param key the given key to get the matching value from
  38593. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38594. * The factory will only be invoked if there's no data for the given key.
  38595. * @return the value corresponding to the key.
  38596. */
  38597. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38598. /**
  38599. * Get a value from its key if present in the dictionary otherwise add it
  38600. * @param key the key to get the value from
  38601. * @param val if there's no such key/value pair in the dictionary add it with this value
  38602. * @return the value corresponding to the key
  38603. */
  38604. getOrAdd(key: string, val: T): T;
  38605. /**
  38606. * Check if there's a given key in the dictionary
  38607. * @param key the key to check for
  38608. * @return true if the key is present, false otherwise
  38609. */
  38610. contains(key: string): boolean;
  38611. /**
  38612. * Add a new key and its corresponding value
  38613. * @param key the key to add
  38614. * @param value the value corresponding to the key
  38615. * @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
  38616. */
  38617. add(key: string, value: T): boolean;
  38618. /**
  38619. * Update a specific value associated to a key
  38620. * @param key defines the key to use
  38621. * @param value defines the value to store
  38622. * @returns true if the value was updated (or false if the key was not found)
  38623. */
  38624. set(key: string, value: T): boolean;
  38625. /**
  38626. * Get the element of the given key and remove it from the dictionary
  38627. * @param key defines the key to search
  38628. * @returns the value associated with the key or null if not found
  38629. */
  38630. getAndRemove(key: string): Nullable<T>;
  38631. /**
  38632. * Remove a key/value from the dictionary.
  38633. * @param key the key to remove
  38634. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38635. */
  38636. remove(key: string): boolean;
  38637. /**
  38638. * Clear the whole content of the dictionary
  38639. */
  38640. clear(): void;
  38641. /**
  38642. * Gets the current count
  38643. */
  38644. get count(): number;
  38645. /**
  38646. * Execute a callback on each key/val of the dictionary.
  38647. * Note that you can remove any element in this dictionary in the callback implementation
  38648. * @param callback the callback to execute on a given key/value pair
  38649. */
  38650. forEach(callback: (key: string, val: T) => void): void;
  38651. /**
  38652. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38653. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38654. * Note that you can remove any element in this dictionary in the callback implementation
  38655. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38656. * @returns the first item
  38657. */
  38658. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38659. private _count;
  38660. private _data;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. /** @hidden */
  38665. export interface ICollisionCoordinator {
  38666. createCollider(): Collider;
  38667. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38668. init(scene: Scene): void;
  38669. }
  38670. /** @hidden */
  38671. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38672. private _scene;
  38673. private _scaledPosition;
  38674. private _scaledVelocity;
  38675. private _finalPosition;
  38676. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38677. createCollider(): Collider;
  38678. init(scene: Scene): void;
  38679. private _collideWithWorld;
  38680. }
  38681. }
  38682. declare module BABYLON {
  38683. /**
  38684. * Class used to manage all inputs for the scene.
  38685. */
  38686. export class InputManager {
  38687. /** The distance in pixel that you have to move to prevent some events */
  38688. static DragMovementThreshold: number;
  38689. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38690. static LongPressDelay: number;
  38691. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38692. static DoubleClickDelay: number;
  38693. /** If you need to check double click without raising a single click at first click, enable this flag */
  38694. static ExclusiveDoubleClickMode: boolean;
  38695. private _wheelEventName;
  38696. private _onPointerMove;
  38697. private _onPointerDown;
  38698. private _onPointerUp;
  38699. private _initClickEvent;
  38700. private _initActionManager;
  38701. private _delayedSimpleClick;
  38702. private _delayedSimpleClickTimeout;
  38703. private _previousDelayedSimpleClickTimeout;
  38704. private _meshPickProceed;
  38705. private _previousButtonPressed;
  38706. private _currentPickResult;
  38707. private _previousPickResult;
  38708. private _totalPointersPressed;
  38709. private _doubleClickOccured;
  38710. private _pointerOverMesh;
  38711. private _pickedDownMesh;
  38712. private _pickedUpMesh;
  38713. private _pointerX;
  38714. private _pointerY;
  38715. private _unTranslatedPointerX;
  38716. private _unTranslatedPointerY;
  38717. private _startingPointerPosition;
  38718. private _previousStartingPointerPosition;
  38719. private _startingPointerTime;
  38720. private _previousStartingPointerTime;
  38721. private _pointerCaptures;
  38722. private _onKeyDown;
  38723. private _onKeyUp;
  38724. private _onCanvasFocusObserver;
  38725. private _onCanvasBlurObserver;
  38726. private _scene;
  38727. /**
  38728. * Creates a new InputManager
  38729. * @param scene defines the hosting scene
  38730. */
  38731. constructor(scene: Scene);
  38732. /**
  38733. * Gets the mesh that is currently under the pointer
  38734. */
  38735. get meshUnderPointer(): Nullable<AbstractMesh>;
  38736. /**
  38737. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38738. */
  38739. get unTranslatedPointer(): Vector2;
  38740. /**
  38741. * Gets or sets the current on-screen X position of the pointer
  38742. */
  38743. get pointerX(): number;
  38744. set pointerX(value: number);
  38745. /**
  38746. * Gets or sets the current on-screen Y position of the pointer
  38747. */
  38748. get pointerY(): number;
  38749. set pointerY(value: number);
  38750. private _updatePointerPosition;
  38751. private _processPointerMove;
  38752. private _setRayOnPointerInfo;
  38753. private _checkPrePointerObservable;
  38754. /**
  38755. * Use this method to simulate a pointer move on a mesh
  38756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38759. */
  38760. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38761. /**
  38762. * Use this method to simulate a pointer down on a mesh
  38763. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38764. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38765. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38766. */
  38767. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38768. private _processPointerDown;
  38769. /** @hidden */
  38770. _isPointerSwiping(): boolean;
  38771. /**
  38772. * Use this method to simulate a pointer up on a mesh
  38773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38776. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38777. */
  38778. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38779. private _processPointerUp;
  38780. /**
  38781. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38782. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38783. * @returns true if the pointer was captured
  38784. */
  38785. isPointerCaptured(pointerId?: number): boolean;
  38786. /**
  38787. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38788. * @param attachUp defines if you want to attach events to pointerup
  38789. * @param attachDown defines if you want to attach events to pointerdown
  38790. * @param attachMove defines if you want to attach events to pointermove
  38791. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38792. */
  38793. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38794. /**
  38795. * Detaches all event handlers
  38796. */
  38797. detachControl(): void;
  38798. /**
  38799. * Force the value of meshUnderPointer
  38800. * @param mesh defines the mesh to use
  38801. */
  38802. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38803. /**
  38804. * Gets the mesh under the pointer
  38805. * @returns a Mesh or null if no mesh is under the pointer
  38806. */
  38807. getPointerOverMesh(): Nullable<AbstractMesh>;
  38808. }
  38809. }
  38810. declare module BABYLON {
  38811. /**
  38812. * This class defines the direct association between an animation and a target
  38813. */
  38814. export class TargetedAnimation {
  38815. /**
  38816. * Animation to perform
  38817. */
  38818. animation: Animation;
  38819. /**
  38820. * Target to animate
  38821. */
  38822. target: any;
  38823. /**
  38824. * Returns the string "TargetedAnimation"
  38825. * @returns "TargetedAnimation"
  38826. */
  38827. getClassName(): string;
  38828. /**
  38829. * Serialize the object
  38830. * @returns the JSON object representing the current entity
  38831. */
  38832. serialize(): any;
  38833. }
  38834. /**
  38835. * Use this class to create coordinated animations on multiple targets
  38836. */
  38837. export class AnimationGroup implements IDisposable {
  38838. /** The name of the animation group */
  38839. name: string;
  38840. private _scene;
  38841. private _targetedAnimations;
  38842. private _animatables;
  38843. private _from;
  38844. private _to;
  38845. private _isStarted;
  38846. private _isPaused;
  38847. private _speedRatio;
  38848. private _loopAnimation;
  38849. private _isAdditive;
  38850. /**
  38851. * Gets or sets the unique id of the node
  38852. */
  38853. uniqueId: number;
  38854. /**
  38855. * This observable will notify when one animation have ended
  38856. */
  38857. onAnimationEndObservable: Observable<TargetedAnimation>;
  38858. /**
  38859. * Observer raised when one animation loops
  38860. */
  38861. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38862. /**
  38863. * Observer raised when all animations have looped
  38864. */
  38865. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38866. /**
  38867. * This observable will notify when all animations have ended.
  38868. */
  38869. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38870. /**
  38871. * This observable will notify when all animations have paused.
  38872. */
  38873. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38874. /**
  38875. * This observable will notify when all animations are playing.
  38876. */
  38877. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38878. /**
  38879. * Gets the first frame
  38880. */
  38881. get from(): number;
  38882. /**
  38883. * Gets the last frame
  38884. */
  38885. get to(): number;
  38886. /**
  38887. * Define if the animations are started
  38888. */
  38889. get isStarted(): boolean;
  38890. /**
  38891. * Gets a value indicating that the current group is playing
  38892. */
  38893. get isPlaying(): boolean;
  38894. /**
  38895. * Gets or sets the speed ratio to use for all animations
  38896. */
  38897. get speedRatio(): number;
  38898. /**
  38899. * Gets or sets the speed ratio to use for all animations
  38900. */
  38901. set speedRatio(value: number);
  38902. /**
  38903. * Gets or sets if all animations should loop or not
  38904. */
  38905. get loopAnimation(): boolean;
  38906. set loopAnimation(value: boolean);
  38907. /**
  38908. * Gets or sets if all animations should be evaluated additively
  38909. */
  38910. get isAdditive(): boolean;
  38911. set isAdditive(value: boolean);
  38912. /**
  38913. * Gets the targeted animations for this animation group
  38914. */
  38915. get targetedAnimations(): Array<TargetedAnimation>;
  38916. /**
  38917. * returning the list of animatables controlled by this animation group.
  38918. */
  38919. get animatables(): Array<Animatable>;
  38920. /**
  38921. * Gets the list of target animations
  38922. */
  38923. get children(): TargetedAnimation[];
  38924. /**
  38925. * Instantiates a new Animation Group.
  38926. * This helps managing several animations at once.
  38927. * @see https://doc.babylonjs.com/how_to/group
  38928. * @param name Defines the name of the group
  38929. * @param scene Defines the scene the group belongs to
  38930. */
  38931. constructor(
  38932. /** The name of the animation group */
  38933. name: string, scene?: Nullable<Scene>);
  38934. /**
  38935. * Add an animation (with its target) in the group
  38936. * @param animation defines the animation we want to add
  38937. * @param target defines the target of the animation
  38938. * @returns the TargetedAnimation object
  38939. */
  38940. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38941. /**
  38942. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38943. * It can add constant keys at begin or end
  38944. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38945. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38946. * @returns the animation group
  38947. */
  38948. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38949. private _animationLoopCount;
  38950. private _animationLoopFlags;
  38951. private _processLoop;
  38952. /**
  38953. * Start all animations on given targets
  38954. * @param loop defines if animations must loop
  38955. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38956. * @param from defines the from key (optional)
  38957. * @param to defines the to key (optional)
  38958. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38959. * @returns the current animation group
  38960. */
  38961. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38962. /**
  38963. * Pause all animations
  38964. * @returns the animation group
  38965. */
  38966. pause(): AnimationGroup;
  38967. /**
  38968. * Play all animations to initial state
  38969. * This function will start() the animations if they were not started or will restart() them if they were paused
  38970. * @param loop defines if animations must loop
  38971. * @returns the animation group
  38972. */
  38973. play(loop?: boolean): AnimationGroup;
  38974. /**
  38975. * Reset all animations to initial state
  38976. * @returns the animation group
  38977. */
  38978. reset(): AnimationGroup;
  38979. /**
  38980. * Restart animations from key 0
  38981. * @returns the animation group
  38982. */
  38983. restart(): AnimationGroup;
  38984. /**
  38985. * Stop all animations
  38986. * @returns the animation group
  38987. */
  38988. stop(): AnimationGroup;
  38989. /**
  38990. * Set animation weight for all animatables
  38991. * @param weight defines the weight to use
  38992. * @return the animationGroup
  38993. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38994. */
  38995. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38996. /**
  38997. * Synchronize and normalize all animatables with a source animatable
  38998. * @param root defines the root animatable to synchronize with
  38999. * @return the animationGroup
  39000. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39001. */
  39002. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39003. /**
  39004. * Goes to a specific frame in this animation group
  39005. * @param frame the frame number to go to
  39006. * @return the animationGroup
  39007. */
  39008. goToFrame(frame: number): AnimationGroup;
  39009. /**
  39010. * Dispose all associated resources
  39011. */
  39012. dispose(): void;
  39013. private _checkAnimationGroupEnded;
  39014. /**
  39015. * Clone the current animation group and returns a copy
  39016. * @param newName defines the name of the new group
  39017. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39018. * @returns the new aniamtion group
  39019. */
  39020. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39021. /**
  39022. * Serializes the animationGroup to an object
  39023. * @returns Serialized object
  39024. */
  39025. serialize(): any;
  39026. /**
  39027. * Returns a new AnimationGroup object parsed from the source provided.
  39028. * @param parsedAnimationGroup defines the source
  39029. * @param scene defines the scene that will receive the animationGroup
  39030. * @returns a new AnimationGroup
  39031. */
  39032. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39033. /**
  39034. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39035. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39036. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39037. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39038. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39039. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39040. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39041. */
  39042. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39043. /**
  39044. * Returns the string "AnimationGroup"
  39045. * @returns "AnimationGroup"
  39046. */
  39047. getClassName(): string;
  39048. /**
  39049. * Creates a detailled string about the object
  39050. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39051. * @returns a string representing the object
  39052. */
  39053. toString(fullDetails?: boolean): string;
  39054. }
  39055. }
  39056. declare module BABYLON {
  39057. /**
  39058. * Define an interface for all classes that will hold resources
  39059. */
  39060. export interface IDisposable {
  39061. /**
  39062. * Releases all held resources
  39063. */
  39064. dispose(): void;
  39065. }
  39066. /** Interface defining initialization parameters for Scene class */
  39067. export interface SceneOptions {
  39068. /**
  39069. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39070. * It will improve performance when the number of geometries becomes important.
  39071. */
  39072. useGeometryUniqueIdsMap?: boolean;
  39073. /**
  39074. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39076. */
  39077. useMaterialMeshMap?: boolean;
  39078. /**
  39079. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39080. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39081. */
  39082. useClonedMeshMap?: boolean;
  39083. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39084. virtual?: boolean;
  39085. }
  39086. /**
  39087. * Represents a scene to be rendered by the engine.
  39088. * @see https://doc.babylonjs.com/features/scene
  39089. */
  39090. export class Scene extends AbstractScene implements IAnimatable {
  39091. /** The fog is deactivated */
  39092. static readonly FOGMODE_NONE: number;
  39093. /** The fog density is following an exponential function */
  39094. static readonly FOGMODE_EXP: number;
  39095. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39096. static readonly FOGMODE_EXP2: number;
  39097. /** The fog density is following a linear function. */
  39098. static readonly FOGMODE_LINEAR: number;
  39099. /**
  39100. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39101. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39102. */
  39103. static MinDeltaTime: number;
  39104. /**
  39105. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39106. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39107. */
  39108. static MaxDeltaTime: number;
  39109. /**
  39110. * Factory used to create the default material.
  39111. * @param name The name of the material to create
  39112. * @param scene The scene to create the material for
  39113. * @returns The default material
  39114. */
  39115. static DefaultMaterialFactory(scene: Scene): Material;
  39116. /**
  39117. * Factory used to create the a collision coordinator.
  39118. * @returns The collision coordinator
  39119. */
  39120. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39121. /** @hidden */
  39122. _inputManager: InputManager;
  39123. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39124. cameraToUseForPointers: Nullable<Camera>;
  39125. /** @hidden */
  39126. readonly _isScene: boolean;
  39127. /** @hidden */
  39128. _blockEntityCollection: boolean;
  39129. /**
  39130. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39131. */
  39132. autoClear: boolean;
  39133. /**
  39134. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39135. */
  39136. autoClearDepthAndStencil: boolean;
  39137. /**
  39138. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39139. */
  39140. clearColor: Color4;
  39141. /**
  39142. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39143. */
  39144. ambientColor: Color3;
  39145. /**
  39146. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39147. * It should only be one of the following (if not the default embedded one):
  39148. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39149. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39150. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39151. * The material properties need to be setup according to the type of texture in use.
  39152. */
  39153. environmentBRDFTexture: BaseTexture;
  39154. /** @hidden */
  39155. protected _environmentTexture: Nullable<BaseTexture>;
  39156. /**
  39157. * Texture used in all pbr material as the reflection texture.
  39158. * As in the majority of the scene they are the same (exception for multi room and so on),
  39159. * this is easier to reference from here than from all the materials.
  39160. */
  39161. get environmentTexture(): Nullable<BaseTexture>;
  39162. /**
  39163. * Texture used in all pbr material as the reflection texture.
  39164. * As in the majority of the scene they are the same (exception for multi room and so on),
  39165. * this is easier to set here than in all the materials.
  39166. */
  39167. set environmentTexture(value: Nullable<BaseTexture>);
  39168. /** @hidden */
  39169. protected _environmentIntensity: number;
  39170. /**
  39171. * Intensity of the environment in all pbr material.
  39172. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39173. * As in the majority of the scene they are the same (exception for multi room and so on),
  39174. * this is easier to reference from here than from all the materials.
  39175. */
  39176. get environmentIntensity(): number;
  39177. /**
  39178. * Intensity of the environment in all pbr material.
  39179. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39180. * As in the majority of the scene they are the same (exception for multi room and so on),
  39181. * this is easier to set here than in all the materials.
  39182. */
  39183. set environmentIntensity(value: number);
  39184. /** @hidden */
  39185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39186. /**
  39187. * Default image processing configuration used either in the rendering
  39188. * Forward main pass or through the imageProcessingPostProcess if present.
  39189. * As in the majority of the scene they are the same (exception for multi camera),
  39190. * this is easier to reference from here than from all the materials and post process.
  39191. *
  39192. * No setter as we it is a shared configuration, you can set the values instead.
  39193. */
  39194. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39195. private _forceWireframe;
  39196. /**
  39197. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39198. */
  39199. set forceWireframe(value: boolean);
  39200. get forceWireframe(): boolean;
  39201. private _skipFrustumClipping;
  39202. /**
  39203. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39204. */
  39205. set skipFrustumClipping(value: boolean);
  39206. get skipFrustumClipping(): boolean;
  39207. private _forcePointsCloud;
  39208. /**
  39209. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39210. */
  39211. set forcePointsCloud(value: boolean);
  39212. get forcePointsCloud(): boolean;
  39213. /**
  39214. * Gets or sets the active clipplane 1
  39215. */
  39216. clipPlane: Nullable<Plane>;
  39217. /**
  39218. * Gets or sets the active clipplane 2
  39219. */
  39220. clipPlane2: Nullable<Plane>;
  39221. /**
  39222. * Gets or sets the active clipplane 3
  39223. */
  39224. clipPlane3: Nullable<Plane>;
  39225. /**
  39226. * Gets or sets the active clipplane 4
  39227. */
  39228. clipPlane4: Nullable<Plane>;
  39229. /**
  39230. * Gets or sets the active clipplane 5
  39231. */
  39232. clipPlane5: Nullable<Plane>;
  39233. /**
  39234. * Gets or sets the active clipplane 6
  39235. */
  39236. clipPlane6: Nullable<Plane>;
  39237. /**
  39238. * Gets or sets a boolean indicating if animations are enabled
  39239. */
  39240. animationsEnabled: boolean;
  39241. private _animationPropertiesOverride;
  39242. /**
  39243. * Gets or sets the animation properties override
  39244. */
  39245. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39246. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39247. /**
  39248. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39249. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39250. */
  39251. useConstantAnimationDeltaTime: boolean;
  39252. /**
  39253. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39254. * Please note that it requires to run a ray cast through the scene on every frame
  39255. */
  39256. constantlyUpdateMeshUnderPointer: boolean;
  39257. /**
  39258. * Defines the HTML cursor to use when hovering over interactive elements
  39259. */
  39260. hoverCursor: string;
  39261. /**
  39262. * Defines the HTML default cursor to use (empty by default)
  39263. */
  39264. defaultCursor: string;
  39265. /**
  39266. * Defines whether cursors are handled by the scene.
  39267. */
  39268. doNotHandleCursors: boolean;
  39269. /**
  39270. * This is used to call preventDefault() on pointer down
  39271. * in order to block unwanted artifacts like system double clicks
  39272. */
  39273. preventDefaultOnPointerDown: boolean;
  39274. /**
  39275. * This is used to call preventDefault() on pointer up
  39276. * in order to block unwanted artifacts like system double clicks
  39277. */
  39278. preventDefaultOnPointerUp: boolean;
  39279. /**
  39280. * Gets or sets user defined metadata
  39281. */
  39282. metadata: any;
  39283. /**
  39284. * For internal use only. Please do not use.
  39285. */
  39286. reservedDataStore: any;
  39287. /**
  39288. * Gets the name of the plugin used to load this scene (null by default)
  39289. */
  39290. loadingPluginName: string;
  39291. /**
  39292. * Use this array to add regular expressions used to disable offline support for specific urls
  39293. */
  39294. disableOfflineSupportExceptionRules: RegExp[];
  39295. /**
  39296. * An event triggered when the scene is disposed.
  39297. */
  39298. onDisposeObservable: Observable<Scene>;
  39299. private _onDisposeObserver;
  39300. /** Sets a function to be executed when this scene is disposed. */
  39301. set onDispose(callback: () => void);
  39302. /**
  39303. * An event triggered before rendering the scene (right after animations and physics)
  39304. */
  39305. onBeforeRenderObservable: Observable<Scene>;
  39306. private _onBeforeRenderObserver;
  39307. /** Sets a function to be executed before rendering this scene */
  39308. set beforeRender(callback: Nullable<() => void>);
  39309. /**
  39310. * An event triggered after rendering the scene
  39311. */
  39312. onAfterRenderObservable: Observable<Scene>;
  39313. /**
  39314. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39315. */
  39316. onAfterRenderCameraObservable: Observable<Camera>;
  39317. private _onAfterRenderObserver;
  39318. /** Sets a function to be executed after rendering this scene */
  39319. set afterRender(callback: Nullable<() => void>);
  39320. /**
  39321. * An event triggered before animating the scene
  39322. */
  39323. onBeforeAnimationsObservable: Observable<Scene>;
  39324. /**
  39325. * An event triggered after animations processing
  39326. */
  39327. onAfterAnimationsObservable: Observable<Scene>;
  39328. /**
  39329. * An event triggered before draw calls are ready to be sent
  39330. */
  39331. onBeforeDrawPhaseObservable: Observable<Scene>;
  39332. /**
  39333. * An event triggered after draw calls have been sent
  39334. */
  39335. onAfterDrawPhaseObservable: Observable<Scene>;
  39336. /**
  39337. * An event triggered when the scene is ready
  39338. */
  39339. onReadyObservable: Observable<Scene>;
  39340. /**
  39341. * An event triggered before rendering a camera
  39342. */
  39343. onBeforeCameraRenderObservable: Observable<Camera>;
  39344. private _onBeforeCameraRenderObserver;
  39345. /** Sets a function to be executed before rendering a camera*/
  39346. set beforeCameraRender(callback: () => void);
  39347. /**
  39348. * An event triggered after rendering a camera
  39349. */
  39350. onAfterCameraRenderObservable: Observable<Camera>;
  39351. private _onAfterCameraRenderObserver;
  39352. /** Sets a function to be executed after rendering a camera*/
  39353. set afterCameraRender(callback: () => void);
  39354. /**
  39355. * An event triggered when active meshes evaluation is about to start
  39356. */
  39357. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39358. /**
  39359. * An event triggered when active meshes evaluation is done
  39360. */
  39361. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39362. /**
  39363. * An event triggered when particles rendering is about to start
  39364. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39365. */
  39366. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39367. /**
  39368. * An event triggered when particles rendering is done
  39369. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39370. */
  39371. onAfterParticlesRenderingObservable: Observable<Scene>;
  39372. /**
  39373. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39374. */
  39375. onDataLoadedObservable: Observable<Scene>;
  39376. /**
  39377. * An event triggered when a camera is created
  39378. */
  39379. onNewCameraAddedObservable: Observable<Camera>;
  39380. /**
  39381. * An event triggered when a camera is removed
  39382. */
  39383. onCameraRemovedObservable: Observable<Camera>;
  39384. /**
  39385. * An event triggered when a light is created
  39386. */
  39387. onNewLightAddedObservable: Observable<Light>;
  39388. /**
  39389. * An event triggered when a light is removed
  39390. */
  39391. onLightRemovedObservable: Observable<Light>;
  39392. /**
  39393. * An event triggered when a geometry is created
  39394. */
  39395. onNewGeometryAddedObservable: Observable<Geometry>;
  39396. /**
  39397. * An event triggered when a geometry is removed
  39398. */
  39399. onGeometryRemovedObservable: Observable<Geometry>;
  39400. /**
  39401. * An event triggered when a transform node is created
  39402. */
  39403. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39404. /**
  39405. * An event triggered when a transform node is removed
  39406. */
  39407. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39408. /**
  39409. * An event triggered when a mesh is created
  39410. */
  39411. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39412. /**
  39413. * An event triggered when a mesh is removed
  39414. */
  39415. onMeshRemovedObservable: Observable<AbstractMesh>;
  39416. /**
  39417. * An event triggered when a skeleton is created
  39418. */
  39419. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39420. /**
  39421. * An event triggered when a skeleton is removed
  39422. */
  39423. onSkeletonRemovedObservable: Observable<Skeleton>;
  39424. /**
  39425. * An event triggered when a material is created
  39426. */
  39427. onNewMaterialAddedObservable: Observable<Material>;
  39428. /**
  39429. * An event triggered when a material is removed
  39430. */
  39431. onMaterialRemovedObservable: Observable<Material>;
  39432. /**
  39433. * An event triggered when a texture is created
  39434. */
  39435. onNewTextureAddedObservable: Observable<BaseTexture>;
  39436. /**
  39437. * An event triggered when a texture is removed
  39438. */
  39439. onTextureRemovedObservable: Observable<BaseTexture>;
  39440. /**
  39441. * An event triggered when render targets are about to be rendered
  39442. * Can happen multiple times per frame.
  39443. */
  39444. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39445. /**
  39446. * An event triggered when render targets were rendered.
  39447. * Can happen multiple times per frame.
  39448. */
  39449. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39450. /**
  39451. * An event triggered before calculating deterministic simulation step
  39452. */
  39453. onBeforeStepObservable: Observable<Scene>;
  39454. /**
  39455. * An event triggered after calculating deterministic simulation step
  39456. */
  39457. onAfterStepObservable: Observable<Scene>;
  39458. /**
  39459. * An event triggered when the activeCamera property is updated
  39460. */
  39461. onActiveCameraChanged: Observable<Scene>;
  39462. /**
  39463. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39464. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39465. * 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)
  39466. */
  39467. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39468. /**
  39469. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39470. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39471. * 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)
  39472. */
  39473. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39474. /**
  39475. * This Observable will when a mesh has been imported into the scene.
  39476. */
  39477. onMeshImportedObservable: Observable<AbstractMesh>;
  39478. /**
  39479. * This Observable will when an animation file has been imported into the scene.
  39480. */
  39481. onAnimationFileImportedObservable: Observable<Scene>;
  39482. /**
  39483. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39484. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39485. */
  39486. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39487. /** @hidden */
  39488. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39489. /**
  39490. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39491. */
  39492. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39493. /**
  39494. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39495. */
  39496. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39497. /**
  39498. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39499. */
  39500. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39501. /** Callback called when a pointer move is detected */
  39502. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39503. /** Callback called when a pointer down is detected */
  39504. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39505. /** Callback called when a pointer up is detected */
  39506. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39507. /** Callback called when a pointer pick is detected */
  39508. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39509. /**
  39510. * 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).
  39511. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39512. */
  39513. onPrePointerObservable: Observable<PointerInfoPre>;
  39514. /**
  39515. * Observable event triggered each time an input event is received from the rendering canvas
  39516. */
  39517. onPointerObservable: Observable<PointerInfo>;
  39518. /**
  39519. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39520. */
  39521. get unTranslatedPointer(): Vector2;
  39522. /**
  39523. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39524. */
  39525. static get DragMovementThreshold(): number;
  39526. static set DragMovementThreshold(value: number);
  39527. /**
  39528. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39529. */
  39530. static get LongPressDelay(): number;
  39531. static set LongPressDelay(value: number);
  39532. /**
  39533. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39534. */
  39535. static get DoubleClickDelay(): number;
  39536. static set DoubleClickDelay(value: number);
  39537. /** If you need to check double click without raising a single click at first click, enable this flag */
  39538. static get ExclusiveDoubleClickMode(): boolean;
  39539. static set ExclusiveDoubleClickMode(value: boolean);
  39540. /** @hidden */
  39541. _mirroredCameraPosition: Nullable<Vector3>;
  39542. /**
  39543. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39544. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39545. */
  39546. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39547. /**
  39548. * Observable event triggered each time an keyboard event is received from the hosting window
  39549. */
  39550. onKeyboardObservable: Observable<KeyboardInfo>;
  39551. private _useRightHandedSystem;
  39552. /**
  39553. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39554. */
  39555. set useRightHandedSystem(value: boolean);
  39556. get useRightHandedSystem(): boolean;
  39557. private _timeAccumulator;
  39558. private _currentStepId;
  39559. private _currentInternalStep;
  39560. /**
  39561. * Sets the step Id used by deterministic lock step
  39562. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39563. * @param newStepId defines the step Id
  39564. */
  39565. setStepId(newStepId: number): void;
  39566. /**
  39567. * Gets the step Id used by deterministic lock step
  39568. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39569. * @returns the step Id
  39570. */
  39571. getStepId(): number;
  39572. /**
  39573. * Gets the internal step used by deterministic lock step
  39574. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39575. * @returns the internal step
  39576. */
  39577. getInternalStep(): number;
  39578. private _fogEnabled;
  39579. /**
  39580. * Gets or sets a boolean indicating if fog is enabled on this scene
  39581. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39582. * (Default is true)
  39583. */
  39584. set fogEnabled(value: boolean);
  39585. get fogEnabled(): boolean;
  39586. private _fogMode;
  39587. /**
  39588. * Gets or sets the fog mode to use
  39589. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39590. * | mode | value |
  39591. * | --- | --- |
  39592. * | FOGMODE_NONE | 0 |
  39593. * | FOGMODE_EXP | 1 |
  39594. * | FOGMODE_EXP2 | 2 |
  39595. * | FOGMODE_LINEAR | 3 |
  39596. */
  39597. set fogMode(value: number);
  39598. get fogMode(): number;
  39599. /**
  39600. * Gets or sets the fog color to use
  39601. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39602. * (Default is Color3(0.2, 0.2, 0.3))
  39603. */
  39604. fogColor: Color3;
  39605. /**
  39606. * Gets or sets the fog density to use
  39607. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39608. * (Default is 0.1)
  39609. */
  39610. fogDensity: number;
  39611. /**
  39612. * Gets or sets the fog start distance to use
  39613. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39614. * (Default is 0)
  39615. */
  39616. fogStart: number;
  39617. /**
  39618. * Gets or sets the fog end distance to use
  39619. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39620. * (Default is 1000)
  39621. */
  39622. fogEnd: number;
  39623. /**
  39624. * Flag indicating that the frame buffer binding is handled by another component
  39625. */
  39626. prePass: boolean;
  39627. private _shadowsEnabled;
  39628. /**
  39629. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39630. */
  39631. set shadowsEnabled(value: boolean);
  39632. get shadowsEnabled(): boolean;
  39633. private _lightsEnabled;
  39634. /**
  39635. * Gets or sets a boolean indicating if lights are enabled on this scene
  39636. */
  39637. set lightsEnabled(value: boolean);
  39638. get lightsEnabled(): boolean;
  39639. /** All of the active cameras added to this scene. */
  39640. activeCameras: Camera[];
  39641. /** @hidden */
  39642. _activeCamera: Nullable<Camera>;
  39643. /** Gets or sets the current active camera */
  39644. get activeCamera(): Nullable<Camera>;
  39645. set activeCamera(value: Nullable<Camera>);
  39646. private _defaultMaterial;
  39647. /** The default material used on meshes when no material is affected */
  39648. get defaultMaterial(): Material;
  39649. /** The default material used on meshes when no material is affected */
  39650. set defaultMaterial(value: Material);
  39651. private _texturesEnabled;
  39652. /**
  39653. * Gets or sets a boolean indicating if textures are enabled on this scene
  39654. */
  39655. set texturesEnabled(value: boolean);
  39656. get texturesEnabled(): boolean;
  39657. /**
  39658. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39659. */
  39660. physicsEnabled: boolean;
  39661. /**
  39662. * Gets or sets a boolean indicating if particles are enabled on this scene
  39663. */
  39664. particlesEnabled: boolean;
  39665. /**
  39666. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39667. */
  39668. spritesEnabled: boolean;
  39669. private _skeletonsEnabled;
  39670. /**
  39671. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39672. */
  39673. set skeletonsEnabled(value: boolean);
  39674. get skeletonsEnabled(): boolean;
  39675. /**
  39676. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39677. */
  39678. lensFlaresEnabled: boolean;
  39679. /**
  39680. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39681. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39682. */
  39683. collisionsEnabled: boolean;
  39684. private _collisionCoordinator;
  39685. /** @hidden */
  39686. get collisionCoordinator(): ICollisionCoordinator;
  39687. /**
  39688. * Defines the gravity applied to this scene (used only for collisions)
  39689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39690. */
  39691. gravity: Vector3;
  39692. /**
  39693. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39694. */
  39695. postProcessesEnabled: boolean;
  39696. /**
  39697. * The list of postprocesses added to the scene
  39698. */
  39699. postProcesses: PostProcess[];
  39700. /**
  39701. * Gets the current postprocess manager
  39702. */
  39703. postProcessManager: PostProcessManager;
  39704. /**
  39705. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39706. */
  39707. renderTargetsEnabled: boolean;
  39708. /**
  39709. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39710. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39711. */
  39712. dumpNextRenderTargets: boolean;
  39713. /**
  39714. * The list of user defined render targets added to the scene
  39715. */
  39716. customRenderTargets: RenderTargetTexture[];
  39717. /**
  39718. * Defines if texture loading must be delayed
  39719. * If true, textures will only be loaded when they need to be rendered
  39720. */
  39721. useDelayedTextureLoading: boolean;
  39722. /**
  39723. * Gets the list of meshes imported to the scene through SceneLoader
  39724. */
  39725. importedMeshesFiles: String[];
  39726. /**
  39727. * Gets or sets a boolean indicating if probes are enabled on this scene
  39728. */
  39729. probesEnabled: boolean;
  39730. /**
  39731. * Gets or sets the current offline provider to use to store scene data
  39732. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39733. */
  39734. offlineProvider: IOfflineProvider;
  39735. /**
  39736. * Gets or sets the action manager associated with the scene
  39737. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39738. */
  39739. actionManager: AbstractActionManager;
  39740. private _meshesForIntersections;
  39741. /**
  39742. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39743. */
  39744. proceduralTexturesEnabled: boolean;
  39745. private _engine;
  39746. private _totalVertices;
  39747. /** @hidden */
  39748. _activeIndices: PerfCounter;
  39749. /** @hidden */
  39750. _activeParticles: PerfCounter;
  39751. /** @hidden */
  39752. _activeBones: PerfCounter;
  39753. private _animationRatio;
  39754. /** @hidden */
  39755. _animationTimeLast: number;
  39756. /** @hidden */
  39757. _animationTime: number;
  39758. /**
  39759. * Gets or sets a general scale for animation speed
  39760. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39761. */
  39762. animationTimeScale: number;
  39763. /** @hidden */
  39764. _cachedMaterial: Nullable<Material>;
  39765. /** @hidden */
  39766. _cachedEffect: Nullable<Effect>;
  39767. /** @hidden */
  39768. _cachedVisibility: Nullable<number>;
  39769. private _renderId;
  39770. private _frameId;
  39771. private _executeWhenReadyTimeoutId;
  39772. private _intermediateRendering;
  39773. private _viewUpdateFlag;
  39774. private _projectionUpdateFlag;
  39775. /** @hidden */
  39776. _toBeDisposed: Nullable<IDisposable>[];
  39777. private _activeRequests;
  39778. /** @hidden */
  39779. _pendingData: any[];
  39780. private _isDisposed;
  39781. /**
  39782. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39783. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39784. */
  39785. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39786. private _activeMeshes;
  39787. private _processedMaterials;
  39788. private _renderTargets;
  39789. /** @hidden */
  39790. _activeParticleSystems: SmartArray<IParticleSystem>;
  39791. private _activeSkeletons;
  39792. private _softwareSkinnedMeshes;
  39793. private _renderingManager;
  39794. /** @hidden */
  39795. _activeAnimatables: Animatable[];
  39796. private _transformMatrix;
  39797. private _sceneUbo;
  39798. /** @hidden */
  39799. _viewMatrix: Matrix;
  39800. private _projectionMatrix;
  39801. /** @hidden */
  39802. _forcedViewPosition: Nullable<Vector3>;
  39803. /** @hidden */
  39804. _frustumPlanes: Plane[];
  39805. /**
  39806. * Gets the list of frustum planes (built from the active camera)
  39807. */
  39808. get frustumPlanes(): Plane[];
  39809. /**
  39810. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39811. * This is useful if there are more lights that the maximum simulteanous authorized
  39812. */
  39813. requireLightSorting: boolean;
  39814. /** @hidden */
  39815. readonly useMaterialMeshMap: boolean;
  39816. /** @hidden */
  39817. readonly useClonedMeshMap: boolean;
  39818. private _externalData;
  39819. private _uid;
  39820. /**
  39821. * @hidden
  39822. * Backing store of defined scene components.
  39823. */
  39824. _components: ISceneComponent[];
  39825. /**
  39826. * @hidden
  39827. * Backing store of defined scene components.
  39828. */
  39829. _serializableComponents: ISceneSerializableComponent[];
  39830. /**
  39831. * List of components to register on the next registration step.
  39832. */
  39833. private _transientComponents;
  39834. /**
  39835. * Registers the transient components if needed.
  39836. */
  39837. private _registerTransientComponents;
  39838. /**
  39839. * @hidden
  39840. * Add a component to the scene.
  39841. * Note that the ccomponent could be registered on th next frame if this is called after
  39842. * the register component stage.
  39843. * @param component Defines the component to add to the scene
  39844. */
  39845. _addComponent(component: ISceneComponent): void;
  39846. /**
  39847. * @hidden
  39848. * Gets a component from the scene.
  39849. * @param name defines the name of the component to retrieve
  39850. * @returns the component or null if not present
  39851. */
  39852. _getComponent(name: string): Nullable<ISceneComponent>;
  39853. /**
  39854. * @hidden
  39855. * Defines the actions happening before camera updates.
  39856. */
  39857. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39858. /**
  39859. * @hidden
  39860. * Defines the actions happening before clear the canvas.
  39861. */
  39862. _beforeClearStage: Stage<SimpleStageAction>;
  39863. /**
  39864. * @hidden
  39865. * Defines the actions when collecting render targets for the frame.
  39866. */
  39867. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39868. /**
  39869. * @hidden
  39870. * Defines the actions happening for one camera in the frame.
  39871. */
  39872. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39873. /**
  39874. * @hidden
  39875. * Defines the actions happening during the per mesh ready checks.
  39876. */
  39877. _isReadyForMeshStage: Stage<MeshStageAction>;
  39878. /**
  39879. * @hidden
  39880. * Defines the actions happening before evaluate active mesh checks.
  39881. */
  39882. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39883. /**
  39884. * @hidden
  39885. * Defines the actions happening during the evaluate sub mesh checks.
  39886. */
  39887. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39888. /**
  39889. * @hidden
  39890. * Defines the actions happening during the active mesh stage.
  39891. */
  39892. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39893. /**
  39894. * @hidden
  39895. * Defines the actions happening during the per camera render target step.
  39896. */
  39897. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39898. /**
  39899. * @hidden
  39900. * Defines the actions happening just before the active camera is drawing.
  39901. */
  39902. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39903. /**
  39904. * @hidden
  39905. * Defines the actions happening just before a render target is drawing.
  39906. */
  39907. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39908. /**
  39909. * @hidden
  39910. * Defines the actions happening just before a rendering group is drawing.
  39911. */
  39912. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39913. /**
  39914. * @hidden
  39915. * Defines the actions happening just before a mesh is drawing.
  39916. */
  39917. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39918. /**
  39919. * @hidden
  39920. * Defines the actions happening just after a mesh has been drawn.
  39921. */
  39922. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39923. /**
  39924. * @hidden
  39925. * Defines the actions happening just after a rendering group has been drawn.
  39926. */
  39927. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39928. /**
  39929. * @hidden
  39930. * Defines the actions happening just after the active camera has been drawn.
  39931. */
  39932. _afterCameraDrawStage: Stage<CameraStageAction>;
  39933. /**
  39934. * @hidden
  39935. * Defines the actions happening just after a render target has been drawn.
  39936. */
  39937. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39938. /**
  39939. * @hidden
  39940. * Defines the actions happening just after rendering all cameras and computing intersections.
  39941. */
  39942. _afterRenderStage: Stage<SimpleStageAction>;
  39943. /**
  39944. * @hidden
  39945. * Defines the actions happening when a pointer move event happens.
  39946. */
  39947. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39948. /**
  39949. * @hidden
  39950. * Defines the actions happening when a pointer down event happens.
  39951. */
  39952. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39953. /**
  39954. * @hidden
  39955. * Defines the actions happening when a pointer up event happens.
  39956. */
  39957. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39958. /**
  39959. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39960. */
  39961. private geometriesByUniqueId;
  39962. /**
  39963. * Creates a new Scene
  39964. * @param engine defines the engine to use to render this scene
  39965. * @param options defines the scene options
  39966. */
  39967. constructor(engine: Engine, options?: SceneOptions);
  39968. /**
  39969. * Gets a string idenfifying the name of the class
  39970. * @returns "Scene" string
  39971. */
  39972. getClassName(): string;
  39973. private _defaultMeshCandidates;
  39974. /**
  39975. * @hidden
  39976. */
  39977. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39978. private _defaultSubMeshCandidates;
  39979. /**
  39980. * @hidden
  39981. */
  39982. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39983. /**
  39984. * Sets the default candidate providers for the scene.
  39985. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39986. * and getCollidingSubMeshCandidates to their default function
  39987. */
  39988. setDefaultCandidateProviders(): void;
  39989. /**
  39990. * Gets the mesh that is currently under the pointer
  39991. */
  39992. get meshUnderPointer(): Nullable<AbstractMesh>;
  39993. /**
  39994. * Gets or sets the current on-screen X position of the pointer
  39995. */
  39996. get pointerX(): number;
  39997. set pointerX(value: number);
  39998. /**
  39999. * Gets or sets the current on-screen Y position of the pointer
  40000. */
  40001. get pointerY(): number;
  40002. set pointerY(value: number);
  40003. /**
  40004. * Gets the cached material (ie. the latest rendered one)
  40005. * @returns the cached material
  40006. */
  40007. getCachedMaterial(): Nullable<Material>;
  40008. /**
  40009. * Gets the cached effect (ie. the latest rendered one)
  40010. * @returns the cached effect
  40011. */
  40012. getCachedEffect(): Nullable<Effect>;
  40013. /**
  40014. * Gets the cached visibility state (ie. the latest rendered one)
  40015. * @returns the cached visibility state
  40016. */
  40017. getCachedVisibility(): Nullable<number>;
  40018. /**
  40019. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40020. * @param material defines the current material
  40021. * @param effect defines the current effect
  40022. * @param visibility defines the current visibility state
  40023. * @returns true if one parameter is not cached
  40024. */
  40025. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40026. /**
  40027. * Gets the engine associated with the scene
  40028. * @returns an Engine
  40029. */
  40030. getEngine(): Engine;
  40031. /**
  40032. * Gets the total number of vertices rendered per frame
  40033. * @returns the total number of vertices rendered per frame
  40034. */
  40035. getTotalVertices(): number;
  40036. /**
  40037. * Gets the performance counter for total vertices
  40038. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40039. */
  40040. get totalVerticesPerfCounter(): PerfCounter;
  40041. /**
  40042. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40043. * @returns the total number of active indices rendered per frame
  40044. */
  40045. getActiveIndices(): number;
  40046. /**
  40047. * Gets the performance counter for active indices
  40048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40049. */
  40050. get totalActiveIndicesPerfCounter(): PerfCounter;
  40051. /**
  40052. * Gets the total number of active particles rendered per frame
  40053. * @returns the total number of active particles rendered per frame
  40054. */
  40055. getActiveParticles(): number;
  40056. /**
  40057. * Gets the performance counter for active particles
  40058. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40059. */
  40060. get activeParticlesPerfCounter(): PerfCounter;
  40061. /**
  40062. * Gets the total number of active bones rendered per frame
  40063. * @returns the total number of active bones rendered per frame
  40064. */
  40065. getActiveBones(): number;
  40066. /**
  40067. * Gets the performance counter for active bones
  40068. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40069. */
  40070. get activeBonesPerfCounter(): PerfCounter;
  40071. /**
  40072. * Gets the array of active meshes
  40073. * @returns an array of AbstractMesh
  40074. */
  40075. getActiveMeshes(): SmartArray<AbstractMesh>;
  40076. /**
  40077. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40078. * @returns a number
  40079. */
  40080. getAnimationRatio(): number;
  40081. /**
  40082. * Gets an unique Id for the current render phase
  40083. * @returns a number
  40084. */
  40085. getRenderId(): number;
  40086. /**
  40087. * Gets an unique Id for the current frame
  40088. * @returns a number
  40089. */
  40090. getFrameId(): number;
  40091. /** Call this function if you want to manually increment the render Id*/
  40092. incrementRenderId(): void;
  40093. private _createUbo;
  40094. /**
  40095. * Use this method to simulate a pointer move on a mesh
  40096. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40097. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40098. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40099. * @returns the current scene
  40100. */
  40101. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40102. /**
  40103. * Use this method to simulate a pointer down on a mesh
  40104. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40105. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40106. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40107. * @returns the current scene
  40108. */
  40109. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40110. /**
  40111. * Use this method to simulate a pointer up on a mesh
  40112. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40113. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40114. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40115. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40116. * @returns the current scene
  40117. */
  40118. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40119. /**
  40120. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40121. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40122. * @returns true if the pointer was captured
  40123. */
  40124. isPointerCaptured(pointerId?: number): boolean;
  40125. /**
  40126. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40127. * @param attachUp defines if you want to attach events to pointerup
  40128. * @param attachDown defines if you want to attach events to pointerdown
  40129. * @param attachMove defines if you want to attach events to pointermove
  40130. */
  40131. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40132. /** Detaches all event handlers*/
  40133. detachControl(): void;
  40134. /**
  40135. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40136. * Delay loaded resources are not taking in account
  40137. * @return true if all required resources are ready
  40138. */
  40139. isReady(): boolean;
  40140. /** Resets all cached information relative to material (including effect and visibility) */
  40141. resetCachedMaterial(): void;
  40142. /**
  40143. * Registers a function to be called before every frame render
  40144. * @param func defines the function to register
  40145. */
  40146. registerBeforeRender(func: () => void): void;
  40147. /**
  40148. * Unregisters a function called before every frame render
  40149. * @param func defines the function to unregister
  40150. */
  40151. unregisterBeforeRender(func: () => void): void;
  40152. /**
  40153. * Registers a function to be called after every frame render
  40154. * @param func defines the function to register
  40155. */
  40156. registerAfterRender(func: () => void): void;
  40157. /**
  40158. * Unregisters a function called after every frame render
  40159. * @param func defines the function to unregister
  40160. */
  40161. unregisterAfterRender(func: () => void): void;
  40162. private _executeOnceBeforeRender;
  40163. /**
  40164. * The provided function will run before render once and will be disposed afterwards.
  40165. * A timeout delay can be provided so that the function will be executed in N ms.
  40166. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40167. * @param func The function to be executed.
  40168. * @param timeout optional delay in ms
  40169. */
  40170. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40171. /** @hidden */
  40172. _addPendingData(data: any): void;
  40173. /** @hidden */
  40174. _removePendingData(data: any): void;
  40175. /**
  40176. * Returns the number of items waiting to be loaded
  40177. * @returns the number of items waiting to be loaded
  40178. */
  40179. getWaitingItemsCount(): number;
  40180. /**
  40181. * Returns a boolean indicating if the scene is still loading data
  40182. */
  40183. get isLoading(): boolean;
  40184. /**
  40185. * Registers a function to be executed when the scene is ready
  40186. * @param {Function} func - the function to be executed
  40187. */
  40188. executeWhenReady(func: () => void): void;
  40189. /**
  40190. * Returns a promise that resolves when the scene is ready
  40191. * @returns A promise that resolves when the scene is ready
  40192. */
  40193. whenReadyAsync(): Promise<void>;
  40194. /** @hidden */
  40195. _checkIsReady(): void;
  40196. /**
  40197. * Gets all animatable attached to the scene
  40198. */
  40199. get animatables(): Animatable[];
  40200. /**
  40201. * Resets the last animation time frame.
  40202. * Useful to override when animations start running when loading a scene for the first time.
  40203. */
  40204. resetLastAnimationTimeFrame(): void;
  40205. /**
  40206. * Gets the current view matrix
  40207. * @returns a Matrix
  40208. */
  40209. getViewMatrix(): Matrix;
  40210. /**
  40211. * Gets the current projection matrix
  40212. * @returns a Matrix
  40213. */
  40214. getProjectionMatrix(): Matrix;
  40215. /**
  40216. * Gets the current transform matrix
  40217. * @returns a Matrix made of View * Projection
  40218. */
  40219. getTransformMatrix(): Matrix;
  40220. /**
  40221. * Sets the current transform matrix
  40222. * @param viewL defines the View matrix to use
  40223. * @param projectionL defines the Projection matrix to use
  40224. * @param viewR defines the right View matrix to use (if provided)
  40225. * @param projectionR defines the right Projection matrix to use (if provided)
  40226. */
  40227. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40228. /**
  40229. * Gets the uniform buffer used to store scene data
  40230. * @returns a UniformBuffer
  40231. */
  40232. getSceneUniformBuffer(): UniformBuffer;
  40233. /**
  40234. * Gets an unique (relatively to the current scene) Id
  40235. * @returns an unique number for the scene
  40236. */
  40237. getUniqueId(): number;
  40238. /**
  40239. * Add a mesh to the list of scene's meshes
  40240. * @param newMesh defines the mesh to add
  40241. * @param recursive if all child meshes should also be added to the scene
  40242. */
  40243. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40244. /**
  40245. * Remove a mesh for the list of scene's meshes
  40246. * @param toRemove defines the mesh to remove
  40247. * @param recursive if all child meshes should also be removed from the scene
  40248. * @returns the index where the mesh was in the mesh list
  40249. */
  40250. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40251. /**
  40252. * Add a transform node to the list of scene's transform nodes
  40253. * @param newTransformNode defines the transform node to add
  40254. */
  40255. addTransformNode(newTransformNode: TransformNode): void;
  40256. /**
  40257. * Remove a transform node for the list of scene's transform nodes
  40258. * @param toRemove defines the transform node to remove
  40259. * @returns the index where the transform node was in the transform node list
  40260. */
  40261. removeTransformNode(toRemove: TransformNode): number;
  40262. /**
  40263. * Remove a skeleton for the list of scene's skeletons
  40264. * @param toRemove defines the skeleton to remove
  40265. * @returns the index where the skeleton was in the skeleton list
  40266. */
  40267. removeSkeleton(toRemove: Skeleton): number;
  40268. /**
  40269. * Remove a morph target for the list of scene's morph targets
  40270. * @param toRemove defines the morph target to remove
  40271. * @returns the index where the morph target was in the morph target list
  40272. */
  40273. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40274. /**
  40275. * Remove a light for the list of scene's lights
  40276. * @param toRemove defines the light to remove
  40277. * @returns the index where the light was in the light list
  40278. */
  40279. removeLight(toRemove: Light): number;
  40280. /**
  40281. * Remove a camera for the list of scene's cameras
  40282. * @param toRemove defines the camera to remove
  40283. * @returns the index where the camera was in the camera list
  40284. */
  40285. removeCamera(toRemove: Camera): number;
  40286. /**
  40287. * Remove a particle system for the list of scene's particle systems
  40288. * @param toRemove defines the particle system to remove
  40289. * @returns the index where the particle system was in the particle system list
  40290. */
  40291. removeParticleSystem(toRemove: IParticleSystem): number;
  40292. /**
  40293. * Remove a animation for the list of scene's animations
  40294. * @param toRemove defines the animation to remove
  40295. * @returns the index where the animation was in the animation list
  40296. */
  40297. removeAnimation(toRemove: Animation): number;
  40298. /**
  40299. * Will stop the animation of the given target
  40300. * @param target - the target
  40301. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40302. * @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)
  40303. */
  40304. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40305. /**
  40306. * Removes the given animation group from this scene.
  40307. * @param toRemove The animation group to remove
  40308. * @returns The index of the removed animation group
  40309. */
  40310. removeAnimationGroup(toRemove: AnimationGroup): number;
  40311. /**
  40312. * Removes the given multi-material from this scene.
  40313. * @param toRemove The multi-material to remove
  40314. * @returns The index of the removed multi-material
  40315. */
  40316. removeMultiMaterial(toRemove: MultiMaterial): number;
  40317. /**
  40318. * Removes the given material from this scene.
  40319. * @param toRemove The material to remove
  40320. * @returns The index of the removed material
  40321. */
  40322. removeMaterial(toRemove: Material): number;
  40323. /**
  40324. * Removes the given action manager from this scene.
  40325. * @param toRemove The action manager to remove
  40326. * @returns The index of the removed action manager
  40327. */
  40328. removeActionManager(toRemove: AbstractActionManager): number;
  40329. /**
  40330. * Removes the given texture from this scene.
  40331. * @param toRemove The texture to remove
  40332. * @returns The index of the removed texture
  40333. */
  40334. removeTexture(toRemove: BaseTexture): number;
  40335. /**
  40336. * Adds the given light to this scene
  40337. * @param newLight The light to add
  40338. */
  40339. addLight(newLight: Light): void;
  40340. /**
  40341. * Sorts the list list based on light priorities
  40342. */
  40343. sortLightsByPriority(): void;
  40344. /**
  40345. * Adds the given camera to this scene
  40346. * @param newCamera The camera to add
  40347. */
  40348. addCamera(newCamera: Camera): void;
  40349. /**
  40350. * Adds the given skeleton to this scene
  40351. * @param newSkeleton The skeleton to add
  40352. */
  40353. addSkeleton(newSkeleton: Skeleton): void;
  40354. /**
  40355. * Adds the given particle system to this scene
  40356. * @param newParticleSystem The particle system to add
  40357. */
  40358. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40359. /**
  40360. * Adds the given animation to this scene
  40361. * @param newAnimation The animation to add
  40362. */
  40363. addAnimation(newAnimation: Animation): void;
  40364. /**
  40365. * Adds the given animation group to this scene.
  40366. * @param newAnimationGroup The animation group to add
  40367. */
  40368. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40369. /**
  40370. * Adds the given multi-material to this scene
  40371. * @param newMultiMaterial The multi-material to add
  40372. */
  40373. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40374. /**
  40375. * Adds the given material to this scene
  40376. * @param newMaterial The material to add
  40377. */
  40378. addMaterial(newMaterial: Material): void;
  40379. /**
  40380. * Adds the given morph target to this scene
  40381. * @param newMorphTargetManager The morph target to add
  40382. */
  40383. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40384. /**
  40385. * Adds the given geometry to this scene
  40386. * @param newGeometry The geometry to add
  40387. */
  40388. addGeometry(newGeometry: Geometry): void;
  40389. /**
  40390. * Adds the given action manager to this scene
  40391. * @param newActionManager The action manager to add
  40392. */
  40393. addActionManager(newActionManager: AbstractActionManager): void;
  40394. /**
  40395. * Adds the given texture to this scene.
  40396. * @param newTexture The texture to add
  40397. */
  40398. addTexture(newTexture: BaseTexture): void;
  40399. /**
  40400. * Switch active camera
  40401. * @param newCamera defines the new active camera
  40402. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40403. */
  40404. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40405. /**
  40406. * sets the active camera of the scene using its ID
  40407. * @param id defines the camera's ID
  40408. * @return the new active camera or null if none found.
  40409. */
  40410. setActiveCameraByID(id: string): Nullable<Camera>;
  40411. /**
  40412. * sets the active camera of the scene using its name
  40413. * @param name defines the camera's name
  40414. * @returns the new active camera or null if none found.
  40415. */
  40416. setActiveCameraByName(name: string): Nullable<Camera>;
  40417. /**
  40418. * get an animation group using its name
  40419. * @param name defines the material's name
  40420. * @return the animation group or null if none found.
  40421. */
  40422. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40423. /**
  40424. * Get a material using its unique id
  40425. * @param uniqueId defines the material's unique id
  40426. * @return the material or null if none found.
  40427. */
  40428. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40429. /**
  40430. * get a material using its id
  40431. * @param id defines the material's ID
  40432. * @return the material or null if none found.
  40433. */
  40434. getMaterialByID(id: string): Nullable<Material>;
  40435. /**
  40436. * Gets a the last added material using a given id
  40437. * @param id defines the material's ID
  40438. * @return the last material with the given id or null if none found.
  40439. */
  40440. getLastMaterialByID(id: string): Nullable<Material>;
  40441. /**
  40442. * Gets a material using its name
  40443. * @param name defines the material's name
  40444. * @return the material or null if none found.
  40445. */
  40446. getMaterialByName(name: string): Nullable<Material>;
  40447. /**
  40448. * Get a texture using its unique id
  40449. * @param uniqueId defines the texture's unique id
  40450. * @return the texture or null if none found.
  40451. */
  40452. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40453. /**
  40454. * Gets a camera using its id
  40455. * @param id defines the id to look for
  40456. * @returns the camera or null if not found
  40457. */
  40458. getCameraByID(id: string): Nullable<Camera>;
  40459. /**
  40460. * Gets a camera using its unique id
  40461. * @param uniqueId defines the unique id to look for
  40462. * @returns the camera or null if not found
  40463. */
  40464. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40465. /**
  40466. * Gets a camera using its name
  40467. * @param name defines the camera's name
  40468. * @return the camera or null if none found.
  40469. */
  40470. getCameraByName(name: string): Nullable<Camera>;
  40471. /**
  40472. * Gets a bone using its id
  40473. * @param id defines the bone's id
  40474. * @return the bone or null if not found
  40475. */
  40476. getBoneByID(id: string): Nullable<Bone>;
  40477. /**
  40478. * Gets a bone using its id
  40479. * @param name defines the bone's name
  40480. * @return the bone or null if not found
  40481. */
  40482. getBoneByName(name: string): Nullable<Bone>;
  40483. /**
  40484. * Gets a light node using its name
  40485. * @param name defines the the light's name
  40486. * @return the light or null if none found.
  40487. */
  40488. getLightByName(name: string): Nullable<Light>;
  40489. /**
  40490. * Gets a light node using its id
  40491. * @param id defines the light's id
  40492. * @return the light or null if none found.
  40493. */
  40494. getLightByID(id: string): Nullable<Light>;
  40495. /**
  40496. * Gets a light node using its scene-generated unique ID
  40497. * @param uniqueId defines the light's unique id
  40498. * @return the light or null if none found.
  40499. */
  40500. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40501. /**
  40502. * Gets a particle system by id
  40503. * @param id defines the particle system id
  40504. * @return the corresponding system or null if none found
  40505. */
  40506. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40507. /**
  40508. * Gets a geometry using its ID
  40509. * @param id defines the geometry's id
  40510. * @return the geometry or null if none found.
  40511. */
  40512. getGeometryByID(id: string): Nullable<Geometry>;
  40513. private _getGeometryByUniqueID;
  40514. /**
  40515. * Add a new geometry to this scene
  40516. * @param geometry defines the geometry to be added to the scene.
  40517. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40518. * @return a boolean defining if the geometry was added or not
  40519. */
  40520. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40521. /**
  40522. * Removes an existing geometry
  40523. * @param geometry defines the geometry to be removed from the scene
  40524. * @return a boolean defining if the geometry was removed or not
  40525. */
  40526. removeGeometry(geometry: Geometry): boolean;
  40527. /**
  40528. * Gets the list of geometries attached to the scene
  40529. * @returns an array of Geometry
  40530. */
  40531. getGeometries(): Geometry[];
  40532. /**
  40533. * Gets the first added mesh found of a given ID
  40534. * @param id defines the id to search for
  40535. * @return the mesh found or null if not found at all
  40536. */
  40537. getMeshByID(id: string): Nullable<AbstractMesh>;
  40538. /**
  40539. * Gets a list of meshes using their id
  40540. * @param id defines the id to search for
  40541. * @returns a list of meshes
  40542. */
  40543. getMeshesByID(id: string): Array<AbstractMesh>;
  40544. /**
  40545. * Gets the first added transform node found of a given ID
  40546. * @param id defines the id to search for
  40547. * @return the found transform node or null if not found at all.
  40548. */
  40549. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40550. /**
  40551. * Gets a transform node with its auto-generated unique id
  40552. * @param uniqueId efines the unique id to search for
  40553. * @return the found transform node or null if not found at all.
  40554. */
  40555. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40556. /**
  40557. * Gets a list of transform nodes using their id
  40558. * @param id defines the id to search for
  40559. * @returns a list of transform nodes
  40560. */
  40561. getTransformNodesByID(id: string): Array<TransformNode>;
  40562. /**
  40563. * Gets a mesh with its auto-generated unique id
  40564. * @param uniqueId defines the unique id to search for
  40565. * @return the found mesh or null if not found at all.
  40566. */
  40567. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40568. /**
  40569. * Gets a the last added mesh using a given id
  40570. * @param id defines the id to search for
  40571. * @return the found mesh or null if not found at all.
  40572. */
  40573. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40574. /**
  40575. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40576. * @param id defines the id to search for
  40577. * @return the found node or null if not found at all
  40578. */
  40579. getLastEntryByID(id: string): Nullable<Node>;
  40580. /**
  40581. * Gets a node (Mesh, Camera, Light) using a given id
  40582. * @param id defines the id to search for
  40583. * @return the found node or null if not found at all
  40584. */
  40585. getNodeByID(id: string): Nullable<Node>;
  40586. /**
  40587. * Gets a node (Mesh, Camera, Light) using a given name
  40588. * @param name defines the name to search for
  40589. * @return the found node or null if not found at all.
  40590. */
  40591. getNodeByName(name: string): Nullable<Node>;
  40592. /**
  40593. * Gets a mesh using a given name
  40594. * @param name defines the name to search for
  40595. * @return the found mesh or null if not found at all.
  40596. */
  40597. getMeshByName(name: string): Nullable<AbstractMesh>;
  40598. /**
  40599. * Gets a transform node using a given name
  40600. * @param name defines the name to search for
  40601. * @return the found transform node or null if not found at all.
  40602. */
  40603. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40604. /**
  40605. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40606. * @param id defines the id to search for
  40607. * @return the found skeleton or null if not found at all.
  40608. */
  40609. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40610. /**
  40611. * Gets a skeleton using a given auto generated unique id
  40612. * @param uniqueId defines the unique id to search for
  40613. * @return the found skeleton or null if not found at all.
  40614. */
  40615. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40616. /**
  40617. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40618. * @param id defines the id to search for
  40619. * @return the found skeleton or null if not found at all.
  40620. */
  40621. getSkeletonById(id: string): Nullable<Skeleton>;
  40622. /**
  40623. * Gets a skeleton using a given name
  40624. * @param name defines the name to search for
  40625. * @return the found skeleton or null if not found at all.
  40626. */
  40627. getSkeletonByName(name: string): Nullable<Skeleton>;
  40628. /**
  40629. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40630. * @param id defines the id to search for
  40631. * @return the found morph target manager or null if not found at all.
  40632. */
  40633. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40634. /**
  40635. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40636. * @param id defines the id to search for
  40637. * @return the found morph target or null if not found at all.
  40638. */
  40639. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40640. /**
  40641. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40642. * @param name defines the name to search for
  40643. * @return the found morph target or null if not found at all.
  40644. */
  40645. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40646. /**
  40647. * Gets a boolean indicating if the given mesh is active
  40648. * @param mesh defines the mesh to look for
  40649. * @returns true if the mesh is in the active list
  40650. */
  40651. isActiveMesh(mesh: AbstractMesh): boolean;
  40652. /**
  40653. * Return a unique id as a string which can serve as an identifier for the scene
  40654. */
  40655. get uid(): string;
  40656. /**
  40657. * Add an externaly attached data from its key.
  40658. * This method call will fail and return false, if such key already exists.
  40659. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40660. * @param key the unique key that identifies the data
  40661. * @param data the data object to associate to the key for this Engine instance
  40662. * @return true if no such key were already present and the data was added successfully, false otherwise
  40663. */
  40664. addExternalData<T>(key: string, data: T): boolean;
  40665. /**
  40666. * Get an externaly attached data from its key
  40667. * @param key the unique key that identifies the data
  40668. * @return the associated data, if present (can be null), or undefined if not present
  40669. */
  40670. getExternalData<T>(key: string): Nullable<T>;
  40671. /**
  40672. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40673. * @param key the unique key that identifies the data
  40674. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40675. * @return the associated data, can be null if the factory returned null.
  40676. */
  40677. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40678. /**
  40679. * Remove an externaly attached data from the Engine instance
  40680. * @param key the unique key that identifies the data
  40681. * @return true if the data was successfully removed, false if it doesn't exist
  40682. */
  40683. removeExternalData(key: string): boolean;
  40684. private _evaluateSubMesh;
  40685. /**
  40686. * Clear the processed materials smart array preventing retention point in material dispose.
  40687. */
  40688. freeProcessedMaterials(): void;
  40689. private _preventFreeActiveMeshesAndRenderingGroups;
  40690. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40691. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40692. * when disposing several meshes in a row or a hierarchy of meshes.
  40693. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40694. */
  40695. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40696. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40697. /**
  40698. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40699. */
  40700. freeActiveMeshes(): void;
  40701. /**
  40702. * Clear the info related to rendering groups preventing retention points during dispose.
  40703. */
  40704. freeRenderingGroups(): void;
  40705. /** @hidden */
  40706. _isInIntermediateRendering(): boolean;
  40707. /**
  40708. * Lambda returning the list of potentially active meshes.
  40709. */
  40710. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40711. /**
  40712. * Lambda returning the list of potentially active sub meshes.
  40713. */
  40714. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40715. /**
  40716. * Lambda returning the list of potentially intersecting sub meshes.
  40717. */
  40718. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40719. /**
  40720. * Lambda returning the list of potentially colliding sub meshes.
  40721. */
  40722. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40723. private _activeMeshesFrozen;
  40724. private _skipEvaluateActiveMeshesCompletely;
  40725. /**
  40726. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40727. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40728. * @returns the current scene
  40729. */
  40730. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40731. /**
  40732. * Use this function to restart evaluating active meshes on every frame
  40733. * @returns the current scene
  40734. */
  40735. unfreezeActiveMeshes(): Scene;
  40736. private _evaluateActiveMeshes;
  40737. private _activeMesh;
  40738. /**
  40739. * Update the transform matrix to update from the current active camera
  40740. * @param force defines a boolean used to force the update even if cache is up to date
  40741. */
  40742. updateTransformMatrix(force?: boolean): void;
  40743. private _bindFrameBuffer;
  40744. /** @hidden */
  40745. _allowPostProcessClearColor: boolean;
  40746. /** @hidden */
  40747. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40748. private _processSubCameras;
  40749. private _checkIntersections;
  40750. /** @hidden */
  40751. _advancePhysicsEngineStep(step: number): void;
  40752. /**
  40753. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40754. */
  40755. getDeterministicFrameTime: () => number;
  40756. /** @hidden */
  40757. _animate(): void;
  40758. /** Execute all animations (for a frame) */
  40759. animate(): void;
  40760. /**
  40761. * Render the scene
  40762. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40763. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40764. */
  40765. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40766. /**
  40767. * Freeze all materials
  40768. * A frozen material will not be updatable but should be faster to render
  40769. */
  40770. freezeMaterials(): void;
  40771. /**
  40772. * Unfreeze all materials
  40773. * A frozen material will not be updatable but should be faster to render
  40774. */
  40775. unfreezeMaterials(): void;
  40776. /**
  40777. * Releases all held ressources
  40778. */
  40779. dispose(): void;
  40780. /**
  40781. * Gets if the scene is already disposed
  40782. */
  40783. get isDisposed(): boolean;
  40784. /**
  40785. * Call this function to reduce memory footprint of the scene.
  40786. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40787. */
  40788. clearCachedVertexData(): void;
  40789. /**
  40790. * This function will remove the local cached buffer data from texture.
  40791. * It will save memory but will prevent the texture from being rebuilt
  40792. */
  40793. cleanCachedTextureBuffer(): void;
  40794. /**
  40795. * Get the world extend vectors with an optional filter
  40796. *
  40797. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40798. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40799. */
  40800. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40801. min: Vector3;
  40802. max: Vector3;
  40803. };
  40804. /**
  40805. * Creates a ray that can be used to pick in the scene
  40806. * @param x defines the x coordinate of the origin (on-screen)
  40807. * @param y defines the y coordinate of the origin (on-screen)
  40808. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40809. * @param camera defines the camera to use for the picking
  40810. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40811. * @returns a Ray
  40812. */
  40813. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40814. /**
  40815. * Creates a ray that can be used to pick in the scene
  40816. * @param x defines the x coordinate of the origin (on-screen)
  40817. * @param y defines the y coordinate of the origin (on-screen)
  40818. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40819. * @param result defines the ray where to store the picking ray
  40820. * @param camera defines the camera to use for the picking
  40821. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40822. * @returns the current scene
  40823. */
  40824. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40825. /**
  40826. * Creates a ray that can be used to pick in the scene
  40827. * @param x defines the x coordinate of the origin (on-screen)
  40828. * @param y defines the y coordinate of the origin (on-screen)
  40829. * @param camera defines the camera to use for the picking
  40830. * @returns a Ray
  40831. */
  40832. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40833. /**
  40834. * Creates a ray that can be used to pick in the scene
  40835. * @param x defines the x coordinate of the origin (on-screen)
  40836. * @param y defines the y coordinate of the origin (on-screen)
  40837. * @param result defines the ray where to store the picking ray
  40838. * @param camera defines the camera to use for the picking
  40839. * @returns the current scene
  40840. */
  40841. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40842. /** Launch a ray to try to pick a mesh in the scene
  40843. * @param x position on screen
  40844. * @param y position on screen
  40845. * @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
  40846. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40847. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40848. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40849. * @returns a PickingInfo
  40850. */
  40851. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40852. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40853. * @param x position on screen
  40854. * @param y position on screen
  40855. * @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
  40856. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40857. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40858. * @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)
  40859. */
  40860. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40861. /** Use the given ray to pick a mesh in the scene
  40862. * @param ray The ray to use to pick meshes
  40863. * @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
  40864. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40865. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40866. * @returns a PickingInfo
  40867. */
  40868. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40869. /**
  40870. * Launch a ray to try to pick a mesh in the scene
  40871. * @param x X position on screen
  40872. * @param y Y position on screen
  40873. * @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
  40874. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40875. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40876. * @returns an array of PickingInfo
  40877. */
  40878. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40879. /**
  40880. * Launch a ray to try to pick a mesh in the scene
  40881. * @param ray Ray to use
  40882. * @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
  40883. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40884. * @returns an array of PickingInfo
  40885. */
  40886. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40887. /**
  40888. * Force the value of meshUnderPointer
  40889. * @param mesh defines the mesh to use
  40890. */
  40891. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40892. /**
  40893. * Gets the mesh under the pointer
  40894. * @returns a Mesh or null if no mesh is under the pointer
  40895. */
  40896. getPointerOverMesh(): Nullable<AbstractMesh>;
  40897. /** @hidden */
  40898. _rebuildGeometries(): void;
  40899. /** @hidden */
  40900. _rebuildTextures(): void;
  40901. private _getByTags;
  40902. /**
  40903. * Get a list of meshes by tags
  40904. * @param tagsQuery defines the tags query to use
  40905. * @param forEach defines a predicate used to filter results
  40906. * @returns an array of Mesh
  40907. */
  40908. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40909. /**
  40910. * Get a list of cameras by tags
  40911. * @param tagsQuery defines the tags query to use
  40912. * @param forEach defines a predicate used to filter results
  40913. * @returns an array of Camera
  40914. */
  40915. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40916. /**
  40917. * Get a list of lights by tags
  40918. * @param tagsQuery defines the tags query to use
  40919. * @param forEach defines a predicate used to filter results
  40920. * @returns an array of Light
  40921. */
  40922. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40923. /**
  40924. * Get a list of materials by tags
  40925. * @param tagsQuery defines the tags query to use
  40926. * @param forEach defines a predicate used to filter results
  40927. * @returns an array of Material
  40928. */
  40929. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40930. /**
  40931. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40932. * This allowed control for front to back rendering or reversly depending of the special needs.
  40933. *
  40934. * @param renderingGroupId The rendering group id corresponding to its index
  40935. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40936. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40937. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40938. */
  40939. 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;
  40940. /**
  40941. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40942. *
  40943. * @param renderingGroupId The rendering group id corresponding to its index
  40944. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40945. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40946. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40947. */
  40948. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40949. /**
  40950. * Gets the current auto clear configuration for one rendering group of the rendering
  40951. * manager.
  40952. * @param index the rendering group index to get the information for
  40953. * @returns The auto clear setup for the requested rendering group
  40954. */
  40955. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40956. private _blockMaterialDirtyMechanism;
  40957. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40958. get blockMaterialDirtyMechanism(): boolean;
  40959. set blockMaterialDirtyMechanism(value: boolean);
  40960. /**
  40961. * Will flag all materials as dirty to trigger new shader compilation
  40962. * @param flag defines the flag used to specify which material part must be marked as dirty
  40963. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40964. */
  40965. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40966. /** @hidden */
  40967. _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;
  40968. /** @hidden */
  40969. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40970. /** @hidden */
  40971. _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;
  40972. /** @hidden */
  40973. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40974. /** @hidden */
  40975. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40976. /** @hidden */
  40977. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40978. }
  40979. }
  40980. declare module BABYLON {
  40981. /**
  40982. * Set of assets to keep when moving a scene into an asset container.
  40983. */
  40984. export class KeepAssets extends AbstractScene {
  40985. }
  40986. /**
  40987. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40988. */
  40989. export class InstantiatedEntries {
  40990. /**
  40991. * List of new root nodes (eg. nodes with no parent)
  40992. */
  40993. rootNodes: TransformNode[];
  40994. /**
  40995. * List of new skeletons
  40996. */
  40997. skeletons: Skeleton[];
  40998. /**
  40999. * List of new animation groups
  41000. */
  41001. animationGroups: AnimationGroup[];
  41002. }
  41003. /**
  41004. * Container with a set of assets that can be added or removed from a scene.
  41005. */
  41006. export class AssetContainer extends AbstractScene {
  41007. private _wasAddedToScene;
  41008. /**
  41009. * The scene the AssetContainer belongs to.
  41010. */
  41011. scene: Scene;
  41012. /**
  41013. * Instantiates an AssetContainer.
  41014. * @param scene The scene the AssetContainer belongs to.
  41015. */
  41016. constructor(scene: Scene);
  41017. /**
  41018. * Instantiate or clone all meshes and add the new ones to the scene.
  41019. * Skeletons and animation groups will all be cloned
  41020. * @param nameFunction defines an optional function used to get new names for clones
  41021. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41022. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41023. */
  41024. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41025. /**
  41026. * Adds all the assets from the container to the scene.
  41027. */
  41028. addAllToScene(): void;
  41029. /**
  41030. * Removes all the assets in the container from the scene
  41031. */
  41032. removeAllFromScene(): void;
  41033. /**
  41034. * Disposes all the assets in the container
  41035. */
  41036. dispose(): void;
  41037. private _moveAssets;
  41038. /**
  41039. * Removes all the assets contained in the scene and adds them to the container.
  41040. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41041. */
  41042. moveAllFromScene(keepAssets?: KeepAssets): void;
  41043. /**
  41044. * 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.
  41045. * @returns the root mesh
  41046. */
  41047. createRootMesh(): Mesh;
  41048. /**
  41049. * Merge animations (direct and animation groups) from this asset container into a scene
  41050. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41051. * @param animatables set of animatables to retarget to a node from the scene
  41052. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41053. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41054. */
  41055. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41056. }
  41057. }
  41058. declare module BABYLON {
  41059. /**
  41060. * Defines how the parser contract is defined.
  41061. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41062. */
  41063. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41064. /**
  41065. * Defines how the individual parser contract is defined.
  41066. * These parser can parse an individual asset
  41067. */
  41068. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41069. /**
  41070. * Base class of the scene acting as a container for the different elements composing a scene.
  41071. * This class is dynamically extended by the different components of the scene increasing
  41072. * flexibility and reducing coupling
  41073. */
  41074. export abstract class AbstractScene {
  41075. /**
  41076. * Stores the list of available parsers in the application.
  41077. */
  41078. private static _BabylonFileParsers;
  41079. /**
  41080. * Stores the list of available individual parsers in the application.
  41081. */
  41082. private static _IndividualBabylonFileParsers;
  41083. /**
  41084. * Adds a parser in the list of available ones
  41085. * @param name Defines the name of the parser
  41086. * @param parser Defines the parser to add
  41087. */
  41088. static AddParser(name: string, parser: BabylonFileParser): void;
  41089. /**
  41090. * Gets a general parser from the list of avaialble ones
  41091. * @param name Defines the name of the parser
  41092. * @returns the requested parser or null
  41093. */
  41094. static GetParser(name: string): Nullable<BabylonFileParser>;
  41095. /**
  41096. * Adds n individual parser in the list of available ones
  41097. * @param name Defines the name of the parser
  41098. * @param parser Defines the parser to add
  41099. */
  41100. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41101. /**
  41102. * Gets an individual parser from the list of avaialble ones
  41103. * @param name Defines the name of the parser
  41104. * @returns the requested parser or null
  41105. */
  41106. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41107. /**
  41108. * Parser json data and populate both a scene and its associated container object
  41109. * @param jsonData Defines the data to parse
  41110. * @param scene Defines the scene to parse the data for
  41111. * @param container Defines the container attached to the parsing sequence
  41112. * @param rootUrl Defines the root url of the data
  41113. */
  41114. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41115. /**
  41116. * Gets the list of root nodes (ie. nodes with no parent)
  41117. */
  41118. rootNodes: Node[];
  41119. /** All of the cameras added to this scene
  41120. * @see https://doc.babylonjs.com/babylon101/cameras
  41121. */
  41122. cameras: Camera[];
  41123. /**
  41124. * All of the lights added to this scene
  41125. * @see https://doc.babylonjs.com/babylon101/lights
  41126. */
  41127. lights: Light[];
  41128. /**
  41129. * All of the (abstract) meshes added to this scene
  41130. */
  41131. meshes: AbstractMesh[];
  41132. /**
  41133. * The list of skeletons added to the scene
  41134. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41135. */
  41136. skeletons: Skeleton[];
  41137. /**
  41138. * All of the particle systems added to this scene
  41139. * @see https://doc.babylonjs.com/babylon101/particles
  41140. */
  41141. particleSystems: IParticleSystem[];
  41142. /**
  41143. * Gets a list of Animations associated with the scene
  41144. */
  41145. animations: Animation[];
  41146. /**
  41147. * All of the animation groups added to this scene
  41148. * @see https://doc.babylonjs.com/how_to/group
  41149. */
  41150. animationGroups: AnimationGroup[];
  41151. /**
  41152. * All of the multi-materials added to this scene
  41153. * @see https://doc.babylonjs.com/how_to/multi_materials
  41154. */
  41155. multiMaterials: MultiMaterial[];
  41156. /**
  41157. * All of the materials added to this scene
  41158. * In the context of a Scene, it is not supposed to be modified manually.
  41159. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41160. * Note also that the order of the Material within the array is not significant and might change.
  41161. * @see https://doc.babylonjs.com/babylon101/materials
  41162. */
  41163. materials: Material[];
  41164. /**
  41165. * The list of morph target managers added to the scene
  41166. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41167. */
  41168. morphTargetManagers: MorphTargetManager[];
  41169. /**
  41170. * The list of geometries used in the scene.
  41171. */
  41172. geometries: Geometry[];
  41173. /**
  41174. * All of the tranform nodes added to this scene
  41175. * In the context of a Scene, it is not supposed to be modified manually.
  41176. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41177. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41178. * @see https://doc.babylonjs.com/how_to/transformnode
  41179. */
  41180. transformNodes: TransformNode[];
  41181. /**
  41182. * ActionManagers available on the scene.
  41183. */
  41184. actionManagers: AbstractActionManager[];
  41185. /**
  41186. * Textures to keep.
  41187. */
  41188. textures: BaseTexture[];
  41189. /**
  41190. * Environment texture for the scene
  41191. */
  41192. environmentTexture: Nullable<BaseTexture>;
  41193. /**
  41194. * @returns all meshes, lights, cameras, transformNodes and bones
  41195. */
  41196. getNodes(): Array<Node>;
  41197. }
  41198. }
  41199. declare module BABYLON {
  41200. /**
  41201. * Interface used to define options for Sound class
  41202. */
  41203. export interface ISoundOptions {
  41204. /**
  41205. * Does the sound autoplay once loaded.
  41206. */
  41207. autoplay?: boolean;
  41208. /**
  41209. * Does the sound loop after it finishes playing once.
  41210. */
  41211. loop?: boolean;
  41212. /**
  41213. * Sound's volume
  41214. */
  41215. volume?: number;
  41216. /**
  41217. * Is it a spatial sound?
  41218. */
  41219. spatialSound?: boolean;
  41220. /**
  41221. * Maximum distance to hear that sound
  41222. */
  41223. maxDistance?: number;
  41224. /**
  41225. * Uses user defined attenuation function
  41226. */
  41227. useCustomAttenuation?: boolean;
  41228. /**
  41229. * Define the roll off factor of spatial sounds.
  41230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41231. */
  41232. rolloffFactor?: number;
  41233. /**
  41234. * Define the reference distance the sound should be heard perfectly.
  41235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41236. */
  41237. refDistance?: number;
  41238. /**
  41239. * Define the distance attenuation model the sound will follow.
  41240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41241. */
  41242. distanceModel?: string;
  41243. /**
  41244. * Defines the playback speed (1 by default)
  41245. */
  41246. playbackRate?: number;
  41247. /**
  41248. * Defines if the sound is from a streaming source
  41249. */
  41250. streaming?: boolean;
  41251. /**
  41252. * Defines an optional length (in seconds) inside the sound file
  41253. */
  41254. length?: number;
  41255. /**
  41256. * Defines an optional offset (in seconds) inside the sound file
  41257. */
  41258. offset?: number;
  41259. /**
  41260. * If true, URLs will not be required to state the audio file codec to use.
  41261. */
  41262. skipCodecCheck?: boolean;
  41263. }
  41264. /**
  41265. * Defines a sound that can be played in the application.
  41266. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41268. */
  41269. export class Sound {
  41270. /**
  41271. * The name of the sound in the scene.
  41272. */
  41273. name: string;
  41274. /**
  41275. * Does the sound autoplay once loaded.
  41276. */
  41277. autoplay: boolean;
  41278. /**
  41279. * Does the sound loop after it finishes playing once.
  41280. */
  41281. loop: boolean;
  41282. /**
  41283. * Does the sound use a custom attenuation curve to simulate the falloff
  41284. * happening when the source gets further away from the camera.
  41285. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41286. */
  41287. useCustomAttenuation: boolean;
  41288. /**
  41289. * The sound track id this sound belongs to.
  41290. */
  41291. soundTrackId: number;
  41292. /**
  41293. * Is this sound currently played.
  41294. */
  41295. isPlaying: boolean;
  41296. /**
  41297. * Is this sound currently paused.
  41298. */
  41299. isPaused: boolean;
  41300. /**
  41301. * Does this sound enables spatial sound.
  41302. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41303. */
  41304. spatialSound: boolean;
  41305. /**
  41306. * Define the reference distance the sound should be heard perfectly.
  41307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41308. */
  41309. refDistance: number;
  41310. /**
  41311. * Define the roll off factor of spatial sounds.
  41312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41313. */
  41314. rolloffFactor: number;
  41315. /**
  41316. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41317. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41318. */
  41319. maxDistance: number;
  41320. /**
  41321. * Define the distance attenuation model the sound will follow.
  41322. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41323. */
  41324. distanceModel: string;
  41325. /**
  41326. * @hidden
  41327. * Back Compat
  41328. **/
  41329. onended: () => any;
  41330. /**
  41331. * Gets or sets an object used to store user defined information for the sound.
  41332. */
  41333. metadata: any;
  41334. /**
  41335. * Observable event when the current playing sound finishes.
  41336. */
  41337. onEndedObservable: Observable<Sound>;
  41338. private _panningModel;
  41339. private _playbackRate;
  41340. private _streaming;
  41341. private _startTime;
  41342. private _startOffset;
  41343. private _position;
  41344. /** @hidden */
  41345. _positionInEmitterSpace: boolean;
  41346. private _localDirection;
  41347. private _volume;
  41348. private _isReadyToPlay;
  41349. private _isDirectional;
  41350. private _readyToPlayCallback;
  41351. private _audioBuffer;
  41352. private _soundSource;
  41353. private _streamingSource;
  41354. private _soundPanner;
  41355. private _soundGain;
  41356. private _inputAudioNode;
  41357. private _outputAudioNode;
  41358. private _coneInnerAngle;
  41359. private _coneOuterAngle;
  41360. private _coneOuterGain;
  41361. private _scene;
  41362. private _connectedTransformNode;
  41363. private _customAttenuationFunction;
  41364. private _registerFunc;
  41365. private _isOutputConnected;
  41366. private _htmlAudioElement;
  41367. private _urlType;
  41368. private _length?;
  41369. private _offset?;
  41370. /** @hidden */
  41371. static _SceneComponentInitialization: (scene: Scene) => void;
  41372. /**
  41373. * Create a sound and attach it to a scene
  41374. * @param name Name of your sound
  41375. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41376. * @param scene defines the scene the sound belongs to
  41377. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41378. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41379. */
  41380. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41381. /**
  41382. * Release the sound and its associated resources
  41383. */
  41384. dispose(): void;
  41385. /**
  41386. * Gets if the sounds is ready to be played or not.
  41387. * @returns true if ready, otherwise false
  41388. */
  41389. isReady(): boolean;
  41390. private _soundLoaded;
  41391. /**
  41392. * Sets the data of the sound from an audiobuffer
  41393. * @param audioBuffer The audioBuffer containing the data
  41394. */
  41395. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41396. /**
  41397. * Updates the current sounds options such as maxdistance, loop...
  41398. * @param options A JSON object containing values named as the object properties
  41399. */
  41400. updateOptions(options: ISoundOptions): void;
  41401. private _createSpatialParameters;
  41402. private _updateSpatialParameters;
  41403. /**
  41404. * Switch the panning model to HRTF:
  41405. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41407. */
  41408. switchPanningModelToHRTF(): void;
  41409. /**
  41410. * Switch the panning model to Equal Power:
  41411. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41413. */
  41414. switchPanningModelToEqualPower(): void;
  41415. private _switchPanningModel;
  41416. /**
  41417. * Connect this sound to a sound track audio node like gain...
  41418. * @param soundTrackAudioNode the sound track audio node to connect to
  41419. */
  41420. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41421. /**
  41422. * Transform this sound into a directional source
  41423. * @param coneInnerAngle Size of the inner cone in degree
  41424. * @param coneOuterAngle Size of the outer cone in degree
  41425. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41426. */
  41427. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41428. /**
  41429. * Gets or sets the inner angle for the directional cone.
  41430. */
  41431. get directionalConeInnerAngle(): number;
  41432. /**
  41433. * Gets or sets the inner angle for the directional cone.
  41434. */
  41435. set directionalConeInnerAngle(value: number);
  41436. /**
  41437. * Gets or sets the outer angle for the directional cone.
  41438. */
  41439. get directionalConeOuterAngle(): number;
  41440. /**
  41441. * Gets or sets the outer angle for the directional cone.
  41442. */
  41443. set directionalConeOuterAngle(value: number);
  41444. /**
  41445. * Sets the position of the emitter if spatial sound is enabled
  41446. * @param newPosition Defines the new posisiton
  41447. */
  41448. setPosition(newPosition: Vector3): void;
  41449. /**
  41450. * Sets the local direction of the emitter if spatial sound is enabled
  41451. * @param newLocalDirection Defines the new local direction
  41452. */
  41453. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41454. private _updateDirection;
  41455. /** @hidden */
  41456. updateDistanceFromListener(): void;
  41457. /**
  41458. * Sets a new custom attenuation function for the sound.
  41459. * @param callback Defines the function used for the attenuation
  41460. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41461. */
  41462. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41463. /**
  41464. * Play the sound
  41465. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41466. * @param offset (optional) Start the sound at a specific time in seconds
  41467. * @param length (optional) Sound duration (in seconds)
  41468. */
  41469. play(time?: number, offset?: number, length?: number): void;
  41470. private _onended;
  41471. /**
  41472. * Stop the sound
  41473. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41474. */
  41475. stop(time?: number): void;
  41476. /**
  41477. * Put the sound in pause
  41478. */
  41479. pause(): void;
  41480. /**
  41481. * Sets a dedicated volume for this sounds
  41482. * @param newVolume Define the new volume of the sound
  41483. * @param time Define time for gradual change to new volume
  41484. */
  41485. setVolume(newVolume: number, time?: number): void;
  41486. /**
  41487. * Set the sound play back rate
  41488. * @param newPlaybackRate Define the playback rate the sound should be played at
  41489. */
  41490. setPlaybackRate(newPlaybackRate: number): void;
  41491. /**
  41492. * Gets the volume of the sound.
  41493. * @returns the volume of the sound
  41494. */
  41495. getVolume(): number;
  41496. /**
  41497. * Attach the sound to a dedicated mesh
  41498. * @param transformNode The transform node to connect the sound with
  41499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41500. */
  41501. attachToMesh(transformNode: TransformNode): void;
  41502. /**
  41503. * Detach the sound from the previously attached mesh
  41504. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41505. */
  41506. detachFromMesh(): void;
  41507. private _onRegisterAfterWorldMatrixUpdate;
  41508. /**
  41509. * Clone the current sound in the scene.
  41510. * @returns the new sound clone
  41511. */
  41512. clone(): Nullable<Sound>;
  41513. /**
  41514. * Gets the current underlying audio buffer containing the data
  41515. * @returns the audio buffer
  41516. */
  41517. getAudioBuffer(): Nullable<AudioBuffer>;
  41518. /**
  41519. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41520. * @returns the source node
  41521. */
  41522. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41523. /**
  41524. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41525. * @returns the gain node
  41526. */
  41527. getSoundGain(): Nullable<GainNode>;
  41528. /**
  41529. * Serializes the Sound in a JSON representation
  41530. * @returns the JSON representation of the sound
  41531. */
  41532. serialize(): any;
  41533. /**
  41534. * Parse a JSON representation of a sound to innstantiate in a given scene
  41535. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41536. * @param scene Define the scene the new parsed sound should be created in
  41537. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41538. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41539. * @returns the newly parsed sound
  41540. */
  41541. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41542. }
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * This defines an action helpful to play a defined sound on a triggered action.
  41547. */
  41548. export class PlaySoundAction extends Action {
  41549. private _sound;
  41550. /**
  41551. * Instantiate the action
  41552. * @param triggerOptions defines the trigger options
  41553. * @param sound defines the sound to play
  41554. * @param condition defines the trigger related conditions
  41555. */
  41556. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41557. /** @hidden */
  41558. _prepare(): void;
  41559. /**
  41560. * Execute the action and play the sound.
  41561. */
  41562. execute(): void;
  41563. /**
  41564. * Serializes the actions and its related information.
  41565. * @param parent defines the object to serialize in
  41566. * @returns the serialized object
  41567. */
  41568. serialize(parent: any): any;
  41569. }
  41570. /**
  41571. * This defines an action helpful to stop a defined sound on a triggered action.
  41572. */
  41573. export class StopSoundAction extends Action {
  41574. private _sound;
  41575. /**
  41576. * Instantiate the action
  41577. * @param triggerOptions defines the trigger options
  41578. * @param sound defines the sound to stop
  41579. * @param condition defines the trigger related conditions
  41580. */
  41581. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41582. /** @hidden */
  41583. _prepare(): void;
  41584. /**
  41585. * Execute the action and stop the sound.
  41586. */
  41587. execute(): void;
  41588. /**
  41589. * Serializes the actions and its related information.
  41590. * @param parent defines the object to serialize in
  41591. * @returns the serialized object
  41592. */
  41593. serialize(parent: any): any;
  41594. }
  41595. }
  41596. declare module BABYLON {
  41597. /**
  41598. * This defines an action responsible to change the value of a property
  41599. * by interpolating between its current value and the newly set one once triggered.
  41600. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41601. */
  41602. export class InterpolateValueAction extends Action {
  41603. /**
  41604. * Defines the path of the property where the value should be interpolated
  41605. */
  41606. propertyPath: string;
  41607. /**
  41608. * Defines the target value at the end of the interpolation.
  41609. */
  41610. value: any;
  41611. /**
  41612. * Defines the time it will take for the property to interpolate to the value.
  41613. */
  41614. duration: number;
  41615. /**
  41616. * Defines if the other scene animations should be stopped when the action has been triggered
  41617. */
  41618. stopOtherAnimations?: boolean;
  41619. /**
  41620. * Defines a callback raised once the interpolation animation has been done.
  41621. */
  41622. onInterpolationDone?: () => void;
  41623. /**
  41624. * Observable triggered once the interpolation animation has been done.
  41625. */
  41626. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41627. private _target;
  41628. private _effectiveTarget;
  41629. private _property;
  41630. /**
  41631. * Instantiate the action
  41632. * @param triggerOptions defines the trigger options
  41633. * @param target defines the object containing the value to interpolate
  41634. * @param propertyPath defines the path to the property in the target object
  41635. * @param value defines the target value at the end of the interpolation
  41636. * @param duration deines the time it will take for the property to interpolate to the value.
  41637. * @param condition defines the trigger related conditions
  41638. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41639. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41640. */
  41641. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41642. /** @hidden */
  41643. _prepare(): void;
  41644. /**
  41645. * Execute the action starts the value interpolation.
  41646. */
  41647. execute(): void;
  41648. /**
  41649. * Serializes the actions and its related information.
  41650. * @param parent defines the object to serialize in
  41651. * @returns the serialized object
  41652. */
  41653. serialize(parent: any): any;
  41654. }
  41655. }
  41656. declare module BABYLON {
  41657. /**
  41658. * Options allowed during the creation of a sound track.
  41659. */
  41660. export interface ISoundTrackOptions {
  41661. /**
  41662. * The volume the sound track should take during creation
  41663. */
  41664. volume?: number;
  41665. /**
  41666. * Define if the sound track is the main sound track of the scene
  41667. */
  41668. mainTrack?: boolean;
  41669. }
  41670. /**
  41671. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41672. * It will be also used in a future release to apply effects on a specific track.
  41673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41674. */
  41675. export class SoundTrack {
  41676. /**
  41677. * The unique identifier of the sound track in the scene.
  41678. */
  41679. id: number;
  41680. /**
  41681. * The list of sounds included in the sound track.
  41682. */
  41683. soundCollection: Array<Sound>;
  41684. private _outputAudioNode;
  41685. private _scene;
  41686. private _connectedAnalyser;
  41687. private _options;
  41688. private _isInitialized;
  41689. /**
  41690. * Creates a new sound track.
  41691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41692. * @param scene Define the scene the sound track belongs to
  41693. * @param options
  41694. */
  41695. constructor(scene: Scene, options?: ISoundTrackOptions);
  41696. private _initializeSoundTrackAudioGraph;
  41697. /**
  41698. * Release the sound track and its associated resources
  41699. */
  41700. dispose(): void;
  41701. /**
  41702. * Adds a sound to this sound track
  41703. * @param sound define the cound to add
  41704. * @ignoreNaming
  41705. */
  41706. AddSound(sound: Sound): void;
  41707. /**
  41708. * Removes a sound to this sound track
  41709. * @param sound define the cound to remove
  41710. * @ignoreNaming
  41711. */
  41712. RemoveSound(sound: Sound): void;
  41713. /**
  41714. * Set a global volume for the full sound track.
  41715. * @param newVolume Define the new volume of the sound track
  41716. */
  41717. setVolume(newVolume: number): void;
  41718. /**
  41719. * Switch the panning model to HRTF:
  41720. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41722. */
  41723. switchPanningModelToHRTF(): void;
  41724. /**
  41725. * Switch the panning model to Equal Power:
  41726. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41727. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41728. */
  41729. switchPanningModelToEqualPower(): void;
  41730. /**
  41731. * Connect the sound track to an audio analyser allowing some amazing
  41732. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41734. * @param analyser The analyser to connect to the engine
  41735. */
  41736. connectToAnalyser(analyser: Analyser): void;
  41737. }
  41738. }
  41739. declare module BABYLON {
  41740. interface AbstractScene {
  41741. /**
  41742. * The list of sounds used in the scene.
  41743. */
  41744. sounds: Nullable<Array<Sound>>;
  41745. }
  41746. interface Scene {
  41747. /**
  41748. * @hidden
  41749. * Backing field
  41750. */
  41751. _mainSoundTrack: SoundTrack;
  41752. /**
  41753. * The main sound track played by the scene.
  41754. * It cotains your primary collection of sounds.
  41755. */
  41756. mainSoundTrack: SoundTrack;
  41757. /**
  41758. * The list of sound tracks added to the scene
  41759. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41760. */
  41761. soundTracks: Nullable<Array<SoundTrack>>;
  41762. /**
  41763. * Gets a sound using a given name
  41764. * @param name defines the name to search for
  41765. * @return the found sound or null if not found at all.
  41766. */
  41767. getSoundByName(name: string): Nullable<Sound>;
  41768. /**
  41769. * Gets or sets if audio support is enabled
  41770. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41771. */
  41772. audioEnabled: boolean;
  41773. /**
  41774. * Gets or sets if audio will be output to headphones
  41775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41776. */
  41777. headphone: boolean;
  41778. /**
  41779. * Gets or sets custom audio listener position provider
  41780. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41781. */
  41782. audioListenerPositionProvider: Nullable<() => Vector3>;
  41783. /**
  41784. * Gets or sets a refresh rate when using 3D audio positioning
  41785. */
  41786. audioPositioningRefreshRate: number;
  41787. }
  41788. /**
  41789. * Defines the sound scene component responsible to manage any sounds
  41790. * in a given scene.
  41791. */
  41792. export class AudioSceneComponent implements ISceneSerializableComponent {
  41793. /**
  41794. * The component name helpfull to identify the component in the list of scene components.
  41795. */
  41796. readonly name: string;
  41797. /**
  41798. * The scene the component belongs to.
  41799. */
  41800. scene: Scene;
  41801. private _audioEnabled;
  41802. /**
  41803. * Gets whether audio is enabled or not.
  41804. * Please use related enable/disable method to switch state.
  41805. */
  41806. get audioEnabled(): boolean;
  41807. private _headphone;
  41808. /**
  41809. * Gets whether audio is outputing to headphone or not.
  41810. * Please use the according Switch methods to change output.
  41811. */
  41812. get headphone(): boolean;
  41813. /**
  41814. * Gets or sets a refresh rate when using 3D audio positioning
  41815. */
  41816. audioPositioningRefreshRate: number;
  41817. private _audioListenerPositionProvider;
  41818. /**
  41819. * Gets the current audio listener position provider
  41820. */
  41821. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41822. /**
  41823. * Sets a custom listener position for all sounds in the scene
  41824. * By default, this is the position of the first active camera
  41825. */
  41826. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41827. /**
  41828. * Creates a new instance of the component for the given scene
  41829. * @param scene Defines the scene to register the component in
  41830. */
  41831. constructor(scene: Scene);
  41832. /**
  41833. * Registers the component in a given scene
  41834. */
  41835. register(): void;
  41836. /**
  41837. * Rebuilds the elements related to this component in case of
  41838. * context lost for instance.
  41839. */
  41840. rebuild(): void;
  41841. /**
  41842. * Serializes the component data to the specified json object
  41843. * @param serializationObject The object to serialize to
  41844. */
  41845. serialize(serializationObject: any): void;
  41846. /**
  41847. * Adds all the elements from the container to the scene
  41848. * @param container the container holding the elements
  41849. */
  41850. addFromContainer(container: AbstractScene): void;
  41851. /**
  41852. * Removes all the elements in the container from the scene
  41853. * @param container contains the elements to remove
  41854. * @param dispose if the removed element should be disposed (default: false)
  41855. */
  41856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41857. /**
  41858. * Disposes the component and the associated ressources.
  41859. */
  41860. dispose(): void;
  41861. /**
  41862. * Disables audio in the associated scene.
  41863. */
  41864. disableAudio(): void;
  41865. /**
  41866. * Enables audio in the associated scene.
  41867. */
  41868. enableAudio(): void;
  41869. /**
  41870. * Switch audio to headphone output.
  41871. */
  41872. switchAudioModeForHeadphones(): void;
  41873. /**
  41874. * Switch audio to normal speakers.
  41875. */
  41876. switchAudioModeForNormalSpeakers(): void;
  41877. private _cachedCameraDirection;
  41878. private _cachedCameraPosition;
  41879. private _lastCheck;
  41880. private _afterRender;
  41881. }
  41882. }
  41883. declare module BABYLON {
  41884. /**
  41885. * Wraps one or more Sound objects and selects one with random weight for playback.
  41886. */
  41887. export class WeightedSound {
  41888. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41889. loop: boolean;
  41890. private _coneInnerAngle;
  41891. private _coneOuterAngle;
  41892. private _volume;
  41893. /** A Sound is currently playing. */
  41894. isPlaying: boolean;
  41895. /** A Sound is currently paused. */
  41896. isPaused: boolean;
  41897. private _sounds;
  41898. private _weights;
  41899. private _currentIndex?;
  41900. /**
  41901. * Creates a new WeightedSound from the list of sounds given.
  41902. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41903. * @param sounds Array of Sounds that will be selected from.
  41904. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41905. */
  41906. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41907. /**
  41908. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41909. */
  41910. get directionalConeInnerAngle(): number;
  41911. /**
  41912. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41913. */
  41914. set directionalConeInnerAngle(value: number);
  41915. /**
  41916. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41917. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41918. */
  41919. get directionalConeOuterAngle(): number;
  41920. /**
  41921. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41922. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41923. */
  41924. set directionalConeOuterAngle(value: number);
  41925. /**
  41926. * Playback volume.
  41927. */
  41928. get volume(): number;
  41929. /**
  41930. * Playback volume.
  41931. */
  41932. set volume(value: number);
  41933. private _onended;
  41934. /**
  41935. * Suspend playback
  41936. */
  41937. pause(): void;
  41938. /**
  41939. * Stop playback
  41940. */
  41941. stop(): void;
  41942. /**
  41943. * Start playback.
  41944. * @param startOffset Position the clip head at a specific time in seconds.
  41945. */
  41946. play(startOffset?: number): void;
  41947. }
  41948. }
  41949. declare module BABYLON {
  41950. /**
  41951. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41952. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41953. */
  41954. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41955. /**
  41956. * Gets the name of the behavior.
  41957. */
  41958. get name(): string;
  41959. /**
  41960. * The easing function used by animations
  41961. */
  41962. static EasingFunction: BackEase;
  41963. /**
  41964. * The easing mode used by animations
  41965. */
  41966. static EasingMode: number;
  41967. /**
  41968. * The duration of the animation, in milliseconds
  41969. */
  41970. transitionDuration: number;
  41971. /**
  41972. * Length of the distance animated by the transition when lower radius is reached
  41973. */
  41974. lowerRadiusTransitionRange: number;
  41975. /**
  41976. * Length of the distance animated by the transition when upper radius is reached
  41977. */
  41978. upperRadiusTransitionRange: number;
  41979. private _autoTransitionRange;
  41980. /**
  41981. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41982. */
  41983. get autoTransitionRange(): boolean;
  41984. /**
  41985. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41986. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41987. */
  41988. set autoTransitionRange(value: boolean);
  41989. private _attachedCamera;
  41990. private _onAfterCheckInputsObserver;
  41991. private _onMeshTargetChangedObserver;
  41992. /**
  41993. * Initializes the behavior.
  41994. */
  41995. init(): void;
  41996. /**
  41997. * Attaches the behavior to its arc rotate camera.
  41998. * @param camera Defines the camera to attach the behavior to
  41999. */
  42000. attach(camera: ArcRotateCamera): void;
  42001. /**
  42002. * Detaches the behavior from its current arc rotate camera.
  42003. */
  42004. detach(): void;
  42005. private _radiusIsAnimating;
  42006. private _radiusBounceTransition;
  42007. private _animatables;
  42008. private _cachedWheelPrecision;
  42009. /**
  42010. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42011. * @param radiusLimit The limit to check against.
  42012. * @return Bool to indicate if at limit.
  42013. */
  42014. private _isRadiusAtLimit;
  42015. /**
  42016. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42017. * @param radiusDelta The delta by which to animate to. Can be negative.
  42018. */
  42019. private _applyBoundRadiusAnimation;
  42020. /**
  42021. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42022. */
  42023. protected _clearAnimationLocks(): void;
  42024. /**
  42025. * Stops and removes all animations that have been applied to the camera
  42026. */
  42027. stopAllAnimations(): void;
  42028. }
  42029. }
  42030. declare module BABYLON {
  42031. /**
  42032. * 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.
  42033. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42034. */
  42035. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42036. /**
  42037. * Gets the name of the behavior.
  42038. */
  42039. get name(): string;
  42040. private _mode;
  42041. private _radiusScale;
  42042. private _positionScale;
  42043. private _defaultElevation;
  42044. private _elevationReturnTime;
  42045. private _elevationReturnWaitTime;
  42046. private _zoomStopsAnimation;
  42047. private _framingTime;
  42048. /**
  42049. * The easing function used by animations
  42050. */
  42051. static EasingFunction: ExponentialEase;
  42052. /**
  42053. * The easing mode used by animations
  42054. */
  42055. static EasingMode: number;
  42056. /**
  42057. * Sets the current mode used by the behavior
  42058. */
  42059. set mode(mode: number);
  42060. /**
  42061. * Gets current mode used by the behavior.
  42062. */
  42063. get mode(): number;
  42064. /**
  42065. * Sets the scale applied to the radius (1 by default)
  42066. */
  42067. set radiusScale(radius: number);
  42068. /**
  42069. * Gets the scale applied to the radius
  42070. */
  42071. get radiusScale(): number;
  42072. /**
  42073. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42074. */
  42075. set positionScale(scale: number);
  42076. /**
  42077. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42078. */
  42079. get positionScale(): number;
  42080. /**
  42081. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42082. * behaviour is triggered, in radians.
  42083. */
  42084. set defaultElevation(elevation: number);
  42085. /**
  42086. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42087. * behaviour is triggered, in radians.
  42088. */
  42089. get defaultElevation(): number;
  42090. /**
  42091. * Sets the time (in milliseconds) taken to return to the default beta position.
  42092. * Negative value indicates camera should not return to default.
  42093. */
  42094. set elevationReturnTime(speed: number);
  42095. /**
  42096. * Gets the time (in milliseconds) taken to return to the default beta position.
  42097. * Negative value indicates camera should not return to default.
  42098. */
  42099. get elevationReturnTime(): number;
  42100. /**
  42101. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42102. */
  42103. set elevationReturnWaitTime(time: number);
  42104. /**
  42105. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42106. */
  42107. get elevationReturnWaitTime(): number;
  42108. /**
  42109. * Sets the flag that indicates if user zooming should stop animation.
  42110. */
  42111. set zoomStopsAnimation(flag: boolean);
  42112. /**
  42113. * Gets the flag that indicates if user zooming should stop animation.
  42114. */
  42115. get zoomStopsAnimation(): boolean;
  42116. /**
  42117. * Sets the transition time when framing the mesh, in milliseconds
  42118. */
  42119. set framingTime(time: number);
  42120. /**
  42121. * Gets the transition time when framing the mesh, in milliseconds
  42122. */
  42123. get framingTime(): number;
  42124. /**
  42125. * Define if the behavior should automatically change the configured
  42126. * camera limits and sensibilities.
  42127. */
  42128. autoCorrectCameraLimitsAndSensibility: boolean;
  42129. private _onPrePointerObservableObserver;
  42130. private _onAfterCheckInputsObserver;
  42131. private _onMeshTargetChangedObserver;
  42132. private _attachedCamera;
  42133. private _isPointerDown;
  42134. private _lastInteractionTime;
  42135. /**
  42136. * Initializes the behavior.
  42137. */
  42138. init(): void;
  42139. /**
  42140. * Attaches the behavior to its arc rotate camera.
  42141. * @param camera Defines the camera to attach the behavior to
  42142. */
  42143. attach(camera: ArcRotateCamera): void;
  42144. /**
  42145. * Detaches the behavior from its current arc rotate camera.
  42146. */
  42147. detach(): void;
  42148. private _animatables;
  42149. private _betaIsAnimating;
  42150. private _betaTransition;
  42151. private _radiusTransition;
  42152. private _vectorTransition;
  42153. /**
  42154. * Targets the given mesh and updates zoom level accordingly.
  42155. * @param mesh The mesh to target.
  42156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42158. */
  42159. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42160. /**
  42161. * Targets the given mesh with its children and updates zoom level accordingly.
  42162. * @param mesh The mesh to target.
  42163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42165. */
  42166. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42167. /**
  42168. * Targets the given meshes with their children and updates zoom level accordingly.
  42169. * @param meshes The mesh to target.
  42170. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42171. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42172. */
  42173. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42174. /**
  42175. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42176. * @param minimumWorld Determines the smaller position of the bounding box extend
  42177. * @param maximumWorld Determines the bigger position of the bounding box extend
  42178. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42179. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42180. */
  42181. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42182. /**
  42183. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42184. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42185. * frustum width.
  42186. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42187. * to fully enclose the mesh in the viewing frustum.
  42188. */
  42189. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42190. /**
  42191. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42192. * is automatically returned to its default position (expected to be above ground plane).
  42193. */
  42194. private _maintainCameraAboveGround;
  42195. /**
  42196. * Returns the frustum slope based on the canvas ratio and camera FOV
  42197. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42198. */
  42199. private _getFrustumSlope;
  42200. /**
  42201. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42202. */
  42203. private _clearAnimationLocks;
  42204. /**
  42205. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42206. */
  42207. private _applyUserInteraction;
  42208. /**
  42209. * Stops and removes all animations that have been applied to the camera
  42210. */
  42211. stopAllAnimations(): void;
  42212. /**
  42213. * Gets a value indicating if the user is moving the camera
  42214. */
  42215. get isUserIsMoving(): boolean;
  42216. /**
  42217. * The camera can move all the way towards the mesh.
  42218. */
  42219. static IgnoreBoundsSizeMode: number;
  42220. /**
  42221. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42222. */
  42223. static FitFrustumSidesMode: number;
  42224. }
  42225. }
  42226. declare module BABYLON {
  42227. /**
  42228. * Base class for Camera Pointer Inputs.
  42229. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42230. * for example usage.
  42231. */
  42232. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42233. /**
  42234. * Defines the camera the input is attached to.
  42235. */
  42236. abstract camera: Camera;
  42237. /**
  42238. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42239. */
  42240. protected _altKey: boolean;
  42241. protected _ctrlKey: boolean;
  42242. protected _metaKey: boolean;
  42243. protected _shiftKey: boolean;
  42244. /**
  42245. * Which mouse buttons were pressed at time of last mouse event.
  42246. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42247. */
  42248. protected _buttonsPressed: number;
  42249. /**
  42250. * Defines the buttons associated with the input to handle camera move.
  42251. */
  42252. buttons: number[];
  42253. /**
  42254. * Attach the input controls to a specific dom element to get the input from.
  42255. * @param element Defines the element the controls should be listened from
  42256. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42257. */
  42258. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42259. /**
  42260. * Detach the current controls from the specified dom element.
  42261. * @param element Defines the element to stop listening the inputs from
  42262. */
  42263. detachControl(element: Nullable<HTMLElement>): void;
  42264. /**
  42265. * Gets the class name of the current input.
  42266. * @returns the class name
  42267. */
  42268. getClassName(): string;
  42269. /**
  42270. * Get the friendly name associated with the input class.
  42271. * @returns the input friendly name
  42272. */
  42273. getSimpleName(): string;
  42274. /**
  42275. * Called on pointer POINTERDOUBLETAP event.
  42276. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42277. */
  42278. protected onDoubleTap(type: string): void;
  42279. /**
  42280. * Called on pointer POINTERMOVE event if only a single touch is active.
  42281. * Override this method to provide functionality.
  42282. */
  42283. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42284. /**
  42285. * Called on pointer POINTERMOVE event if multiple touches are active.
  42286. * Override this method to provide functionality.
  42287. */
  42288. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42289. /**
  42290. * Called on JS contextmenu event.
  42291. * Override this method to provide functionality.
  42292. */
  42293. protected onContextMenu(evt: PointerEvent): void;
  42294. /**
  42295. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42296. * press.
  42297. * Override this method to provide functionality.
  42298. */
  42299. protected onButtonDown(evt: PointerEvent): void;
  42300. /**
  42301. * Called each time a new POINTERUP event occurs. Ie, for each button
  42302. * release.
  42303. * Override this method to provide functionality.
  42304. */
  42305. protected onButtonUp(evt: PointerEvent): void;
  42306. /**
  42307. * Called when window becomes inactive.
  42308. * Override this method to provide functionality.
  42309. */
  42310. protected onLostFocus(): void;
  42311. private _pointerInput;
  42312. private _observer;
  42313. private _onLostFocus;
  42314. private pointA;
  42315. private pointB;
  42316. }
  42317. }
  42318. declare module BABYLON {
  42319. /**
  42320. * Manage the pointers inputs to control an arc rotate camera.
  42321. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42322. */
  42323. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42324. /**
  42325. * Defines the camera the input is attached to.
  42326. */
  42327. camera: ArcRotateCamera;
  42328. /**
  42329. * Gets the class name of the current input.
  42330. * @returns the class name
  42331. */
  42332. getClassName(): string;
  42333. /**
  42334. * Defines the buttons associated with the input to handle camera move.
  42335. */
  42336. buttons: number[];
  42337. /**
  42338. * Defines the pointer angular sensibility along the X axis or how fast is
  42339. * the camera rotating.
  42340. */
  42341. angularSensibilityX: number;
  42342. /**
  42343. * Defines the pointer angular sensibility along the Y axis or how fast is
  42344. * the camera rotating.
  42345. */
  42346. angularSensibilityY: number;
  42347. /**
  42348. * Defines the pointer pinch precision or how fast is the camera zooming.
  42349. */
  42350. pinchPrecision: number;
  42351. /**
  42352. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42353. * from 0.
  42354. * It defines the percentage of current camera.radius to use as delta when
  42355. * pinch zoom is used.
  42356. */
  42357. pinchDeltaPercentage: number;
  42358. /**
  42359. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42360. * that any object in the plane at the camera's target point will scale
  42361. * perfectly with finger motion.
  42362. * Overrides pinchDeltaPercentage and pinchPrecision.
  42363. */
  42364. useNaturalPinchZoom: boolean;
  42365. /**
  42366. * Defines the pointer panning sensibility or how fast is the camera moving.
  42367. */
  42368. panningSensibility: number;
  42369. /**
  42370. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42371. */
  42372. multiTouchPanning: boolean;
  42373. /**
  42374. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42375. * zoom (pinch) through multitouch.
  42376. */
  42377. multiTouchPanAndZoom: boolean;
  42378. /**
  42379. * Revers pinch action direction.
  42380. */
  42381. pinchInwards: boolean;
  42382. private _isPanClick;
  42383. private _twoFingerActivityCount;
  42384. private _isPinching;
  42385. /**
  42386. * Called on pointer POINTERMOVE event if only a single touch is active.
  42387. */
  42388. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42389. /**
  42390. * Called on pointer POINTERDOUBLETAP event.
  42391. */
  42392. protected onDoubleTap(type: string): void;
  42393. /**
  42394. * Called on pointer POINTERMOVE event if multiple touches are active.
  42395. */
  42396. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42397. /**
  42398. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42399. * press.
  42400. */
  42401. protected onButtonDown(evt: PointerEvent): void;
  42402. /**
  42403. * Called each time a new POINTERUP event occurs. Ie, for each button
  42404. * release.
  42405. */
  42406. protected onButtonUp(evt: PointerEvent): void;
  42407. /**
  42408. * Called when window becomes inactive.
  42409. */
  42410. protected onLostFocus(): void;
  42411. }
  42412. }
  42413. declare module BABYLON {
  42414. /**
  42415. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42416. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42417. */
  42418. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42419. /**
  42420. * Defines the camera the input is attached to.
  42421. */
  42422. camera: ArcRotateCamera;
  42423. /**
  42424. * Defines the list of key codes associated with the up action (increase alpha)
  42425. */
  42426. keysUp: number[];
  42427. /**
  42428. * Defines the list of key codes associated with the down action (decrease alpha)
  42429. */
  42430. keysDown: number[];
  42431. /**
  42432. * Defines the list of key codes associated with the left action (increase beta)
  42433. */
  42434. keysLeft: number[];
  42435. /**
  42436. * Defines the list of key codes associated with the right action (decrease beta)
  42437. */
  42438. keysRight: number[];
  42439. /**
  42440. * Defines the list of key codes associated with the reset action.
  42441. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42442. */
  42443. keysReset: number[];
  42444. /**
  42445. * Defines the panning sensibility of the inputs.
  42446. * (How fast is the camera panning)
  42447. */
  42448. panningSensibility: number;
  42449. /**
  42450. * Defines the zooming sensibility of the inputs.
  42451. * (How fast is the camera zooming)
  42452. */
  42453. zoomingSensibility: number;
  42454. /**
  42455. * Defines whether maintaining the alt key down switch the movement mode from
  42456. * orientation to zoom.
  42457. */
  42458. useAltToZoom: boolean;
  42459. /**
  42460. * Rotation speed of the camera
  42461. */
  42462. angularSpeed: number;
  42463. private _keys;
  42464. private _ctrlPressed;
  42465. private _altPressed;
  42466. private _onCanvasBlurObserver;
  42467. private _onKeyboardObserver;
  42468. private _engine;
  42469. private _scene;
  42470. /**
  42471. * Attach the input controls to a specific dom element to get the input from.
  42472. * @param element Defines the element the controls should be listened from
  42473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42474. */
  42475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42476. /**
  42477. * Detach the current controls from the specified dom element.
  42478. * @param element Defines the element to stop listening the inputs from
  42479. */
  42480. detachControl(element: Nullable<HTMLElement>): void;
  42481. /**
  42482. * Update the current camera state depending on the inputs that have been used this frame.
  42483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42484. */
  42485. checkInputs(): void;
  42486. /**
  42487. * Gets the class name of the current intput.
  42488. * @returns the class name
  42489. */
  42490. getClassName(): string;
  42491. /**
  42492. * Get the friendly name associated with the input class.
  42493. * @returns the input friendly name
  42494. */
  42495. getSimpleName(): string;
  42496. }
  42497. }
  42498. declare module BABYLON {
  42499. /**
  42500. * Manage the mouse wheel inputs to control an arc rotate camera.
  42501. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42502. */
  42503. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42504. /**
  42505. * Defines the camera the input is attached to.
  42506. */
  42507. camera: ArcRotateCamera;
  42508. /**
  42509. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42510. */
  42511. wheelPrecision: number;
  42512. /**
  42513. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42514. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42515. */
  42516. wheelDeltaPercentage: number;
  42517. private _wheel;
  42518. private _observer;
  42519. private computeDeltaFromMouseWheelLegacyEvent;
  42520. /**
  42521. * Attach the input controls to a specific dom element to get the input from.
  42522. * @param element Defines the element the controls should be listened from
  42523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42524. */
  42525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42526. /**
  42527. * Detach the current controls from the specified dom element.
  42528. * @param element Defines the element to stop listening the inputs from
  42529. */
  42530. detachControl(element: Nullable<HTMLElement>): void;
  42531. /**
  42532. * Gets the class name of the current intput.
  42533. * @returns the class name
  42534. */
  42535. getClassName(): string;
  42536. /**
  42537. * Get the friendly name associated with the input class.
  42538. * @returns the input friendly name
  42539. */
  42540. getSimpleName(): string;
  42541. }
  42542. }
  42543. declare module BABYLON {
  42544. /**
  42545. * Default Inputs manager for the ArcRotateCamera.
  42546. * It groups all the default supported inputs for ease of use.
  42547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42548. */
  42549. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42550. /**
  42551. * Instantiates a new ArcRotateCameraInputsManager.
  42552. * @param camera Defines the camera the inputs belong to
  42553. */
  42554. constructor(camera: ArcRotateCamera);
  42555. /**
  42556. * Add mouse wheel input support to the input manager.
  42557. * @returns the current input manager
  42558. */
  42559. addMouseWheel(): ArcRotateCameraInputsManager;
  42560. /**
  42561. * Add pointers input support to the input manager.
  42562. * @returns the current input manager
  42563. */
  42564. addPointers(): ArcRotateCameraInputsManager;
  42565. /**
  42566. * Add keyboard input support to the input manager.
  42567. * @returns the current input manager
  42568. */
  42569. addKeyboard(): ArcRotateCameraInputsManager;
  42570. }
  42571. }
  42572. declare module BABYLON {
  42573. /**
  42574. * This represents an orbital type of camera.
  42575. *
  42576. * 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.
  42577. * 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.
  42578. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42579. */
  42580. export class ArcRotateCamera extends TargetCamera {
  42581. /**
  42582. * Defines the rotation angle of the camera along the longitudinal axis.
  42583. */
  42584. alpha: number;
  42585. /**
  42586. * Defines the rotation angle of the camera along the latitudinal axis.
  42587. */
  42588. beta: number;
  42589. /**
  42590. * Defines the radius of the camera from it s target point.
  42591. */
  42592. radius: number;
  42593. protected _target: Vector3;
  42594. protected _targetHost: Nullable<AbstractMesh>;
  42595. /**
  42596. * Defines the target point of the camera.
  42597. * The camera looks towards it form the radius distance.
  42598. */
  42599. get target(): Vector3;
  42600. set target(value: Vector3);
  42601. /**
  42602. * Define the current local position of the camera in the scene
  42603. */
  42604. get position(): Vector3;
  42605. set position(newPosition: Vector3);
  42606. protected _upVector: Vector3;
  42607. protected _upToYMatrix: Matrix;
  42608. protected _YToUpMatrix: Matrix;
  42609. /**
  42610. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42611. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42612. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42613. */
  42614. set upVector(vec: Vector3);
  42615. get upVector(): Vector3;
  42616. /**
  42617. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42618. */
  42619. setMatUp(): void;
  42620. /**
  42621. * Current inertia value on the longitudinal axis.
  42622. * The bigger this number the longer it will take for the camera to stop.
  42623. */
  42624. inertialAlphaOffset: number;
  42625. /**
  42626. * Current inertia value on the latitudinal axis.
  42627. * The bigger this number the longer it will take for the camera to stop.
  42628. */
  42629. inertialBetaOffset: number;
  42630. /**
  42631. * Current inertia value on the radius axis.
  42632. * The bigger this number the longer it will take for the camera to stop.
  42633. */
  42634. inertialRadiusOffset: number;
  42635. /**
  42636. * Minimum allowed angle on the longitudinal axis.
  42637. * This can help limiting how the Camera is able to move in the scene.
  42638. */
  42639. lowerAlphaLimit: Nullable<number>;
  42640. /**
  42641. * Maximum allowed angle on the longitudinal axis.
  42642. * This can help limiting how the Camera is able to move in the scene.
  42643. */
  42644. upperAlphaLimit: Nullable<number>;
  42645. /**
  42646. * Minimum allowed angle on the latitudinal axis.
  42647. * This can help limiting how the Camera is able to move in the scene.
  42648. */
  42649. lowerBetaLimit: number;
  42650. /**
  42651. * Maximum allowed angle on the latitudinal axis.
  42652. * This can help limiting how the Camera is able to move in the scene.
  42653. */
  42654. upperBetaLimit: number;
  42655. /**
  42656. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42657. * This can help limiting how the Camera is able to move in the scene.
  42658. */
  42659. lowerRadiusLimit: Nullable<number>;
  42660. /**
  42661. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42662. * This can help limiting how the Camera is able to move in the scene.
  42663. */
  42664. upperRadiusLimit: Nullable<number>;
  42665. /**
  42666. * Defines the current inertia value used during panning of the camera along the X axis.
  42667. */
  42668. inertialPanningX: number;
  42669. /**
  42670. * Defines the current inertia value used during panning of the camera along the Y axis.
  42671. */
  42672. inertialPanningY: number;
  42673. /**
  42674. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42675. * Basically if your fingers moves away from more than this distance you will be considered
  42676. * in pinch mode.
  42677. */
  42678. pinchToPanMaxDistance: number;
  42679. /**
  42680. * Defines the maximum distance the camera can pan.
  42681. * This could help keeping the cammera always in your scene.
  42682. */
  42683. panningDistanceLimit: Nullable<number>;
  42684. /**
  42685. * Defines the target of the camera before paning.
  42686. */
  42687. panningOriginTarget: Vector3;
  42688. /**
  42689. * Defines the value of the inertia used during panning.
  42690. * 0 would mean stop inertia and one would mean no decelleration at all.
  42691. */
  42692. panningInertia: number;
  42693. /**
  42694. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42695. */
  42696. get angularSensibilityX(): number;
  42697. set angularSensibilityX(value: number);
  42698. /**
  42699. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42700. */
  42701. get angularSensibilityY(): number;
  42702. set angularSensibilityY(value: number);
  42703. /**
  42704. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42705. */
  42706. get pinchPrecision(): number;
  42707. set pinchPrecision(value: number);
  42708. /**
  42709. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42710. * It will be used instead of pinchDeltaPrecision if different from 0.
  42711. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42712. */
  42713. get pinchDeltaPercentage(): number;
  42714. set pinchDeltaPercentage(value: number);
  42715. /**
  42716. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42717. * and pinch delta percentage.
  42718. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42719. * that any object in the plane at the camera's target point will scale
  42720. * perfectly with finger motion.
  42721. */
  42722. get useNaturalPinchZoom(): boolean;
  42723. set useNaturalPinchZoom(value: boolean);
  42724. /**
  42725. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42726. */
  42727. get panningSensibility(): number;
  42728. set panningSensibility(value: number);
  42729. /**
  42730. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42731. */
  42732. get keysUp(): number[];
  42733. set keysUp(value: number[]);
  42734. /**
  42735. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42736. */
  42737. get keysDown(): number[];
  42738. set keysDown(value: number[]);
  42739. /**
  42740. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42741. */
  42742. get keysLeft(): number[];
  42743. set keysLeft(value: number[]);
  42744. /**
  42745. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42746. */
  42747. get keysRight(): number[];
  42748. set keysRight(value: number[]);
  42749. /**
  42750. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42751. */
  42752. get wheelPrecision(): number;
  42753. set wheelPrecision(value: number);
  42754. /**
  42755. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42756. * It will be used instead of pinchDeltaPrecision if different from 0.
  42757. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42758. */
  42759. get wheelDeltaPercentage(): number;
  42760. set wheelDeltaPercentage(value: number);
  42761. /**
  42762. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42763. */
  42764. zoomOnFactor: number;
  42765. /**
  42766. * Defines a screen offset for the camera position.
  42767. */
  42768. targetScreenOffset: Vector2;
  42769. /**
  42770. * Allows the camera to be completely reversed.
  42771. * If false the camera can not arrive upside down.
  42772. */
  42773. allowUpsideDown: boolean;
  42774. /**
  42775. * Define if double tap/click is used to restore the previously saved state of the camera.
  42776. */
  42777. useInputToRestoreState: boolean;
  42778. /** @hidden */
  42779. _viewMatrix: Matrix;
  42780. /** @hidden */
  42781. _useCtrlForPanning: boolean;
  42782. /** @hidden */
  42783. _panningMouseButton: number;
  42784. /**
  42785. * Defines the input associated to the camera.
  42786. */
  42787. inputs: ArcRotateCameraInputsManager;
  42788. /** @hidden */
  42789. _reset: () => void;
  42790. /**
  42791. * Defines the allowed panning axis.
  42792. */
  42793. panningAxis: Vector3;
  42794. protected _localDirection: Vector3;
  42795. protected _transformedDirection: Vector3;
  42796. private _bouncingBehavior;
  42797. /**
  42798. * Gets the bouncing behavior of the camera if it has been enabled.
  42799. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42800. */
  42801. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42802. /**
  42803. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42804. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42805. */
  42806. get useBouncingBehavior(): boolean;
  42807. set useBouncingBehavior(value: boolean);
  42808. private _framingBehavior;
  42809. /**
  42810. * Gets the framing behavior of the camera if it has been enabled.
  42811. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42812. */
  42813. get framingBehavior(): Nullable<FramingBehavior>;
  42814. /**
  42815. * Defines if the framing behavior of the camera is enabled on the camera.
  42816. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42817. */
  42818. get useFramingBehavior(): boolean;
  42819. set useFramingBehavior(value: boolean);
  42820. private _autoRotationBehavior;
  42821. /**
  42822. * Gets the auto rotation behavior of the camera if it has been enabled.
  42823. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42824. */
  42825. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42826. /**
  42827. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42828. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42829. */
  42830. get useAutoRotationBehavior(): boolean;
  42831. set useAutoRotationBehavior(value: boolean);
  42832. /**
  42833. * Observable triggered when the mesh target has been changed on the camera.
  42834. */
  42835. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42836. /**
  42837. * Event raised when the camera is colliding with a mesh.
  42838. */
  42839. onCollide: (collidedMesh: AbstractMesh) => void;
  42840. /**
  42841. * Defines whether the camera should check collision with the objects oh the scene.
  42842. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42843. */
  42844. checkCollisions: boolean;
  42845. /**
  42846. * Defines the collision radius of the camera.
  42847. * This simulates a sphere around the camera.
  42848. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42849. */
  42850. collisionRadius: Vector3;
  42851. protected _collider: Collider;
  42852. protected _previousPosition: Vector3;
  42853. protected _collisionVelocity: Vector3;
  42854. protected _newPosition: Vector3;
  42855. protected _previousAlpha: number;
  42856. protected _previousBeta: number;
  42857. protected _previousRadius: number;
  42858. protected _collisionTriggered: boolean;
  42859. protected _targetBoundingCenter: Nullable<Vector3>;
  42860. private _computationVector;
  42861. /**
  42862. * Instantiates a new ArcRotateCamera in a given scene
  42863. * @param name Defines the name of the camera
  42864. * @param alpha Defines the camera rotation along the logitudinal axis
  42865. * @param beta Defines the camera rotation along the latitudinal axis
  42866. * @param radius Defines the camera distance from its target
  42867. * @param target Defines the camera target
  42868. * @param scene Defines the scene the camera belongs to
  42869. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42870. */
  42871. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42872. /** @hidden */
  42873. _initCache(): void;
  42874. /** @hidden */
  42875. _updateCache(ignoreParentClass?: boolean): void;
  42876. protected _getTargetPosition(): Vector3;
  42877. private _storedAlpha;
  42878. private _storedBeta;
  42879. private _storedRadius;
  42880. private _storedTarget;
  42881. private _storedTargetScreenOffset;
  42882. /**
  42883. * Stores the current state of the camera (alpha, beta, radius and target)
  42884. * @returns the camera itself
  42885. */
  42886. storeState(): Camera;
  42887. /**
  42888. * @hidden
  42889. * Restored camera state. You must call storeState() first
  42890. */
  42891. _restoreStateValues(): boolean;
  42892. /** @hidden */
  42893. _isSynchronizedViewMatrix(): boolean;
  42894. /**
  42895. * Attached controls to the current camera.
  42896. * @param element Defines the element the controls should be listened from
  42897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42898. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42899. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42900. */
  42901. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42902. /**
  42903. * Detach the current controls from the camera.
  42904. * The camera will stop reacting to inputs.
  42905. * @param element Defines the element to stop listening the inputs from
  42906. */
  42907. detachControl(element: HTMLElement): void;
  42908. /** @hidden */
  42909. _checkInputs(): void;
  42910. protected _checkLimits(): void;
  42911. /**
  42912. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42913. */
  42914. rebuildAnglesAndRadius(): void;
  42915. /**
  42916. * Use a position to define the current camera related information like alpha, beta and radius
  42917. * @param position Defines the position to set the camera at
  42918. */
  42919. setPosition(position: Vector3): void;
  42920. /**
  42921. * Defines the target the camera should look at.
  42922. * This will automatically adapt alpha beta and radius to fit within the new target.
  42923. * @param target Defines the new target as a Vector or a mesh
  42924. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42925. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42926. */
  42927. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42928. /** @hidden */
  42929. _getViewMatrix(): Matrix;
  42930. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42931. /**
  42932. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42933. * @param meshes Defines the mesh to zoom on
  42934. * @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)
  42935. */
  42936. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42937. /**
  42938. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42939. * The target will be changed but the radius
  42940. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42941. * @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)
  42942. */
  42943. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42944. min: Vector3;
  42945. max: Vector3;
  42946. distance: number;
  42947. }, doNotUpdateMaxZ?: boolean): void;
  42948. /**
  42949. * @override
  42950. * Override Camera.createRigCamera
  42951. */
  42952. createRigCamera(name: string, cameraIndex: number): Camera;
  42953. /**
  42954. * @hidden
  42955. * @override
  42956. * Override Camera._updateRigCameras
  42957. */
  42958. _updateRigCameras(): void;
  42959. /**
  42960. * Destroy the camera and release the current resources hold by it.
  42961. */
  42962. dispose(): void;
  42963. /**
  42964. * Gets the current object class name.
  42965. * @return the class name
  42966. */
  42967. getClassName(): string;
  42968. }
  42969. }
  42970. declare module BABYLON {
  42971. /**
  42972. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42973. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42974. */
  42975. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42976. /**
  42977. * Gets the name of the behavior.
  42978. */
  42979. get name(): string;
  42980. private _zoomStopsAnimation;
  42981. private _idleRotationSpeed;
  42982. private _idleRotationWaitTime;
  42983. private _idleRotationSpinupTime;
  42984. /**
  42985. * Sets the flag that indicates if user zooming should stop animation.
  42986. */
  42987. set zoomStopsAnimation(flag: boolean);
  42988. /**
  42989. * Gets the flag that indicates if user zooming should stop animation.
  42990. */
  42991. get zoomStopsAnimation(): boolean;
  42992. /**
  42993. * Sets the default speed at which the camera rotates around the model.
  42994. */
  42995. set idleRotationSpeed(speed: number);
  42996. /**
  42997. * Gets the default speed at which the camera rotates around the model.
  42998. */
  42999. get idleRotationSpeed(): number;
  43000. /**
  43001. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43002. */
  43003. set idleRotationWaitTime(time: number);
  43004. /**
  43005. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43006. */
  43007. get idleRotationWaitTime(): number;
  43008. /**
  43009. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43010. */
  43011. set idleRotationSpinupTime(time: number);
  43012. /**
  43013. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43014. */
  43015. get idleRotationSpinupTime(): number;
  43016. /**
  43017. * Gets a value indicating if the camera is currently rotating because of this behavior
  43018. */
  43019. get rotationInProgress(): boolean;
  43020. private _onPrePointerObservableObserver;
  43021. private _onAfterCheckInputsObserver;
  43022. private _attachedCamera;
  43023. private _isPointerDown;
  43024. private _lastFrameTime;
  43025. private _lastInteractionTime;
  43026. private _cameraRotationSpeed;
  43027. /**
  43028. * Initializes the behavior.
  43029. */
  43030. init(): void;
  43031. /**
  43032. * Attaches the behavior to its arc rotate camera.
  43033. * @param camera Defines the camera to attach the behavior to
  43034. */
  43035. attach(camera: ArcRotateCamera): void;
  43036. /**
  43037. * Detaches the behavior from its current arc rotate camera.
  43038. */
  43039. detach(): void;
  43040. /**
  43041. * Returns true if user is scrolling.
  43042. * @return true if user is scrolling.
  43043. */
  43044. private _userIsZooming;
  43045. private _lastFrameRadius;
  43046. private _shouldAnimationStopForInteraction;
  43047. /**
  43048. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43049. */
  43050. private _applyUserInteraction;
  43051. private _userIsMoving;
  43052. }
  43053. }
  43054. declare module BABYLON {
  43055. /**
  43056. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43057. */
  43058. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43059. private ui;
  43060. /**
  43061. * The name of the behavior
  43062. */
  43063. name: string;
  43064. /**
  43065. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43066. */
  43067. distanceAwayFromFace: number;
  43068. /**
  43069. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43070. */
  43071. distanceAwayFromBottomOfFace: number;
  43072. private _faceVectors;
  43073. private _target;
  43074. private _scene;
  43075. private _onRenderObserver;
  43076. private _tmpMatrix;
  43077. private _tmpVector;
  43078. /**
  43079. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43080. * @param ui The transform node that should be attched to the mesh
  43081. */
  43082. constructor(ui: TransformNode);
  43083. /**
  43084. * Initializes the behavior
  43085. */
  43086. init(): void;
  43087. private _closestFace;
  43088. private _zeroVector;
  43089. private _lookAtTmpMatrix;
  43090. private _lookAtToRef;
  43091. /**
  43092. * Attaches the AttachToBoxBehavior to the passed in mesh
  43093. * @param target The mesh that the specified node will be attached to
  43094. */
  43095. attach(target: Mesh): void;
  43096. /**
  43097. * Detaches the behavior from the mesh
  43098. */
  43099. detach(): void;
  43100. }
  43101. }
  43102. declare module BABYLON {
  43103. /**
  43104. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43105. */
  43106. export class FadeInOutBehavior implements Behavior<Mesh> {
  43107. /**
  43108. * Time in milliseconds to delay before fading in (Default: 0)
  43109. */
  43110. delay: number;
  43111. /**
  43112. * Time in milliseconds for the mesh to fade in (Default: 300)
  43113. */
  43114. fadeInTime: number;
  43115. private _millisecondsPerFrame;
  43116. private _hovered;
  43117. private _hoverValue;
  43118. private _ownerNode;
  43119. /**
  43120. * Instatiates the FadeInOutBehavior
  43121. */
  43122. constructor();
  43123. /**
  43124. * The name of the behavior
  43125. */
  43126. get name(): string;
  43127. /**
  43128. * Initializes the behavior
  43129. */
  43130. init(): void;
  43131. /**
  43132. * Attaches the fade behavior on the passed in mesh
  43133. * @param ownerNode The mesh that will be faded in/out once attached
  43134. */
  43135. attach(ownerNode: Mesh): void;
  43136. /**
  43137. * Detaches the behavior from the mesh
  43138. */
  43139. detach(): void;
  43140. /**
  43141. * Triggers the mesh to begin fading in or out
  43142. * @param value if the object should fade in or out (true to fade in)
  43143. */
  43144. fadeIn(value: boolean): void;
  43145. private _update;
  43146. private _setAllVisibility;
  43147. }
  43148. }
  43149. declare module BABYLON {
  43150. /**
  43151. * Class containing a set of static utilities functions for managing Pivots
  43152. * @hidden
  43153. */
  43154. export class PivotTools {
  43155. private static _PivotCached;
  43156. private static _OldPivotPoint;
  43157. private static _PivotTranslation;
  43158. private static _PivotTmpVector;
  43159. /** @hidden */
  43160. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43161. /** @hidden */
  43162. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43163. }
  43164. }
  43165. declare module BABYLON {
  43166. /**
  43167. * Class containing static functions to help procedurally build meshes
  43168. */
  43169. export class PlaneBuilder {
  43170. /**
  43171. * Creates a plane mesh
  43172. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43173. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43174. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43176. * * 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
  43177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43178. * @param name defines the name of the mesh
  43179. * @param options defines the options used to create the mesh
  43180. * @param scene defines the hosting scene
  43181. * @returns the plane mesh
  43182. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43183. */
  43184. static CreatePlane(name: string, options: {
  43185. size?: number;
  43186. width?: number;
  43187. height?: number;
  43188. sideOrientation?: number;
  43189. frontUVs?: Vector4;
  43190. backUVs?: Vector4;
  43191. updatable?: boolean;
  43192. sourcePlane?: Plane;
  43193. }, scene?: Nullable<Scene>): Mesh;
  43194. }
  43195. }
  43196. declare module BABYLON {
  43197. /**
  43198. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43199. */
  43200. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43201. private static _AnyMouseID;
  43202. /**
  43203. * Abstract mesh the behavior is set on
  43204. */
  43205. attachedNode: AbstractMesh;
  43206. private _dragPlane;
  43207. private _scene;
  43208. private _pointerObserver;
  43209. private _beforeRenderObserver;
  43210. private static _planeScene;
  43211. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43212. /**
  43213. * 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)
  43214. */
  43215. maxDragAngle: number;
  43216. /**
  43217. * @hidden
  43218. */
  43219. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43220. /**
  43221. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43222. */
  43223. currentDraggingPointerID: number;
  43224. /**
  43225. * The last position where the pointer hit the drag plane in world space
  43226. */
  43227. lastDragPosition: Vector3;
  43228. /**
  43229. * If the behavior is currently in a dragging state
  43230. */
  43231. dragging: boolean;
  43232. /**
  43233. * 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)
  43234. */
  43235. dragDeltaRatio: number;
  43236. /**
  43237. * If the drag plane orientation should be updated during the dragging (Default: true)
  43238. */
  43239. updateDragPlane: boolean;
  43240. private _debugMode;
  43241. private _moving;
  43242. /**
  43243. * Fires each time the attached mesh is dragged with the pointer
  43244. * * delta between last drag position and current drag position in world space
  43245. * * dragDistance along the drag axis
  43246. * * dragPlaneNormal normal of the current drag plane used during the drag
  43247. * * dragPlanePoint in world space where the drag intersects the drag plane
  43248. */
  43249. onDragObservable: Observable<{
  43250. delta: Vector3;
  43251. dragPlanePoint: Vector3;
  43252. dragPlaneNormal: Vector3;
  43253. dragDistance: number;
  43254. pointerId: number;
  43255. }>;
  43256. /**
  43257. * Fires each time a drag begins (eg. mouse down on mesh)
  43258. */
  43259. onDragStartObservable: Observable<{
  43260. dragPlanePoint: Vector3;
  43261. pointerId: number;
  43262. }>;
  43263. /**
  43264. * Fires each time a drag ends (eg. mouse release after drag)
  43265. */
  43266. onDragEndObservable: Observable<{
  43267. dragPlanePoint: Vector3;
  43268. pointerId: number;
  43269. }>;
  43270. /**
  43271. * If the attached mesh should be moved when dragged
  43272. */
  43273. moveAttached: boolean;
  43274. /**
  43275. * If the drag behavior will react to drag events (Default: true)
  43276. */
  43277. enabled: boolean;
  43278. /**
  43279. * If pointer events should start and release the drag (Default: true)
  43280. */
  43281. startAndReleaseDragOnPointerEvents: boolean;
  43282. /**
  43283. * If camera controls should be detached during the drag
  43284. */
  43285. detachCameraControls: boolean;
  43286. /**
  43287. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43288. */
  43289. useObjectOrientationForDragging: boolean;
  43290. private _options;
  43291. /**
  43292. * Gets the options used by the behavior
  43293. */
  43294. get options(): {
  43295. dragAxis?: Vector3;
  43296. dragPlaneNormal?: Vector3;
  43297. };
  43298. /**
  43299. * Sets the options used by the behavior
  43300. */
  43301. set options(options: {
  43302. dragAxis?: Vector3;
  43303. dragPlaneNormal?: Vector3;
  43304. });
  43305. /**
  43306. * Creates a pointer drag behavior that can be attached to a mesh
  43307. * @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)
  43308. */
  43309. constructor(options?: {
  43310. dragAxis?: Vector3;
  43311. dragPlaneNormal?: Vector3;
  43312. });
  43313. /**
  43314. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43315. */
  43316. validateDrag: (targetPosition: Vector3) => boolean;
  43317. /**
  43318. * The name of the behavior
  43319. */
  43320. get name(): string;
  43321. /**
  43322. * Initializes the behavior
  43323. */
  43324. init(): void;
  43325. private _tmpVector;
  43326. private _alternatePickedPoint;
  43327. private _worldDragAxis;
  43328. private _targetPosition;
  43329. private _attachedElement;
  43330. /**
  43331. * Attaches the drag behavior the passed in mesh
  43332. * @param ownerNode The mesh that will be dragged around once attached
  43333. * @param predicate Predicate to use for pick filtering
  43334. */
  43335. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43336. /**
  43337. * Force relase the drag action by code.
  43338. */
  43339. releaseDrag(): void;
  43340. private _startDragRay;
  43341. private _lastPointerRay;
  43342. /**
  43343. * Simulates the start of a pointer drag event on the behavior
  43344. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43345. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43346. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43347. */
  43348. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43349. private _startDrag;
  43350. private _dragDelta;
  43351. private _moveDrag;
  43352. private _pickWithRayOnDragPlane;
  43353. private _pointA;
  43354. private _pointC;
  43355. private _localAxis;
  43356. private _lookAt;
  43357. private _updateDragPlanePosition;
  43358. /**
  43359. * Detaches the behavior from the mesh
  43360. */
  43361. detach(): void;
  43362. }
  43363. }
  43364. declare module BABYLON {
  43365. /**
  43366. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43367. */
  43368. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43369. private _dragBehaviorA;
  43370. private _dragBehaviorB;
  43371. private _startDistance;
  43372. private _initialScale;
  43373. private _targetScale;
  43374. private _ownerNode;
  43375. private _sceneRenderObserver;
  43376. /**
  43377. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43378. */
  43379. constructor();
  43380. /**
  43381. * The name of the behavior
  43382. */
  43383. get name(): string;
  43384. /**
  43385. * Initializes the behavior
  43386. */
  43387. init(): void;
  43388. private _getCurrentDistance;
  43389. /**
  43390. * Attaches the scale behavior the passed in mesh
  43391. * @param ownerNode The mesh that will be scaled around once attached
  43392. */
  43393. attach(ownerNode: Mesh): void;
  43394. /**
  43395. * Detaches the behavior from the mesh
  43396. */
  43397. detach(): void;
  43398. }
  43399. }
  43400. declare module BABYLON {
  43401. /**
  43402. * 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
  43403. */
  43404. export class SixDofDragBehavior implements Behavior<Mesh> {
  43405. private static _virtualScene;
  43406. private _ownerNode;
  43407. private _sceneRenderObserver;
  43408. private _scene;
  43409. private _targetPosition;
  43410. private _virtualOriginMesh;
  43411. private _virtualDragMesh;
  43412. private _pointerObserver;
  43413. private _moving;
  43414. private _startingOrientation;
  43415. private _attachedElement;
  43416. /**
  43417. * 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)
  43418. */
  43419. private zDragFactor;
  43420. /**
  43421. * If the object should rotate to face the drag origin
  43422. */
  43423. rotateDraggedObject: boolean;
  43424. /**
  43425. * If the behavior is currently in a dragging state
  43426. */
  43427. dragging: boolean;
  43428. /**
  43429. * 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)
  43430. */
  43431. dragDeltaRatio: number;
  43432. /**
  43433. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43434. */
  43435. currentDraggingPointerID: number;
  43436. /**
  43437. * If camera controls should be detached during the drag
  43438. */
  43439. detachCameraControls: boolean;
  43440. /**
  43441. * Fires each time a drag starts
  43442. */
  43443. onDragStartObservable: Observable<{}>;
  43444. /**
  43445. * Fires each time a drag ends (eg. mouse release after drag)
  43446. */
  43447. onDragEndObservable: Observable<{}>;
  43448. /**
  43449. * 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
  43450. */
  43451. constructor();
  43452. /**
  43453. * The name of the behavior
  43454. */
  43455. get name(): string;
  43456. /**
  43457. * Initializes the behavior
  43458. */
  43459. init(): void;
  43460. /**
  43461. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43462. */
  43463. private get _pointerCamera();
  43464. /**
  43465. * Attaches the scale behavior the passed in mesh
  43466. * @param ownerNode The mesh that will be scaled around once attached
  43467. */
  43468. attach(ownerNode: Mesh): void;
  43469. /**
  43470. * Detaches the behavior from the mesh
  43471. */
  43472. detach(): void;
  43473. }
  43474. }
  43475. declare module BABYLON {
  43476. /**
  43477. * Class used to apply inverse kinematics to bones
  43478. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43479. */
  43480. export class BoneIKController {
  43481. private static _tmpVecs;
  43482. private static _tmpQuat;
  43483. private static _tmpMats;
  43484. /**
  43485. * Gets or sets the target mesh
  43486. */
  43487. targetMesh: AbstractMesh;
  43488. /** Gets or sets the mesh used as pole */
  43489. poleTargetMesh: AbstractMesh;
  43490. /**
  43491. * Gets or sets the bone used as pole
  43492. */
  43493. poleTargetBone: Nullable<Bone>;
  43494. /**
  43495. * Gets or sets the target position
  43496. */
  43497. targetPosition: Vector3;
  43498. /**
  43499. * Gets or sets the pole target position
  43500. */
  43501. poleTargetPosition: Vector3;
  43502. /**
  43503. * Gets or sets the pole target local offset
  43504. */
  43505. poleTargetLocalOffset: Vector3;
  43506. /**
  43507. * Gets or sets the pole angle
  43508. */
  43509. poleAngle: number;
  43510. /**
  43511. * Gets or sets the mesh associated with the controller
  43512. */
  43513. mesh: AbstractMesh;
  43514. /**
  43515. * 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)
  43516. */
  43517. slerpAmount: number;
  43518. private _bone1Quat;
  43519. private _bone1Mat;
  43520. private _bone2Ang;
  43521. private _bone1;
  43522. private _bone2;
  43523. private _bone1Length;
  43524. private _bone2Length;
  43525. private _maxAngle;
  43526. private _maxReach;
  43527. private _rightHandedSystem;
  43528. private _bendAxis;
  43529. private _slerping;
  43530. private _adjustRoll;
  43531. /**
  43532. * Gets or sets maximum allowed angle
  43533. */
  43534. get maxAngle(): number;
  43535. set maxAngle(value: number);
  43536. /**
  43537. * Creates a new BoneIKController
  43538. * @param mesh defines the mesh to control
  43539. * @param bone defines the bone to control
  43540. * @param options defines options to set up the controller
  43541. */
  43542. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43543. targetMesh?: AbstractMesh;
  43544. poleTargetMesh?: AbstractMesh;
  43545. poleTargetBone?: Bone;
  43546. poleTargetLocalOffset?: Vector3;
  43547. poleAngle?: number;
  43548. bendAxis?: Vector3;
  43549. maxAngle?: number;
  43550. slerpAmount?: number;
  43551. });
  43552. private _setMaxAngle;
  43553. /**
  43554. * Force the controller to update the bones
  43555. */
  43556. update(): void;
  43557. }
  43558. }
  43559. declare module BABYLON {
  43560. /**
  43561. * Class used to make a bone look toward a point in space
  43562. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43563. */
  43564. export class BoneLookController {
  43565. private static _tmpVecs;
  43566. private static _tmpQuat;
  43567. private static _tmpMats;
  43568. /**
  43569. * The target Vector3 that the bone will look at
  43570. */
  43571. target: Vector3;
  43572. /**
  43573. * The mesh that the bone is attached to
  43574. */
  43575. mesh: AbstractMesh;
  43576. /**
  43577. * The bone that will be looking to the target
  43578. */
  43579. bone: Bone;
  43580. /**
  43581. * The up axis of the coordinate system that is used when the bone is rotated
  43582. */
  43583. upAxis: Vector3;
  43584. /**
  43585. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43586. */
  43587. upAxisSpace: Space;
  43588. /**
  43589. * Used to make an adjustment to the yaw of the bone
  43590. */
  43591. adjustYaw: number;
  43592. /**
  43593. * Used to make an adjustment to the pitch of the bone
  43594. */
  43595. adjustPitch: number;
  43596. /**
  43597. * Used to make an adjustment to the roll of the bone
  43598. */
  43599. adjustRoll: number;
  43600. /**
  43601. * 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)
  43602. */
  43603. slerpAmount: number;
  43604. private _minYaw;
  43605. private _maxYaw;
  43606. private _minPitch;
  43607. private _maxPitch;
  43608. private _minYawSin;
  43609. private _minYawCos;
  43610. private _maxYawSin;
  43611. private _maxYawCos;
  43612. private _midYawConstraint;
  43613. private _minPitchTan;
  43614. private _maxPitchTan;
  43615. private _boneQuat;
  43616. private _slerping;
  43617. private _transformYawPitch;
  43618. private _transformYawPitchInv;
  43619. private _firstFrameSkipped;
  43620. private _yawRange;
  43621. private _fowardAxis;
  43622. /**
  43623. * Gets or sets the minimum yaw angle that the bone can look to
  43624. */
  43625. get minYaw(): number;
  43626. set minYaw(value: number);
  43627. /**
  43628. * Gets or sets the maximum yaw angle that the bone can look to
  43629. */
  43630. get maxYaw(): number;
  43631. set maxYaw(value: number);
  43632. /**
  43633. * Gets or sets the minimum pitch angle that the bone can look to
  43634. */
  43635. get minPitch(): number;
  43636. set minPitch(value: number);
  43637. /**
  43638. * Gets or sets the maximum pitch angle that the bone can look to
  43639. */
  43640. get maxPitch(): number;
  43641. set maxPitch(value: number);
  43642. /**
  43643. * Create a BoneLookController
  43644. * @param mesh the mesh that the bone belongs to
  43645. * @param bone the bone that will be looking to the target
  43646. * @param target the target Vector3 to look at
  43647. * @param options optional settings:
  43648. * * maxYaw: the maximum angle the bone will yaw to
  43649. * * minYaw: the minimum angle the bone will yaw to
  43650. * * maxPitch: the maximum angle the bone will pitch to
  43651. * * minPitch: the minimum angle the bone will yaw to
  43652. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43653. * * upAxis: the up axis of the coordinate system
  43654. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43655. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43656. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43657. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43658. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43659. * * adjustRoll: used to make an adjustment to the roll of the bone
  43660. **/
  43661. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43662. maxYaw?: number;
  43663. minYaw?: number;
  43664. maxPitch?: number;
  43665. minPitch?: number;
  43666. slerpAmount?: number;
  43667. upAxis?: Vector3;
  43668. upAxisSpace?: Space;
  43669. yawAxis?: Vector3;
  43670. pitchAxis?: Vector3;
  43671. adjustYaw?: number;
  43672. adjustPitch?: number;
  43673. adjustRoll?: number;
  43674. });
  43675. /**
  43676. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43677. */
  43678. update(): void;
  43679. private _getAngleDiff;
  43680. private _getAngleBetween;
  43681. private _isAngleBetween;
  43682. }
  43683. }
  43684. declare module BABYLON {
  43685. /**
  43686. * Manage the gamepad inputs to control an arc rotate camera.
  43687. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43688. */
  43689. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43690. /**
  43691. * Defines the camera the input is attached to.
  43692. */
  43693. camera: ArcRotateCamera;
  43694. /**
  43695. * Defines the gamepad the input is gathering event from.
  43696. */
  43697. gamepad: Nullable<Gamepad>;
  43698. /**
  43699. * Defines the gamepad rotation sensiblity.
  43700. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43701. */
  43702. gamepadRotationSensibility: number;
  43703. /**
  43704. * Defines the gamepad move sensiblity.
  43705. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43706. */
  43707. gamepadMoveSensibility: number;
  43708. private _yAxisScale;
  43709. /**
  43710. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43711. */
  43712. get invertYAxis(): boolean;
  43713. set invertYAxis(value: boolean);
  43714. private _onGamepadConnectedObserver;
  43715. private _onGamepadDisconnectedObserver;
  43716. /**
  43717. * Attach the input controls to a specific dom element to get the input from.
  43718. * @param element Defines the element the controls should be listened from
  43719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43720. */
  43721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43722. /**
  43723. * Detach the current controls from the specified dom element.
  43724. * @param element Defines the element to stop listening the inputs from
  43725. */
  43726. detachControl(element: Nullable<HTMLElement>): void;
  43727. /**
  43728. * Update the current camera state depending on the inputs that have been used this frame.
  43729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43730. */
  43731. checkInputs(): void;
  43732. /**
  43733. * Gets the class name of the current intput.
  43734. * @returns the class name
  43735. */
  43736. getClassName(): string;
  43737. /**
  43738. * Get the friendly name associated with the input class.
  43739. * @returns the input friendly name
  43740. */
  43741. getSimpleName(): string;
  43742. }
  43743. }
  43744. declare module BABYLON {
  43745. interface ArcRotateCameraInputsManager {
  43746. /**
  43747. * Add orientation input support to the input manager.
  43748. * @returns the current input manager
  43749. */
  43750. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43751. }
  43752. /**
  43753. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43754. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43755. */
  43756. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43757. /**
  43758. * Defines the camera the input is attached to.
  43759. */
  43760. camera: ArcRotateCamera;
  43761. /**
  43762. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43763. */
  43764. alphaCorrection: number;
  43765. /**
  43766. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43767. */
  43768. gammaCorrection: number;
  43769. private _alpha;
  43770. private _gamma;
  43771. private _dirty;
  43772. private _deviceOrientationHandler;
  43773. /**
  43774. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43775. */
  43776. constructor();
  43777. /**
  43778. * Attach the input controls to a specific dom element to get the input from.
  43779. * @param element Defines the element the controls should be listened from
  43780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43781. */
  43782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43783. /** @hidden */
  43784. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43785. /**
  43786. * Update the current camera state depending on the inputs that have been used this frame.
  43787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43788. */
  43789. checkInputs(): void;
  43790. /**
  43791. * Detach the current controls from the specified dom element.
  43792. * @param element Defines the element to stop listening the inputs from
  43793. */
  43794. detachControl(element: Nullable<HTMLElement>): void;
  43795. /**
  43796. * Gets the class name of the current intput.
  43797. * @returns the class name
  43798. */
  43799. getClassName(): string;
  43800. /**
  43801. * Get the friendly name associated with the input class.
  43802. * @returns the input friendly name
  43803. */
  43804. getSimpleName(): string;
  43805. }
  43806. }
  43807. declare module BABYLON {
  43808. /**
  43809. * Listen to mouse events to control the camera.
  43810. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43811. */
  43812. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43813. /**
  43814. * Defines the camera the input is attached to.
  43815. */
  43816. camera: FlyCamera;
  43817. /**
  43818. * Defines if touch is enabled. (Default is true.)
  43819. */
  43820. touchEnabled: boolean;
  43821. /**
  43822. * Defines the buttons associated with the input to handle camera rotation.
  43823. */
  43824. buttons: number[];
  43825. /**
  43826. * Assign buttons for Yaw control.
  43827. */
  43828. buttonsYaw: number[];
  43829. /**
  43830. * Assign buttons for Pitch control.
  43831. */
  43832. buttonsPitch: number[];
  43833. /**
  43834. * Assign buttons for Roll control.
  43835. */
  43836. buttonsRoll: number[];
  43837. /**
  43838. * Detect if any button is being pressed while mouse is moved.
  43839. * -1 = Mouse locked.
  43840. * 0 = Left button.
  43841. * 1 = Middle Button.
  43842. * 2 = Right Button.
  43843. */
  43844. activeButton: number;
  43845. /**
  43846. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43847. * Higher values reduce its sensitivity.
  43848. */
  43849. angularSensibility: number;
  43850. private _mousemoveCallback;
  43851. private _observer;
  43852. private _rollObserver;
  43853. private previousPosition;
  43854. private noPreventDefault;
  43855. private element;
  43856. /**
  43857. * Listen to mouse events to control the camera.
  43858. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43860. */
  43861. constructor(touchEnabled?: boolean);
  43862. /**
  43863. * Attach the mouse control to the HTML DOM element.
  43864. * @param element Defines the element that listens to the input events.
  43865. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43866. */
  43867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43868. /**
  43869. * Detach the current controls from the specified dom element.
  43870. * @param element Defines the element to stop listening the inputs from
  43871. */
  43872. detachControl(element: Nullable<HTMLElement>): void;
  43873. /**
  43874. * Gets the class name of the current input.
  43875. * @returns the class name.
  43876. */
  43877. getClassName(): string;
  43878. /**
  43879. * Get the friendly name associated with the input class.
  43880. * @returns the input's friendly name.
  43881. */
  43882. getSimpleName(): string;
  43883. private _pointerInput;
  43884. private _onMouseMove;
  43885. /**
  43886. * Rotate camera by mouse offset.
  43887. */
  43888. private rotateCamera;
  43889. }
  43890. }
  43891. declare module BABYLON {
  43892. /**
  43893. * Default Inputs manager for the FlyCamera.
  43894. * It groups all the default supported inputs for ease of use.
  43895. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43896. */
  43897. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43898. /**
  43899. * Instantiates a new FlyCameraInputsManager.
  43900. * @param camera Defines the camera the inputs belong to.
  43901. */
  43902. constructor(camera: FlyCamera);
  43903. /**
  43904. * Add keyboard input support to the input manager.
  43905. * @returns the new FlyCameraKeyboardMoveInput().
  43906. */
  43907. addKeyboard(): FlyCameraInputsManager;
  43908. /**
  43909. * Add mouse input support to the input manager.
  43910. * @param touchEnabled Enable touch screen support.
  43911. * @returns the new FlyCameraMouseInput().
  43912. */
  43913. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43914. }
  43915. }
  43916. declare module BABYLON {
  43917. /**
  43918. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43919. * such as in a 3D Space Shooter or a Flight Simulator.
  43920. */
  43921. export class FlyCamera extends TargetCamera {
  43922. /**
  43923. * Define the collision ellipsoid of the camera.
  43924. * This is helpful for simulating a camera body, like a player's body.
  43925. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43926. */
  43927. ellipsoid: Vector3;
  43928. /**
  43929. * Define an offset for the position of the ellipsoid around the camera.
  43930. * This can be helpful if the camera is attached away from the player's body center,
  43931. * such as at its head.
  43932. */
  43933. ellipsoidOffset: Vector3;
  43934. /**
  43935. * Enable or disable collisions of the camera with the rest of the scene objects.
  43936. */
  43937. checkCollisions: boolean;
  43938. /**
  43939. * Enable or disable gravity on the camera.
  43940. */
  43941. applyGravity: boolean;
  43942. /**
  43943. * Define the current direction the camera is moving to.
  43944. */
  43945. cameraDirection: Vector3;
  43946. /**
  43947. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43948. * This overrides and empties cameraRotation.
  43949. */
  43950. rotationQuaternion: Quaternion;
  43951. /**
  43952. * Track Roll to maintain the wanted Rolling when looking around.
  43953. */
  43954. _trackRoll: number;
  43955. /**
  43956. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43957. */
  43958. rollCorrect: number;
  43959. /**
  43960. * Mimic a banked turn, Rolling the camera when Yawing.
  43961. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43962. */
  43963. bankedTurn: boolean;
  43964. /**
  43965. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43966. */
  43967. bankedTurnLimit: number;
  43968. /**
  43969. * Value of 0 disables the banked Roll.
  43970. * Value of 1 is equal to the Yaw angle in radians.
  43971. */
  43972. bankedTurnMultiplier: number;
  43973. /**
  43974. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43975. */
  43976. inputs: FlyCameraInputsManager;
  43977. /**
  43978. * Gets the input sensibility for mouse input.
  43979. * Higher values reduce sensitivity.
  43980. */
  43981. get angularSensibility(): number;
  43982. /**
  43983. * Sets the input sensibility for a mouse input.
  43984. * Higher values reduce sensitivity.
  43985. */
  43986. set angularSensibility(value: number);
  43987. /**
  43988. * Get the keys for camera movement forward.
  43989. */
  43990. get keysForward(): number[];
  43991. /**
  43992. * Set the keys for camera movement forward.
  43993. */
  43994. set keysForward(value: number[]);
  43995. /**
  43996. * Get the keys for camera movement backward.
  43997. */
  43998. get keysBackward(): number[];
  43999. set keysBackward(value: number[]);
  44000. /**
  44001. * Get the keys for camera movement up.
  44002. */
  44003. get keysUp(): number[];
  44004. /**
  44005. * Set the keys for camera movement up.
  44006. */
  44007. set keysUp(value: number[]);
  44008. /**
  44009. * Get the keys for camera movement down.
  44010. */
  44011. get keysDown(): number[];
  44012. /**
  44013. * Set the keys for camera movement down.
  44014. */
  44015. set keysDown(value: number[]);
  44016. /**
  44017. * Get the keys for camera movement left.
  44018. */
  44019. get keysLeft(): number[];
  44020. /**
  44021. * Set the keys for camera movement left.
  44022. */
  44023. set keysLeft(value: number[]);
  44024. /**
  44025. * Set the keys for camera movement right.
  44026. */
  44027. get keysRight(): number[];
  44028. /**
  44029. * Set the keys for camera movement right.
  44030. */
  44031. set keysRight(value: number[]);
  44032. /**
  44033. * Event raised when the camera collides with a mesh in the scene.
  44034. */
  44035. onCollide: (collidedMesh: AbstractMesh) => void;
  44036. private _collider;
  44037. private _needMoveForGravity;
  44038. private _oldPosition;
  44039. private _diffPosition;
  44040. private _newPosition;
  44041. /** @hidden */
  44042. _localDirection: Vector3;
  44043. /** @hidden */
  44044. _transformedDirection: Vector3;
  44045. /**
  44046. * Instantiates a FlyCamera.
  44047. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44048. * such as in a 3D Space Shooter or a Flight Simulator.
  44049. * @param name Define the name of the camera in the scene.
  44050. * @param position Define the starting position of the camera in the scene.
  44051. * @param scene Define the scene the camera belongs to.
  44052. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44053. */
  44054. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44055. /**
  44056. * Attach a control to the HTML DOM element.
  44057. * @param element Defines the element that listens to the input events.
  44058. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44059. */
  44060. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44061. /**
  44062. * Detach a control from the HTML DOM element.
  44063. * The camera will stop reacting to that input.
  44064. * @param element Defines the element that listens to the input events.
  44065. */
  44066. detachControl(element: HTMLElement): void;
  44067. private _collisionMask;
  44068. /**
  44069. * Get the mask that the camera ignores in collision events.
  44070. */
  44071. get collisionMask(): number;
  44072. /**
  44073. * Set the mask that the camera ignores in collision events.
  44074. */
  44075. set collisionMask(mask: number);
  44076. /** @hidden */
  44077. _collideWithWorld(displacement: Vector3): void;
  44078. /** @hidden */
  44079. private _onCollisionPositionChange;
  44080. /** @hidden */
  44081. _checkInputs(): void;
  44082. /** @hidden */
  44083. _decideIfNeedsToMove(): boolean;
  44084. /** @hidden */
  44085. _updatePosition(): void;
  44086. /**
  44087. * Restore the Roll to its target value at the rate specified.
  44088. * @param rate - Higher means slower restoring.
  44089. * @hidden
  44090. */
  44091. restoreRoll(rate: number): void;
  44092. /**
  44093. * Destroy the camera and release the current resources held by it.
  44094. */
  44095. dispose(): void;
  44096. /**
  44097. * Get the current object class name.
  44098. * @returns the class name.
  44099. */
  44100. getClassName(): string;
  44101. }
  44102. }
  44103. declare module BABYLON {
  44104. /**
  44105. * Listen to keyboard events to control the camera.
  44106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44107. */
  44108. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44109. /**
  44110. * Defines the camera the input is attached to.
  44111. */
  44112. camera: FlyCamera;
  44113. /**
  44114. * The list of keyboard keys used to control the forward move of the camera.
  44115. */
  44116. keysForward: number[];
  44117. /**
  44118. * The list of keyboard keys used to control the backward move of the camera.
  44119. */
  44120. keysBackward: number[];
  44121. /**
  44122. * The list of keyboard keys used to control the forward move of the camera.
  44123. */
  44124. keysUp: number[];
  44125. /**
  44126. * The list of keyboard keys used to control the backward move of the camera.
  44127. */
  44128. keysDown: number[];
  44129. /**
  44130. * The list of keyboard keys used to control the right strafe move of the camera.
  44131. */
  44132. keysRight: number[];
  44133. /**
  44134. * The list of keyboard keys used to control the left strafe move of the camera.
  44135. */
  44136. keysLeft: number[];
  44137. private _keys;
  44138. private _onCanvasBlurObserver;
  44139. private _onKeyboardObserver;
  44140. private _engine;
  44141. private _scene;
  44142. /**
  44143. * Attach the input controls to a specific dom element to get the input from.
  44144. * @param element Defines the element the controls should be listened from
  44145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44146. */
  44147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44148. /**
  44149. * Detach the current controls from the specified dom element.
  44150. * @param element Defines the element to stop listening the inputs from
  44151. */
  44152. detachControl(element: Nullable<HTMLElement>): void;
  44153. /**
  44154. * Gets the class name of the current intput.
  44155. * @returns the class name
  44156. */
  44157. getClassName(): string;
  44158. /** @hidden */
  44159. _onLostFocus(e: FocusEvent): void;
  44160. /**
  44161. * Get the friendly name associated with the input class.
  44162. * @returns the input friendly name
  44163. */
  44164. getSimpleName(): string;
  44165. /**
  44166. * Update the current camera state depending on the inputs that have been used this frame.
  44167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44168. */
  44169. checkInputs(): void;
  44170. }
  44171. }
  44172. declare module BABYLON {
  44173. /**
  44174. * Manage the mouse wheel inputs to control a follow camera.
  44175. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44176. */
  44177. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44178. /**
  44179. * Defines the camera the input is attached to.
  44180. */
  44181. camera: FollowCamera;
  44182. /**
  44183. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44184. */
  44185. axisControlRadius: boolean;
  44186. /**
  44187. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44188. */
  44189. axisControlHeight: boolean;
  44190. /**
  44191. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44192. */
  44193. axisControlRotation: boolean;
  44194. /**
  44195. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44196. * relation to mouseWheel events.
  44197. */
  44198. wheelPrecision: number;
  44199. /**
  44200. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44201. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44202. */
  44203. wheelDeltaPercentage: number;
  44204. private _wheel;
  44205. private _observer;
  44206. /**
  44207. * Attach the input controls to a specific dom element to get the input from.
  44208. * @param element Defines the element the controls should be listened from
  44209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44210. */
  44211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44212. /**
  44213. * Detach the current controls from the specified dom element.
  44214. * @param element Defines the element to stop listening the inputs from
  44215. */
  44216. detachControl(element: Nullable<HTMLElement>): void;
  44217. /**
  44218. * Gets the class name of the current intput.
  44219. * @returns the class name
  44220. */
  44221. getClassName(): string;
  44222. /**
  44223. * Get the friendly name associated with the input class.
  44224. * @returns the input friendly name
  44225. */
  44226. getSimpleName(): string;
  44227. }
  44228. }
  44229. declare module BABYLON {
  44230. /**
  44231. * Manage the pointers inputs to control an follow camera.
  44232. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44233. */
  44234. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44235. /**
  44236. * Defines the camera the input is attached to.
  44237. */
  44238. camera: FollowCamera;
  44239. /**
  44240. * Gets the class name of the current input.
  44241. * @returns the class name
  44242. */
  44243. getClassName(): string;
  44244. /**
  44245. * Defines the pointer angular sensibility along the X axis or how fast is
  44246. * the camera rotating.
  44247. * A negative number will reverse the axis direction.
  44248. */
  44249. angularSensibilityX: number;
  44250. /**
  44251. * Defines the pointer angular sensibility along the Y axis or how fast is
  44252. * the camera rotating.
  44253. * A negative number will reverse the axis direction.
  44254. */
  44255. angularSensibilityY: number;
  44256. /**
  44257. * Defines the pointer pinch precision or how fast is the camera zooming.
  44258. * A negative number will reverse the axis direction.
  44259. */
  44260. pinchPrecision: number;
  44261. /**
  44262. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44263. * from 0.
  44264. * It defines the percentage of current camera.radius to use as delta when
  44265. * pinch zoom is used.
  44266. */
  44267. pinchDeltaPercentage: number;
  44268. /**
  44269. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44270. */
  44271. axisXControlRadius: boolean;
  44272. /**
  44273. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44274. */
  44275. axisXControlHeight: boolean;
  44276. /**
  44277. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44278. */
  44279. axisXControlRotation: boolean;
  44280. /**
  44281. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44282. */
  44283. axisYControlRadius: boolean;
  44284. /**
  44285. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44286. */
  44287. axisYControlHeight: boolean;
  44288. /**
  44289. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44290. */
  44291. axisYControlRotation: boolean;
  44292. /**
  44293. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44294. */
  44295. axisPinchControlRadius: boolean;
  44296. /**
  44297. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44298. */
  44299. axisPinchControlHeight: boolean;
  44300. /**
  44301. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44302. */
  44303. axisPinchControlRotation: boolean;
  44304. /**
  44305. * Log error messages if basic misconfiguration has occurred.
  44306. */
  44307. warningEnable: boolean;
  44308. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44309. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44310. private _warningCounter;
  44311. private _warning;
  44312. }
  44313. }
  44314. declare module BABYLON {
  44315. /**
  44316. * Default Inputs manager for the FollowCamera.
  44317. * It groups all the default supported inputs for ease of use.
  44318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44319. */
  44320. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44321. /**
  44322. * Instantiates a new FollowCameraInputsManager.
  44323. * @param camera Defines the camera the inputs belong to
  44324. */
  44325. constructor(camera: FollowCamera);
  44326. /**
  44327. * Add keyboard input support to the input manager.
  44328. * @returns the current input manager
  44329. */
  44330. addKeyboard(): FollowCameraInputsManager;
  44331. /**
  44332. * Add mouse wheel input support to the input manager.
  44333. * @returns the current input manager
  44334. */
  44335. addMouseWheel(): FollowCameraInputsManager;
  44336. /**
  44337. * Add pointers input support to the input manager.
  44338. * @returns the current input manager
  44339. */
  44340. addPointers(): FollowCameraInputsManager;
  44341. /**
  44342. * Add orientation input support to the input manager.
  44343. * @returns the current input manager
  44344. */
  44345. addVRDeviceOrientation(): FollowCameraInputsManager;
  44346. }
  44347. }
  44348. declare module BABYLON {
  44349. /**
  44350. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44351. * an arc rotate version arcFollowCamera are available.
  44352. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44353. */
  44354. export class FollowCamera extends TargetCamera {
  44355. /**
  44356. * Distance the follow camera should follow an object at
  44357. */
  44358. radius: number;
  44359. /**
  44360. * Minimum allowed distance of the camera to the axis of rotation
  44361. * (The camera can not get closer).
  44362. * This can help limiting how the Camera is able to move in the scene.
  44363. */
  44364. lowerRadiusLimit: Nullable<number>;
  44365. /**
  44366. * Maximum allowed distance of the camera to the axis of rotation
  44367. * (The camera can not get further).
  44368. * This can help limiting how the Camera is able to move in the scene.
  44369. */
  44370. upperRadiusLimit: Nullable<number>;
  44371. /**
  44372. * Define a rotation offset between the camera and the object it follows
  44373. */
  44374. rotationOffset: number;
  44375. /**
  44376. * Minimum allowed angle to camera position relative to target object.
  44377. * This can help limiting how the Camera is able to move in the scene.
  44378. */
  44379. lowerRotationOffsetLimit: Nullable<number>;
  44380. /**
  44381. * Maximum allowed angle to camera position relative to target object.
  44382. * This can help limiting how the Camera is able to move in the scene.
  44383. */
  44384. upperRotationOffsetLimit: Nullable<number>;
  44385. /**
  44386. * Define a height offset between the camera and the object it follows.
  44387. * It can help following an object from the top (like a car chaing a plane)
  44388. */
  44389. heightOffset: number;
  44390. /**
  44391. * Minimum allowed height of camera position relative to target object.
  44392. * This can help limiting how the Camera is able to move in the scene.
  44393. */
  44394. lowerHeightOffsetLimit: Nullable<number>;
  44395. /**
  44396. * Maximum allowed height of camera position relative to target object.
  44397. * This can help limiting how the Camera is able to move in the scene.
  44398. */
  44399. upperHeightOffsetLimit: Nullable<number>;
  44400. /**
  44401. * Define how fast the camera can accelerate to follow it s target.
  44402. */
  44403. cameraAcceleration: number;
  44404. /**
  44405. * Define the speed limit of the camera following an object.
  44406. */
  44407. maxCameraSpeed: number;
  44408. /**
  44409. * Define the target of the camera.
  44410. */
  44411. lockedTarget: Nullable<AbstractMesh>;
  44412. /**
  44413. * Defines the input associated with the camera.
  44414. */
  44415. inputs: FollowCameraInputsManager;
  44416. /**
  44417. * Instantiates the follow camera.
  44418. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44419. * @param name Define the name of the camera in the scene
  44420. * @param position Define the position of the camera
  44421. * @param scene Define the scene the camera belong to
  44422. * @param lockedTarget Define the target of the camera
  44423. */
  44424. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44425. private _follow;
  44426. /**
  44427. * Attached controls to the current camera.
  44428. * @param element Defines the element the controls should be listened from
  44429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44430. */
  44431. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44432. /**
  44433. * Detach the current controls from the camera.
  44434. * The camera will stop reacting to inputs.
  44435. * @param element Defines the element to stop listening the inputs from
  44436. */
  44437. detachControl(element: HTMLElement): void;
  44438. /** @hidden */
  44439. _checkInputs(): void;
  44440. private _checkLimits;
  44441. /**
  44442. * Gets the camera class name.
  44443. * @returns the class name
  44444. */
  44445. getClassName(): string;
  44446. }
  44447. /**
  44448. * Arc Rotate version of the follow camera.
  44449. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44450. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44451. */
  44452. export class ArcFollowCamera extends TargetCamera {
  44453. /** The longitudinal angle of the camera */
  44454. alpha: number;
  44455. /** The latitudinal angle of the camera */
  44456. beta: number;
  44457. /** The radius of the camera from its target */
  44458. radius: number;
  44459. /** Define the camera target (the mesh it should follow) */
  44460. target: Nullable<AbstractMesh>;
  44461. private _cartesianCoordinates;
  44462. /**
  44463. * Instantiates a new ArcFollowCamera
  44464. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44465. * @param name Define the name of the camera
  44466. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44467. * @param beta Define the rotation angle of the camera around the elevation axis
  44468. * @param radius Define the radius of the camera from its target point
  44469. * @param target Define the target of the camera
  44470. * @param scene Define the scene the camera belongs to
  44471. */
  44472. constructor(name: string,
  44473. /** The longitudinal angle of the camera */
  44474. alpha: number,
  44475. /** The latitudinal angle of the camera */
  44476. beta: number,
  44477. /** The radius of the camera from its target */
  44478. radius: number,
  44479. /** Define the camera target (the mesh it should follow) */
  44480. target: Nullable<AbstractMesh>, scene: Scene);
  44481. private _follow;
  44482. /** @hidden */
  44483. _checkInputs(): void;
  44484. /**
  44485. * Returns the class name of the object.
  44486. * It is mostly used internally for serialization purposes.
  44487. */
  44488. getClassName(): string;
  44489. }
  44490. }
  44491. declare module BABYLON {
  44492. /**
  44493. * Manage the keyboard inputs to control the movement of a follow camera.
  44494. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44495. */
  44496. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44497. /**
  44498. * Defines the camera the input is attached to.
  44499. */
  44500. camera: FollowCamera;
  44501. /**
  44502. * Defines the list of key codes associated with the up action (increase heightOffset)
  44503. */
  44504. keysHeightOffsetIncr: number[];
  44505. /**
  44506. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44507. */
  44508. keysHeightOffsetDecr: number[];
  44509. /**
  44510. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44511. */
  44512. keysHeightOffsetModifierAlt: boolean;
  44513. /**
  44514. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44515. */
  44516. keysHeightOffsetModifierCtrl: boolean;
  44517. /**
  44518. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44519. */
  44520. keysHeightOffsetModifierShift: boolean;
  44521. /**
  44522. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44523. */
  44524. keysRotationOffsetIncr: number[];
  44525. /**
  44526. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44527. */
  44528. keysRotationOffsetDecr: number[];
  44529. /**
  44530. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44531. */
  44532. keysRotationOffsetModifierAlt: boolean;
  44533. /**
  44534. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44535. */
  44536. keysRotationOffsetModifierCtrl: boolean;
  44537. /**
  44538. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44539. */
  44540. keysRotationOffsetModifierShift: boolean;
  44541. /**
  44542. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44543. */
  44544. keysRadiusIncr: number[];
  44545. /**
  44546. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44547. */
  44548. keysRadiusDecr: number[];
  44549. /**
  44550. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44551. */
  44552. keysRadiusModifierAlt: boolean;
  44553. /**
  44554. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44555. */
  44556. keysRadiusModifierCtrl: boolean;
  44557. /**
  44558. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44559. */
  44560. keysRadiusModifierShift: boolean;
  44561. /**
  44562. * Defines the rate of change of heightOffset.
  44563. */
  44564. heightSensibility: number;
  44565. /**
  44566. * Defines the rate of change of rotationOffset.
  44567. */
  44568. rotationSensibility: number;
  44569. /**
  44570. * Defines the rate of change of radius.
  44571. */
  44572. radiusSensibility: number;
  44573. private _keys;
  44574. private _ctrlPressed;
  44575. private _altPressed;
  44576. private _shiftPressed;
  44577. private _onCanvasBlurObserver;
  44578. private _onKeyboardObserver;
  44579. private _engine;
  44580. private _scene;
  44581. /**
  44582. * Attach the input controls to a specific dom element to get the input from.
  44583. * @param element Defines the element the controls should be listened from
  44584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44585. */
  44586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44587. /**
  44588. * Detach the current controls from the specified dom element.
  44589. * @param element Defines the element to stop listening the inputs from
  44590. */
  44591. detachControl(element: Nullable<HTMLElement>): void;
  44592. /**
  44593. * Update the current camera state depending on the inputs that have been used this frame.
  44594. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44595. */
  44596. checkInputs(): void;
  44597. /**
  44598. * Gets the class name of the current input.
  44599. * @returns the class name
  44600. */
  44601. getClassName(): string;
  44602. /**
  44603. * Get the friendly name associated with the input class.
  44604. * @returns the input friendly name
  44605. */
  44606. getSimpleName(): string;
  44607. /**
  44608. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44609. * allow modification of the heightOffset value.
  44610. */
  44611. private _modifierHeightOffset;
  44612. /**
  44613. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44614. * allow modification of the rotationOffset value.
  44615. */
  44616. private _modifierRotationOffset;
  44617. /**
  44618. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44619. * allow modification of the radius value.
  44620. */
  44621. private _modifierRadius;
  44622. }
  44623. }
  44624. declare module BABYLON {
  44625. interface FreeCameraInputsManager {
  44626. /**
  44627. * @hidden
  44628. */
  44629. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44630. /**
  44631. * Add orientation input support to the input manager.
  44632. * @returns the current input manager
  44633. */
  44634. addDeviceOrientation(): FreeCameraInputsManager;
  44635. }
  44636. /**
  44637. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44638. * Screen rotation is taken into account.
  44639. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44640. */
  44641. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44642. private _camera;
  44643. private _screenOrientationAngle;
  44644. private _constantTranform;
  44645. private _screenQuaternion;
  44646. private _alpha;
  44647. private _beta;
  44648. private _gamma;
  44649. /**
  44650. * Can be used to detect if a device orientation sensor is available on a device
  44651. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44652. * @returns a promise that will resolve on orientation change
  44653. */
  44654. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44655. /**
  44656. * @hidden
  44657. */
  44658. _onDeviceOrientationChangedObservable: Observable<void>;
  44659. /**
  44660. * Instantiates a new input
  44661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44662. */
  44663. constructor();
  44664. /**
  44665. * Define the camera controlled by the input.
  44666. */
  44667. get camera(): FreeCamera;
  44668. set camera(camera: FreeCamera);
  44669. /**
  44670. * Attach the input controls to a specific dom element to get the input from.
  44671. * @param element Defines the element the controls should be listened from
  44672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44673. */
  44674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44675. private _orientationChanged;
  44676. private _deviceOrientation;
  44677. /**
  44678. * Detach the current controls from the specified dom element.
  44679. * @param element Defines the element to stop listening the inputs from
  44680. */
  44681. detachControl(element: Nullable<HTMLElement>): void;
  44682. /**
  44683. * Update the current camera state depending on the inputs that have been used this frame.
  44684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44685. */
  44686. checkInputs(): void;
  44687. /**
  44688. * Gets the class name of the current intput.
  44689. * @returns the class name
  44690. */
  44691. getClassName(): string;
  44692. /**
  44693. * Get the friendly name associated with the input class.
  44694. * @returns the input friendly name
  44695. */
  44696. getSimpleName(): string;
  44697. }
  44698. }
  44699. declare module BABYLON {
  44700. /**
  44701. * Manage the gamepad inputs to control a free camera.
  44702. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44703. */
  44704. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44705. /**
  44706. * Define the camera the input is attached to.
  44707. */
  44708. camera: FreeCamera;
  44709. /**
  44710. * Define the Gamepad controlling the input
  44711. */
  44712. gamepad: Nullable<Gamepad>;
  44713. /**
  44714. * Defines the gamepad rotation sensiblity.
  44715. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44716. */
  44717. gamepadAngularSensibility: number;
  44718. /**
  44719. * Defines the gamepad move sensiblity.
  44720. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44721. */
  44722. gamepadMoveSensibility: number;
  44723. private _yAxisScale;
  44724. /**
  44725. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44726. */
  44727. get invertYAxis(): boolean;
  44728. set invertYAxis(value: boolean);
  44729. private _onGamepadConnectedObserver;
  44730. private _onGamepadDisconnectedObserver;
  44731. private _cameraTransform;
  44732. private _deltaTransform;
  44733. private _vector3;
  44734. private _vector2;
  44735. /**
  44736. * Attach the input controls to a specific dom element to get the input from.
  44737. * @param element Defines the element the controls should be listened from
  44738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44739. */
  44740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44741. /**
  44742. * Detach the current controls from the specified dom element.
  44743. * @param element Defines the element to stop listening the inputs from
  44744. */
  44745. detachControl(element: Nullable<HTMLElement>): void;
  44746. /**
  44747. * Update the current camera state depending on the inputs that have been used this frame.
  44748. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44749. */
  44750. checkInputs(): void;
  44751. /**
  44752. * Gets the class name of the current intput.
  44753. * @returns the class name
  44754. */
  44755. getClassName(): string;
  44756. /**
  44757. * Get the friendly name associated with the input class.
  44758. * @returns the input friendly name
  44759. */
  44760. getSimpleName(): string;
  44761. }
  44762. }
  44763. declare module BABYLON {
  44764. /**
  44765. * Defines the potential axis of a Joystick
  44766. */
  44767. export enum JoystickAxis {
  44768. /** X axis */
  44769. X = 0,
  44770. /** Y axis */
  44771. Y = 1,
  44772. /** Z axis */
  44773. Z = 2
  44774. }
  44775. /**
  44776. * Represents the different customization options available
  44777. * for VirtualJoystick
  44778. */
  44779. interface VirtualJoystickCustomizations {
  44780. /**
  44781. * Size of the joystick's puck
  44782. */
  44783. puckSize: number;
  44784. /**
  44785. * Size of the joystick's container
  44786. */
  44787. containerSize: number;
  44788. /**
  44789. * Color of the joystick && puck
  44790. */
  44791. color: string;
  44792. /**
  44793. * Image URL for the joystick's puck
  44794. */
  44795. puckImage?: string;
  44796. /**
  44797. * Image URL for the joystick's container
  44798. */
  44799. containerImage?: string;
  44800. /**
  44801. * Defines the unmoving position of the joystick container
  44802. */
  44803. position?: {
  44804. x: number;
  44805. y: number;
  44806. };
  44807. /**
  44808. * Defines whether or not the joystick container is always visible
  44809. */
  44810. alwaysVisible: boolean;
  44811. /**
  44812. * Defines whether or not to limit the movement of the puck to the joystick's container
  44813. */
  44814. limitToContainer: boolean;
  44815. }
  44816. /**
  44817. * Class used to define virtual joystick (used in touch mode)
  44818. */
  44819. export class VirtualJoystick {
  44820. /**
  44821. * Gets or sets a boolean indicating that left and right values must be inverted
  44822. */
  44823. reverseLeftRight: boolean;
  44824. /**
  44825. * Gets or sets a boolean indicating that up and down values must be inverted
  44826. */
  44827. reverseUpDown: boolean;
  44828. /**
  44829. * Gets the offset value for the position (ie. the change of the position value)
  44830. */
  44831. deltaPosition: Vector3;
  44832. /**
  44833. * Gets a boolean indicating if the virtual joystick was pressed
  44834. */
  44835. pressed: boolean;
  44836. /**
  44837. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44838. */
  44839. static Canvas: Nullable<HTMLCanvasElement>;
  44840. /**
  44841. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44842. */
  44843. limitToContainer: boolean;
  44844. private static _globalJoystickIndex;
  44845. private static _alwaysVisibleSticks;
  44846. private static vjCanvasContext;
  44847. private static vjCanvasWidth;
  44848. private static vjCanvasHeight;
  44849. private static halfWidth;
  44850. private static _GetDefaultOptions;
  44851. private _action;
  44852. private _axisTargetedByLeftAndRight;
  44853. private _axisTargetedByUpAndDown;
  44854. private _joystickSensibility;
  44855. private _inversedSensibility;
  44856. private _joystickPointerID;
  44857. private _joystickColor;
  44858. private _joystickPointerPos;
  44859. private _joystickPreviousPointerPos;
  44860. private _joystickPointerStartPos;
  44861. private _deltaJoystickVector;
  44862. private _leftJoystick;
  44863. private _touches;
  44864. private _joystickPosition;
  44865. private _alwaysVisible;
  44866. private _puckImage;
  44867. private _containerImage;
  44868. private _joystickPuckSize;
  44869. private _joystickContainerSize;
  44870. private _clearPuckSize;
  44871. private _clearContainerSize;
  44872. private _clearPuckSizeOffset;
  44873. private _clearContainerSizeOffset;
  44874. private _onPointerDownHandlerRef;
  44875. private _onPointerMoveHandlerRef;
  44876. private _onPointerUpHandlerRef;
  44877. private _onResize;
  44878. /**
  44879. * Creates a new virtual joystick
  44880. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44881. * @param customizations Defines the options we want to customize the VirtualJoystick
  44882. */
  44883. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44884. /**
  44885. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44886. * @param newJoystickSensibility defines the new sensibility
  44887. */
  44888. setJoystickSensibility(newJoystickSensibility: number): void;
  44889. private _onPointerDown;
  44890. private _onPointerMove;
  44891. private _onPointerUp;
  44892. /**
  44893. * Change the color of the virtual joystick
  44894. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44895. */
  44896. setJoystickColor(newColor: string): void;
  44897. /**
  44898. * Size of the joystick's container
  44899. */
  44900. set containerSize(newSize: number);
  44901. get containerSize(): number;
  44902. /**
  44903. * Size of the joystick's puck
  44904. */
  44905. set puckSize(newSize: number);
  44906. get puckSize(): number;
  44907. /**
  44908. * Clears the set position of the joystick
  44909. */
  44910. clearPosition(): void;
  44911. /**
  44912. * Defines whether or not the joystick container is always visible
  44913. */
  44914. set alwaysVisible(value: boolean);
  44915. get alwaysVisible(): boolean;
  44916. /**
  44917. * Sets the constant position of the Joystick container
  44918. * @param x X axis coordinate
  44919. * @param y Y axis coordinate
  44920. */
  44921. setPosition(x: number, y: number): void;
  44922. /**
  44923. * Defines a callback to call when the joystick is touched
  44924. * @param action defines the callback
  44925. */
  44926. setActionOnTouch(action: () => any): void;
  44927. /**
  44928. * Defines which axis you'd like to control for left & right
  44929. * @param axis defines the axis to use
  44930. */
  44931. setAxisForLeftRight(axis: JoystickAxis): void;
  44932. /**
  44933. * Defines which axis you'd like to control for up & down
  44934. * @param axis defines the axis to use
  44935. */
  44936. setAxisForUpDown(axis: JoystickAxis): void;
  44937. /**
  44938. * Clears the canvas from the previous puck / container draw
  44939. */
  44940. private _clearPreviousDraw;
  44941. /**
  44942. * Loads `urlPath` to be used for the container's image
  44943. * @param urlPath defines the urlPath of an image to use
  44944. */
  44945. setContainerImage(urlPath: string): void;
  44946. /**
  44947. * Loads `urlPath` to be used for the puck's image
  44948. * @param urlPath defines the urlPath of an image to use
  44949. */
  44950. setPuckImage(urlPath: string): void;
  44951. /**
  44952. * Draws the Virtual Joystick's container
  44953. */
  44954. private _drawContainer;
  44955. /**
  44956. * Draws the Virtual Joystick's puck
  44957. */
  44958. private _drawPuck;
  44959. private _drawVirtualJoystick;
  44960. /**
  44961. * Release internal HTML canvas
  44962. */
  44963. releaseCanvas(): void;
  44964. }
  44965. }
  44966. declare module BABYLON {
  44967. interface FreeCameraInputsManager {
  44968. /**
  44969. * Add virtual joystick input support to the input manager.
  44970. * @returns the current input manager
  44971. */
  44972. addVirtualJoystick(): FreeCameraInputsManager;
  44973. }
  44974. /**
  44975. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44977. */
  44978. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44979. /**
  44980. * Defines the camera the input is attached to.
  44981. */
  44982. camera: FreeCamera;
  44983. private _leftjoystick;
  44984. private _rightjoystick;
  44985. /**
  44986. * Gets the left stick of the virtual joystick.
  44987. * @returns The virtual Joystick
  44988. */
  44989. getLeftJoystick(): VirtualJoystick;
  44990. /**
  44991. * Gets the right stick of the virtual joystick.
  44992. * @returns The virtual Joystick
  44993. */
  44994. getRightJoystick(): VirtualJoystick;
  44995. /**
  44996. * Update the current camera state depending on the inputs that have been used this frame.
  44997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44998. */
  44999. checkInputs(): void;
  45000. /**
  45001. * Attach the input controls to a specific dom element to get the input from.
  45002. * @param element Defines the element the controls should be listened from
  45003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45004. */
  45005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45006. /**
  45007. * Detach the current controls from the specified dom element.
  45008. * @param element Defines the element to stop listening the inputs from
  45009. */
  45010. detachControl(element: Nullable<HTMLElement>): void;
  45011. /**
  45012. * Gets the class name of the current intput.
  45013. * @returns the class name
  45014. */
  45015. getClassName(): string;
  45016. /**
  45017. * Get the friendly name associated with the input class.
  45018. * @returns the input friendly name
  45019. */
  45020. getSimpleName(): string;
  45021. }
  45022. }
  45023. declare module BABYLON {
  45024. /**
  45025. * This represents a FPS type of camera controlled by touch.
  45026. * This is like a universal camera minus the Gamepad controls.
  45027. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45028. */
  45029. export class TouchCamera extends FreeCamera {
  45030. /**
  45031. * Defines the touch sensibility for rotation.
  45032. * The higher the faster.
  45033. */
  45034. get touchAngularSensibility(): number;
  45035. set touchAngularSensibility(value: number);
  45036. /**
  45037. * Defines the touch sensibility for move.
  45038. * The higher the faster.
  45039. */
  45040. get touchMoveSensibility(): number;
  45041. set touchMoveSensibility(value: number);
  45042. /**
  45043. * Instantiates a new touch camera.
  45044. * This represents a FPS type of camera controlled by touch.
  45045. * This is like a universal camera minus the Gamepad controls.
  45046. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45047. * @param name Define the name of the camera in the scene
  45048. * @param position Define the start position of the camera in the scene
  45049. * @param scene Define the scene the camera belongs to
  45050. */
  45051. constructor(name: string, position: Vector3, scene: Scene);
  45052. /**
  45053. * Gets the current object class name.
  45054. * @return the class name
  45055. */
  45056. getClassName(): string;
  45057. /** @hidden */
  45058. _setupInputs(): void;
  45059. }
  45060. }
  45061. declare module BABYLON {
  45062. /**
  45063. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45064. * being tilted forward or back and left or right.
  45065. */
  45066. export class DeviceOrientationCamera extends FreeCamera {
  45067. private _initialQuaternion;
  45068. private _quaternionCache;
  45069. private _tmpDragQuaternion;
  45070. private _disablePointerInputWhenUsingDeviceOrientation;
  45071. /**
  45072. * Creates a new device orientation camera
  45073. * @param name The name of the camera
  45074. * @param position The start position camera
  45075. * @param scene The scene the camera belongs to
  45076. */
  45077. constructor(name: string, position: Vector3, scene: Scene);
  45078. /**
  45079. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45080. */
  45081. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45082. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45083. private _dragFactor;
  45084. /**
  45085. * Enabled turning on the y axis when the orientation sensor is active
  45086. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45087. */
  45088. enableHorizontalDragging(dragFactor?: number): void;
  45089. /**
  45090. * Gets the current instance class name ("DeviceOrientationCamera").
  45091. * This helps avoiding instanceof at run time.
  45092. * @returns the class name
  45093. */
  45094. getClassName(): string;
  45095. /**
  45096. * @hidden
  45097. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45098. */
  45099. _checkInputs(): void;
  45100. /**
  45101. * Reset the camera to its default orientation on the specified axis only.
  45102. * @param axis The axis to reset
  45103. */
  45104. resetToCurrentRotation(axis?: Axis): void;
  45105. }
  45106. }
  45107. declare module BABYLON {
  45108. /**
  45109. * Defines supported buttons for XBox360 compatible gamepads
  45110. */
  45111. export enum Xbox360Button {
  45112. /** A */
  45113. A = 0,
  45114. /** B */
  45115. B = 1,
  45116. /** X */
  45117. X = 2,
  45118. /** Y */
  45119. Y = 3,
  45120. /** Left button */
  45121. LB = 4,
  45122. /** Right button */
  45123. RB = 5,
  45124. /** Back */
  45125. Back = 8,
  45126. /** Start */
  45127. Start = 9,
  45128. /** Left stick */
  45129. LeftStick = 10,
  45130. /** Right stick */
  45131. RightStick = 11
  45132. }
  45133. /** Defines values for XBox360 DPad */
  45134. export enum Xbox360Dpad {
  45135. /** Up */
  45136. Up = 12,
  45137. /** Down */
  45138. Down = 13,
  45139. /** Left */
  45140. Left = 14,
  45141. /** Right */
  45142. Right = 15
  45143. }
  45144. /**
  45145. * Defines a XBox360 gamepad
  45146. */
  45147. export class Xbox360Pad extends Gamepad {
  45148. private _leftTrigger;
  45149. private _rightTrigger;
  45150. private _onlefttriggerchanged;
  45151. private _onrighttriggerchanged;
  45152. private _onbuttondown;
  45153. private _onbuttonup;
  45154. private _ondpaddown;
  45155. private _ondpadup;
  45156. /** Observable raised when a button is pressed */
  45157. onButtonDownObservable: Observable<Xbox360Button>;
  45158. /** Observable raised when a button is released */
  45159. onButtonUpObservable: Observable<Xbox360Button>;
  45160. /** Observable raised when a pad is pressed */
  45161. onPadDownObservable: Observable<Xbox360Dpad>;
  45162. /** Observable raised when a pad is released */
  45163. onPadUpObservable: Observable<Xbox360Dpad>;
  45164. private _buttonA;
  45165. private _buttonB;
  45166. private _buttonX;
  45167. private _buttonY;
  45168. private _buttonBack;
  45169. private _buttonStart;
  45170. private _buttonLB;
  45171. private _buttonRB;
  45172. private _buttonLeftStick;
  45173. private _buttonRightStick;
  45174. private _dPadUp;
  45175. private _dPadDown;
  45176. private _dPadLeft;
  45177. private _dPadRight;
  45178. private _isXboxOnePad;
  45179. /**
  45180. * Creates a new XBox360 gamepad object
  45181. * @param id defines the id of this gamepad
  45182. * @param index defines its index
  45183. * @param gamepad defines the internal HTML gamepad object
  45184. * @param xboxOne defines if it is a XBox One gamepad
  45185. */
  45186. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45187. /**
  45188. * Defines the callback to call when left trigger is pressed
  45189. * @param callback defines the callback to use
  45190. */
  45191. onlefttriggerchanged(callback: (value: number) => void): void;
  45192. /**
  45193. * Defines the callback to call when right trigger is pressed
  45194. * @param callback defines the callback to use
  45195. */
  45196. onrighttriggerchanged(callback: (value: number) => void): void;
  45197. /**
  45198. * Gets the left trigger value
  45199. */
  45200. get leftTrigger(): number;
  45201. /**
  45202. * Sets the left trigger value
  45203. */
  45204. set leftTrigger(newValue: number);
  45205. /**
  45206. * Gets the right trigger value
  45207. */
  45208. get rightTrigger(): number;
  45209. /**
  45210. * Sets the right trigger value
  45211. */
  45212. set rightTrigger(newValue: number);
  45213. /**
  45214. * Defines the callback to call when a button is pressed
  45215. * @param callback defines the callback to use
  45216. */
  45217. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45218. /**
  45219. * Defines the callback to call when a button is released
  45220. * @param callback defines the callback to use
  45221. */
  45222. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45223. /**
  45224. * Defines the callback to call when a pad is pressed
  45225. * @param callback defines the callback to use
  45226. */
  45227. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45228. /**
  45229. * Defines the callback to call when a pad is released
  45230. * @param callback defines the callback to use
  45231. */
  45232. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45233. private _setButtonValue;
  45234. private _setDPadValue;
  45235. /**
  45236. * Gets the value of the `A` button
  45237. */
  45238. get buttonA(): number;
  45239. /**
  45240. * Sets the value of the `A` button
  45241. */
  45242. set buttonA(value: number);
  45243. /**
  45244. * Gets the value of the `B` button
  45245. */
  45246. get buttonB(): number;
  45247. /**
  45248. * Sets the value of the `B` button
  45249. */
  45250. set buttonB(value: number);
  45251. /**
  45252. * Gets the value of the `X` button
  45253. */
  45254. get buttonX(): number;
  45255. /**
  45256. * Sets the value of the `X` button
  45257. */
  45258. set buttonX(value: number);
  45259. /**
  45260. * Gets the value of the `Y` button
  45261. */
  45262. get buttonY(): number;
  45263. /**
  45264. * Sets the value of the `Y` button
  45265. */
  45266. set buttonY(value: number);
  45267. /**
  45268. * Gets the value of the `Start` button
  45269. */
  45270. get buttonStart(): number;
  45271. /**
  45272. * Sets the value of the `Start` button
  45273. */
  45274. set buttonStart(value: number);
  45275. /**
  45276. * Gets the value of the `Back` button
  45277. */
  45278. get buttonBack(): number;
  45279. /**
  45280. * Sets the value of the `Back` button
  45281. */
  45282. set buttonBack(value: number);
  45283. /**
  45284. * Gets the value of the `Left` button
  45285. */
  45286. get buttonLB(): number;
  45287. /**
  45288. * Sets the value of the `Left` button
  45289. */
  45290. set buttonLB(value: number);
  45291. /**
  45292. * Gets the value of the `Right` button
  45293. */
  45294. get buttonRB(): number;
  45295. /**
  45296. * Sets the value of the `Right` button
  45297. */
  45298. set buttonRB(value: number);
  45299. /**
  45300. * Gets the value of the Left joystick
  45301. */
  45302. get buttonLeftStick(): number;
  45303. /**
  45304. * Sets the value of the Left joystick
  45305. */
  45306. set buttonLeftStick(value: number);
  45307. /**
  45308. * Gets the value of the Right joystick
  45309. */
  45310. get buttonRightStick(): number;
  45311. /**
  45312. * Sets the value of the Right joystick
  45313. */
  45314. set buttonRightStick(value: number);
  45315. /**
  45316. * Gets the value of D-pad up
  45317. */
  45318. get dPadUp(): number;
  45319. /**
  45320. * Sets the value of D-pad up
  45321. */
  45322. set dPadUp(value: number);
  45323. /**
  45324. * Gets the value of D-pad down
  45325. */
  45326. get dPadDown(): number;
  45327. /**
  45328. * Sets the value of D-pad down
  45329. */
  45330. set dPadDown(value: number);
  45331. /**
  45332. * Gets the value of D-pad left
  45333. */
  45334. get dPadLeft(): number;
  45335. /**
  45336. * Sets the value of D-pad left
  45337. */
  45338. set dPadLeft(value: number);
  45339. /**
  45340. * Gets the value of D-pad right
  45341. */
  45342. get dPadRight(): number;
  45343. /**
  45344. * Sets the value of D-pad right
  45345. */
  45346. set dPadRight(value: number);
  45347. /**
  45348. * Force the gamepad to synchronize with device values
  45349. */
  45350. update(): void;
  45351. /**
  45352. * Disposes the gamepad
  45353. */
  45354. dispose(): void;
  45355. }
  45356. }
  45357. declare module BABYLON {
  45358. /**
  45359. * Defines supported buttons for DualShock compatible gamepads
  45360. */
  45361. export enum DualShockButton {
  45362. /** Cross */
  45363. Cross = 0,
  45364. /** Circle */
  45365. Circle = 1,
  45366. /** Square */
  45367. Square = 2,
  45368. /** Triangle */
  45369. Triangle = 3,
  45370. /** L1 */
  45371. L1 = 4,
  45372. /** R1 */
  45373. R1 = 5,
  45374. /** Share */
  45375. Share = 8,
  45376. /** Options */
  45377. Options = 9,
  45378. /** Left stick */
  45379. LeftStick = 10,
  45380. /** Right stick */
  45381. RightStick = 11
  45382. }
  45383. /** Defines values for DualShock DPad */
  45384. export enum DualShockDpad {
  45385. /** Up */
  45386. Up = 12,
  45387. /** Down */
  45388. Down = 13,
  45389. /** Left */
  45390. Left = 14,
  45391. /** Right */
  45392. Right = 15
  45393. }
  45394. /**
  45395. * Defines a DualShock gamepad
  45396. */
  45397. export class DualShockPad extends Gamepad {
  45398. private _leftTrigger;
  45399. private _rightTrigger;
  45400. private _onlefttriggerchanged;
  45401. private _onrighttriggerchanged;
  45402. private _onbuttondown;
  45403. private _onbuttonup;
  45404. private _ondpaddown;
  45405. private _ondpadup;
  45406. /** Observable raised when a button is pressed */
  45407. onButtonDownObservable: Observable<DualShockButton>;
  45408. /** Observable raised when a button is released */
  45409. onButtonUpObservable: Observable<DualShockButton>;
  45410. /** Observable raised when a pad is pressed */
  45411. onPadDownObservable: Observable<DualShockDpad>;
  45412. /** Observable raised when a pad is released */
  45413. onPadUpObservable: Observable<DualShockDpad>;
  45414. private _buttonCross;
  45415. private _buttonCircle;
  45416. private _buttonSquare;
  45417. private _buttonTriangle;
  45418. private _buttonShare;
  45419. private _buttonOptions;
  45420. private _buttonL1;
  45421. private _buttonR1;
  45422. private _buttonLeftStick;
  45423. private _buttonRightStick;
  45424. private _dPadUp;
  45425. private _dPadDown;
  45426. private _dPadLeft;
  45427. private _dPadRight;
  45428. /**
  45429. * Creates a new DualShock gamepad object
  45430. * @param id defines the id of this gamepad
  45431. * @param index defines its index
  45432. * @param gamepad defines the internal HTML gamepad object
  45433. */
  45434. constructor(id: string, index: number, gamepad: any);
  45435. /**
  45436. * Defines the callback to call when left trigger is pressed
  45437. * @param callback defines the callback to use
  45438. */
  45439. onlefttriggerchanged(callback: (value: number) => void): void;
  45440. /**
  45441. * Defines the callback to call when right trigger is pressed
  45442. * @param callback defines the callback to use
  45443. */
  45444. onrighttriggerchanged(callback: (value: number) => void): void;
  45445. /**
  45446. * Gets the left trigger value
  45447. */
  45448. get leftTrigger(): number;
  45449. /**
  45450. * Sets the left trigger value
  45451. */
  45452. set leftTrigger(newValue: number);
  45453. /**
  45454. * Gets the right trigger value
  45455. */
  45456. get rightTrigger(): number;
  45457. /**
  45458. * Sets the right trigger value
  45459. */
  45460. set rightTrigger(newValue: number);
  45461. /**
  45462. * Defines the callback to call when a button is pressed
  45463. * @param callback defines the callback to use
  45464. */
  45465. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45466. /**
  45467. * Defines the callback to call when a button is released
  45468. * @param callback defines the callback to use
  45469. */
  45470. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45471. /**
  45472. * Defines the callback to call when a pad is pressed
  45473. * @param callback defines the callback to use
  45474. */
  45475. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45476. /**
  45477. * Defines the callback to call when a pad is released
  45478. * @param callback defines the callback to use
  45479. */
  45480. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45481. private _setButtonValue;
  45482. private _setDPadValue;
  45483. /**
  45484. * Gets the value of the `Cross` button
  45485. */
  45486. get buttonCross(): number;
  45487. /**
  45488. * Sets the value of the `Cross` button
  45489. */
  45490. set buttonCross(value: number);
  45491. /**
  45492. * Gets the value of the `Circle` button
  45493. */
  45494. get buttonCircle(): number;
  45495. /**
  45496. * Sets the value of the `Circle` button
  45497. */
  45498. set buttonCircle(value: number);
  45499. /**
  45500. * Gets the value of the `Square` button
  45501. */
  45502. get buttonSquare(): number;
  45503. /**
  45504. * Sets the value of the `Square` button
  45505. */
  45506. set buttonSquare(value: number);
  45507. /**
  45508. * Gets the value of the `Triangle` button
  45509. */
  45510. get buttonTriangle(): number;
  45511. /**
  45512. * Sets the value of the `Triangle` button
  45513. */
  45514. set buttonTriangle(value: number);
  45515. /**
  45516. * Gets the value of the `Options` button
  45517. */
  45518. get buttonOptions(): number;
  45519. /**
  45520. * Sets the value of the `Options` button
  45521. */
  45522. set buttonOptions(value: number);
  45523. /**
  45524. * Gets the value of the `Share` button
  45525. */
  45526. get buttonShare(): number;
  45527. /**
  45528. * Sets the value of the `Share` button
  45529. */
  45530. set buttonShare(value: number);
  45531. /**
  45532. * Gets the value of the `L1` button
  45533. */
  45534. get buttonL1(): number;
  45535. /**
  45536. * Sets the value of the `L1` button
  45537. */
  45538. set buttonL1(value: number);
  45539. /**
  45540. * Gets the value of the `R1` button
  45541. */
  45542. get buttonR1(): number;
  45543. /**
  45544. * Sets the value of the `R1` button
  45545. */
  45546. set buttonR1(value: number);
  45547. /**
  45548. * Gets the value of the Left joystick
  45549. */
  45550. get buttonLeftStick(): number;
  45551. /**
  45552. * Sets the value of the Left joystick
  45553. */
  45554. set buttonLeftStick(value: number);
  45555. /**
  45556. * Gets the value of the Right joystick
  45557. */
  45558. get buttonRightStick(): number;
  45559. /**
  45560. * Sets the value of the Right joystick
  45561. */
  45562. set buttonRightStick(value: number);
  45563. /**
  45564. * Gets the value of D-pad up
  45565. */
  45566. get dPadUp(): number;
  45567. /**
  45568. * Sets the value of D-pad up
  45569. */
  45570. set dPadUp(value: number);
  45571. /**
  45572. * Gets the value of D-pad down
  45573. */
  45574. get dPadDown(): number;
  45575. /**
  45576. * Sets the value of D-pad down
  45577. */
  45578. set dPadDown(value: number);
  45579. /**
  45580. * Gets the value of D-pad left
  45581. */
  45582. get dPadLeft(): number;
  45583. /**
  45584. * Sets the value of D-pad left
  45585. */
  45586. set dPadLeft(value: number);
  45587. /**
  45588. * Gets the value of D-pad right
  45589. */
  45590. get dPadRight(): number;
  45591. /**
  45592. * Sets the value of D-pad right
  45593. */
  45594. set dPadRight(value: number);
  45595. /**
  45596. * Force the gamepad to synchronize with device values
  45597. */
  45598. update(): void;
  45599. /**
  45600. * Disposes the gamepad
  45601. */
  45602. dispose(): void;
  45603. }
  45604. }
  45605. declare module BABYLON {
  45606. /**
  45607. * Manager for handling gamepads
  45608. */
  45609. export class GamepadManager {
  45610. private _scene?;
  45611. private _babylonGamepads;
  45612. private _oneGamepadConnected;
  45613. /** @hidden */
  45614. _isMonitoring: boolean;
  45615. private _gamepadEventSupported;
  45616. private _gamepadSupport?;
  45617. /**
  45618. * observable to be triggered when the gamepad controller has been connected
  45619. */
  45620. onGamepadConnectedObservable: Observable<Gamepad>;
  45621. /**
  45622. * observable to be triggered when the gamepad controller has been disconnected
  45623. */
  45624. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45625. private _onGamepadConnectedEvent;
  45626. private _onGamepadDisconnectedEvent;
  45627. /**
  45628. * Initializes the gamepad manager
  45629. * @param _scene BabylonJS scene
  45630. */
  45631. constructor(_scene?: Scene | undefined);
  45632. /**
  45633. * The gamepads in the game pad manager
  45634. */
  45635. get gamepads(): Gamepad[];
  45636. /**
  45637. * Get the gamepad controllers based on type
  45638. * @param type The type of gamepad controller
  45639. * @returns Nullable gamepad
  45640. */
  45641. getGamepadByType(type?: number): Nullable<Gamepad>;
  45642. /**
  45643. * Disposes the gamepad manager
  45644. */
  45645. dispose(): void;
  45646. private _addNewGamepad;
  45647. private _startMonitoringGamepads;
  45648. private _stopMonitoringGamepads;
  45649. /** @hidden */
  45650. _checkGamepadsStatus(): void;
  45651. private _updateGamepadObjects;
  45652. }
  45653. }
  45654. declare module BABYLON {
  45655. interface Scene {
  45656. /** @hidden */
  45657. _gamepadManager: Nullable<GamepadManager>;
  45658. /**
  45659. * Gets the gamepad manager associated with the scene
  45660. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45661. */
  45662. gamepadManager: GamepadManager;
  45663. }
  45664. /**
  45665. * Interface representing a free camera inputs manager
  45666. */
  45667. interface FreeCameraInputsManager {
  45668. /**
  45669. * Adds gamepad input support to the FreeCameraInputsManager.
  45670. * @returns the FreeCameraInputsManager
  45671. */
  45672. addGamepad(): FreeCameraInputsManager;
  45673. }
  45674. /**
  45675. * Interface representing an arc rotate camera inputs manager
  45676. */
  45677. interface ArcRotateCameraInputsManager {
  45678. /**
  45679. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45680. * @returns the camera inputs manager
  45681. */
  45682. addGamepad(): ArcRotateCameraInputsManager;
  45683. }
  45684. /**
  45685. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45686. */
  45687. export class GamepadSystemSceneComponent implements ISceneComponent {
  45688. /**
  45689. * The component name helpfull to identify the component in the list of scene components.
  45690. */
  45691. readonly name: string;
  45692. /**
  45693. * The scene the component belongs to.
  45694. */
  45695. scene: Scene;
  45696. /**
  45697. * Creates a new instance of the component for the given scene
  45698. * @param scene Defines the scene to register the component in
  45699. */
  45700. constructor(scene: Scene);
  45701. /**
  45702. * Registers the component in a given scene
  45703. */
  45704. register(): void;
  45705. /**
  45706. * Rebuilds the elements related to this component in case of
  45707. * context lost for instance.
  45708. */
  45709. rebuild(): void;
  45710. /**
  45711. * Disposes the component and the associated ressources
  45712. */
  45713. dispose(): void;
  45714. private _beforeCameraUpdate;
  45715. }
  45716. }
  45717. declare module BABYLON {
  45718. /**
  45719. * 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,
  45720. * which still works and will still be found in many Playgrounds.
  45721. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45722. */
  45723. export class UniversalCamera extends TouchCamera {
  45724. /**
  45725. * Defines the gamepad rotation sensiblity.
  45726. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45727. */
  45728. get gamepadAngularSensibility(): number;
  45729. set gamepadAngularSensibility(value: number);
  45730. /**
  45731. * Defines the gamepad move sensiblity.
  45732. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45733. */
  45734. get gamepadMoveSensibility(): number;
  45735. set gamepadMoveSensibility(value: number);
  45736. /**
  45737. * 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,
  45738. * which still works and will still be found in many Playgrounds.
  45739. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45740. * @param name Define the name of the camera in the scene
  45741. * @param position Define the start position of the camera in the scene
  45742. * @param scene Define the scene the camera belongs to
  45743. */
  45744. constructor(name: string, position: Vector3, scene: Scene);
  45745. /**
  45746. * Gets the current object class name.
  45747. * @return the class name
  45748. */
  45749. getClassName(): string;
  45750. }
  45751. }
  45752. declare module BABYLON {
  45753. /**
  45754. * This represents a FPS type of camera. This is only here for back compat purpose.
  45755. * Please use the UniversalCamera instead as both are identical.
  45756. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45757. */
  45758. export class GamepadCamera extends UniversalCamera {
  45759. /**
  45760. * Instantiates a new Gamepad Camera
  45761. * This represents a FPS type of camera. This is only here for back compat purpose.
  45762. * Please use the UniversalCamera instead as both are identical.
  45763. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45764. * @param name Define the name of the camera in the scene
  45765. * @param position Define the start position of the camera in the scene
  45766. * @param scene Define the scene the camera belongs to
  45767. */
  45768. constructor(name: string, position: Vector3, scene: Scene);
  45769. /**
  45770. * Gets the current object class name.
  45771. * @return the class name
  45772. */
  45773. getClassName(): string;
  45774. }
  45775. }
  45776. declare module BABYLON {
  45777. /** @hidden */
  45778. export var passPixelShader: {
  45779. name: string;
  45780. shader: string;
  45781. };
  45782. }
  45783. declare module BABYLON {
  45784. /** @hidden */
  45785. export var passCubePixelShader: {
  45786. name: string;
  45787. shader: string;
  45788. };
  45789. }
  45790. declare module BABYLON {
  45791. /**
  45792. * PassPostProcess which produces an output the same as it's input
  45793. */
  45794. export class PassPostProcess extends PostProcess {
  45795. /**
  45796. * Creates the PassPostProcess
  45797. * @param name The name of the effect.
  45798. * @param options The required width/height ratio to downsize to before computing the render pass.
  45799. * @param camera The camera to apply the render pass to.
  45800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45801. * @param engine The engine which the post process will be applied. (default: current engine)
  45802. * @param reusable If the post process can be reused on the same frame. (default: false)
  45803. * @param textureType The type of texture to be used when performing the post processing.
  45804. * @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)
  45805. */
  45806. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45807. }
  45808. /**
  45809. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45810. */
  45811. export class PassCubePostProcess extends PostProcess {
  45812. private _face;
  45813. /**
  45814. * Gets or sets the cube face to display.
  45815. * * 0 is +X
  45816. * * 1 is -X
  45817. * * 2 is +Y
  45818. * * 3 is -Y
  45819. * * 4 is +Z
  45820. * * 5 is -Z
  45821. */
  45822. get face(): number;
  45823. set face(value: number);
  45824. /**
  45825. * Creates the PassCubePostProcess
  45826. * @param name The name of the effect.
  45827. * @param options The required width/height ratio to downsize to before computing the render pass.
  45828. * @param camera The camera to apply the render pass to.
  45829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45830. * @param engine The engine which the post process will be applied. (default: current engine)
  45831. * @param reusable If the post process can be reused on the same frame. (default: false)
  45832. * @param textureType The type of texture to be used when performing the post processing.
  45833. * @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)
  45834. */
  45835. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45836. }
  45837. }
  45838. declare module BABYLON {
  45839. /** @hidden */
  45840. export var anaglyphPixelShader: {
  45841. name: string;
  45842. shader: string;
  45843. };
  45844. }
  45845. declare module BABYLON {
  45846. /**
  45847. * Postprocess used to generate anaglyphic rendering
  45848. */
  45849. export class AnaglyphPostProcess extends PostProcess {
  45850. private _passedProcess;
  45851. /**
  45852. * Creates a new AnaglyphPostProcess
  45853. * @param name defines postprocess name
  45854. * @param options defines creation options or target ratio scale
  45855. * @param rigCameras defines cameras using this postprocess
  45856. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45857. * @param engine defines hosting engine
  45858. * @param reusable defines if the postprocess will be reused multiple times per frame
  45859. */
  45860. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45861. }
  45862. }
  45863. declare module BABYLON {
  45864. /**
  45865. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45866. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45867. */
  45868. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45869. /**
  45870. * Creates a new AnaglyphArcRotateCamera
  45871. * @param name defines camera name
  45872. * @param alpha defines alpha angle (in radians)
  45873. * @param beta defines beta angle (in radians)
  45874. * @param radius defines radius
  45875. * @param target defines camera target
  45876. * @param interaxialDistance defines distance between each color axis
  45877. * @param scene defines the hosting scene
  45878. */
  45879. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45880. /**
  45881. * Gets camera class name
  45882. * @returns AnaglyphArcRotateCamera
  45883. */
  45884. getClassName(): string;
  45885. }
  45886. }
  45887. declare module BABYLON {
  45888. /**
  45889. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45890. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45891. */
  45892. export class AnaglyphFreeCamera extends FreeCamera {
  45893. /**
  45894. * Creates a new AnaglyphFreeCamera
  45895. * @param name defines camera name
  45896. * @param position defines initial position
  45897. * @param interaxialDistance defines distance between each color axis
  45898. * @param scene defines the hosting scene
  45899. */
  45900. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45901. /**
  45902. * Gets camera class name
  45903. * @returns AnaglyphFreeCamera
  45904. */
  45905. getClassName(): string;
  45906. }
  45907. }
  45908. declare module BABYLON {
  45909. /**
  45910. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45911. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45912. */
  45913. export class AnaglyphGamepadCamera extends GamepadCamera {
  45914. /**
  45915. * Creates a new AnaglyphGamepadCamera
  45916. * @param name defines camera name
  45917. * @param position defines initial position
  45918. * @param interaxialDistance defines distance between each color axis
  45919. * @param scene defines the hosting scene
  45920. */
  45921. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45922. /**
  45923. * Gets camera class name
  45924. * @returns AnaglyphGamepadCamera
  45925. */
  45926. getClassName(): string;
  45927. }
  45928. }
  45929. declare module BABYLON {
  45930. /**
  45931. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45932. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45933. */
  45934. export class AnaglyphUniversalCamera extends UniversalCamera {
  45935. /**
  45936. * Creates a new AnaglyphUniversalCamera
  45937. * @param name defines camera name
  45938. * @param position defines initial position
  45939. * @param interaxialDistance defines distance between each color axis
  45940. * @param scene defines the hosting scene
  45941. */
  45942. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45943. /**
  45944. * Gets camera class name
  45945. * @returns AnaglyphUniversalCamera
  45946. */
  45947. getClassName(): string;
  45948. }
  45949. }
  45950. declare module BABYLON {
  45951. /**
  45952. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45953. * @see https://doc.babylonjs.com/features/cameras
  45954. */
  45955. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45956. /**
  45957. * Creates a new StereoscopicArcRotateCamera
  45958. * @param name defines camera name
  45959. * @param alpha defines alpha angle (in radians)
  45960. * @param beta defines beta angle (in radians)
  45961. * @param radius defines radius
  45962. * @param target defines camera target
  45963. * @param interaxialDistance defines distance between each color axis
  45964. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45965. * @param scene defines the hosting scene
  45966. */
  45967. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45968. /**
  45969. * Gets camera class name
  45970. * @returns StereoscopicArcRotateCamera
  45971. */
  45972. getClassName(): string;
  45973. }
  45974. }
  45975. declare module BABYLON {
  45976. /**
  45977. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45978. * @see https://doc.babylonjs.com/features/cameras
  45979. */
  45980. export class StereoscopicFreeCamera extends FreeCamera {
  45981. /**
  45982. * Creates a new StereoscopicFreeCamera
  45983. * @param name defines camera name
  45984. * @param position defines initial position
  45985. * @param interaxialDistance defines distance between each color axis
  45986. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45987. * @param scene defines the hosting scene
  45988. */
  45989. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45990. /**
  45991. * Gets camera class name
  45992. * @returns StereoscopicFreeCamera
  45993. */
  45994. getClassName(): string;
  45995. }
  45996. }
  45997. declare module BABYLON {
  45998. /**
  45999. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46000. * @see https://doc.babylonjs.com/features/cameras
  46001. */
  46002. export class StereoscopicGamepadCamera extends GamepadCamera {
  46003. /**
  46004. * Creates a new StereoscopicGamepadCamera
  46005. * @param name defines camera name
  46006. * @param position defines initial position
  46007. * @param interaxialDistance defines distance between each color axis
  46008. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46009. * @param scene defines the hosting scene
  46010. */
  46011. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46012. /**
  46013. * Gets camera class name
  46014. * @returns StereoscopicGamepadCamera
  46015. */
  46016. getClassName(): string;
  46017. }
  46018. }
  46019. declare module BABYLON {
  46020. /**
  46021. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46022. * @see https://doc.babylonjs.com/features/cameras
  46023. */
  46024. export class StereoscopicUniversalCamera extends UniversalCamera {
  46025. /**
  46026. * Creates a new StereoscopicUniversalCamera
  46027. * @param name defines camera name
  46028. * @param position defines initial position
  46029. * @param interaxialDistance defines distance between each color axis
  46030. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46031. * @param scene defines the hosting scene
  46032. */
  46033. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46034. /**
  46035. * Gets camera class name
  46036. * @returns StereoscopicUniversalCamera
  46037. */
  46038. getClassName(): string;
  46039. }
  46040. }
  46041. declare module BABYLON {
  46042. /**
  46043. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46044. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46045. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46046. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46047. */
  46048. export class VirtualJoysticksCamera extends FreeCamera {
  46049. /**
  46050. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46051. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46052. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46053. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46054. * @param name Define the name of the camera in the scene
  46055. * @param position Define the start position of the camera in the scene
  46056. * @param scene Define the scene the camera belongs to
  46057. */
  46058. constructor(name: string, position: Vector3, scene: Scene);
  46059. /**
  46060. * Gets the current object class name.
  46061. * @return the class name
  46062. */
  46063. getClassName(): string;
  46064. }
  46065. }
  46066. declare module BABYLON {
  46067. /**
  46068. * This represents all the required metrics to create a VR camera.
  46069. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46070. */
  46071. export class VRCameraMetrics {
  46072. /**
  46073. * Define the horizontal resolution off the screen.
  46074. */
  46075. hResolution: number;
  46076. /**
  46077. * Define the vertical resolution off the screen.
  46078. */
  46079. vResolution: number;
  46080. /**
  46081. * Define the horizontal screen size.
  46082. */
  46083. hScreenSize: number;
  46084. /**
  46085. * Define the vertical screen size.
  46086. */
  46087. vScreenSize: number;
  46088. /**
  46089. * Define the vertical screen center position.
  46090. */
  46091. vScreenCenter: number;
  46092. /**
  46093. * Define the distance of the eyes to the screen.
  46094. */
  46095. eyeToScreenDistance: number;
  46096. /**
  46097. * Define the distance between both lenses
  46098. */
  46099. lensSeparationDistance: number;
  46100. /**
  46101. * Define the distance between both viewer's eyes.
  46102. */
  46103. interpupillaryDistance: number;
  46104. /**
  46105. * Define the distortion factor of the VR postprocess.
  46106. * Please, touch with care.
  46107. */
  46108. distortionK: number[];
  46109. /**
  46110. * Define the chromatic aberration correction factors for the VR post process.
  46111. */
  46112. chromaAbCorrection: number[];
  46113. /**
  46114. * Define the scale factor of the post process.
  46115. * The smaller the better but the slower.
  46116. */
  46117. postProcessScaleFactor: number;
  46118. /**
  46119. * Define an offset for the lens center.
  46120. */
  46121. lensCenterOffset: number;
  46122. /**
  46123. * Define if the current vr camera should compensate the distortion of the lense or not.
  46124. */
  46125. compensateDistortion: boolean;
  46126. /**
  46127. * Defines if multiview should be enabled when rendering (Default: false)
  46128. */
  46129. multiviewEnabled: boolean;
  46130. /**
  46131. * Gets the rendering aspect ratio based on the provided resolutions.
  46132. */
  46133. get aspectRatio(): number;
  46134. /**
  46135. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46136. */
  46137. get aspectRatioFov(): number;
  46138. /**
  46139. * @hidden
  46140. */
  46141. get leftHMatrix(): Matrix;
  46142. /**
  46143. * @hidden
  46144. */
  46145. get rightHMatrix(): Matrix;
  46146. /**
  46147. * @hidden
  46148. */
  46149. get leftPreViewMatrix(): Matrix;
  46150. /**
  46151. * @hidden
  46152. */
  46153. get rightPreViewMatrix(): Matrix;
  46154. /**
  46155. * Get the default VRMetrics based on the most generic setup.
  46156. * @returns the default vr metrics
  46157. */
  46158. static GetDefault(): VRCameraMetrics;
  46159. }
  46160. }
  46161. declare module BABYLON {
  46162. /** @hidden */
  46163. export var vrDistortionCorrectionPixelShader: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module BABYLON {
  46169. /**
  46170. * VRDistortionCorrectionPostProcess used for mobile VR
  46171. */
  46172. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46173. private _isRightEye;
  46174. private _distortionFactors;
  46175. private _postProcessScaleFactor;
  46176. private _lensCenterOffset;
  46177. private _scaleIn;
  46178. private _scaleFactor;
  46179. private _lensCenter;
  46180. /**
  46181. * Initializes the VRDistortionCorrectionPostProcess
  46182. * @param name The name of the effect.
  46183. * @param camera The camera to apply the render pass to.
  46184. * @param isRightEye If this is for the right eye distortion
  46185. * @param vrMetrics All the required metrics for the VR camera
  46186. */
  46187. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46188. }
  46189. }
  46190. declare module BABYLON {
  46191. /**
  46192. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46193. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46194. */
  46195. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46196. /**
  46197. * Creates a new VRDeviceOrientationArcRotateCamera
  46198. * @param name defines camera name
  46199. * @param alpha defines the camera rotation along the logitudinal axis
  46200. * @param beta defines the camera rotation along the latitudinal axis
  46201. * @param radius defines the camera distance from its target
  46202. * @param target defines the camera target
  46203. * @param scene defines the scene the camera belongs to
  46204. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46205. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46206. */
  46207. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46208. /**
  46209. * Gets camera class name
  46210. * @returns VRDeviceOrientationArcRotateCamera
  46211. */
  46212. getClassName(): string;
  46213. }
  46214. }
  46215. declare module BABYLON {
  46216. /**
  46217. * Camera used to simulate VR rendering (based on FreeCamera)
  46218. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46219. */
  46220. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46221. /**
  46222. * Creates a new VRDeviceOrientationFreeCamera
  46223. * @param name defines camera name
  46224. * @param position defines the start position of the camera
  46225. * @param scene defines the scene the camera belongs to
  46226. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46227. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46228. */
  46229. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46230. /**
  46231. * Gets camera class name
  46232. * @returns VRDeviceOrientationFreeCamera
  46233. */
  46234. getClassName(): string;
  46235. }
  46236. }
  46237. declare module BABYLON {
  46238. /**
  46239. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46240. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46241. */
  46242. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46243. /**
  46244. * Creates a new VRDeviceOrientationGamepadCamera
  46245. * @param name defines camera name
  46246. * @param position defines the start position of the camera
  46247. * @param scene defines the scene the camera belongs to
  46248. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46249. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46250. */
  46251. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46252. /**
  46253. * Gets camera class name
  46254. * @returns VRDeviceOrientationGamepadCamera
  46255. */
  46256. getClassName(): string;
  46257. }
  46258. }
  46259. declare module BABYLON {
  46260. /**
  46261. * A class extending Texture allowing drawing on a texture
  46262. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46263. */
  46264. export class DynamicTexture extends Texture {
  46265. private _generateMipMaps;
  46266. private _canvas;
  46267. private _context;
  46268. /**
  46269. * Creates a DynamicTexture
  46270. * @param name defines the name of the texture
  46271. * @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
  46272. * @param scene defines the scene where you want the texture
  46273. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46274. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46275. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46276. */
  46277. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46278. /**
  46279. * Get the current class name of the texture useful for serialization or dynamic coding.
  46280. * @returns "DynamicTexture"
  46281. */
  46282. getClassName(): string;
  46283. /**
  46284. * Gets the current state of canRescale
  46285. */
  46286. get canRescale(): boolean;
  46287. private _recreate;
  46288. /**
  46289. * Scales the texture
  46290. * @param ratio the scale factor to apply to both width and height
  46291. */
  46292. scale(ratio: number): void;
  46293. /**
  46294. * Resizes the texture
  46295. * @param width the new width
  46296. * @param height the new height
  46297. */
  46298. scaleTo(width: number, height: number): void;
  46299. /**
  46300. * Gets the context of the canvas used by the texture
  46301. * @returns the canvas context of the dynamic texture
  46302. */
  46303. getContext(): CanvasRenderingContext2D;
  46304. /**
  46305. * Clears the texture
  46306. */
  46307. clear(): void;
  46308. /**
  46309. * Updates the texture
  46310. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46311. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46312. */
  46313. update(invertY?: boolean, premulAlpha?: boolean): void;
  46314. /**
  46315. * Draws text onto the texture
  46316. * @param text defines the text to be drawn
  46317. * @param x defines the placement of the text from the left
  46318. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46319. * @param font defines the font to be used with font-style, font-size, font-name
  46320. * @param color defines the color used for the text
  46321. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46322. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46323. * @param update defines whether texture is immediately update (default is true)
  46324. */
  46325. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46326. /**
  46327. * Clones the texture
  46328. * @returns the clone of the texture.
  46329. */
  46330. clone(): DynamicTexture;
  46331. /**
  46332. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46333. * @returns a serialized dynamic texture object
  46334. */
  46335. serialize(): any;
  46336. private _IsCanvasElement;
  46337. /** @hidden */
  46338. _rebuild(): void;
  46339. }
  46340. }
  46341. declare module BABYLON {
  46342. /**
  46343. * Class containing static functions to help procedurally build meshes
  46344. */
  46345. export class GroundBuilder {
  46346. /**
  46347. * Creates a ground mesh
  46348. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46349. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46351. * @param name defines the name of the mesh
  46352. * @param options defines the options used to create the mesh
  46353. * @param scene defines the hosting scene
  46354. * @returns the ground mesh
  46355. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46356. */
  46357. static CreateGround(name: string, options: {
  46358. width?: number;
  46359. height?: number;
  46360. subdivisions?: number;
  46361. subdivisionsX?: number;
  46362. subdivisionsY?: number;
  46363. updatable?: boolean;
  46364. }, scene: any): Mesh;
  46365. /**
  46366. * Creates a tiled ground mesh
  46367. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46368. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46369. * * 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
  46370. * * 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
  46371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46372. * @param name defines the name of the mesh
  46373. * @param options defines the options used to create the mesh
  46374. * @param scene defines the hosting scene
  46375. * @returns the tiled ground mesh
  46376. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46377. */
  46378. static CreateTiledGround(name: string, options: {
  46379. xmin: number;
  46380. zmin: number;
  46381. xmax: number;
  46382. zmax: number;
  46383. subdivisions?: {
  46384. w: number;
  46385. h: number;
  46386. };
  46387. precision?: {
  46388. w: number;
  46389. h: number;
  46390. };
  46391. updatable?: boolean;
  46392. }, scene?: Nullable<Scene>): Mesh;
  46393. /**
  46394. * Creates a ground mesh from a height map
  46395. * * The parameter `url` sets the URL of the height map image resource.
  46396. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46397. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46398. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46399. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46400. * * 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.
  46401. * * 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).
  46402. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46404. * @param name defines the name of the mesh
  46405. * @param url defines the url to the height map
  46406. * @param options defines the options used to create the mesh
  46407. * @param scene defines the hosting scene
  46408. * @returns the ground mesh
  46409. * @see https://doc.babylonjs.com/babylon101/height_map
  46410. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46411. */
  46412. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46413. width?: number;
  46414. height?: number;
  46415. subdivisions?: number;
  46416. minHeight?: number;
  46417. maxHeight?: number;
  46418. colorFilter?: Color3;
  46419. alphaFilter?: number;
  46420. updatable?: boolean;
  46421. onReady?: (mesh: GroundMesh) => void;
  46422. }, scene?: Nullable<Scene>): GroundMesh;
  46423. }
  46424. }
  46425. declare module BABYLON {
  46426. /**
  46427. * Class containing static functions to help procedurally build meshes
  46428. */
  46429. export class TorusBuilder {
  46430. /**
  46431. * Creates a torus mesh
  46432. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46433. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46434. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46436. * * 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
  46437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46438. * @param name defines the name of the mesh
  46439. * @param options defines the options used to create the mesh
  46440. * @param scene defines the hosting scene
  46441. * @returns the torus mesh
  46442. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46443. */
  46444. static CreateTorus(name: string, options: {
  46445. diameter?: number;
  46446. thickness?: number;
  46447. tessellation?: number;
  46448. updatable?: boolean;
  46449. sideOrientation?: number;
  46450. frontUVs?: Vector4;
  46451. backUVs?: Vector4;
  46452. }, scene: any): Mesh;
  46453. }
  46454. }
  46455. declare module BABYLON {
  46456. /**
  46457. * Class containing static functions to help procedurally build meshes
  46458. */
  46459. export class CylinderBuilder {
  46460. /**
  46461. * Creates a cylinder or a cone mesh
  46462. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46463. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46464. * * 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.
  46465. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46466. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46467. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46468. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46469. * * 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).
  46470. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46471. * * 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).
  46472. * * 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
  46473. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46474. * * 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
  46475. * * 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.
  46476. * * If `enclose` is false, a ring surface is one element.
  46477. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46478. * * 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
  46479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46480. * * 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
  46481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46482. * @param name defines the name of the mesh
  46483. * @param options defines the options used to create the mesh
  46484. * @param scene defines the hosting scene
  46485. * @returns the cylinder mesh
  46486. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46487. */
  46488. static CreateCylinder(name: string, options: {
  46489. height?: number;
  46490. diameterTop?: number;
  46491. diameterBottom?: number;
  46492. diameter?: number;
  46493. tessellation?: number;
  46494. subdivisions?: number;
  46495. arc?: number;
  46496. faceColors?: Color4[];
  46497. faceUV?: Vector4[];
  46498. updatable?: boolean;
  46499. hasRings?: boolean;
  46500. enclose?: boolean;
  46501. cap?: number;
  46502. sideOrientation?: number;
  46503. frontUVs?: Vector4;
  46504. backUVs?: Vector4;
  46505. }, scene: any): Mesh;
  46506. }
  46507. }
  46508. declare module BABYLON {
  46509. /**
  46510. * States of the webXR experience
  46511. */
  46512. export enum WebXRState {
  46513. /**
  46514. * Transitioning to being in XR mode
  46515. */
  46516. ENTERING_XR = 0,
  46517. /**
  46518. * Transitioning to non XR mode
  46519. */
  46520. EXITING_XR = 1,
  46521. /**
  46522. * In XR mode and presenting
  46523. */
  46524. IN_XR = 2,
  46525. /**
  46526. * Not entered XR mode
  46527. */
  46528. NOT_IN_XR = 3
  46529. }
  46530. /**
  46531. * Abstraction of the XR render target
  46532. */
  46533. export interface WebXRRenderTarget extends IDisposable {
  46534. /**
  46535. * xrpresent context of the canvas which can be used to display/mirror xr content
  46536. */
  46537. canvasContext: WebGLRenderingContext;
  46538. /**
  46539. * xr layer for the canvas
  46540. */
  46541. xrLayer: Nullable<XRWebGLLayer>;
  46542. /**
  46543. * Initializes the xr layer for the session
  46544. * @param xrSession xr session
  46545. * @returns a promise that will resolve once the XR Layer has been created
  46546. */
  46547. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46548. }
  46549. }
  46550. declare module BABYLON {
  46551. /**
  46552. * COnfiguration object for WebXR output canvas
  46553. */
  46554. export class WebXRManagedOutputCanvasOptions {
  46555. /**
  46556. * An optional canvas in case you wish to create it yourself and provide it here.
  46557. * If not provided, a new canvas will be created
  46558. */
  46559. canvasElement?: HTMLCanvasElement;
  46560. /**
  46561. * Options for this XR Layer output
  46562. */
  46563. canvasOptions?: XRWebGLLayerOptions;
  46564. /**
  46565. * CSS styling for a newly created canvas (if not provided)
  46566. */
  46567. newCanvasCssStyle?: string;
  46568. /**
  46569. * Get the default values of the configuration object
  46570. * @returns default values of this configuration object
  46571. */
  46572. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46573. }
  46574. /**
  46575. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46576. */
  46577. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46578. private _options;
  46579. private _canvas;
  46580. private _engine;
  46581. private _originalCanvasSize;
  46582. /**
  46583. * Rendering context of the canvas which can be used to display/mirror xr content
  46584. */
  46585. canvasContext: WebGLRenderingContext;
  46586. /**
  46587. * xr layer for the canvas
  46588. */
  46589. xrLayer: Nullable<XRWebGLLayer>;
  46590. /**
  46591. * Obseervers registered here will be triggered when the xr layer was initialized
  46592. */
  46593. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46594. /**
  46595. * Initializes the canvas to be added/removed upon entering/exiting xr
  46596. * @param _xrSessionManager The XR Session manager
  46597. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46598. */
  46599. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46600. /**
  46601. * Disposes of the object
  46602. */
  46603. dispose(): void;
  46604. /**
  46605. * Initializes the xr layer for the session
  46606. * @param xrSession xr session
  46607. * @returns a promise that will resolve once the XR Layer has been created
  46608. */
  46609. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46610. private _addCanvas;
  46611. private _removeCanvas;
  46612. private _setCanvasSize;
  46613. private _setManagedOutputCanvas;
  46614. }
  46615. }
  46616. declare module BABYLON {
  46617. /**
  46618. * Manages an XRSession to work with Babylon's engine
  46619. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46620. */
  46621. export class WebXRSessionManager implements IDisposable {
  46622. /** The scene which the session should be created for */
  46623. scene: Scene;
  46624. private _referenceSpace;
  46625. private _rttProvider;
  46626. private _sessionEnded;
  46627. private _xrNavigator;
  46628. private baseLayer;
  46629. /**
  46630. * The base reference space from which the session started. good if you want to reset your
  46631. * reference space
  46632. */
  46633. baseReferenceSpace: XRReferenceSpace;
  46634. /**
  46635. * Current XR frame
  46636. */
  46637. currentFrame: Nullable<XRFrame>;
  46638. /** WebXR timestamp updated every frame */
  46639. currentTimestamp: number;
  46640. /**
  46641. * Used just in case of a failure to initialize an immersive session.
  46642. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46643. */
  46644. defaultHeightCompensation: number;
  46645. /**
  46646. * Fires every time a new xrFrame arrives which can be used to update the camera
  46647. */
  46648. onXRFrameObservable: Observable<XRFrame>;
  46649. /**
  46650. * Fires when the reference space changed
  46651. */
  46652. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46653. /**
  46654. * Fires when the xr session is ended either by the device or manually done
  46655. */
  46656. onXRSessionEnded: Observable<any>;
  46657. /**
  46658. * Fires when the xr session is ended either by the device or manually done
  46659. */
  46660. onXRSessionInit: Observable<XRSession>;
  46661. /**
  46662. * Underlying xr session
  46663. */
  46664. session: XRSession;
  46665. /**
  46666. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46667. * or get the offset the player is currently at.
  46668. */
  46669. viewerReferenceSpace: XRReferenceSpace;
  46670. /**
  46671. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46672. * @param scene The scene which the session should be created for
  46673. */
  46674. constructor(
  46675. /** The scene which the session should be created for */
  46676. scene: Scene);
  46677. /**
  46678. * The current reference space used in this session. This reference space can constantly change!
  46679. * It is mainly used to offset the camera's position.
  46680. */
  46681. get referenceSpace(): XRReferenceSpace;
  46682. /**
  46683. * Set a new reference space and triggers the observable
  46684. */
  46685. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46686. /**
  46687. * Disposes of the session manager
  46688. */
  46689. dispose(): void;
  46690. /**
  46691. * Stops the xrSession and restores the render loop
  46692. * @returns Promise which resolves after it exits XR
  46693. */
  46694. exitXRAsync(): Promise<void>;
  46695. /**
  46696. * Gets the correct render target texture to be rendered this frame for this eye
  46697. * @param eye the eye for which to get the render target
  46698. * @returns the render target for the specified eye
  46699. */
  46700. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46701. /**
  46702. * Creates a WebXRRenderTarget object for the XR session
  46703. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46704. * @param options optional options to provide when creating a new render target
  46705. * @returns a WebXR render target to which the session can render
  46706. */
  46707. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46708. /**
  46709. * Initializes the manager
  46710. * After initialization enterXR can be called to start an XR session
  46711. * @returns Promise which resolves after it is initialized
  46712. */
  46713. initializeAsync(): Promise<void>;
  46714. /**
  46715. * Initializes an xr session
  46716. * @param xrSessionMode mode to initialize
  46717. * @param xrSessionInit defines optional and required values to pass to the session builder
  46718. * @returns a promise which will resolve once the session has been initialized
  46719. */
  46720. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46721. /**
  46722. * Checks if a session would be supported for the creation options specified
  46723. * @param sessionMode session mode to check if supported eg. immersive-vr
  46724. * @returns A Promise that resolves to true if supported and false if not
  46725. */
  46726. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46727. /**
  46728. * Resets the reference space to the one started the session
  46729. */
  46730. resetReferenceSpace(): void;
  46731. /**
  46732. * Starts rendering to the xr layer
  46733. */
  46734. runXRRenderLoop(): void;
  46735. /**
  46736. * Sets the reference space on the xr session
  46737. * @param referenceSpaceType space to set
  46738. * @returns a promise that will resolve once the reference space has been set
  46739. */
  46740. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46741. /**
  46742. * Updates the render state of the session
  46743. * @param state state to set
  46744. * @returns a promise that resolves once the render state has been updated
  46745. */
  46746. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46747. /**
  46748. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46749. * @param sessionMode defines the session to test
  46750. * @returns a promise with boolean as final value
  46751. */
  46752. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46753. private _createRenderTargetTexture;
  46754. }
  46755. }
  46756. declare module BABYLON {
  46757. /**
  46758. * WebXR Camera which holds the views for the xrSession
  46759. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46760. */
  46761. export class WebXRCamera extends FreeCamera {
  46762. private _xrSessionManager;
  46763. private _firstFrame;
  46764. private _referenceQuaternion;
  46765. private _referencedPosition;
  46766. private _xrInvPositionCache;
  46767. private _xrInvQuaternionCache;
  46768. /**
  46769. * Should position compensation execute on first frame.
  46770. * This is used when copying the position from a native (non XR) camera
  46771. */
  46772. compensateOnFirstFrame: boolean;
  46773. /**
  46774. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46775. * @param name the name of the camera
  46776. * @param scene the scene to add the camera to
  46777. * @param _xrSessionManager a constructed xr session manager
  46778. */
  46779. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46780. /**
  46781. * Return the user's height, unrelated to the current ground.
  46782. * This will be the y position of this camera, when ground level is 0.
  46783. */
  46784. get realWorldHeight(): number;
  46785. /** @hidden */
  46786. _updateForDualEyeDebugging(): void;
  46787. /**
  46788. * Sets this camera's transformation based on a non-vr camera
  46789. * @param otherCamera the non-vr camera to copy the transformation from
  46790. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46791. */
  46792. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46793. /**
  46794. * Gets the current instance class name ("WebXRCamera").
  46795. * @returns the class name
  46796. */
  46797. getClassName(): string;
  46798. private _rotate180;
  46799. private _updateFromXRSession;
  46800. private _updateNumberOfRigCameras;
  46801. private _updateReferenceSpace;
  46802. private _updateReferenceSpaceOffset;
  46803. }
  46804. }
  46805. declare module BABYLON {
  46806. /**
  46807. * Defining the interface required for a (webxr) feature
  46808. */
  46809. export interface IWebXRFeature extends IDisposable {
  46810. /**
  46811. * Is this feature attached
  46812. */
  46813. attached: boolean;
  46814. /**
  46815. * Should auto-attach be disabled?
  46816. */
  46817. disableAutoAttach: boolean;
  46818. /**
  46819. * Attach the feature to the session
  46820. * Will usually be called by the features manager
  46821. *
  46822. * @param force should attachment be forced (even when already attached)
  46823. * @returns true if successful.
  46824. */
  46825. attach(force?: boolean): boolean;
  46826. /**
  46827. * Detach the feature from the session
  46828. * Will usually be called by the features manager
  46829. *
  46830. * @returns true if successful.
  46831. */
  46832. detach(): boolean;
  46833. /**
  46834. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46835. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46836. *
  46837. * @returns whether or not the feature is compatible in this environment
  46838. */
  46839. isCompatible(): boolean;
  46840. /**
  46841. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46842. */
  46843. xrNativeFeatureName?: string;
  46844. }
  46845. /**
  46846. * A list of the currently available features without referencing them
  46847. */
  46848. export class WebXRFeatureName {
  46849. /**
  46850. * The name of the anchor system feature
  46851. */
  46852. static ANCHOR_SYSTEM: string;
  46853. /**
  46854. * The name of the background remover feature
  46855. */
  46856. static BACKGROUND_REMOVER: string;
  46857. /**
  46858. * The name of the hit test feature
  46859. */
  46860. static HIT_TEST: string;
  46861. /**
  46862. * physics impostors for xr controllers feature
  46863. */
  46864. static PHYSICS_CONTROLLERS: string;
  46865. /**
  46866. * The name of the plane detection feature
  46867. */
  46868. static PLANE_DETECTION: string;
  46869. /**
  46870. * The name of the pointer selection feature
  46871. */
  46872. static POINTER_SELECTION: string;
  46873. /**
  46874. * The name of the teleportation feature
  46875. */
  46876. static TELEPORTATION: string;
  46877. }
  46878. /**
  46879. * Defining the constructor of a feature. Used to register the modules.
  46880. */
  46881. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46882. /**
  46883. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46884. * It is mainly used in AR sessions.
  46885. *
  46886. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46887. */
  46888. export class WebXRFeaturesManager implements IDisposable {
  46889. private _xrSessionManager;
  46890. private static readonly _AvailableFeatures;
  46891. private _features;
  46892. /**
  46893. * constructs a new features manages.
  46894. *
  46895. * @param _xrSessionManager an instance of WebXRSessionManager
  46896. */
  46897. constructor(_xrSessionManager: WebXRSessionManager);
  46898. /**
  46899. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46900. * Mainly used internally.
  46901. *
  46902. * @param featureName the name of the feature to register
  46903. * @param constructorFunction the function used to construct the module
  46904. * @param version the (babylon) version of the module
  46905. * @param stable is that a stable version of this module
  46906. */
  46907. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46908. /**
  46909. * Returns a constructor of a specific feature.
  46910. *
  46911. * @param featureName the name of the feature to construct
  46912. * @param version the version of the feature to load
  46913. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46914. * @param options optional options provided to the module.
  46915. * @returns a function that, when called, will return a new instance of this feature
  46916. */
  46917. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46918. /**
  46919. * Can be used to return the list of features currently registered
  46920. *
  46921. * @returns an Array of available features
  46922. */
  46923. static GetAvailableFeatures(): string[];
  46924. /**
  46925. * Gets the versions available for a specific feature
  46926. * @param featureName the name of the feature
  46927. * @returns an array with the available versions
  46928. */
  46929. static GetAvailableVersions(featureName: string): string[];
  46930. /**
  46931. * Return the latest unstable version of this feature
  46932. * @param featureName the name of the feature to search
  46933. * @returns the version number. if not found will return -1
  46934. */
  46935. static GetLatestVersionOfFeature(featureName: string): number;
  46936. /**
  46937. * Return the latest stable version of this feature
  46938. * @param featureName the name of the feature to search
  46939. * @returns the version number. if not found will return -1
  46940. */
  46941. static GetStableVersionOfFeature(featureName: string): number;
  46942. /**
  46943. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46944. * Can be used during a session to start a feature
  46945. * @param featureName the name of feature to attach
  46946. */
  46947. attachFeature(featureName: string): void;
  46948. /**
  46949. * Can be used inside a session or when the session ends to detach a specific feature
  46950. * @param featureName the name of the feature to detach
  46951. */
  46952. detachFeature(featureName: string): void;
  46953. /**
  46954. * Used to disable an already-enabled feature
  46955. * The feature will be disposed and will be recreated once enabled.
  46956. * @param featureName the feature to disable
  46957. * @returns true if disable was successful
  46958. */
  46959. disableFeature(featureName: string | {
  46960. Name: string;
  46961. }): boolean;
  46962. /**
  46963. * dispose this features manager
  46964. */
  46965. dispose(): void;
  46966. /**
  46967. * 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.
  46968. * 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.
  46969. *
  46970. * @param featureName the name of the feature to load or the class of the feature
  46971. * @param version optional version to load. if not provided the latest version will be enabled
  46972. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46973. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46974. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  46975. * @returns a new constructed feature or throws an error if feature not found.
  46976. */
  46977. enableFeature(featureName: string | {
  46978. Name: string;
  46979. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  46980. /**
  46981. * get the implementation of an enabled feature.
  46982. * @param featureName the name of the feature to load
  46983. * @returns the feature class, if found
  46984. */
  46985. getEnabledFeature(featureName: string): IWebXRFeature;
  46986. /**
  46987. * Get the list of enabled features
  46988. * @returns an array of enabled features
  46989. */
  46990. getEnabledFeatures(): string[];
  46991. /**
  46992. * This function will exten the session creation configuration object with enabled features.
  46993. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  46994. * according to the defined "required" variable, provided during enableFeature call
  46995. * @param xrSessionInit the xr Session init object to extend
  46996. *
  46997. * @returns an extended XRSessionInit object
  46998. */
  46999. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47000. }
  47001. }
  47002. declare module BABYLON {
  47003. /**
  47004. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47005. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47006. */
  47007. export class WebXRExperienceHelper implements IDisposable {
  47008. private scene;
  47009. private _nonVRCamera;
  47010. private _originalSceneAutoClear;
  47011. private _supported;
  47012. /**
  47013. * Camera used to render xr content
  47014. */
  47015. camera: WebXRCamera;
  47016. /** A features manager for this xr session */
  47017. featuresManager: WebXRFeaturesManager;
  47018. /**
  47019. * Observers registered here will be triggered after the camera's initial transformation is set
  47020. * This can be used to set a different ground level or an extra rotation.
  47021. *
  47022. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47023. * to the position set after this observable is done executing.
  47024. */
  47025. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47026. /**
  47027. * Fires when the state of the experience helper has changed
  47028. */
  47029. onStateChangedObservable: Observable<WebXRState>;
  47030. /** Session manager used to keep track of xr session */
  47031. sessionManager: WebXRSessionManager;
  47032. /**
  47033. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47034. */
  47035. state: WebXRState;
  47036. /**
  47037. * Creates a WebXRExperienceHelper
  47038. * @param scene The scene the helper should be created in
  47039. */
  47040. private constructor();
  47041. /**
  47042. * Creates the experience helper
  47043. * @param scene the scene to attach the experience helper to
  47044. * @returns a promise for the experience helper
  47045. */
  47046. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47047. /**
  47048. * Disposes of the experience helper
  47049. */
  47050. dispose(): void;
  47051. /**
  47052. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47053. * @param sessionMode options for the XR session
  47054. * @param referenceSpaceType frame of reference of the XR session
  47055. * @param renderTarget the output canvas that will be used to enter XR mode
  47056. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47057. * @returns promise that resolves after xr mode has entered
  47058. */
  47059. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47060. /**
  47061. * Exits XR mode and returns the scene to its original state
  47062. * @returns promise that resolves after xr mode has exited
  47063. */
  47064. exitXRAsync(): Promise<void>;
  47065. private _nonXRToXRCamera;
  47066. private _setState;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * X-Y values for axes in WebXR
  47072. */
  47073. export interface IWebXRMotionControllerAxesValue {
  47074. /**
  47075. * The value of the x axis
  47076. */
  47077. x: number;
  47078. /**
  47079. * The value of the y-axis
  47080. */
  47081. y: number;
  47082. }
  47083. /**
  47084. * changed / previous values for the values of this component
  47085. */
  47086. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47087. /**
  47088. * current (this frame) value
  47089. */
  47090. current: T;
  47091. /**
  47092. * previous (last change) value
  47093. */
  47094. previous: T;
  47095. }
  47096. /**
  47097. * Represents changes in the component between current frame and last values recorded
  47098. */
  47099. export interface IWebXRMotionControllerComponentChanges {
  47100. /**
  47101. * will be populated with previous and current values if axes changed
  47102. */
  47103. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47104. /**
  47105. * will be populated with previous and current values if pressed changed
  47106. */
  47107. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47108. /**
  47109. * will be populated with previous and current values if touched changed
  47110. */
  47111. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47112. /**
  47113. * will be populated with previous and current values if value changed
  47114. */
  47115. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47116. }
  47117. /**
  47118. * This class represents a single component (for example button or thumbstick) of a motion controller
  47119. */
  47120. export class WebXRControllerComponent implements IDisposable {
  47121. /**
  47122. * the id of this component
  47123. */
  47124. id: string;
  47125. /**
  47126. * the type of the component
  47127. */
  47128. type: MotionControllerComponentType;
  47129. private _buttonIndex;
  47130. private _axesIndices;
  47131. private _axes;
  47132. private _changes;
  47133. private _currentValue;
  47134. private _hasChanges;
  47135. private _pressed;
  47136. private _touched;
  47137. /**
  47138. * button component type
  47139. */
  47140. static BUTTON_TYPE: MotionControllerComponentType;
  47141. /**
  47142. * squeeze component type
  47143. */
  47144. static SQUEEZE_TYPE: MotionControllerComponentType;
  47145. /**
  47146. * Thumbstick component type
  47147. */
  47148. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47149. /**
  47150. * Touchpad component type
  47151. */
  47152. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47153. /**
  47154. * trigger component type
  47155. */
  47156. static TRIGGER_TYPE: MotionControllerComponentType;
  47157. /**
  47158. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47159. * the axes data changes
  47160. */
  47161. onAxisValueChangedObservable: Observable<{
  47162. x: number;
  47163. y: number;
  47164. }>;
  47165. /**
  47166. * Observers registered here will be triggered when the state of a button changes
  47167. * State change is either pressed / touched / value
  47168. */
  47169. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47170. /**
  47171. * Creates a new component for a motion controller.
  47172. * It is created by the motion controller itself
  47173. *
  47174. * @param id the id of this component
  47175. * @param type the type of the component
  47176. * @param _buttonIndex index in the buttons array of the gamepad
  47177. * @param _axesIndices indices of the values in the axes array of the gamepad
  47178. */
  47179. constructor(
  47180. /**
  47181. * the id of this component
  47182. */
  47183. id: string,
  47184. /**
  47185. * the type of the component
  47186. */
  47187. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47188. /**
  47189. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47190. */
  47191. get axes(): IWebXRMotionControllerAxesValue;
  47192. /**
  47193. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47194. */
  47195. get changes(): IWebXRMotionControllerComponentChanges;
  47196. /**
  47197. * Return whether or not the component changed the last frame
  47198. */
  47199. get hasChanges(): boolean;
  47200. /**
  47201. * is the button currently pressed
  47202. */
  47203. get pressed(): boolean;
  47204. /**
  47205. * is the button currently touched
  47206. */
  47207. get touched(): boolean;
  47208. /**
  47209. * Get the current value of this component
  47210. */
  47211. get value(): number;
  47212. /**
  47213. * Dispose this component
  47214. */
  47215. dispose(): void;
  47216. /**
  47217. * Are there axes correlating to this component
  47218. * @return true is axes data is available
  47219. */
  47220. isAxes(): boolean;
  47221. /**
  47222. * Is this component a button (hence - pressable)
  47223. * @returns true if can be pressed
  47224. */
  47225. isButton(): boolean;
  47226. /**
  47227. * update this component using the gamepad object it is in. Called on every frame
  47228. * @param nativeController the native gamepad controller object
  47229. */
  47230. update(nativeController: IMinimalMotionControllerObject): void;
  47231. }
  47232. }
  47233. declare module BABYLON {
  47234. /**
  47235. * Interface used to represent data loading progression
  47236. */
  47237. export interface ISceneLoaderProgressEvent {
  47238. /**
  47239. * Defines if data length to load can be evaluated
  47240. */
  47241. readonly lengthComputable: boolean;
  47242. /**
  47243. * Defines the loaded data length
  47244. */
  47245. readonly loaded: number;
  47246. /**
  47247. * Defines the data length to load
  47248. */
  47249. readonly total: number;
  47250. }
  47251. /**
  47252. * Interface used by SceneLoader plugins to define supported file extensions
  47253. */
  47254. export interface ISceneLoaderPluginExtensions {
  47255. /**
  47256. * Defines the list of supported extensions
  47257. */
  47258. [extension: string]: {
  47259. isBinary: boolean;
  47260. };
  47261. }
  47262. /**
  47263. * Interface used by SceneLoader plugin factory
  47264. */
  47265. export interface ISceneLoaderPluginFactory {
  47266. /**
  47267. * Defines the name of the factory
  47268. */
  47269. name: string;
  47270. /**
  47271. * Function called to create a new plugin
  47272. * @return the new plugin
  47273. */
  47274. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47275. /**
  47276. * The callback that returns true if the data can be directly loaded.
  47277. * @param data string containing the file data
  47278. * @returns if the data can be loaded directly
  47279. */
  47280. canDirectLoad?(data: string): boolean;
  47281. }
  47282. /**
  47283. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47284. */
  47285. export interface ISceneLoaderPluginBase {
  47286. /**
  47287. * The friendly name of this plugin.
  47288. */
  47289. name: string;
  47290. /**
  47291. * The file extensions supported by this plugin.
  47292. */
  47293. extensions: string | ISceneLoaderPluginExtensions;
  47294. /**
  47295. * The callback called when loading from a url.
  47296. * @param scene scene loading this url
  47297. * @param url url to load
  47298. * @param onSuccess callback called when the file successfully loads
  47299. * @param onProgress callback called while file is loading (if the server supports this mode)
  47300. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47301. * @param onError callback called when the file fails to load
  47302. * @returns a file request object
  47303. */
  47304. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47305. /**
  47306. * The callback called when loading from a file object.
  47307. * @param scene scene loading this file
  47308. * @param file defines the file to load
  47309. * @param onSuccess defines the callback to call when data is loaded
  47310. * @param onProgress defines the callback to call during loading process
  47311. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47312. * @param onError defines the callback to call when an error occurs
  47313. * @returns a file request object
  47314. */
  47315. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47316. /**
  47317. * The callback that returns true if the data can be directly loaded.
  47318. * @param data string containing the file data
  47319. * @returns if the data can be loaded directly
  47320. */
  47321. canDirectLoad?(data: string): boolean;
  47322. /**
  47323. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47324. * @param scene scene loading this data
  47325. * @param data string containing the data
  47326. * @returns data to pass to the plugin
  47327. */
  47328. directLoad?(scene: Scene, data: string): any;
  47329. /**
  47330. * The callback that allows custom handling of the root url based on the response url.
  47331. * @param rootUrl the original root url
  47332. * @param responseURL the response url if available
  47333. * @returns the new root url
  47334. */
  47335. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47336. }
  47337. /**
  47338. * Interface used to define a SceneLoader plugin
  47339. */
  47340. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47341. /**
  47342. * Import meshes into a scene.
  47343. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47344. * @param scene The scene to import into
  47345. * @param data The data to import
  47346. * @param rootUrl The root url for scene and resources
  47347. * @param meshes The meshes array to import into
  47348. * @param particleSystems The particle systems array to import into
  47349. * @param skeletons The skeletons array to import into
  47350. * @param onError The callback when import fails
  47351. * @returns True if successful or false otherwise
  47352. */
  47353. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47354. /**
  47355. * Load into a scene.
  47356. * @param scene The scene to load into
  47357. * @param data The data to import
  47358. * @param rootUrl The root url for scene and resources
  47359. * @param onError The callback when import fails
  47360. * @returns True if successful or false otherwise
  47361. */
  47362. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47363. /**
  47364. * Load into an asset container.
  47365. * @param scene The scene to load into
  47366. * @param data The data to import
  47367. * @param rootUrl The root url for scene and resources
  47368. * @param onError The callback when import fails
  47369. * @returns The loaded asset container
  47370. */
  47371. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47372. }
  47373. /**
  47374. * Interface used to define an async SceneLoader plugin
  47375. */
  47376. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47377. /**
  47378. * Import meshes into a scene.
  47379. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47380. * @param scene The scene to import into
  47381. * @param data The data to import
  47382. * @param rootUrl The root url for scene and resources
  47383. * @param onProgress The callback when the load progresses
  47384. * @param fileName Defines the name of the file to load
  47385. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47386. */
  47387. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47388. meshes: AbstractMesh[];
  47389. particleSystems: IParticleSystem[];
  47390. skeletons: Skeleton[];
  47391. animationGroups: AnimationGroup[];
  47392. }>;
  47393. /**
  47394. * Load into a scene.
  47395. * @param scene The scene to load into
  47396. * @param data The data to import
  47397. * @param rootUrl The root url for scene and resources
  47398. * @param onProgress The callback when the load progresses
  47399. * @param fileName Defines the name of the file to load
  47400. * @returns Nothing
  47401. */
  47402. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47403. /**
  47404. * Load into an asset container.
  47405. * @param scene The scene to load into
  47406. * @param data The data to import
  47407. * @param rootUrl The root url for scene and resources
  47408. * @param onProgress The callback when the load progresses
  47409. * @param fileName Defines the name of the file to load
  47410. * @returns The loaded asset container
  47411. */
  47412. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47413. }
  47414. /**
  47415. * Mode that determines how to handle old animation groups before loading new ones.
  47416. */
  47417. export enum SceneLoaderAnimationGroupLoadingMode {
  47418. /**
  47419. * Reset all old animations to initial state then dispose them.
  47420. */
  47421. Clean = 0,
  47422. /**
  47423. * Stop all old animations.
  47424. */
  47425. Stop = 1,
  47426. /**
  47427. * Restart old animations from first frame.
  47428. */
  47429. Sync = 2,
  47430. /**
  47431. * Old animations remains untouched.
  47432. */
  47433. NoSync = 3
  47434. }
  47435. /**
  47436. * Class used to load scene from various file formats using registered plugins
  47437. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47438. */
  47439. export class SceneLoader {
  47440. /**
  47441. * No logging while loading
  47442. */
  47443. static readonly NO_LOGGING: number;
  47444. /**
  47445. * Minimal logging while loading
  47446. */
  47447. static readonly MINIMAL_LOGGING: number;
  47448. /**
  47449. * Summary logging while loading
  47450. */
  47451. static readonly SUMMARY_LOGGING: number;
  47452. /**
  47453. * Detailled logging while loading
  47454. */
  47455. static readonly DETAILED_LOGGING: number;
  47456. /**
  47457. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47458. */
  47459. static get ForceFullSceneLoadingForIncremental(): boolean;
  47460. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47461. /**
  47462. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47463. */
  47464. static get ShowLoadingScreen(): boolean;
  47465. static set ShowLoadingScreen(value: boolean);
  47466. /**
  47467. * Defines the current logging level (while loading the scene)
  47468. * @ignorenaming
  47469. */
  47470. static get loggingLevel(): number;
  47471. static set loggingLevel(value: number);
  47472. /**
  47473. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47474. */
  47475. static get CleanBoneMatrixWeights(): boolean;
  47476. static set CleanBoneMatrixWeights(value: boolean);
  47477. /**
  47478. * Event raised when a plugin is used to load a scene
  47479. */
  47480. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47481. private static _registeredPlugins;
  47482. private static _showingLoadingScreen;
  47483. private static _getDefaultPlugin;
  47484. private static _getPluginForExtension;
  47485. private static _getPluginForDirectLoad;
  47486. private static _getPluginForFilename;
  47487. private static _getDirectLoad;
  47488. private static _loadData;
  47489. private static _getFileInfo;
  47490. /**
  47491. * Gets a plugin that can load the given extension
  47492. * @param extension defines the extension to load
  47493. * @returns a plugin or null if none works
  47494. */
  47495. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47496. /**
  47497. * Gets a boolean indicating that the given extension can be loaded
  47498. * @param extension defines the extension to load
  47499. * @returns true if the extension is supported
  47500. */
  47501. static IsPluginForExtensionAvailable(extension: string): boolean;
  47502. /**
  47503. * Adds a new plugin to the list of registered plugins
  47504. * @param plugin defines the plugin to add
  47505. */
  47506. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47507. /**
  47508. * Import meshes into a scene
  47509. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47510. * @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)
  47511. * @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)
  47512. * @param scene the instance of BABYLON.Scene to append to
  47513. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47514. * @param onProgress a callback with a progress event for each file being loaded
  47515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47516. * @param pluginExtension the extension used to determine the plugin
  47517. * @returns The loaded plugin
  47518. */
  47519. 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>;
  47520. /**
  47521. * Import meshes into a scene
  47522. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47523. * @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)
  47524. * @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)
  47525. * @param scene the instance of BABYLON.Scene to append to
  47526. * @param onProgress a callback with a progress event for each file being loaded
  47527. * @param pluginExtension the extension used to determine the plugin
  47528. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47529. */
  47530. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47531. meshes: AbstractMesh[];
  47532. particleSystems: IParticleSystem[];
  47533. skeletons: Skeleton[];
  47534. animationGroups: AnimationGroup[];
  47535. }>;
  47536. /**
  47537. * Load a scene
  47538. * @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)
  47539. * @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)
  47540. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47541. * @param onSuccess a callback with the scene when import succeeds
  47542. * @param onProgress a callback with a progress event for each file being loaded
  47543. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47544. * @param pluginExtension the extension used to determine the plugin
  47545. * @returns The loaded plugin
  47546. */
  47547. 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>;
  47548. /**
  47549. * Load a scene
  47550. * @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)
  47551. * @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)
  47552. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47553. * @param onProgress a callback with a progress event for each file being loaded
  47554. * @param pluginExtension the extension used to determine the plugin
  47555. * @returns The loaded scene
  47556. */
  47557. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47558. /**
  47559. * Append a scene
  47560. * @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)
  47561. * @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)
  47562. * @param scene is the instance of BABYLON.Scene to append to
  47563. * @param onSuccess a callback with the scene when import succeeds
  47564. * @param onProgress a callback with a progress event for each file being loaded
  47565. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47566. * @param pluginExtension the extension used to determine the plugin
  47567. * @returns The loaded plugin
  47568. */
  47569. 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>;
  47570. /**
  47571. * Append a scene
  47572. * @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)
  47573. * @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)
  47574. * @param scene is the instance of BABYLON.Scene to append to
  47575. * @param onProgress a callback with a progress event for each file being loaded
  47576. * @param pluginExtension the extension used to determine the plugin
  47577. * @returns The given scene
  47578. */
  47579. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47580. /**
  47581. * Load a scene into an asset container
  47582. * @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)
  47583. * @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)
  47584. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47585. * @param onSuccess a callback with the scene when import succeeds
  47586. * @param onProgress a callback with a progress event for each file being loaded
  47587. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47588. * @param pluginExtension the extension used to determine the plugin
  47589. * @returns The loaded plugin
  47590. */
  47591. 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>;
  47592. /**
  47593. * Load a scene into an asset container
  47594. * @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)
  47595. * @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)
  47596. * @param scene is the instance of Scene to append to
  47597. * @param onProgress a callback with a progress event for each file being loaded
  47598. * @param pluginExtension the extension used to determine the plugin
  47599. * @returns The loaded asset container
  47600. */
  47601. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47602. /**
  47603. * Import animations from a file into a scene
  47604. * @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)
  47605. * @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)
  47606. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47607. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47608. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47609. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47610. * @param onSuccess a callback with the scene when import succeeds
  47611. * @param onProgress a callback with a progress event for each file being loaded
  47612. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47613. * @param pluginExtension the extension used to determine the plugin
  47614. */
  47615. 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;
  47616. /**
  47617. * Import animations from a file into a scene
  47618. * @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)
  47619. * @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)
  47620. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47621. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47622. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47623. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47624. * @param onSuccess a callback with the scene when import succeeds
  47625. * @param onProgress a callback with a progress event for each file being loaded
  47626. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47627. * @param pluginExtension the extension used to determine the plugin
  47628. * @returns the updated scene with imported animations
  47629. */
  47630. 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>;
  47631. }
  47632. }
  47633. declare module BABYLON {
  47634. /**
  47635. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47636. */
  47637. export type MotionControllerHandedness = "none" | "left" | "right";
  47638. /**
  47639. * The type of components available in motion controllers.
  47640. * This is not the name of the component.
  47641. */
  47642. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47643. /**
  47644. * The state of a controller component
  47645. */
  47646. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47647. /**
  47648. * The schema of motion controller layout.
  47649. * No object will be initialized using this interface
  47650. * This is used just to define the profile.
  47651. */
  47652. export interface IMotionControllerLayout {
  47653. /**
  47654. * Path to load the assets. Usually relative to the base path
  47655. */
  47656. assetPath: string;
  47657. /**
  47658. * Available components (unsorted)
  47659. */
  47660. components: {
  47661. /**
  47662. * A map of component Ids
  47663. */
  47664. [componentId: string]: {
  47665. /**
  47666. * The type of input the component outputs
  47667. */
  47668. type: MotionControllerComponentType;
  47669. /**
  47670. * The indices of this component in the gamepad object
  47671. */
  47672. gamepadIndices: {
  47673. /**
  47674. * Index of button
  47675. */
  47676. button?: number;
  47677. /**
  47678. * If available, index of x-axis
  47679. */
  47680. xAxis?: number;
  47681. /**
  47682. * If available, index of y-axis
  47683. */
  47684. yAxis?: number;
  47685. };
  47686. /**
  47687. * The mesh's root node name
  47688. */
  47689. rootNodeName: string;
  47690. /**
  47691. * Animation definitions for this model
  47692. */
  47693. visualResponses: {
  47694. [stateKey: string]: {
  47695. /**
  47696. * What property will be animated
  47697. */
  47698. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47699. /**
  47700. * What states influence this visual response
  47701. */
  47702. states: MotionControllerComponentStateType[];
  47703. /**
  47704. * Type of animation - movement or visibility
  47705. */
  47706. valueNodeProperty: "transform" | "visibility";
  47707. /**
  47708. * Base node name to move. Its position will be calculated according to the min and max nodes
  47709. */
  47710. valueNodeName?: string;
  47711. /**
  47712. * Minimum movement node
  47713. */
  47714. minNodeName?: string;
  47715. /**
  47716. * Max movement node
  47717. */
  47718. maxNodeName?: string;
  47719. };
  47720. };
  47721. /**
  47722. * If touch enabled, what is the name of node to display user feedback
  47723. */
  47724. touchPointNodeName?: string;
  47725. };
  47726. };
  47727. /**
  47728. * Is it xr standard mapping or not
  47729. */
  47730. gamepadMapping: "" | "xr-standard";
  47731. /**
  47732. * Base root node of this entire model
  47733. */
  47734. rootNodeName: string;
  47735. /**
  47736. * Defines the main button component id
  47737. */
  47738. selectComponentId: string;
  47739. }
  47740. /**
  47741. * A definition for the layout map in the input profile
  47742. */
  47743. export interface IMotionControllerLayoutMap {
  47744. /**
  47745. * Layouts with handedness type as a key
  47746. */
  47747. [handedness: string]: IMotionControllerLayout;
  47748. }
  47749. /**
  47750. * The XR Input profile schema
  47751. * Profiles can be found here:
  47752. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47753. */
  47754. export interface IMotionControllerProfile {
  47755. /**
  47756. * fallback profiles for this profileId
  47757. */
  47758. fallbackProfileIds: string[];
  47759. /**
  47760. * The layout map, with handedness as key
  47761. */
  47762. layouts: IMotionControllerLayoutMap;
  47763. /**
  47764. * The id of this profile
  47765. * correlates to the profile(s) in the xrInput.profiles array
  47766. */
  47767. profileId: string;
  47768. }
  47769. /**
  47770. * A helper-interface for the 3 meshes needed for controller button animation
  47771. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47772. */
  47773. export interface IMotionControllerButtonMeshMap {
  47774. /**
  47775. * the mesh that defines the pressed value mesh position.
  47776. * This is used to find the max-position of this button
  47777. */
  47778. pressedMesh: AbstractMesh;
  47779. /**
  47780. * the mesh that defines the unpressed value mesh position.
  47781. * This is used to find the min (or initial) position of this button
  47782. */
  47783. unpressedMesh: AbstractMesh;
  47784. /**
  47785. * The mesh that will be changed when value changes
  47786. */
  47787. valueMesh: AbstractMesh;
  47788. }
  47789. /**
  47790. * A helper-interface for the 3 meshes needed for controller axis animation.
  47791. * This will be expanded when touchpad animations are fully supported
  47792. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47793. */
  47794. export interface IMotionControllerMeshMap {
  47795. /**
  47796. * the mesh that defines the maximum value mesh position.
  47797. */
  47798. maxMesh?: AbstractMesh;
  47799. /**
  47800. * the mesh that defines the minimum value mesh position.
  47801. */
  47802. minMesh?: AbstractMesh;
  47803. /**
  47804. * The mesh that will be changed when axis value changes
  47805. */
  47806. valueMesh: AbstractMesh;
  47807. }
  47808. /**
  47809. * The elements needed for change-detection of the gamepad objects in motion controllers
  47810. */
  47811. export interface IMinimalMotionControllerObject {
  47812. /**
  47813. * Available axes of this controller
  47814. */
  47815. axes: number[];
  47816. /**
  47817. * An array of available buttons
  47818. */
  47819. buttons: Array<{
  47820. /**
  47821. * Value of the button/trigger
  47822. */
  47823. value: number;
  47824. /**
  47825. * If the button/trigger is currently touched
  47826. */
  47827. touched: boolean;
  47828. /**
  47829. * If the button/trigger is currently pressed
  47830. */
  47831. pressed: boolean;
  47832. }>;
  47833. /**
  47834. * EXPERIMENTAL haptic support.
  47835. */
  47836. hapticActuators?: Array<{
  47837. pulse: (value: number, duration: number) => Promise<boolean>;
  47838. }>;
  47839. }
  47840. /**
  47841. * An Abstract Motion controller
  47842. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47843. * Each component has an observable to check for changes in value and state
  47844. */
  47845. export abstract class WebXRAbstractMotionController implements IDisposable {
  47846. protected scene: Scene;
  47847. protected layout: IMotionControllerLayout;
  47848. /**
  47849. * The gamepad object correlating to this controller
  47850. */
  47851. gamepadObject: IMinimalMotionControllerObject;
  47852. /**
  47853. * handedness (left/right/none) of this controller
  47854. */
  47855. handedness: MotionControllerHandedness;
  47856. private _initComponent;
  47857. private _modelReady;
  47858. /**
  47859. * A map of components (WebXRControllerComponent) in this motion controller
  47860. * Components have a ComponentType and can also have both button and axis definitions
  47861. */
  47862. readonly components: {
  47863. [id: string]: WebXRControllerComponent;
  47864. };
  47865. /**
  47866. * Disable the model's animation. Can be set at any time.
  47867. */
  47868. disableAnimation: boolean;
  47869. /**
  47870. * Observers registered here will be triggered when the model of this controller is done loading
  47871. */
  47872. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47873. /**
  47874. * The profile id of this motion controller
  47875. */
  47876. abstract profileId: string;
  47877. /**
  47878. * The root mesh of the model. It is null if the model was not yet initialized
  47879. */
  47880. rootMesh: Nullable<AbstractMesh>;
  47881. /**
  47882. * constructs a new abstract motion controller
  47883. * @param scene the scene to which the model of the controller will be added
  47884. * @param layout The profile layout to load
  47885. * @param gamepadObject The gamepad object correlating to this controller
  47886. * @param handedness handedness (left/right/none) of this controller
  47887. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47888. */
  47889. constructor(scene: Scene, layout: IMotionControllerLayout,
  47890. /**
  47891. * The gamepad object correlating to this controller
  47892. */
  47893. gamepadObject: IMinimalMotionControllerObject,
  47894. /**
  47895. * handedness (left/right/none) of this controller
  47896. */
  47897. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47898. /**
  47899. * Dispose this controller, the model mesh and all its components
  47900. */
  47901. dispose(): void;
  47902. /**
  47903. * Returns all components of specific type
  47904. * @param type the type to search for
  47905. * @return an array of components with this type
  47906. */
  47907. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47908. /**
  47909. * get a component based an its component id as defined in layout.components
  47910. * @param id the id of the component
  47911. * @returns the component correlates to the id or undefined if not found
  47912. */
  47913. getComponent(id: string): WebXRControllerComponent;
  47914. /**
  47915. * Get the list of components available in this motion controller
  47916. * @returns an array of strings correlating to available components
  47917. */
  47918. getComponentIds(): string[];
  47919. /**
  47920. * Get the first component of specific type
  47921. * @param type type of component to find
  47922. * @return a controller component or null if not found
  47923. */
  47924. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47925. /**
  47926. * Get the main (Select) component of this controller as defined in the layout
  47927. * @returns the main component of this controller
  47928. */
  47929. getMainComponent(): WebXRControllerComponent;
  47930. /**
  47931. * Loads the model correlating to this controller
  47932. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47933. * @returns A promise fulfilled with the result of the model loading
  47934. */
  47935. loadModel(): Promise<boolean>;
  47936. /**
  47937. * Update this model using the current XRFrame
  47938. * @param xrFrame the current xr frame to use and update the model
  47939. */
  47940. updateFromXRFrame(xrFrame: XRFrame): void;
  47941. /**
  47942. * Backwards compatibility due to a deeply-integrated typo
  47943. */
  47944. get handness(): XREye;
  47945. /**
  47946. * Pulse (vibrate) this controller
  47947. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47948. * Consecutive calls to this function will cancel the last pulse call
  47949. *
  47950. * @param value the strength of the pulse in 0.0...1.0 range
  47951. * @param duration Duration of the pulse in milliseconds
  47952. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47953. * @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
  47954. */
  47955. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47956. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47957. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47958. /**
  47959. * Moves the axis on the controller mesh based on its current state
  47960. * @param axis the index of the axis
  47961. * @param axisValue the value of the axis which determines the meshes new position
  47962. * @hidden
  47963. */
  47964. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47965. /**
  47966. * Update the model itself with the current frame data
  47967. * @param xrFrame the frame to use for updating the model mesh
  47968. */
  47969. protected updateModel(xrFrame: XRFrame): void;
  47970. /**
  47971. * Get the filename and path for this controller's model
  47972. * @returns a map of filename and path
  47973. */
  47974. protected abstract _getFilenameAndPath(): {
  47975. filename: string;
  47976. path: string;
  47977. };
  47978. /**
  47979. * This function is called before the mesh is loaded. It checks for loading constraints.
  47980. * For example, this function can check if the GLB loader is available
  47981. * If this function returns false, the generic controller will be loaded instead
  47982. * @returns Is the client ready to load the mesh
  47983. */
  47984. protected abstract _getModelLoadingConstraints(): boolean;
  47985. /**
  47986. * This function will be called after the model was successfully loaded and can be used
  47987. * for mesh transformations before it is available for the user
  47988. * @param meshes the loaded meshes
  47989. */
  47990. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47991. /**
  47992. * Set the root mesh for this controller. Important for the WebXR controller class
  47993. * @param meshes the loaded meshes
  47994. */
  47995. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47996. /**
  47997. * A function executed each frame that updates the mesh (if needed)
  47998. * @param xrFrame the current xrFrame
  47999. */
  48000. protected abstract _updateModel(xrFrame: XRFrame): void;
  48001. private _getGenericFilenameAndPath;
  48002. private _getGenericParentMesh;
  48003. }
  48004. }
  48005. declare module BABYLON {
  48006. /**
  48007. * A generic trigger-only motion controller for WebXR
  48008. */
  48009. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48010. /**
  48011. * Static version of the profile id of this controller
  48012. */
  48013. static ProfileId: string;
  48014. profileId: string;
  48015. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48016. protected _getFilenameAndPath(): {
  48017. filename: string;
  48018. path: string;
  48019. };
  48020. protected _getModelLoadingConstraints(): boolean;
  48021. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48022. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48023. protected _updateModel(): void;
  48024. }
  48025. }
  48026. declare module BABYLON {
  48027. /**
  48028. * Class containing static functions to help procedurally build meshes
  48029. */
  48030. export class SphereBuilder {
  48031. /**
  48032. * Creates a sphere mesh
  48033. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48034. * * 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`)
  48035. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48036. * * 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
  48037. * * 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)
  48038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48039. * * 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
  48040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48041. * @param name defines the name of the mesh
  48042. * @param options defines the options used to create the mesh
  48043. * @param scene defines the hosting scene
  48044. * @returns the sphere mesh
  48045. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48046. */
  48047. static CreateSphere(name: string, options: {
  48048. segments?: number;
  48049. diameter?: number;
  48050. diameterX?: number;
  48051. diameterY?: number;
  48052. diameterZ?: number;
  48053. arc?: number;
  48054. slice?: number;
  48055. sideOrientation?: number;
  48056. frontUVs?: Vector4;
  48057. backUVs?: Vector4;
  48058. updatable?: boolean;
  48059. }, scene?: Nullable<Scene>): Mesh;
  48060. }
  48061. }
  48062. declare module BABYLON {
  48063. /**
  48064. * A profiled motion controller has its profile loaded from an online repository.
  48065. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48066. */
  48067. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48068. private _repositoryUrl;
  48069. private _buttonMeshMapping;
  48070. private _touchDots;
  48071. /**
  48072. * The profile ID of this controller. Will be populated when the controller initializes.
  48073. */
  48074. profileId: string;
  48075. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48076. dispose(): void;
  48077. protected _getFilenameAndPath(): {
  48078. filename: string;
  48079. path: string;
  48080. };
  48081. protected _getModelLoadingConstraints(): boolean;
  48082. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48083. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48084. protected _updateModel(_xrFrame: XRFrame): void;
  48085. }
  48086. }
  48087. declare module BABYLON {
  48088. /**
  48089. * A construction function type to create a new controller based on an xrInput object
  48090. */
  48091. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48092. /**
  48093. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48094. *
  48095. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48096. * it should be replaced with auto-loaded controllers.
  48097. *
  48098. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48099. */
  48100. export class WebXRMotionControllerManager {
  48101. private static _AvailableControllers;
  48102. private static _Fallbacks;
  48103. private static _ProfileLoadingPromises;
  48104. private static _ProfilesList;
  48105. /**
  48106. * The base URL of the online controller repository. Can be changed at any time.
  48107. */
  48108. static BaseRepositoryUrl: string;
  48109. /**
  48110. * Which repository gets priority - local or online
  48111. */
  48112. static PrioritizeOnlineRepository: boolean;
  48113. /**
  48114. * Use the online repository, or use only locally-defined controllers
  48115. */
  48116. static UseOnlineRepository: boolean;
  48117. /**
  48118. * Clear the cache used for profile loading and reload when requested again
  48119. */
  48120. static ClearProfilesCache(): void;
  48121. /**
  48122. * Register the default fallbacks.
  48123. * This function is called automatically when this file is imported.
  48124. */
  48125. static DefaultFallbacks(): void;
  48126. /**
  48127. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48128. * @param profileId the profile to which a fallback needs to be found
  48129. * @return an array with corresponding fallback profiles
  48130. */
  48131. static FindFallbackWithProfileId(profileId: string): string[];
  48132. /**
  48133. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48134. * The order of search:
  48135. *
  48136. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48137. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48138. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48139. * 4) return the generic trigger controller if none were found
  48140. *
  48141. * @param xrInput the xrInput to which a new controller is initialized
  48142. * @param scene the scene to which the model will be added
  48143. * @param forceProfile force a certain profile for this controller
  48144. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48145. */
  48146. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48147. /**
  48148. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48149. *
  48150. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48151. *
  48152. * @param type the profile type to register
  48153. * @param constructFunction the function to be called when loading this profile
  48154. */
  48155. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48156. /**
  48157. * Register a fallback to a specific profile.
  48158. * @param profileId the profileId that will receive the fallbacks
  48159. * @param fallbacks A list of fallback profiles
  48160. */
  48161. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48162. /**
  48163. * Will update the list of profiles available in the repository
  48164. * @return a promise that resolves to a map of profiles available online
  48165. */
  48166. static UpdateProfilesList(): Promise<{
  48167. [profile: string]: string;
  48168. }>;
  48169. private static _LoadProfileFromRepository;
  48170. private static _LoadProfilesFromAvailableControllers;
  48171. }
  48172. }
  48173. declare module BABYLON {
  48174. /**
  48175. * Configuration options for the WebXR controller creation
  48176. */
  48177. export interface IWebXRControllerOptions {
  48178. /**
  48179. * Should the controller mesh be animated when a user interacts with it
  48180. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48181. */
  48182. disableMotionControllerAnimation?: boolean;
  48183. /**
  48184. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48185. */
  48186. doNotLoadControllerMesh?: boolean;
  48187. /**
  48188. * Force a specific controller type for this controller.
  48189. * This can be used when creating your own profile or when testing different controllers
  48190. */
  48191. forceControllerProfile?: string;
  48192. /**
  48193. * Defines a rendering group ID for meshes that will be loaded.
  48194. * This is for the default controllers only.
  48195. */
  48196. renderingGroupId?: number;
  48197. }
  48198. /**
  48199. * Represents an XR controller
  48200. */
  48201. export class WebXRInputSource {
  48202. private _scene;
  48203. /** The underlying input source for the controller */
  48204. inputSource: XRInputSource;
  48205. private _options;
  48206. private _tmpVector;
  48207. private _uniqueId;
  48208. /**
  48209. * 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
  48210. */
  48211. grip?: AbstractMesh;
  48212. /**
  48213. * If available, this is the gamepad object related to this controller.
  48214. * Using this object it is possible to get click events and trackpad changes of the
  48215. * webxr controller that is currently being used.
  48216. */
  48217. motionController?: WebXRAbstractMotionController;
  48218. /**
  48219. * Event that fires when the controller is removed/disposed.
  48220. * The object provided as event data is this controller, after associated assets were disposed.
  48221. * uniqueId is still available.
  48222. */
  48223. onDisposeObservable: Observable<WebXRInputSource>;
  48224. /**
  48225. * Will be triggered when the mesh associated with the motion controller is done loading.
  48226. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48227. * A shortened version of controller -> motion controller -> on mesh loaded.
  48228. */
  48229. onMeshLoadedObservable: Observable<AbstractMesh>;
  48230. /**
  48231. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48232. */
  48233. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48234. /**
  48235. * Pointer which can be used to select objects or attach a visible laser to
  48236. */
  48237. pointer: AbstractMesh;
  48238. /**
  48239. * Creates the input source object
  48240. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48241. * @param _scene the scene which the controller should be associated to
  48242. * @param inputSource the underlying input source for the controller
  48243. * @param _options options for this controller creation
  48244. */
  48245. constructor(_scene: Scene,
  48246. /** The underlying input source for the controller */
  48247. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48248. /**
  48249. * Get this controllers unique id
  48250. */
  48251. get uniqueId(): string;
  48252. /**
  48253. * Disposes of the object
  48254. */
  48255. dispose(): void;
  48256. /**
  48257. * Gets a world space ray coming from the pointer or grip
  48258. * @param result the resulting ray
  48259. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48260. */
  48261. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48262. /**
  48263. * Updates the controller pose based on the given XRFrame
  48264. * @param xrFrame xr frame to update the pose with
  48265. * @param referenceSpace reference space to use
  48266. */
  48267. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48268. }
  48269. }
  48270. declare module BABYLON {
  48271. /**
  48272. * The schema for initialization options of the XR Input class
  48273. */
  48274. export interface IWebXRInputOptions {
  48275. /**
  48276. * If set to true no model will be automatically loaded
  48277. */
  48278. doNotLoadControllerMeshes?: boolean;
  48279. /**
  48280. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48281. * If not found, the xr input profile data will be used.
  48282. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48283. */
  48284. forceInputProfile?: string;
  48285. /**
  48286. * Do not send a request to the controller repository to load the profile.
  48287. *
  48288. * Instead, use the controllers available in babylon itself.
  48289. */
  48290. disableOnlineControllerRepository?: boolean;
  48291. /**
  48292. * A custom URL for the controllers repository
  48293. */
  48294. customControllersRepositoryURL?: string;
  48295. /**
  48296. * Should the controller model's components not move according to the user input
  48297. */
  48298. disableControllerAnimation?: boolean;
  48299. /**
  48300. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48301. */
  48302. controllerOptions?: IWebXRControllerOptions;
  48303. }
  48304. /**
  48305. * XR input used to track XR inputs such as controllers/rays
  48306. */
  48307. export class WebXRInput implements IDisposable {
  48308. /**
  48309. * the xr session manager for this session
  48310. */
  48311. xrSessionManager: WebXRSessionManager;
  48312. /**
  48313. * the WebXR camera for this session. Mainly used for teleportation
  48314. */
  48315. xrCamera: WebXRCamera;
  48316. private readonly options;
  48317. /**
  48318. * XR controllers being tracked
  48319. */
  48320. controllers: Array<WebXRInputSource>;
  48321. private _frameObserver;
  48322. private _sessionEndedObserver;
  48323. private _sessionInitObserver;
  48324. /**
  48325. * Event when a controller has been connected/added
  48326. */
  48327. onControllerAddedObservable: Observable<WebXRInputSource>;
  48328. /**
  48329. * Event when a controller has been removed/disconnected
  48330. */
  48331. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48332. /**
  48333. * Initializes the WebXRInput
  48334. * @param xrSessionManager the xr session manager for this session
  48335. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48336. * @param options = initialization options for this xr input
  48337. */
  48338. constructor(
  48339. /**
  48340. * the xr session manager for this session
  48341. */
  48342. xrSessionManager: WebXRSessionManager,
  48343. /**
  48344. * the WebXR camera for this session. Mainly used for teleportation
  48345. */
  48346. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48347. private _onInputSourcesChange;
  48348. private _addAndRemoveControllers;
  48349. /**
  48350. * Disposes of the object
  48351. */
  48352. dispose(): void;
  48353. }
  48354. }
  48355. declare module BABYLON {
  48356. /**
  48357. * This is the base class for all WebXR features.
  48358. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48359. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48360. */
  48361. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48362. protected _xrSessionManager: WebXRSessionManager;
  48363. private _attached;
  48364. private _removeOnDetach;
  48365. /**
  48366. * Should auto-attach be disabled?
  48367. */
  48368. disableAutoAttach: boolean;
  48369. /**
  48370. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48371. */
  48372. xrNativeFeatureName: string;
  48373. /**
  48374. * Construct a new (abstract) WebXR feature
  48375. * @param _xrSessionManager the xr session manager for this feature
  48376. */
  48377. constructor(_xrSessionManager: WebXRSessionManager);
  48378. /**
  48379. * Is this feature attached
  48380. */
  48381. get attached(): boolean;
  48382. /**
  48383. * attach this feature
  48384. *
  48385. * @param force should attachment be forced (even when already attached)
  48386. * @returns true if successful, false is failed or already attached
  48387. */
  48388. attach(force?: boolean): boolean;
  48389. /**
  48390. * detach this feature.
  48391. *
  48392. * @returns true if successful, false if failed or already detached
  48393. */
  48394. detach(): boolean;
  48395. /**
  48396. * Dispose this feature and all of the resources attached
  48397. */
  48398. dispose(): void;
  48399. /**
  48400. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48401. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48402. *
  48403. * @returns whether or not the feature is compatible in this environment
  48404. */
  48405. isCompatible(): boolean;
  48406. /**
  48407. * This is used to register callbacks that will automatically be removed when detach is called.
  48408. * @param observable the observable to which the observer will be attached
  48409. * @param callback the callback to register
  48410. */
  48411. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48412. /**
  48413. * Code in this function will be executed on each xrFrame received from the browser.
  48414. * This function will not execute after the feature is detached.
  48415. * @param _xrFrame the current frame
  48416. */
  48417. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48418. }
  48419. }
  48420. declare module BABYLON {
  48421. /**
  48422. * Renders a layer on top of an existing scene
  48423. */
  48424. export class UtilityLayerRenderer implements IDisposable {
  48425. /** the original scene that will be rendered on top of */
  48426. originalScene: Scene;
  48427. private _pointerCaptures;
  48428. private _lastPointerEvents;
  48429. private static _DefaultUtilityLayer;
  48430. private static _DefaultKeepDepthUtilityLayer;
  48431. private _sharedGizmoLight;
  48432. private _renderCamera;
  48433. /**
  48434. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48435. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48436. * @returns the camera that is used when rendering the utility layer
  48437. */
  48438. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48439. /**
  48440. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48441. * @param cam the camera that should be used when rendering the utility layer
  48442. */
  48443. setRenderCamera(cam: Nullable<Camera>): void;
  48444. /**
  48445. * @hidden
  48446. * Light which used by gizmos to get light shading
  48447. */
  48448. _getSharedGizmoLight(): HemisphericLight;
  48449. /**
  48450. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48451. */
  48452. pickUtilitySceneFirst: boolean;
  48453. /**
  48454. * 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)
  48455. */
  48456. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48457. /**
  48458. * 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)
  48459. */
  48460. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48461. /**
  48462. * The scene that is rendered on top of the original scene
  48463. */
  48464. utilityLayerScene: Scene;
  48465. /**
  48466. * If the utility layer should automatically be rendered on top of existing scene
  48467. */
  48468. shouldRender: boolean;
  48469. /**
  48470. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48471. */
  48472. onlyCheckPointerDownEvents: boolean;
  48473. /**
  48474. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48475. */
  48476. processAllEvents: boolean;
  48477. /**
  48478. * Observable raised when the pointer move from the utility layer scene to the main scene
  48479. */
  48480. onPointerOutObservable: Observable<number>;
  48481. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48482. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48483. private _afterRenderObserver;
  48484. private _sceneDisposeObserver;
  48485. private _originalPointerObserver;
  48486. /**
  48487. * Instantiates a UtilityLayerRenderer
  48488. * @param originalScene the original scene that will be rendered on top of
  48489. * @param handleEvents boolean indicating if the utility layer should handle events
  48490. */
  48491. constructor(
  48492. /** the original scene that will be rendered on top of */
  48493. originalScene: Scene, handleEvents?: boolean);
  48494. private _notifyObservers;
  48495. /**
  48496. * Renders the utility layers scene on top of the original scene
  48497. */
  48498. render(): void;
  48499. /**
  48500. * Disposes of the renderer
  48501. */
  48502. dispose(): void;
  48503. private _updateCamera;
  48504. }
  48505. }
  48506. declare module BABYLON {
  48507. /**
  48508. * Options interface for the pointer selection module
  48509. */
  48510. export interface IWebXRControllerPointerSelectionOptions {
  48511. /**
  48512. * if provided, this scene will be used to render meshes.
  48513. */
  48514. customUtilityLayerScene?: Scene;
  48515. /**
  48516. * 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)
  48517. * If not disabled, the last picked point will be used to execute a pointer up event
  48518. * If disabled, pointer up event will be triggered right after the pointer down event.
  48519. * Used in screen and gaze target ray mode only
  48520. */
  48521. disablePointerUpOnTouchOut: boolean;
  48522. /**
  48523. * For gaze mode (time to select instead of press)
  48524. */
  48525. forceGazeMode: boolean;
  48526. /**
  48527. * 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
  48528. * to start a new countdown to the pointer down event.
  48529. * Defaults to 1.
  48530. */
  48531. gazeModePointerMovedFactor?: number;
  48532. /**
  48533. * Different button type to use instead of the main component
  48534. */
  48535. overrideButtonId?: string;
  48536. /**
  48537. * use this rendering group id for the meshes (optional)
  48538. */
  48539. renderingGroupId?: number;
  48540. /**
  48541. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48542. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48543. * 3000 means 3 seconds between pointing at something and selecting it
  48544. */
  48545. timeToSelect?: number;
  48546. /**
  48547. * Should meshes created here be added to a utility layer or the main scene
  48548. */
  48549. useUtilityLayer?: boolean;
  48550. /**
  48551. * the xr input to use with this pointer selection
  48552. */
  48553. xrInput: WebXRInput;
  48554. }
  48555. /**
  48556. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48557. */
  48558. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48559. private readonly _options;
  48560. private static _idCounter;
  48561. private _attachController;
  48562. private _controllers;
  48563. private _scene;
  48564. private _tmpVectorForPickCompare;
  48565. /**
  48566. * The module's name
  48567. */
  48568. static readonly Name: string;
  48569. /**
  48570. * The (Babylon) version of this module.
  48571. * This is an integer representing the implementation version.
  48572. * This number does not correspond to the WebXR specs version
  48573. */
  48574. static readonly Version: number;
  48575. /**
  48576. * Disable lighting on the laser pointer (so it will always be visible)
  48577. */
  48578. disablePointerLighting: boolean;
  48579. /**
  48580. * Disable lighting on the selection mesh (so it will always be visible)
  48581. */
  48582. disableSelectionMeshLighting: boolean;
  48583. /**
  48584. * Should the laser pointer be displayed
  48585. */
  48586. displayLaserPointer: boolean;
  48587. /**
  48588. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48589. */
  48590. displaySelectionMesh: boolean;
  48591. /**
  48592. * This color will be set to the laser pointer when selection is triggered
  48593. */
  48594. laserPointerPickedColor: Color3;
  48595. /**
  48596. * Default color of the laser pointer
  48597. */
  48598. laserPointerDefaultColor: Color3;
  48599. /**
  48600. * default color of the selection ring
  48601. */
  48602. selectionMeshDefaultColor: Color3;
  48603. /**
  48604. * This color will be applied to the selection ring when selection is triggered
  48605. */
  48606. selectionMeshPickedColor: Color3;
  48607. /**
  48608. * Optional filter to be used for ray selection. This predicate shares behavior with
  48609. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48610. */
  48611. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48612. /**
  48613. * constructs a new background remover module
  48614. * @param _xrSessionManager the session manager for this module
  48615. * @param _options read-only options to be used in this module
  48616. */
  48617. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48618. /**
  48619. * attach this feature
  48620. * Will usually be called by the features manager
  48621. *
  48622. * @returns true if successful.
  48623. */
  48624. attach(): boolean;
  48625. /**
  48626. * detach this feature.
  48627. * Will usually be called by the features manager
  48628. *
  48629. * @returns true if successful.
  48630. */
  48631. detach(): boolean;
  48632. /**
  48633. * Will get the mesh under a specific pointer.
  48634. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48635. * @param controllerId the controllerId to check
  48636. * @returns The mesh under pointer or null if no mesh is under the pointer
  48637. */
  48638. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48639. /**
  48640. * Get the xr controller that correlates to the pointer id in the pointer event
  48641. *
  48642. * @param id the pointer id to search for
  48643. * @returns the controller that correlates to this id or null if not found
  48644. */
  48645. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48646. protected _onXRFrame(_xrFrame: XRFrame): void;
  48647. private _attachGazeMode;
  48648. private _attachScreenRayMode;
  48649. private _attachTrackedPointerRayMode;
  48650. private _convertNormalToDirectionOfRay;
  48651. private _detachController;
  48652. private _generateNewMeshPair;
  48653. private _pickingMoved;
  48654. private _updatePointerDistance;
  48655. /** @hidden */
  48656. get lasterPointerDefaultColor(): Color3;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * Button which can be used to enter a different mode of XR
  48662. */
  48663. export class WebXREnterExitUIButton {
  48664. /** button element */
  48665. element: HTMLElement;
  48666. /** XR initialization options for the button */
  48667. sessionMode: XRSessionMode;
  48668. /** Reference space type */
  48669. referenceSpaceType: XRReferenceSpaceType;
  48670. /**
  48671. * Creates a WebXREnterExitUIButton
  48672. * @param element button element
  48673. * @param sessionMode XR initialization session mode
  48674. * @param referenceSpaceType the type of reference space to be used
  48675. */
  48676. constructor(
  48677. /** button element */
  48678. element: HTMLElement,
  48679. /** XR initialization options for the button */
  48680. sessionMode: XRSessionMode,
  48681. /** Reference space type */
  48682. referenceSpaceType: XRReferenceSpaceType);
  48683. /**
  48684. * Extendable function which can be used to update the button's visuals when the state changes
  48685. * @param activeButton the current active button in the UI
  48686. */
  48687. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48688. }
  48689. /**
  48690. * Options to create the webXR UI
  48691. */
  48692. export class WebXREnterExitUIOptions {
  48693. /**
  48694. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48695. */
  48696. customButtons?: Array<WebXREnterExitUIButton>;
  48697. /**
  48698. * A reference space type to use when creating the default button.
  48699. * Default is local-floor
  48700. */
  48701. referenceSpaceType?: XRReferenceSpaceType;
  48702. /**
  48703. * Context to enter xr with
  48704. */
  48705. renderTarget?: Nullable<WebXRRenderTarget>;
  48706. /**
  48707. * A session mode to use when creating the default button.
  48708. * Default is immersive-vr
  48709. */
  48710. sessionMode?: XRSessionMode;
  48711. /**
  48712. * A list of optional features to init the session with
  48713. */
  48714. optionalFeatures?: string[];
  48715. /**
  48716. * A list of optional features to init the session with
  48717. */
  48718. requiredFeatures?: string[];
  48719. }
  48720. /**
  48721. * UI to allow the user to enter/exit XR mode
  48722. */
  48723. export class WebXREnterExitUI implements IDisposable {
  48724. private scene;
  48725. /** version of the options passed to this UI */
  48726. options: WebXREnterExitUIOptions;
  48727. private _activeButton;
  48728. private _buttons;
  48729. private _overlay;
  48730. /**
  48731. * Fired every time the active button is changed.
  48732. *
  48733. * When xr is entered via a button that launches xr that button will be the callback parameter
  48734. *
  48735. * When exiting xr the callback parameter will be null)
  48736. */
  48737. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48738. /**
  48739. *
  48740. * @param scene babylon scene object to use
  48741. * @param options (read-only) version of the options passed to this UI
  48742. */
  48743. private constructor();
  48744. /**
  48745. * Creates UI to allow the user to enter/exit XR mode
  48746. * @param scene the scene to add the ui to
  48747. * @param helper the xr experience helper to enter/exit xr with
  48748. * @param options options to configure the UI
  48749. * @returns the created ui
  48750. */
  48751. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48752. /**
  48753. * Disposes of the XR UI component
  48754. */
  48755. dispose(): void;
  48756. private _updateButtons;
  48757. }
  48758. }
  48759. declare module BABYLON {
  48760. /**
  48761. * Class containing static functions to help procedurally build meshes
  48762. */
  48763. export class LinesBuilder {
  48764. /**
  48765. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48766. * * 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
  48767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48768. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48769. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48770. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48771. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48772. * * 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
  48773. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48774. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48776. * @param name defines the name of the new line system
  48777. * @param options defines the options used to create the line system
  48778. * @param scene defines the hosting scene
  48779. * @returns a new line system mesh
  48780. */
  48781. static CreateLineSystem(name: string, options: {
  48782. lines: Vector3[][];
  48783. updatable?: boolean;
  48784. instance?: Nullable<LinesMesh>;
  48785. colors?: Nullable<Color4[][]>;
  48786. useVertexAlpha?: boolean;
  48787. }, scene: Nullable<Scene>): LinesMesh;
  48788. /**
  48789. * Creates a line mesh
  48790. * 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
  48791. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48792. * * The parameter `points` is an array successive Vector3
  48793. * * 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
  48794. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48795. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48796. * * When updating an instance, remember that only point positions can change, not the number of points
  48797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48799. * @param name defines the name of the new line system
  48800. * @param options defines the options used to create the line system
  48801. * @param scene defines the hosting scene
  48802. * @returns a new line mesh
  48803. */
  48804. static CreateLines(name: string, options: {
  48805. points: Vector3[];
  48806. updatable?: boolean;
  48807. instance?: Nullable<LinesMesh>;
  48808. colors?: Color4[];
  48809. useVertexAlpha?: boolean;
  48810. }, scene?: Nullable<Scene>): LinesMesh;
  48811. /**
  48812. * Creates a dashed line mesh
  48813. * * 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
  48814. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48815. * * The parameter `points` is an array successive Vector3
  48816. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48817. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48818. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48819. * * 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
  48820. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48821. * * When updating an instance, remember that only point positions can change, not the number of points
  48822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48823. * @param name defines the name of the mesh
  48824. * @param options defines the options used to create the mesh
  48825. * @param scene defines the hosting scene
  48826. * @returns the dashed line mesh
  48827. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48828. */
  48829. static CreateDashedLines(name: string, options: {
  48830. points: Vector3[];
  48831. dashSize?: number;
  48832. gapSize?: number;
  48833. dashNb?: number;
  48834. updatable?: boolean;
  48835. instance?: LinesMesh;
  48836. useVertexAlpha?: boolean;
  48837. }, scene?: Nullable<Scene>): LinesMesh;
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * Construction options for a timer
  48843. */
  48844. export interface ITimerOptions<T> {
  48845. /**
  48846. * Time-to-end
  48847. */
  48848. timeout: number;
  48849. /**
  48850. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48851. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48852. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48853. */
  48854. contextObservable: Observable<T>;
  48855. /**
  48856. * Optional parameters when adding an observer to the observable
  48857. */
  48858. observableParameters?: {
  48859. mask?: number;
  48860. insertFirst?: boolean;
  48861. scope?: any;
  48862. };
  48863. /**
  48864. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48865. */
  48866. breakCondition?: (data?: ITimerData<T>) => boolean;
  48867. /**
  48868. * Will be triggered when the time condition has met
  48869. */
  48870. onEnded?: (data: ITimerData<any>) => void;
  48871. /**
  48872. * Will be triggered when the break condition has met (prematurely ended)
  48873. */
  48874. onAborted?: (data: ITimerData<any>) => void;
  48875. /**
  48876. * Optional function to execute on each tick (or count)
  48877. */
  48878. onTick?: (data: ITimerData<any>) => void;
  48879. }
  48880. /**
  48881. * An interface defining the data sent by the timer
  48882. */
  48883. export interface ITimerData<T> {
  48884. /**
  48885. * When did it start
  48886. */
  48887. startTime: number;
  48888. /**
  48889. * Time now
  48890. */
  48891. currentTime: number;
  48892. /**
  48893. * Time passed since started
  48894. */
  48895. deltaTime: number;
  48896. /**
  48897. * How much is completed, in [0.0...1.0].
  48898. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48899. */
  48900. completeRate: number;
  48901. /**
  48902. * What the registered observable sent in the last count
  48903. */
  48904. payload: T;
  48905. }
  48906. /**
  48907. * The current state of the timer
  48908. */
  48909. export enum TimerState {
  48910. /**
  48911. * Timer initialized, not yet started
  48912. */
  48913. INIT = 0,
  48914. /**
  48915. * Timer started and counting
  48916. */
  48917. STARTED = 1,
  48918. /**
  48919. * Timer ended (whether aborted or time reached)
  48920. */
  48921. ENDED = 2
  48922. }
  48923. /**
  48924. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48925. *
  48926. * @param options options with which to initialize this timer
  48927. */
  48928. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48929. /**
  48930. * An advanced implementation of a timer class
  48931. */
  48932. export class AdvancedTimer<T = any> implements IDisposable {
  48933. /**
  48934. * Will notify each time the timer calculates the remaining time
  48935. */
  48936. onEachCountObservable: Observable<ITimerData<T>>;
  48937. /**
  48938. * Will trigger when the timer was aborted due to the break condition
  48939. */
  48940. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48941. /**
  48942. * Will trigger when the timer ended successfully
  48943. */
  48944. onTimerEndedObservable: Observable<ITimerData<T>>;
  48945. /**
  48946. * Will trigger when the timer state has changed
  48947. */
  48948. onStateChangedObservable: Observable<TimerState>;
  48949. private _observer;
  48950. private _contextObservable;
  48951. private _observableParameters;
  48952. private _startTime;
  48953. private _timer;
  48954. private _state;
  48955. private _breakCondition;
  48956. private _timeToEnd;
  48957. private _breakOnNextTick;
  48958. /**
  48959. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48960. * @param options construction options for this advanced timer
  48961. */
  48962. constructor(options: ITimerOptions<T>);
  48963. /**
  48964. * set a breaking condition for this timer. Default is to never break during count
  48965. * @param predicate the new break condition. Returns true to break, false otherwise
  48966. */
  48967. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48968. /**
  48969. * Reset ALL associated observables in this advanced timer
  48970. */
  48971. clearObservables(): void;
  48972. /**
  48973. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48974. *
  48975. * @param timeToEnd how much time to measure until timer ended
  48976. */
  48977. start(timeToEnd?: number): void;
  48978. /**
  48979. * Will force a stop on the next tick.
  48980. */
  48981. stop(): void;
  48982. /**
  48983. * Dispose this timer, clearing all resources
  48984. */
  48985. dispose(): void;
  48986. private _setState;
  48987. private _tick;
  48988. private _stop;
  48989. }
  48990. }
  48991. declare module BABYLON {
  48992. /**
  48993. * The options container for the teleportation module
  48994. */
  48995. export interface IWebXRTeleportationOptions {
  48996. /**
  48997. * if provided, this scene will be used to render meshes.
  48998. */
  48999. customUtilityLayerScene?: Scene;
  49000. /**
  49001. * Values to configure the default target mesh
  49002. */
  49003. defaultTargetMeshOptions?: {
  49004. /**
  49005. * Fill color of the teleportation area
  49006. */
  49007. teleportationFillColor?: string;
  49008. /**
  49009. * Border color for the teleportation area
  49010. */
  49011. teleportationBorderColor?: string;
  49012. /**
  49013. * Disable the mesh's animation sequence
  49014. */
  49015. disableAnimation?: boolean;
  49016. /**
  49017. * Disable lighting on the material or the ring and arrow
  49018. */
  49019. disableLighting?: boolean;
  49020. /**
  49021. * Override the default material of the torus and arrow
  49022. */
  49023. torusArrowMaterial?: Material;
  49024. };
  49025. /**
  49026. * A list of meshes to use as floor meshes.
  49027. * Meshes can be added and removed after initializing the feature using the
  49028. * addFloorMesh and removeFloorMesh functions
  49029. * If empty, rotation will still work
  49030. */
  49031. floorMeshes?: AbstractMesh[];
  49032. /**
  49033. * use this rendering group id for the meshes (optional)
  49034. */
  49035. renderingGroupId?: number;
  49036. /**
  49037. * Should teleportation move only to snap points
  49038. */
  49039. snapPointsOnly?: boolean;
  49040. /**
  49041. * An array of points to which the teleportation will snap to.
  49042. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49043. */
  49044. snapPositions?: Vector3[];
  49045. /**
  49046. * How close should the teleportation ray be in order to snap to position.
  49047. * Default to 0.8 units (meters)
  49048. */
  49049. snapToPositionRadius?: number;
  49050. /**
  49051. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49052. * If you want to support rotation, make sure your mesh has a direction indicator.
  49053. *
  49054. * When left untouched, the default mesh will be initialized.
  49055. */
  49056. teleportationTargetMesh?: AbstractMesh;
  49057. /**
  49058. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49059. */
  49060. timeToTeleport?: number;
  49061. /**
  49062. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49063. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49064. */
  49065. useMainComponentOnly?: boolean;
  49066. /**
  49067. * Should meshes created here be added to a utility layer or the main scene
  49068. */
  49069. useUtilityLayer?: boolean;
  49070. /**
  49071. * Babylon XR Input class for controller
  49072. */
  49073. xrInput: WebXRInput;
  49074. }
  49075. /**
  49076. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49077. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49078. * the input of the attached controllers.
  49079. */
  49080. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49081. private _options;
  49082. private _controllers;
  49083. private _currentTeleportationControllerId;
  49084. private _floorMeshes;
  49085. private _quadraticBezierCurve;
  49086. private _selectionFeature;
  49087. private _snapToPositions;
  49088. private _snappedToPoint;
  49089. private _teleportationRingMaterial?;
  49090. private _tmpRay;
  49091. private _tmpVector;
  49092. /**
  49093. * The module's name
  49094. */
  49095. static readonly Name: string;
  49096. /**
  49097. * The (Babylon) version of this module.
  49098. * This is an integer representing the implementation version.
  49099. * This number does not correspond to the webxr specs version
  49100. */
  49101. static readonly Version: number;
  49102. /**
  49103. * Is movement backwards enabled
  49104. */
  49105. backwardsMovementEnabled: boolean;
  49106. /**
  49107. * Distance to travel when moving backwards
  49108. */
  49109. backwardsTeleportationDistance: number;
  49110. /**
  49111. * The distance from the user to the inspection point in the direction of the controller
  49112. * A higher number will allow the user to move further
  49113. * defaults to 5 (meters, in xr units)
  49114. */
  49115. parabolicCheckRadius: number;
  49116. /**
  49117. * Should the module support parabolic ray on top of direct ray
  49118. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49119. * Very helpful when moving between floors / different heights
  49120. */
  49121. parabolicRayEnabled: boolean;
  49122. /**
  49123. * How much rotation should be applied when rotating right and left
  49124. */
  49125. rotationAngle: number;
  49126. /**
  49127. * Is rotation enabled when moving forward?
  49128. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49129. */
  49130. rotationEnabled: boolean;
  49131. /**
  49132. * constructs a new anchor system
  49133. * @param _xrSessionManager an instance of WebXRSessionManager
  49134. * @param _options configuration object for this feature
  49135. */
  49136. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49137. /**
  49138. * Get the snapPointsOnly flag
  49139. */
  49140. get snapPointsOnly(): boolean;
  49141. /**
  49142. * Sets the snapPointsOnly flag
  49143. * @param snapToPoints should teleportation be exclusively to snap points
  49144. */
  49145. set snapPointsOnly(snapToPoints: boolean);
  49146. /**
  49147. * Add a new mesh to the floor meshes array
  49148. * @param mesh the mesh to use as floor mesh
  49149. */
  49150. addFloorMesh(mesh: AbstractMesh): void;
  49151. /**
  49152. * Add a new snap-to point to fix teleportation to this position
  49153. * @param newSnapPoint The new Snap-To point
  49154. */
  49155. addSnapPoint(newSnapPoint: Vector3): void;
  49156. attach(): boolean;
  49157. detach(): boolean;
  49158. dispose(): void;
  49159. /**
  49160. * Remove a mesh from the floor meshes array
  49161. * @param mesh the mesh to remove
  49162. */
  49163. removeFloorMesh(mesh: AbstractMesh): void;
  49164. /**
  49165. * Remove a mesh from the floor meshes array using its name
  49166. * @param name the mesh name to remove
  49167. */
  49168. removeFloorMeshByName(name: string): void;
  49169. /**
  49170. * 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
  49171. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49172. * @returns was the point found and removed or not
  49173. */
  49174. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49175. /**
  49176. * This function sets a selection feature that will be disabled when
  49177. * the forward ray is shown and will be reattached when hidden.
  49178. * This is used to remove the selection rays when moving.
  49179. * @param selectionFeature the feature to disable when forward movement is enabled
  49180. */
  49181. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49182. protected _onXRFrame(_xrFrame: XRFrame): void;
  49183. private _attachController;
  49184. private _createDefaultTargetMesh;
  49185. private _detachController;
  49186. private _findClosestSnapPointWithRadius;
  49187. private _setTargetMeshPosition;
  49188. private _setTargetMeshVisibility;
  49189. private _showParabolicPath;
  49190. private _teleportForward;
  49191. }
  49192. }
  49193. declare module BABYLON {
  49194. /**
  49195. * Options for the default xr helper
  49196. */
  49197. export class WebXRDefaultExperienceOptions {
  49198. /**
  49199. * Enable or disable default UI to enter XR
  49200. */
  49201. disableDefaultUI?: boolean;
  49202. /**
  49203. * Should teleportation not initialize. defaults to false.
  49204. */
  49205. disableTeleportation?: boolean;
  49206. /**
  49207. * Floor meshes that will be used for teleport
  49208. */
  49209. floorMeshes?: Array<AbstractMesh>;
  49210. /**
  49211. * If set to true, the first frame will not be used to reset position
  49212. * The first frame is mainly used when copying transformation from the old camera
  49213. * Mainly used in AR
  49214. */
  49215. ignoreNativeCameraTransformation?: boolean;
  49216. /**
  49217. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49218. */
  49219. inputOptions?: IWebXRInputOptions;
  49220. /**
  49221. * optional configuration for the output canvas
  49222. */
  49223. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49224. /**
  49225. * optional UI options. This can be used among other to change session mode and reference space type
  49226. */
  49227. uiOptions?: WebXREnterExitUIOptions;
  49228. /**
  49229. * When loading teleportation and pointer select, use stable versions instead of latest.
  49230. */
  49231. useStablePlugins?: boolean;
  49232. /**
  49233. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49234. */
  49235. renderingGroupId?: number;
  49236. /**
  49237. * A list of optional features to init the session with
  49238. * If set to true, all features we support will be added
  49239. */
  49240. optionalFeatures?: boolean | string[];
  49241. }
  49242. /**
  49243. * Default experience which provides a similar setup to the previous webVRExperience
  49244. */
  49245. export class WebXRDefaultExperience {
  49246. /**
  49247. * Base experience
  49248. */
  49249. baseExperience: WebXRExperienceHelper;
  49250. /**
  49251. * Enables ui for entering/exiting xr
  49252. */
  49253. enterExitUI: WebXREnterExitUI;
  49254. /**
  49255. * Input experience extension
  49256. */
  49257. input: WebXRInput;
  49258. /**
  49259. * Enables laser pointer and selection
  49260. */
  49261. pointerSelection: WebXRControllerPointerSelection;
  49262. /**
  49263. * Default target xr should render to
  49264. */
  49265. renderTarget: WebXRRenderTarget;
  49266. /**
  49267. * Enables teleportation
  49268. */
  49269. teleportation: WebXRMotionControllerTeleportation;
  49270. private constructor();
  49271. /**
  49272. * Creates the default xr experience
  49273. * @param scene scene
  49274. * @param options options for basic configuration
  49275. * @returns resulting WebXRDefaultExperience
  49276. */
  49277. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49278. /**
  49279. * DIsposes of the experience helper
  49280. */
  49281. dispose(): void;
  49282. }
  49283. }
  49284. declare module BABYLON {
  49285. /**
  49286. * Options to modify the vr teleportation behavior.
  49287. */
  49288. export interface VRTeleportationOptions {
  49289. /**
  49290. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49291. */
  49292. floorMeshName?: string;
  49293. /**
  49294. * A list of meshes to be used as the teleportation floor. (default: empty)
  49295. */
  49296. floorMeshes?: Mesh[];
  49297. /**
  49298. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49299. */
  49300. teleportationMode?: number;
  49301. /**
  49302. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49303. */
  49304. teleportationTime?: number;
  49305. /**
  49306. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49307. */
  49308. teleportationSpeed?: number;
  49309. /**
  49310. * The easing function used in the animation or null for Linear. (default CircleEase)
  49311. */
  49312. easingFunction?: EasingFunction;
  49313. }
  49314. /**
  49315. * Options to modify the vr experience helper's behavior.
  49316. */
  49317. export interface VRExperienceHelperOptions extends WebVROptions {
  49318. /**
  49319. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49320. */
  49321. createDeviceOrientationCamera?: boolean;
  49322. /**
  49323. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49324. */
  49325. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49326. /**
  49327. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49328. */
  49329. laserToggle?: boolean;
  49330. /**
  49331. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49332. */
  49333. floorMeshes?: Mesh[];
  49334. /**
  49335. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49336. */
  49337. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49338. /**
  49339. * Defines if WebXR should be used instead of WebVR (if available)
  49340. */
  49341. useXR?: boolean;
  49342. }
  49343. /**
  49344. * Event containing information after VR has been entered
  49345. */
  49346. export class OnAfterEnteringVRObservableEvent {
  49347. /**
  49348. * If entering vr was successful
  49349. */
  49350. success: boolean;
  49351. }
  49352. /**
  49353. * Helps to quickly add VR support to an existing scene.
  49354. * See https://doc.babylonjs.com/how_to/webvr_helper
  49355. */
  49356. export class VRExperienceHelper {
  49357. /** Options to modify the vr experience helper's behavior. */
  49358. webVROptions: VRExperienceHelperOptions;
  49359. private _scene;
  49360. private _position;
  49361. private _btnVR;
  49362. private _btnVRDisplayed;
  49363. private _webVRsupported;
  49364. private _webVRready;
  49365. private _webVRrequesting;
  49366. private _webVRpresenting;
  49367. private _hasEnteredVR;
  49368. private _fullscreenVRpresenting;
  49369. private _inputElement;
  49370. private _webVRCamera;
  49371. private _vrDeviceOrientationCamera;
  49372. private _deviceOrientationCamera;
  49373. private _existingCamera;
  49374. private _onKeyDown;
  49375. private _onVrDisplayPresentChange;
  49376. private _onVRDisplayChanged;
  49377. private _onVRRequestPresentStart;
  49378. private _onVRRequestPresentComplete;
  49379. /**
  49380. * 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)
  49381. */
  49382. enableGazeEvenWhenNoPointerLock: boolean;
  49383. /**
  49384. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49385. */
  49386. exitVROnDoubleTap: boolean;
  49387. /**
  49388. * Observable raised right before entering VR.
  49389. */
  49390. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49391. /**
  49392. * Observable raised when entering VR has completed.
  49393. */
  49394. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49395. /**
  49396. * Observable raised when exiting VR.
  49397. */
  49398. onExitingVRObservable: Observable<VRExperienceHelper>;
  49399. /**
  49400. * Observable raised when controller mesh is loaded.
  49401. */
  49402. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49403. /** Return this.onEnteringVRObservable
  49404. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49405. */
  49406. get onEnteringVR(): Observable<VRExperienceHelper>;
  49407. /** Return this.onExitingVRObservable
  49408. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49409. */
  49410. get onExitingVR(): Observable<VRExperienceHelper>;
  49411. /** Return this.onControllerMeshLoadedObservable
  49412. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49413. */
  49414. get onControllerMeshLoaded(): Observable<WebVRController>;
  49415. private _rayLength;
  49416. private _useCustomVRButton;
  49417. private _teleportationRequested;
  49418. private _teleportActive;
  49419. private _floorMeshName;
  49420. private _floorMeshesCollection;
  49421. private _teleportationMode;
  49422. private _teleportationTime;
  49423. private _teleportationSpeed;
  49424. private _teleportationEasing;
  49425. private _rotationAllowed;
  49426. private _teleportBackwardsVector;
  49427. private _teleportationTarget;
  49428. private _isDefaultTeleportationTarget;
  49429. private _postProcessMove;
  49430. private _teleportationFillColor;
  49431. private _teleportationBorderColor;
  49432. private _rotationAngle;
  49433. private _haloCenter;
  49434. private _cameraGazer;
  49435. private _padSensibilityUp;
  49436. private _padSensibilityDown;
  49437. private _leftController;
  49438. private _rightController;
  49439. private _gazeColor;
  49440. private _laserColor;
  49441. private _pickedLaserColor;
  49442. private _pickedGazeColor;
  49443. /**
  49444. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49445. */
  49446. onNewMeshSelected: Observable<AbstractMesh>;
  49447. /**
  49448. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49449. * This observable will provide the mesh and the controller used to select the mesh
  49450. */
  49451. onMeshSelectedWithController: Observable<{
  49452. mesh: AbstractMesh;
  49453. controller: WebVRController;
  49454. }>;
  49455. /**
  49456. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49457. */
  49458. onNewMeshPicked: Observable<PickingInfo>;
  49459. private _circleEase;
  49460. /**
  49461. * Observable raised before camera teleportation
  49462. */
  49463. onBeforeCameraTeleport: Observable<Vector3>;
  49464. /**
  49465. * Observable raised after camera teleportation
  49466. */
  49467. onAfterCameraTeleport: Observable<Vector3>;
  49468. /**
  49469. * Observable raised when current selected mesh gets unselected
  49470. */
  49471. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49472. private _raySelectionPredicate;
  49473. /**
  49474. * To be optionaly changed by user to define custom ray selection
  49475. */
  49476. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49477. /**
  49478. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49479. */
  49480. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49481. /**
  49482. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49483. */
  49484. teleportationEnabled: boolean;
  49485. private _defaultHeight;
  49486. private _teleportationInitialized;
  49487. private _interactionsEnabled;
  49488. private _interactionsRequested;
  49489. private _displayGaze;
  49490. private _displayLaserPointer;
  49491. /**
  49492. * The mesh used to display where the user is going to teleport.
  49493. */
  49494. get teleportationTarget(): Mesh;
  49495. /**
  49496. * Sets the mesh to be used to display where the user is going to teleport.
  49497. */
  49498. set teleportationTarget(value: Mesh);
  49499. /**
  49500. * 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
  49501. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49502. * See https://doc.babylonjs.com/resources/baking_transformations
  49503. */
  49504. get gazeTrackerMesh(): Mesh;
  49505. set gazeTrackerMesh(value: Mesh);
  49506. /**
  49507. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49508. */
  49509. updateGazeTrackerScale: boolean;
  49510. /**
  49511. * If the gaze trackers color should be updated when selecting meshes
  49512. */
  49513. updateGazeTrackerColor: boolean;
  49514. /**
  49515. * If the controller laser color should be updated when selecting meshes
  49516. */
  49517. updateControllerLaserColor: boolean;
  49518. /**
  49519. * The gaze tracking mesh corresponding to the left controller
  49520. */
  49521. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49522. /**
  49523. * The gaze tracking mesh corresponding to the right controller
  49524. */
  49525. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49526. /**
  49527. * If the ray of the gaze should be displayed.
  49528. */
  49529. get displayGaze(): boolean;
  49530. /**
  49531. * Sets if the ray of the gaze should be displayed.
  49532. */
  49533. set displayGaze(value: boolean);
  49534. /**
  49535. * If the ray of the LaserPointer should be displayed.
  49536. */
  49537. get displayLaserPointer(): boolean;
  49538. /**
  49539. * Sets if the ray of the LaserPointer should be displayed.
  49540. */
  49541. set displayLaserPointer(value: boolean);
  49542. /**
  49543. * The deviceOrientationCamera used as the camera when not in VR.
  49544. */
  49545. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49546. /**
  49547. * Based on the current WebVR support, returns the current VR camera used.
  49548. */
  49549. get currentVRCamera(): Nullable<Camera>;
  49550. /**
  49551. * The webVRCamera which is used when in VR.
  49552. */
  49553. get webVRCamera(): WebVRFreeCamera;
  49554. /**
  49555. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49556. */
  49557. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49558. /**
  49559. * The html button that is used to trigger entering into VR.
  49560. */
  49561. get vrButton(): Nullable<HTMLButtonElement>;
  49562. private get _teleportationRequestInitiated();
  49563. /**
  49564. * Defines whether or not Pointer lock should be requested when switching to
  49565. * full screen.
  49566. */
  49567. requestPointerLockOnFullScreen: boolean;
  49568. /**
  49569. * If asking to force XR, this will be populated with the default xr experience
  49570. */
  49571. xr: WebXRDefaultExperience;
  49572. /**
  49573. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49574. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49575. */
  49576. xrTestDone: boolean;
  49577. /**
  49578. * Instantiates a VRExperienceHelper.
  49579. * Helps to quickly add VR support to an existing scene.
  49580. * @param scene The scene the VRExperienceHelper belongs to.
  49581. * @param webVROptions Options to modify the vr experience helper's behavior.
  49582. */
  49583. constructor(scene: Scene,
  49584. /** Options to modify the vr experience helper's behavior. */
  49585. webVROptions?: VRExperienceHelperOptions);
  49586. private completeVRInit;
  49587. private _onDefaultMeshLoaded;
  49588. private _onResize;
  49589. private _onFullscreenChange;
  49590. /**
  49591. * Gets a value indicating if we are currently in VR mode.
  49592. */
  49593. get isInVRMode(): boolean;
  49594. private onVrDisplayPresentChange;
  49595. private onVRDisplayChanged;
  49596. private moveButtonToBottomRight;
  49597. private displayVRButton;
  49598. private updateButtonVisibility;
  49599. private _cachedAngularSensibility;
  49600. /**
  49601. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49602. * Otherwise, will use the fullscreen API.
  49603. */
  49604. enterVR(): void;
  49605. /**
  49606. * Attempt to exit VR, or fullscreen.
  49607. */
  49608. exitVR(): void;
  49609. /**
  49610. * The position of the vr experience helper.
  49611. */
  49612. get position(): Vector3;
  49613. /**
  49614. * Sets the position of the vr experience helper.
  49615. */
  49616. set position(value: Vector3);
  49617. /**
  49618. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49619. */
  49620. enableInteractions(): void;
  49621. private get _noControllerIsActive();
  49622. private beforeRender;
  49623. private _isTeleportationFloor;
  49624. /**
  49625. * Adds a floor mesh to be used for teleportation.
  49626. * @param floorMesh the mesh to be used for teleportation.
  49627. */
  49628. addFloorMesh(floorMesh: Mesh): void;
  49629. /**
  49630. * Removes a floor mesh from being used for teleportation.
  49631. * @param floorMesh the mesh to be removed.
  49632. */
  49633. removeFloorMesh(floorMesh: Mesh): void;
  49634. /**
  49635. * Enables interactions and teleportation using the VR controllers and gaze.
  49636. * @param vrTeleportationOptions options to modify teleportation behavior.
  49637. */
  49638. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49639. private _onNewGamepadConnected;
  49640. private _tryEnableInteractionOnController;
  49641. private _onNewGamepadDisconnected;
  49642. private _enableInteractionOnController;
  49643. private _checkTeleportWithRay;
  49644. private _checkRotate;
  49645. private _checkTeleportBackwards;
  49646. private _enableTeleportationOnController;
  49647. private _createTeleportationCircles;
  49648. private _displayTeleportationTarget;
  49649. private _hideTeleportationTarget;
  49650. private _rotateCamera;
  49651. private _moveTeleportationSelectorTo;
  49652. private _workingVector;
  49653. private _workingQuaternion;
  49654. private _workingMatrix;
  49655. /**
  49656. * Time Constant Teleportation Mode
  49657. */
  49658. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49659. /**
  49660. * Speed Constant Teleportation Mode
  49661. */
  49662. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49663. /**
  49664. * Teleports the users feet to the desired location
  49665. * @param location The location where the user's feet should be placed
  49666. */
  49667. teleportCamera(location: Vector3): void;
  49668. private _convertNormalToDirectionOfRay;
  49669. private _castRayAndSelectObject;
  49670. private _notifySelectedMeshUnselected;
  49671. /**
  49672. * Permanently set new colors for the laser pointer
  49673. * @param color the new laser color
  49674. * @param pickedColor the new laser color when picked mesh detected
  49675. */
  49676. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49677. /**
  49678. * Set lighting enabled / disabled on the laser pointer of both controllers
  49679. * @param enabled should the lighting be enabled on the laser pointer
  49680. */
  49681. setLaserLightingState(enabled?: boolean): void;
  49682. /**
  49683. * Permanently set new colors for the gaze pointer
  49684. * @param color the new gaze color
  49685. * @param pickedColor the new gaze color when picked mesh detected
  49686. */
  49687. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49688. /**
  49689. * Sets the color of the laser ray from the vr controllers.
  49690. * @param color new color for the ray.
  49691. */
  49692. changeLaserColor(color: Color3): void;
  49693. /**
  49694. * Sets the color of the ray from the vr headsets gaze.
  49695. * @param color new color for the ray.
  49696. */
  49697. changeGazeColor(color: Color3): void;
  49698. /**
  49699. * Exits VR and disposes of the vr experience helper
  49700. */
  49701. dispose(): void;
  49702. /**
  49703. * Gets the name of the VRExperienceHelper class
  49704. * @returns "VRExperienceHelper"
  49705. */
  49706. getClassName(): string;
  49707. }
  49708. }
  49709. declare module BABYLON {
  49710. /**
  49711. * Contains an array of blocks representing the octree
  49712. */
  49713. export interface IOctreeContainer<T> {
  49714. /**
  49715. * Blocks within the octree
  49716. */
  49717. blocks: Array<OctreeBlock<T>>;
  49718. }
  49719. /**
  49720. * Class used to store a cell in an octree
  49721. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49722. */
  49723. export class OctreeBlock<T> {
  49724. /**
  49725. * Gets the content of the current block
  49726. */
  49727. entries: T[];
  49728. /**
  49729. * Gets the list of block children
  49730. */
  49731. blocks: Array<OctreeBlock<T>>;
  49732. private _depth;
  49733. private _maxDepth;
  49734. private _capacity;
  49735. private _minPoint;
  49736. private _maxPoint;
  49737. private _boundingVectors;
  49738. private _creationFunc;
  49739. /**
  49740. * Creates a new block
  49741. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49742. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49743. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49744. * @param depth defines the current depth of this block in the octree
  49745. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49746. * @param creationFunc defines a callback to call when an element is added to the block
  49747. */
  49748. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49749. /**
  49750. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49751. */
  49752. get capacity(): number;
  49753. /**
  49754. * Gets the minimum vector (in world space) of the block's bounding box
  49755. */
  49756. get minPoint(): Vector3;
  49757. /**
  49758. * Gets the maximum vector (in world space) of the block's bounding box
  49759. */
  49760. get maxPoint(): Vector3;
  49761. /**
  49762. * Add a new element to this block
  49763. * @param entry defines the element to add
  49764. */
  49765. addEntry(entry: T): void;
  49766. /**
  49767. * Remove an element from this block
  49768. * @param entry defines the element to remove
  49769. */
  49770. removeEntry(entry: T): void;
  49771. /**
  49772. * Add an array of elements to this block
  49773. * @param entries defines the array of elements to add
  49774. */
  49775. addEntries(entries: T[]): void;
  49776. /**
  49777. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49778. * @param frustumPlanes defines the frustum planes to test
  49779. * @param selection defines the array to store current content if selection is positive
  49780. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49781. */
  49782. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49783. /**
  49784. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49785. * @param sphereCenter defines the bounding sphere center
  49786. * @param sphereRadius defines the bounding sphere radius
  49787. * @param selection defines the array to store current content if selection is positive
  49788. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49789. */
  49790. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49791. /**
  49792. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49793. * @param ray defines the ray to test with
  49794. * @param selection defines the array to store current content if selection is positive
  49795. */
  49796. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49797. /**
  49798. * Subdivide the content into child blocks (this block will then be empty)
  49799. */
  49800. createInnerBlocks(): void;
  49801. /**
  49802. * @hidden
  49803. */
  49804. 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;
  49805. }
  49806. }
  49807. declare module BABYLON {
  49808. /**
  49809. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49811. */
  49812. export class Octree<T> {
  49813. /** 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.) */
  49814. maxDepth: number;
  49815. /**
  49816. * Blocks within the octree containing objects
  49817. */
  49818. blocks: Array<OctreeBlock<T>>;
  49819. /**
  49820. * Content stored in the octree
  49821. */
  49822. dynamicContent: T[];
  49823. private _maxBlockCapacity;
  49824. private _selectionContent;
  49825. private _creationFunc;
  49826. /**
  49827. * Creates a octree
  49828. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49829. * @param creationFunc function to be used to instatiate the octree
  49830. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49831. * @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.)
  49832. */
  49833. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49834. /** 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.) */
  49835. maxDepth?: number);
  49836. /**
  49837. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49838. * @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);
  49839. * @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);
  49840. * @param entries meshes to be added to the octree blocks
  49841. */
  49842. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49843. /**
  49844. * Adds a mesh to the octree
  49845. * @param entry Mesh to add to the octree
  49846. */
  49847. addMesh(entry: T): void;
  49848. /**
  49849. * Remove an element from the octree
  49850. * @param entry defines the element to remove
  49851. */
  49852. removeMesh(entry: T): void;
  49853. /**
  49854. * Selects an array of meshes within the frustum
  49855. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49856. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49857. * @returns array of meshes within the frustum
  49858. */
  49859. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49860. /**
  49861. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49862. * @param sphereCenter defines the bounding sphere center
  49863. * @param sphereRadius defines the bounding sphere radius
  49864. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49865. * @returns an array of objects that intersect the sphere
  49866. */
  49867. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49868. /**
  49869. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49870. * @param ray defines the ray to test with
  49871. * @returns array of intersected objects
  49872. */
  49873. intersectsRay(ray: Ray): SmartArray<T>;
  49874. /**
  49875. * Adds a mesh into the octree block if it intersects the block
  49876. */
  49877. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49878. /**
  49879. * Adds a submesh into the octree block if it intersects the block
  49880. */
  49881. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49882. }
  49883. }
  49884. declare module BABYLON {
  49885. interface Scene {
  49886. /**
  49887. * @hidden
  49888. * Backing Filed
  49889. */
  49890. _selectionOctree: Octree<AbstractMesh>;
  49891. /**
  49892. * Gets the octree used to boost mesh selection (picking)
  49893. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49894. */
  49895. selectionOctree: Octree<AbstractMesh>;
  49896. /**
  49897. * Creates or updates the octree used to boost selection (picking)
  49898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49899. * @param maxCapacity defines the maximum capacity per leaf
  49900. * @param maxDepth defines the maximum depth of the octree
  49901. * @returns an octree of AbstractMesh
  49902. */
  49903. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49904. }
  49905. interface AbstractMesh {
  49906. /**
  49907. * @hidden
  49908. * Backing Field
  49909. */
  49910. _submeshesOctree: Octree<SubMesh>;
  49911. /**
  49912. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49913. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49914. * @param maxCapacity defines the maximum size of each block (64 by default)
  49915. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49916. * @returns the new octree
  49917. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49918. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49919. */
  49920. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49921. }
  49922. /**
  49923. * Defines the octree scene component responsible to manage any octrees
  49924. * in a given scene.
  49925. */
  49926. export class OctreeSceneComponent {
  49927. /**
  49928. * The component name help to identify the component in the list of scene components.
  49929. */
  49930. readonly name: string;
  49931. /**
  49932. * The scene the component belongs to.
  49933. */
  49934. scene: Scene;
  49935. /**
  49936. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49937. */
  49938. readonly checksIsEnabled: boolean;
  49939. /**
  49940. * Creates a new instance of the component for the given scene
  49941. * @param scene Defines the scene to register the component in
  49942. */
  49943. constructor(scene: Scene);
  49944. /**
  49945. * Registers the component in a given scene
  49946. */
  49947. register(): void;
  49948. /**
  49949. * Return the list of active meshes
  49950. * @returns the list of active meshes
  49951. */
  49952. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49953. /**
  49954. * Return the list of active sub meshes
  49955. * @param mesh The mesh to get the candidates sub meshes from
  49956. * @returns the list of active sub meshes
  49957. */
  49958. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49959. private _tempRay;
  49960. /**
  49961. * Return the list of sub meshes intersecting with a given local ray
  49962. * @param mesh defines the mesh to find the submesh for
  49963. * @param localRay defines the ray in local space
  49964. * @returns the list of intersecting sub meshes
  49965. */
  49966. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49967. /**
  49968. * Return the list of sub meshes colliding with a collider
  49969. * @param mesh defines the mesh to find the submesh for
  49970. * @param collider defines the collider to evaluate the collision against
  49971. * @returns the list of colliding sub meshes
  49972. */
  49973. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49974. /**
  49975. * Rebuilds the elements related to this component in case of
  49976. * context lost for instance.
  49977. */
  49978. rebuild(): void;
  49979. /**
  49980. * Disposes the component and the associated ressources.
  49981. */
  49982. dispose(): void;
  49983. }
  49984. }
  49985. declare module BABYLON {
  49986. /**
  49987. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49988. */
  49989. export class Gizmo implements IDisposable {
  49990. /** The utility layer the gizmo will be added to */
  49991. gizmoLayer: UtilityLayerRenderer;
  49992. /**
  49993. * The root mesh of the gizmo
  49994. */
  49995. _rootMesh: Mesh;
  49996. private _attachedMesh;
  49997. private _attachedNode;
  49998. /**
  49999. * Ratio for the scale of the gizmo (Default: 1)
  50000. */
  50001. scaleRatio: number;
  50002. /**
  50003. * If a custom mesh has been set (Default: false)
  50004. */
  50005. protected _customMeshSet: boolean;
  50006. /**
  50007. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50008. * * When set, interactions will be enabled
  50009. */
  50010. get attachedMesh(): Nullable<AbstractMesh>;
  50011. set attachedMesh(value: Nullable<AbstractMesh>);
  50012. /**
  50013. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50014. * * When set, interactions will be enabled
  50015. */
  50016. get attachedNode(): Nullable<Node>;
  50017. set attachedNode(value: Nullable<Node>);
  50018. /**
  50019. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50020. * @param mesh The mesh to replace the default mesh of the gizmo
  50021. */
  50022. setCustomMesh(mesh: Mesh): void;
  50023. /**
  50024. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50025. */
  50026. updateGizmoRotationToMatchAttachedMesh: boolean;
  50027. /**
  50028. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50029. */
  50030. updateGizmoPositionToMatchAttachedMesh: boolean;
  50031. /**
  50032. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50033. */
  50034. updateScale: boolean;
  50035. protected _interactionsEnabled: boolean;
  50036. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50037. private _beforeRenderObserver;
  50038. private _tempVector;
  50039. /**
  50040. * Creates a gizmo
  50041. * @param gizmoLayer The utility layer the gizmo will be added to
  50042. */
  50043. constructor(
  50044. /** The utility layer the gizmo will be added to */
  50045. gizmoLayer?: UtilityLayerRenderer);
  50046. /**
  50047. * Updates the gizmo to match the attached mesh's position/rotation
  50048. */
  50049. protected _update(): void;
  50050. /**
  50051. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50052. * @param value Node, TransformNode or mesh
  50053. */
  50054. protected _matrixChanged(): void;
  50055. /**
  50056. * Disposes of the gizmo
  50057. */
  50058. dispose(): void;
  50059. }
  50060. }
  50061. declare module BABYLON {
  50062. /**
  50063. * Single plane drag gizmo
  50064. */
  50065. export class PlaneDragGizmo extends Gizmo {
  50066. /**
  50067. * Drag behavior responsible for the gizmos dragging interactions
  50068. */
  50069. dragBehavior: PointerDragBehavior;
  50070. private _pointerObserver;
  50071. /**
  50072. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50073. */
  50074. snapDistance: number;
  50075. /**
  50076. * Event that fires each time the gizmo snaps to a new location.
  50077. * * snapDistance is the the change in distance
  50078. */
  50079. onSnapObservable: Observable<{
  50080. snapDistance: number;
  50081. }>;
  50082. private _plane;
  50083. private _coloredMaterial;
  50084. private _hoverMaterial;
  50085. private _isEnabled;
  50086. private _parent;
  50087. /** @hidden */
  50088. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50089. /** @hidden */
  50090. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50091. /**
  50092. * Creates a PlaneDragGizmo
  50093. * @param gizmoLayer The utility layer the gizmo will be added to
  50094. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50095. * @param color The color of the gizmo
  50096. */
  50097. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50098. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50099. /**
  50100. * If the gizmo is enabled
  50101. */
  50102. set isEnabled(value: boolean);
  50103. get isEnabled(): boolean;
  50104. /**
  50105. * Disposes of the gizmo
  50106. */
  50107. dispose(): void;
  50108. }
  50109. }
  50110. declare module BABYLON {
  50111. /**
  50112. * Gizmo that enables dragging a mesh along 3 axis
  50113. */
  50114. export class PositionGizmo extends Gizmo {
  50115. /**
  50116. * Internal gizmo used for interactions on the x axis
  50117. */
  50118. xGizmo: AxisDragGizmo;
  50119. /**
  50120. * Internal gizmo used for interactions on the y axis
  50121. */
  50122. yGizmo: AxisDragGizmo;
  50123. /**
  50124. * Internal gizmo used for interactions on the z axis
  50125. */
  50126. zGizmo: AxisDragGizmo;
  50127. /**
  50128. * Internal gizmo used for interactions on the yz plane
  50129. */
  50130. xPlaneGizmo: PlaneDragGizmo;
  50131. /**
  50132. * Internal gizmo used for interactions on the xz plane
  50133. */
  50134. yPlaneGizmo: PlaneDragGizmo;
  50135. /**
  50136. * Internal gizmo used for interactions on the xy plane
  50137. */
  50138. zPlaneGizmo: PlaneDragGizmo;
  50139. /**
  50140. * private variables
  50141. */
  50142. private _meshAttached;
  50143. private _nodeAttached;
  50144. private _updateGizmoRotationToMatchAttachedMesh;
  50145. private _snapDistance;
  50146. private _scaleRatio;
  50147. /** Fires an event when any of it's sub gizmos are dragged */
  50148. onDragStartObservable: Observable<unknown>;
  50149. /** Fires an event when any of it's sub gizmos are released from dragging */
  50150. onDragEndObservable: Observable<unknown>;
  50151. /**
  50152. * If set to true, planar drag is enabled
  50153. */
  50154. private _planarGizmoEnabled;
  50155. get attachedMesh(): Nullable<AbstractMesh>;
  50156. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50157. get attachedNode(): Nullable<Node>;
  50158. set attachedNode(node: Nullable<Node>);
  50159. /**
  50160. * Creates a PositionGizmo
  50161. * @param gizmoLayer The utility layer the gizmo will be added to
  50162. @param thickness display gizmo axis thickness
  50163. */
  50164. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50165. /**
  50166. * If the planar drag gizmo is enabled
  50167. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50168. */
  50169. set planarGizmoEnabled(value: boolean);
  50170. get planarGizmoEnabled(): boolean;
  50171. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50172. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50173. /**
  50174. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50175. */
  50176. set snapDistance(value: number);
  50177. get snapDistance(): number;
  50178. /**
  50179. * Ratio for the scale of the gizmo (Default: 1)
  50180. */
  50181. set scaleRatio(value: number);
  50182. get scaleRatio(): number;
  50183. /**
  50184. * Disposes of the gizmo
  50185. */
  50186. dispose(): void;
  50187. /**
  50188. * CustomMeshes are not supported by this gizmo
  50189. * @param mesh The mesh to replace the default mesh of the gizmo
  50190. */
  50191. setCustomMesh(mesh: Mesh): void;
  50192. }
  50193. }
  50194. declare module BABYLON {
  50195. /**
  50196. * Single axis drag gizmo
  50197. */
  50198. export class AxisDragGizmo extends Gizmo {
  50199. /**
  50200. * Drag behavior responsible for the gizmos dragging interactions
  50201. */
  50202. dragBehavior: PointerDragBehavior;
  50203. private _pointerObserver;
  50204. /**
  50205. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50206. */
  50207. snapDistance: number;
  50208. /**
  50209. * Event that fires each time the gizmo snaps to a new location.
  50210. * * snapDistance is the the change in distance
  50211. */
  50212. onSnapObservable: Observable<{
  50213. snapDistance: number;
  50214. }>;
  50215. private _isEnabled;
  50216. private _parent;
  50217. private _arrow;
  50218. private _coloredMaterial;
  50219. private _hoverMaterial;
  50220. /** @hidden */
  50221. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50222. /** @hidden */
  50223. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50224. /**
  50225. * Creates an AxisDragGizmo
  50226. * @param gizmoLayer The utility layer the gizmo will be added to
  50227. * @param dragAxis The axis which the gizmo will be able to drag on
  50228. * @param color The color of the gizmo
  50229. * @param thickness display gizmo axis thickness
  50230. */
  50231. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50232. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50233. /**
  50234. * If the gizmo is enabled
  50235. */
  50236. set isEnabled(value: boolean);
  50237. get isEnabled(): boolean;
  50238. /**
  50239. * Disposes of the gizmo
  50240. */
  50241. dispose(): void;
  50242. }
  50243. }
  50244. declare module BABYLON.Debug {
  50245. /**
  50246. * The Axes viewer will show 3 axes in a specific point in space
  50247. */
  50248. export class AxesViewer {
  50249. private _xAxis;
  50250. private _yAxis;
  50251. private _zAxis;
  50252. private _scaleLinesFactor;
  50253. private _instanced;
  50254. /**
  50255. * Gets the hosting scene
  50256. */
  50257. scene: Scene;
  50258. /**
  50259. * Gets or sets a number used to scale line length
  50260. */
  50261. scaleLines: number;
  50262. /** Gets the node hierarchy used to render x-axis */
  50263. get xAxis(): TransformNode;
  50264. /** Gets the node hierarchy used to render y-axis */
  50265. get yAxis(): TransformNode;
  50266. /** Gets the node hierarchy used to render z-axis */
  50267. get zAxis(): TransformNode;
  50268. /**
  50269. * Creates a new AxesViewer
  50270. * @param scene defines the hosting scene
  50271. * @param scaleLines defines a number used to scale line length (1 by default)
  50272. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50273. * @param xAxis defines the node hierarchy used to render the x-axis
  50274. * @param yAxis defines the node hierarchy used to render the y-axis
  50275. * @param zAxis defines the node hierarchy used to render the z-axis
  50276. */
  50277. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50278. /**
  50279. * Force the viewer to update
  50280. * @param position defines the position of the viewer
  50281. * @param xaxis defines the x axis of the viewer
  50282. * @param yaxis defines the y axis of the viewer
  50283. * @param zaxis defines the z axis of the viewer
  50284. */
  50285. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50286. /**
  50287. * Creates an instance of this axes viewer.
  50288. * @returns a new axes viewer with instanced meshes
  50289. */
  50290. createInstance(): AxesViewer;
  50291. /** Releases resources */
  50292. dispose(): void;
  50293. private static _SetRenderingGroupId;
  50294. }
  50295. }
  50296. declare module BABYLON.Debug {
  50297. /**
  50298. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50299. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50300. */
  50301. export class BoneAxesViewer extends AxesViewer {
  50302. /**
  50303. * Gets or sets the target mesh where to display the axes viewer
  50304. */
  50305. mesh: Nullable<Mesh>;
  50306. /**
  50307. * Gets or sets the target bone where to display the axes viewer
  50308. */
  50309. bone: Nullable<Bone>;
  50310. /** Gets current position */
  50311. pos: Vector3;
  50312. /** Gets direction of X axis */
  50313. xaxis: Vector3;
  50314. /** Gets direction of Y axis */
  50315. yaxis: Vector3;
  50316. /** Gets direction of Z axis */
  50317. zaxis: Vector3;
  50318. /**
  50319. * Creates a new BoneAxesViewer
  50320. * @param scene defines the hosting scene
  50321. * @param bone defines the target bone
  50322. * @param mesh defines the target mesh
  50323. * @param scaleLines defines a scaling factor for line length (1 by default)
  50324. */
  50325. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50326. /**
  50327. * Force the viewer to update
  50328. */
  50329. update(): void;
  50330. /** Releases resources */
  50331. dispose(): void;
  50332. }
  50333. }
  50334. declare module BABYLON {
  50335. /**
  50336. * Interface used to define scene explorer extensibility option
  50337. */
  50338. export interface IExplorerExtensibilityOption {
  50339. /**
  50340. * Define the option label
  50341. */
  50342. label: string;
  50343. /**
  50344. * Defines the action to execute on click
  50345. */
  50346. action: (entity: any) => void;
  50347. }
  50348. /**
  50349. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50350. */
  50351. export interface IExplorerExtensibilityGroup {
  50352. /**
  50353. * Defines a predicate to test if a given type mut be extended
  50354. */
  50355. predicate: (entity: any) => boolean;
  50356. /**
  50357. * Gets the list of options added to a type
  50358. */
  50359. entries: IExplorerExtensibilityOption[];
  50360. }
  50361. /**
  50362. * Interface used to define the options to use to create the Inspector
  50363. */
  50364. export interface IInspectorOptions {
  50365. /**
  50366. * Display in overlay mode (default: false)
  50367. */
  50368. overlay?: boolean;
  50369. /**
  50370. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50371. */
  50372. globalRoot?: HTMLElement;
  50373. /**
  50374. * Display the Scene explorer
  50375. */
  50376. showExplorer?: boolean;
  50377. /**
  50378. * Display the property inspector
  50379. */
  50380. showInspector?: boolean;
  50381. /**
  50382. * Display in embed mode (both panes on the right)
  50383. */
  50384. embedMode?: boolean;
  50385. /**
  50386. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50387. */
  50388. handleResize?: boolean;
  50389. /**
  50390. * Allow the panes to popup (default: true)
  50391. */
  50392. enablePopup?: boolean;
  50393. /**
  50394. * Allow the panes to be closed by users (default: true)
  50395. */
  50396. enableClose?: boolean;
  50397. /**
  50398. * Optional list of extensibility entries
  50399. */
  50400. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50401. /**
  50402. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50403. */
  50404. inspectorURL?: string;
  50405. /**
  50406. * Optional initial tab (default to DebugLayerTab.Properties)
  50407. */
  50408. initialTab?: DebugLayerTab;
  50409. }
  50410. interface Scene {
  50411. /**
  50412. * @hidden
  50413. * Backing field
  50414. */
  50415. _debugLayer: DebugLayer;
  50416. /**
  50417. * Gets the debug layer (aka Inspector) associated with the scene
  50418. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50419. */
  50420. debugLayer: DebugLayer;
  50421. }
  50422. /**
  50423. * Enum of inspector action tab
  50424. */
  50425. export enum DebugLayerTab {
  50426. /**
  50427. * Properties tag (default)
  50428. */
  50429. Properties = 0,
  50430. /**
  50431. * Debug tab
  50432. */
  50433. Debug = 1,
  50434. /**
  50435. * Statistics tab
  50436. */
  50437. Statistics = 2,
  50438. /**
  50439. * Tools tab
  50440. */
  50441. Tools = 3,
  50442. /**
  50443. * Settings tab
  50444. */
  50445. Settings = 4
  50446. }
  50447. /**
  50448. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50449. * what is happening in your scene
  50450. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50451. */
  50452. export class DebugLayer {
  50453. /**
  50454. * Define the url to get the inspector script from.
  50455. * By default it uses the babylonjs CDN.
  50456. * @ignoreNaming
  50457. */
  50458. static InspectorURL: string;
  50459. private _scene;
  50460. private BJSINSPECTOR;
  50461. private _onPropertyChangedObservable?;
  50462. /**
  50463. * Observable triggered when a property is changed through the inspector.
  50464. */
  50465. get onPropertyChangedObservable(): any;
  50466. /**
  50467. * Instantiates a new debug layer.
  50468. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50469. * what is happening in your scene
  50470. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50471. * @param scene Defines the scene to inspect
  50472. */
  50473. constructor(scene: Scene);
  50474. /** Creates the inspector window. */
  50475. private _createInspector;
  50476. /**
  50477. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50478. * @param entity defines the entity to select
  50479. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50480. */
  50481. select(entity: any, lineContainerTitles?: string | string[]): void;
  50482. /** Get the inspector from bundle or global */
  50483. private _getGlobalInspector;
  50484. /**
  50485. * Get if the inspector is visible or not.
  50486. * @returns true if visible otherwise, false
  50487. */
  50488. isVisible(): boolean;
  50489. /**
  50490. * Hide the inspector and close its window.
  50491. */
  50492. hide(): void;
  50493. /**
  50494. * Update the scene in the inspector
  50495. */
  50496. setAsActiveScene(): void;
  50497. /**
  50498. * Launch the debugLayer.
  50499. * @param config Define the configuration of the inspector
  50500. * @return a promise fulfilled when the debug layer is visible
  50501. */
  50502. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50503. }
  50504. }
  50505. declare module BABYLON {
  50506. /**
  50507. * Class containing static functions to help procedurally build meshes
  50508. */
  50509. export class BoxBuilder {
  50510. /**
  50511. * Creates a box mesh
  50512. * * The parameter `size` sets the size (float) of each box side (default 1)
  50513. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50514. * * 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)
  50515. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50517. * * 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
  50518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50519. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50520. * @param name defines the name of the mesh
  50521. * @param options defines the options used to create the mesh
  50522. * @param scene defines the hosting scene
  50523. * @returns the box mesh
  50524. */
  50525. static CreateBox(name: string, options: {
  50526. size?: number;
  50527. width?: number;
  50528. height?: number;
  50529. depth?: number;
  50530. faceUV?: Vector4[];
  50531. faceColors?: Color4[];
  50532. sideOrientation?: number;
  50533. frontUVs?: Vector4;
  50534. backUVs?: Vector4;
  50535. wrap?: boolean;
  50536. topBaseAt?: number;
  50537. bottomBaseAt?: number;
  50538. updatable?: boolean;
  50539. }, scene?: Nullable<Scene>): Mesh;
  50540. }
  50541. }
  50542. declare module BABYLON.Debug {
  50543. /**
  50544. * Used to show the physics impostor around the specific mesh
  50545. */
  50546. export class PhysicsViewer {
  50547. /** @hidden */
  50548. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50549. /** @hidden */
  50550. protected _meshes: Array<Nullable<AbstractMesh>>;
  50551. /** @hidden */
  50552. protected _scene: Nullable<Scene>;
  50553. /** @hidden */
  50554. protected _numMeshes: number;
  50555. /** @hidden */
  50556. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50557. private _renderFunction;
  50558. private _utilityLayer;
  50559. private _debugBoxMesh;
  50560. private _debugSphereMesh;
  50561. private _debugCylinderMesh;
  50562. private _debugMaterial;
  50563. private _debugMeshMeshes;
  50564. /**
  50565. * Creates a new PhysicsViewer
  50566. * @param scene defines the hosting scene
  50567. */
  50568. constructor(scene: Scene);
  50569. /** @hidden */
  50570. protected _updateDebugMeshes(): void;
  50571. /**
  50572. * Renders a specified physic impostor
  50573. * @param impostor defines the impostor to render
  50574. * @param targetMesh defines the mesh represented by the impostor
  50575. * @returns the new debug mesh used to render the impostor
  50576. */
  50577. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50578. /**
  50579. * Hides a specified physic impostor
  50580. * @param impostor defines the impostor to hide
  50581. */
  50582. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50583. private _getDebugMaterial;
  50584. private _getDebugBoxMesh;
  50585. private _getDebugSphereMesh;
  50586. private _getDebugCylinderMesh;
  50587. private _getDebugMeshMesh;
  50588. private _getDebugMesh;
  50589. /** Releases all resources */
  50590. dispose(): void;
  50591. }
  50592. }
  50593. declare module BABYLON {
  50594. /**
  50595. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50596. * in order to better appreciate the issue one might have.
  50597. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50598. */
  50599. export class RayHelper {
  50600. /**
  50601. * Defines the ray we are currently tryin to visualize.
  50602. */
  50603. ray: Nullable<Ray>;
  50604. private _renderPoints;
  50605. private _renderLine;
  50606. private _renderFunction;
  50607. private _scene;
  50608. private _updateToMeshFunction;
  50609. private _attachedToMesh;
  50610. private _meshSpaceDirection;
  50611. private _meshSpaceOrigin;
  50612. /**
  50613. * Helper function to create a colored helper in a scene in one line.
  50614. * @param ray Defines the ray we are currently tryin to visualize
  50615. * @param scene Defines the scene the ray is used in
  50616. * @param color Defines the color we want to see the ray in
  50617. * @returns The newly created ray helper.
  50618. */
  50619. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50620. /**
  50621. * Instantiate a new ray helper.
  50622. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50623. * in order to better appreciate the issue one might have.
  50624. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50625. * @param ray Defines the ray we are currently tryin to visualize
  50626. */
  50627. constructor(ray: Ray);
  50628. /**
  50629. * Shows the ray we are willing to debug.
  50630. * @param scene Defines the scene the ray needs to be rendered in
  50631. * @param color Defines the color the ray needs to be rendered in
  50632. */
  50633. show(scene: Scene, color?: Color3): void;
  50634. /**
  50635. * Hides the ray we are debugging.
  50636. */
  50637. hide(): void;
  50638. private _render;
  50639. /**
  50640. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50641. * @param mesh Defines the mesh we want the helper attached to
  50642. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50643. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50644. * @param length Defines the length of the ray
  50645. */
  50646. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50647. /**
  50648. * Detach the ray helper from the mesh it has previously been attached to.
  50649. */
  50650. detachFromMesh(): void;
  50651. private _updateToMesh;
  50652. /**
  50653. * Dispose the helper and release its associated resources.
  50654. */
  50655. dispose(): void;
  50656. }
  50657. }
  50658. declare module BABYLON.Debug {
  50659. /**
  50660. * Class used to render a debug view of a given skeleton
  50661. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50662. */
  50663. export class SkeletonViewer {
  50664. /** defines the skeleton to render */
  50665. skeleton: Skeleton;
  50666. /** defines the mesh attached to the skeleton */
  50667. mesh: AbstractMesh;
  50668. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50669. autoUpdateBonesMatrices: boolean;
  50670. /** defines the rendering group id to use with the viewer */
  50671. renderingGroupId: number;
  50672. /** Gets or sets the color used to render the skeleton */
  50673. color: Color3;
  50674. private _scene;
  50675. private _debugLines;
  50676. private _debugMesh;
  50677. private _isEnabled;
  50678. private _renderFunction;
  50679. private _utilityLayer;
  50680. /**
  50681. * Returns the mesh used to render the bones
  50682. */
  50683. get debugMesh(): Nullable<LinesMesh>;
  50684. /**
  50685. * Creates a new SkeletonViewer
  50686. * @param skeleton defines the skeleton to render
  50687. * @param mesh defines the mesh attached to the skeleton
  50688. * @param scene defines the hosting scene
  50689. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50690. * @param renderingGroupId defines the rendering group id to use with the viewer
  50691. */
  50692. constructor(
  50693. /** defines the skeleton to render */
  50694. skeleton: Skeleton,
  50695. /** defines the mesh attached to the skeleton */
  50696. mesh: AbstractMesh, scene: Scene,
  50697. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50698. autoUpdateBonesMatrices?: boolean,
  50699. /** defines the rendering group id to use with the viewer */
  50700. renderingGroupId?: number);
  50701. /** Gets or sets a boolean indicating if the viewer is enabled */
  50702. set isEnabled(value: boolean);
  50703. get isEnabled(): boolean;
  50704. private _getBonePosition;
  50705. private _getLinesForBonesWithLength;
  50706. private _getLinesForBonesNoLength;
  50707. /** Update the viewer to sync with current skeleton state */
  50708. update(): void;
  50709. /** Release associated resources */
  50710. dispose(): void;
  50711. }
  50712. }
  50713. declare module BABYLON {
  50714. /**
  50715. * Enum for Device Types
  50716. */
  50717. export enum DeviceType {
  50718. /** Generic */
  50719. Generic = 0,
  50720. /** Keyboard */
  50721. Keyboard = 1,
  50722. /** Mouse */
  50723. Mouse = 2,
  50724. /** Touch Pointers */
  50725. Touch = 3,
  50726. /** PS4 Dual Shock */
  50727. DualShock = 4,
  50728. /** Xbox */
  50729. Xbox = 5,
  50730. /** Switch Controller */
  50731. Switch = 6
  50732. }
  50733. /**
  50734. * Enum for All Pointers (Touch/Mouse)
  50735. */
  50736. export enum PointerInput {
  50737. /** Horizontal Axis */
  50738. Horizontal = 0,
  50739. /** Vertical Axis */
  50740. Vertical = 1,
  50741. /** Left Click or Touch */
  50742. LeftClick = 2,
  50743. /** Middle Click */
  50744. MiddleClick = 3,
  50745. /** Right Click */
  50746. RightClick = 4,
  50747. /** Browser Back */
  50748. BrowserBack = 5,
  50749. /** Browser Forward */
  50750. BrowserForward = 6
  50751. }
  50752. /**
  50753. * Enum for Dual Shock Gamepad
  50754. */
  50755. export enum DualShockInput {
  50756. /** Cross */
  50757. Cross = 0,
  50758. /** Circle */
  50759. Circle = 1,
  50760. /** Square */
  50761. Square = 2,
  50762. /** Triangle */
  50763. Triangle = 3,
  50764. /** L1 */
  50765. L1 = 4,
  50766. /** R1 */
  50767. R1 = 5,
  50768. /** L2 */
  50769. L2 = 6,
  50770. /** R2 */
  50771. R2 = 7,
  50772. /** Share */
  50773. Share = 8,
  50774. /** Options */
  50775. Options = 9,
  50776. /** L3 */
  50777. L3 = 10,
  50778. /** R3 */
  50779. R3 = 11,
  50780. /** DPadUp */
  50781. DPadUp = 12,
  50782. /** DPadDown */
  50783. DPadDown = 13,
  50784. /** DPadLeft */
  50785. DPadLeft = 14,
  50786. /** DRight */
  50787. DPadRight = 15,
  50788. /** Home */
  50789. Home = 16,
  50790. /** TouchPad */
  50791. TouchPad = 17,
  50792. /** LStickXAxis */
  50793. LStickXAxis = 18,
  50794. /** LStickYAxis */
  50795. LStickYAxis = 19,
  50796. /** RStickXAxis */
  50797. RStickXAxis = 20,
  50798. /** RStickYAxis */
  50799. RStickYAxis = 21
  50800. }
  50801. /**
  50802. * Enum for Xbox Gamepad
  50803. */
  50804. export enum XboxInput {
  50805. /** A */
  50806. A = 0,
  50807. /** B */
  50808. B = 1,
  50809. /** X */
  50810. X = 2,
  50811. /** Y */
  50812. Y = 3,
  50813. /** LB */
  50814. LB = 4,
  50815. /** RB */
  50816. RB = 5,
  50817. /** LT */
  50818. LT = 6,
  50819. /** RT */
  50820. RT = 7,
  50821. /** Back */
  50822. Back = 8,
  50823. /** Start */
  50824. Start = 9,
  50825. /** LS */
  50826. LS = 10,
  50827. /** RS */
  50828. RS = 11,
  50829. /** DPadUp */
  50830. DPadUp = 12,
  50831. /** DPadDown */
  50832. DPadDown = 13,
  50833. /** DPadLeft */
  50834. DPadLeft = 14,
  50835. /** DRight */
  50836. DPadRight = 15,
  50837. /** Home */
  50838. Home = 16,
  50839. /** LStickXAxis */
  50840. LStickXAxis = 17,
  50841. /** LStickYAxis */
  50842. LStickYAxis = 18,
  50843. /** RStickXAxis */
  50844. RStickXAxis = 19,
  50845. /** RStickYAxis */
  50846. RStickYAxis = 20
  50847. }
  50848. /**
  50849. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50850. */
  50851. export enum SwitchInput {
  50852. /** B */
  50853. B = 0,
  50854. /** A */
  50855. A = 1,
  50856. /** Y */
  50857. Y = 2,
  50858. /** X */
  50859. X = 3,
  50860. /** L */
  50861. L = 4,
  50862. /** R */
  50863. R = 5,
  50864. /** ZL */
  50865. ZL = 6,
  50866. /** ZR */
  50867. ZR = 7,
  50868. /** Minus */
  50869. Minus = 8,
  50870. /** Plus */
  50871. Plus = 9,
  50872. /** LS */
  50873. LS = 10,
  50874. /** RS */
  50875. RS = 11,
  50876. /** DPadUp */
  50877. DPadUp = 12,
  50878. /** DPadDown */
  50879. DPadDown = 13,
  50880. /** DPadLeft */
  50881. DPadLeft = 14,
  50882. /** DRight */
  50883. DPadRight = 15,
  50884. /** Home */
  50885. Home = 16,
  50886. /** Capture */
  50887. Capture = 17,
  50888. /** LStickXAxis */
  50889. LStickXAxis = 18,
  50890. /** LStickYAxis */
  50891. LStickYAxis = 19,
  50892. /** RStickXAxis */
  50893. RStickXAxis = 20,
  50894. /** RStickYAxis */
  50895. RStickYAxis = 21
  50896. }
  50897. }
  50898. declare module BABYLON {
  50899. /**
  50900. * This class will take all inputs from Keyboard, Pointer, and
  50901. * any Gamepads and provide a polling system that all devices
  50902. * will use. This class assumes that there will only be one
  50903. * pointer device and one keyboard.
  50904. */
  50905. export class DeviceInputSystem implements IDisposable {
  50906. /**
  50907. * Callback to be triggered when a device is connected
  50908. */
  50909. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50910. /**
  50911. * Callback to be triggered when a device is disconnected
  50912. */
  50913. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50914. /**
  50915. * Callback to be triggered when event driven input is updated
  50916. */
  50917. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50918. private _inputs;
  50919. private _gamepads;
  50920. private _keyboardActive;
  50921. private _pointerActive;
  50922. private _elementToAttachTo;
  50923. private _keyboardDownEvent;
  50924. private _keyboardUpEvent;
  50925. private _pointerMoveEvent;
  50926. private _pointerDownEvent;
  50927. private _pointerUpEvent;
  50928. private _gamepadConnectedEvent;
  50929. private _gamepadDisconnectedEvent;
  50930. private static _MAX_KEYCODES;
  50931. private static _MAX_POINTER_INPUTS;
  50932. private constructor();
  50933. /**
  50934. * Creates a new DeviceInputSystem instance
  50935. * @param engine Engine to pull input element from
  50936. * @returns The new instance
  50937. */
  50938. static Create(engine: Engine): DeviceInputSystem;
  50939. /**
  50940. * Checks for current device input value, given an id and input index
  50941. * @param deviceName Id of connected device
  50942. * @param inputIndex Index of device input
  50943. * @returns Current value of input
  50944. */
  50945. /**
  50946. * Checks for current device input value, given an id and input index
  50947. * @param deviceType Enum specifiying device type
  50948. * @param deviceSlot "Slot" or index that device is referenced in
  50949. * @param inputIndex Id of input to be checked
  50950. * @returns Current value of input
  50951. */
  50952. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50953. /**
  50954. * Dispose of all the eventlisteners
  50955. */
  50956. dispose(): void;
  50957. /**
  50958. * Add device and inputs to device array
  50959. * @param deviceType Enum specifiying device type
  50960. * @param deviceSlot "Slot" or index that device is referenced in
  50961. * @param numberOfInputs Number of input entries to create for given device
  50962. */
  50963. private _registerDevice;
  50964. /**
  50965. * Given a specific device name, remove that device from the device map
  50966. * @param deviceType Enum specifiying device type
  50967. * @param deviceSlot "Slot" or index that device is referenced in
  50968. */
  50969. private _unregisterDevice;
  50970. /**
  50971. * Handle all actions that come from keyboard interaction
  50972. */
  50973. private _handleKeyActions;
  50974. /**
  50975. * Handle all actions that come from pointer interaction
  50976. */
  50977. private _handlePointerActions;
  50978. /**
  50979. * Handle all actions that come from gamepad interaction
  50980. */
  50981. private _handleGamepadActions;
  50982. /**
  50983. * Update all non-event based devices with each frame
  50984. * @param deviceType Enum specifiying device type
  50985. * @param deviceSlot "Slot" or index that device is referenced in
  50986. * @param inputIndex Id of input to be checked
  50987. */
  50988. private _updateDevice;
  50989. /**
  50990. * Gets DeviceType from the device name
  50991. * @param deviceName Name of Device from DeviceInputSystem
  50992. * @returns DeviceType enum value
  50993. */
  50994. private _getGamepadDeviceType;
  50995. }
  50996. }
  50997. declare module BABYLON {
  50998. /**
  50999. * Type to handle enforcement of inputs
  51000. */
  51001. 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;
  51002. }
  51003. declare module BABYLON {
  51004. /**
  51005. * Class that handles all input for a specific device
  51006. */
  51007. export class DeviceSource<T extends DeviceType> {
  51008. /** Type of device */
  51009. readonly deviceType: DeviceType;
  51010. /** "Slot" or index that device is referenced in */
  51011. readonly deviceSlot: number;
  51012. /**
  51013. * Observable to handle device input changes per device
  51014. */
  51015. readonly onInputChangedObservable: Observable<{
  51016. inputIndex: DeviceInput<T>;
  51017. previousState: Nullable<number>;
  51018. currentState: Nullable<number>;
  51019. }>;
  51020. private readonly _deviceInputSystem;
  51021. /**
  51022. * Default Constructor
  51023. * @param deviceInputSystem Reference to DeviceInputSystem
  51024. * @param deviceType Type of device
  51025. * @param deviceSlot "Slot" or index that device is referenced in
  51026. */
  51027. constructor(deviceInputSystem: DeviceInputSystem,
  51028. /** Type of device */
  51029. deviceType: DeviceType,
  51030. /** "Slot" or index that device is referenced in */
  51031. deviceSlot?: number);
  51032. /**
  51033. * Get input for specific input
  51034. * @param inputIndex index of specific input on device
  51035. * @returns Input value from DeviceInputSystem
  51036. */
  51037. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51038. }
  51039. /**
  51040. * Class to keep track of devices
  51041. */
  51042. export class DeviceSourceManager implements IDisposable {
  51043. /**
  51044. * Observable to be triggered when before a device is connected
  51045. */
  51046. readonly onBeforeDeviceConnectedObservable: Observable<{
  51047. deviceType: DeviceType;
  51048. deviceSlot: number;
  51049. }>;
  51050. /**
  51051. * Observable to be triggered when before a device is disconnected
  51052. */
  51053. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51054. deviceType: DeviceType;
  51055. deviceSlot: number;
  51056. }>;
  51057. /**
  51058. * Observable to be triggered when after a device is connected
  51059. */
  51060. readonly onAfterDeviceConnectedObservable: Observable<{
  51061. deviceType: DeviceType;
  51062. deviceSlot: number;
  51063. }>;
  51064. /**
  51065. * Observable to be triggered when after a device is disconnected
  51066. */
  51067. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51068. deviceType: DeviceType;
  51069. deviceSlot: number;
  51070. }>;
  51071. private readonly _devices;
  51072. private readonly _firstDevice;
  51073. private readonly _deviceInputSystem;
  51074. /**
  51075. * Default Constructor
  51076. * @param engine engine to pull input element from
  51077. */
  51078. constructor(engine: Engine);
  51079. /**
  51080. * Gets a DeviceSource, given a type and slot
  51081. * @param deviceType Enum specifying device type
  51082. * @param deviceSlot "Slot" or index that device is referenced in
  51083. * @returns DeviceSource object
  51084. */
  51085. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51086. /**
  51087. * Gets an array of DeviceSource objects for a given device type
  51088. * @param deviceType Enum specifying device type
  51089. * @returns Array of DeviceSource objects
  51090. */
  51091. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51092. /**
  51093. * Dispose of DeviceInputSystem and other parts
  51094. */
  51095. dispose(): void;
  51096. /**
  51097. * Function to add device name to device list
  51098. * @param deviceType Enum specifying device type
  51099. * @param deviceSlot "Slot" or index that device is referenced in
  51100. */
  51101. private _addDevice;
  51102. /**
  51103. * Function to remove device name to device list
  51104. * @param deviceType Enum specifying device type
  51105. * @param deviceSlot "Slot" or index that device is referenced in
  51106. */
  51107. private _removeDevice;
  51108. /**
  51109. * Updates array storing first connected device of each type
  51110. * @param type Type of Device
  51111. */
  51112. private _updateFirstDevices;
  51113. }
  51114. }
  51115. declare module BABYLON {
  51116. /**
  51117. * Options to create the null engine
  51118. */
  51119. export class NullEngineOptions {
  51120. /**
  51121. * Render width (Default: 512)
  51122. */
  51123. renderWidth: number;
  51124. /**
  51125. * Render height (Default: 256)
  51126. */
  51127. renderHeight: number;
  51128. /**
  51129. * Texture size (Default: 512)
  51130. */
  51131. textureSize: number;
  51132. /**
  51133. * If delta time between frames should be constant
  51134. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51135. */
  51136. deterministicLockstep: boolean;
  51137. /**
  51138. * Maximum about of steps between frames (Default: 4)
  51139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51140. */
  51141. lockstepMaxSteps: number;
  51142. /**
  51143. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51144. */
  51145. useHighPrecisionMatrix?: boolean;
  51146. }
  51147. /**
  51148. * The null engine class provides support for headless version of babylon.js.
  51149. * This can be used in server side scenario or for testing purposes
  51150. */
  51151. export class NullEngine extends Engine {
  51152. private _options;
  51153. /**
  51154. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51156. * @returns true if engine is in deterministic lock step mode
  51157. */
  51158. isDeterministicLockStep(): boolean;
  51159. /**
  51160. * Gets the max steps when engine is running in deterministic lock step
  51161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51162. * @returns the max steps
  51163. */
  51164. getLockstepMaxSteps(): number;
  51165. /**
  51166. * Gets the current hardware scaling level.
  51167. * By default the hardware scaling level is computed from the window device ratio.
  51168. * 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.
  51169. * @returns a number indicating the current hardware scaling level
  51170. */
  51171. getHardwareScalingLevel(): number;
  51172. constructor(options?: NullEngineOptions);
  51173. /**
  51174. * Creates a vertex buffer
  51175. * @param vertices the data for the vertex buffer
  51176. * @returns the new WebGL static buffer
  51177. */
  51178. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51179. /**
  51180. * Creates a new index buffer
  51181. * @param indices defines the content of the index buffer
  51182. * @param updatable defines if the index buffer must be updatable
  51183. * @returns a new webGL buffer
  51184. */
  51185. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51186. /**
  51187. * Clear the current render buffer or the current render target (if any is set up)
  51188. * @param color defines the color to use
  51189. * @param backBuffer defines if the back buffer must be cleared
  51190. * @param depth defines if the depth buffer must be cleared
  51191. * @param stencil defines if the stencil buffer must be cleared
  51192. */
  51193. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51194. /**
  51195. * Gets the current render width
  51196. * @param useScreen defines if screen size must be used (or the current render target if any)
  51197. * @returns a number defining the current render width
  51198. */
  51199. getRenderWidth(useScreen?: boolean): number;
  51200. /**
  51201. * Gets the current render height
  51202. * @param useScreen defines if screen size must be used (or the current render target if any)
  51203. * @returns a number defining the current render height
  51204. */
  51205. getRenderHeight(useScreen?: boolean): number;
  51206. /**
  51207. * Set the WebGL's viewport
  51208. * @param viewport defines the viewport element to be used
  51209. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51210. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51211. */
  51212. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51213. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51214. /**
  51215. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51216. * @param pipelineContext defines the pipeline context to use
  51217. * @param uniformsNames defines the list of uniform names
  51218. * @returns an array of webGL uniform locations
  51219. */
  51220. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51221. /**
  51222. * Gets the lsit of active attributes for a given webGL program
  51223. * @param pipelineContext defines the pipeline context to use
  51224. * @param attributesNames defines the list of attribute names to get
  51225. * @returns an array of indices indicating the offset of each attribute
  51226. */
  51227. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51228. /**
  51229. * Binds an effect to the webGL context
  51230. * @param effect defines the effect to bind
  51231. */
  51232. bindSamplers(effect: Effect): void;
  51233. /**
  51234. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51235. * @param effect defines the effect to activate
  51236. */
  51237. enableEffect(effect: Effect): void;
  51238. /**
  51239. * Set various states to the webGL context
  51240. * @param culling defines backface culling state
  51241. * @param zOffset defines the value to apply to zOffset (0 by default)
  51242. * @param force defines if states must be applied even if cache is up to date
  51243. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51244. */
  51245. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51246. /**
  51247. * Set the value of an uniform to an array of int32
  51248. * @param uniform defines the webGL uniform location where to store the value
  51249. * @param array defines the array of int32 to store
  51250. */
  51251. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51252. /**
  51253. * Set the value of an uniform to an array of int32 (stored as vec2)
  51254. * @param uniform defines the webGL uniform location where to store the value
  51255. * @param array defines the array of int32 to store
  51256. */
  51257. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51258. /**
  51259. * Set the value of an uniform to an array of int32 (stored as vec3)
  51260. * @param uniform defines the webGL uniform location where to store the value
  51261. * @param array defines the array of int32 to store
  51262. */
  51263. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51264. /**
  51265. * Set the value of an uniform to an array of int32 (stored as vec4)
  51266. * @param uniform defines the webGL uniform location where to store the value
  51267. * @param array defines the array of int32 to store
  51268. */
  51269. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51270. /**
  51271. * Set the value of an uniform to an array of float32
  51272. * @param uniform defines the webGL uniform location where to store the value
  51273. * @param array defines the array of float32 to store
  51274. */
  51275. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51276. /**
  51277. * Set the value of an uniform to an array of float32 (stored as vec2)
  51278. * @param uniform defines the webGL uniform location where to store the value
  51279. * @param array defines the array of float32 to store
  51280. */
  51281. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51282. /**
  51283. * Set the value of an uniform to an array of float32 (stored as vec3)
  51284. * @param uniform defines the webGL uniform location where to store the value
  51285. * @param array defines the array of float32 to store
  51286. */
  51287. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51288. /**
  51289. * Set the value of an uniform to an array of float32 (stored as vec4)
  51290. * @param uniform defines the webGL uniform location where to store the value
  51291. * @param array defines the array of float32 to store
  51292. */
  51293. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51294. /**
  51295. * Set the value of an uniform to an array of number
  51296. * @param uniform defines the webGL uniform location where to store the value
  51297. * @param array defines the array of number to store
  51298. */
  51299. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51300. /**
  51301. * Set the value of an uniform to an array of number (stored as vec2)
  51302. * @param uniform defines the webGL uniform location where to store the value
  51303. * @param array defines the array of number to store
  51304. */
  51305. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51306. /**
  51307. * Set the value of an uniform to an array of number (stored as vec3)
  51308. * @param uniform defines the webGL uniform location where to store the value
  51309. * @param array defines the array of number to store
  51310. */
  51311. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51312. /**
  51313. * Set the value of an uniform to an array of number (stored as vec4)
  51314. * @param uniform defines the webGL uniform location where to store the value
  51315. * @param array defines the array of number to store
  51316. */
  51317. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51318. /**
  51319. * Set the value of an uniform to an array of float32 (stored as matrices)
  51320. * @param uniform defines the webGL uniform location where to store the value
  51321. * @param matrices defines the array of float32 to store
  51322. */
  51323. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51324. /**
  51325. * Set the value of an uniform to a matrix (3x3)
  51326. * @param uniform defines the webGL uniform location where to store the value
  51327. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51328. */
  51329. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51330. /**
  51331. * Set the value of an uniform to a matrix (2x2)
  51332. * @param uniform defines the webGL uniform location where to store the value
  51333. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51334. */
  51335. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51336. /**
  51337. * Set the value of an uniform to a number (float)
  51338. * @param uniform defines the webGL uniform location where to store the value
  51339. * @param value defines the float number to store
  51340. */
  51341. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51342. /**
  51343. * Set the value of an uniform to a vec2
  51344. * @param uniform defines the webGL uniform location where to store the value
  51345. * @param x defines the 1st component of the value
  51346. * @param y defines the 2nd component of the value
  51347. */
  51348. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51349. /**
  51350. * Set the value of an uniform to a vec3
  51351. * @param uniform defines the webGL uniform location where to store the value
  51352. * @param x defines the 1st component of the value
  51353. * @param y defines the 2nd component of the value
  51354. * @param z defines the 3rd component of the value
  51355. */
  51356. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51357. /**
  51358. * Set the value of an uniform to a boolean
  51359. * @param uniform defines the webGL uniform location where to store the value
  51360. * @param bool defines the boolean to store
  51361. */
  51362. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51363. /**
  51364. * Set the value of an uniform to a vec4
  51365. * @param uniform defines the webGL uniform location where to store the value
  51366. * @param x defines the 1st component of the value
  51367. * @param y defines the 2nd component of the value
  51368. * @param z defines the 3rd component of the value
  51369. * @param w defines the 4th component of the value
  51370. */
  51371. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51372. /**
  51373. * Sets the current alpha mode
  51374. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51375. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51376. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51377. */
  51378. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51379. /**
  51380. * Bind webGl buffers directly to the webGL context
  51381. * @param vertexBuffers defines the vertex buffer to bind
  51382. * @param indexBuffer defines the index buffer to bind
  51383. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51384. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51385. * @param effect defines the effect associated with the vertex buffer
  51386. */
  51387. bindBuffers(vertexBuffers: {
  51388. [key: string]: VertexBuffer;
  51389. }, indexBuffer: DataBuffer, effect: Effect): void;
  51390. /**
  51391. * Force the entire cache to be cleared
  51392. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51393. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51394. */
  51395. wipeCaches(bruteForce?: boolean): void;
  51396. /**
  51397. * Send a draw order
  51398. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51399. * @param indexStart defines the starting index
  51400. * @param indexCount defines the number of index to draw
  51401. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51402. */
  51403. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51404. /**
  51405. * Draw a list of indexed primitives
  51406. * @param fillMode defines the primitive to use
  51407. * @param indexStart defines the starting index
  51408. * @param indexCount defines the number of index to draw
  51409. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51410. */
  51411. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51412. /**
  51413. * Draw a list of unindexed primitives
  51414. * @param fillMode defines the primitive to use
  51415. * @param verticesStart defines the index of first vertex to draw
  51416. * @param verticesCount defines the count of vertices to draw
  51417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51418. */
  51419. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51420. /** @hidden */
  51421. _createTexture(): WebGLTexture;
  51422. /** @hidden */
  51423. _releaseTexture(texture: InternalTexture): void;
  51424. /**
  51425. * Usually called from Texture.ts.
  51426. * Passed information to create a WebGLTexture
  51427. * @param urlArg defines a value which contains one of the following:
  51428. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51429. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51430. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51431. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51432. * @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)
  51433. * @param scene needed for loading to the correct scene
  51434. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51435. * @param onLoad optional callback to be called upon successful completion
  51436. * @param onError optional callback to be called upon failure
  51437. * @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
  51438. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51439. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51440. * @param forcedExtension defines the extension to use to pick the right loader
  51441. * @param mimeType defines an optional mime type
  51442. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51443. */
  51444. 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;
  51445. /**
  51446. * Creates a new render target texture
  51447. * @param size defines the size of the texture
  51448. * @param options defines the options used to create the texture
  51449. * @returns a new render target texture stored in an InternalTexture
  51450. */
  51451. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51452. /**
  51453. * Update the sampling mode of a given texture
  51454. * @param samplingMode defines the required sampling mode
  51455. * @param texture defines the texture to update
  51456. */
  51457. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51458. /**
  51459. * Binds the frame buffer to the specified texture.
  51460. * @param texture The texture to render to or null for the default canvas
  51461. * @param faceIndex The face of the texture to render to in case of cube texture
  51462. * @param requiredWidth The width of the target to render to
  51463. * @param requiredHeight The height of the target to render to
  51464. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51465. * @param lodLevel defines le lod level to bind to the frame buffer
  51466. */
  51467. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51468. /**
  51469. * Unbind the current render target texture from the webGL context
  51470. * @param texture defines the render target texture to unbind
  51471. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51472. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51473. */
  51474. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51475. /**
  51476. * Creates a dynamic vertex buffer
  51477. * @param vertices the data for the dynamic vertex buffer
  51478. * @returns the new WebGL dynamic buffer
  51479. */
  51480. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51481. /**
  51482. * Update the content of a dynamic texture
  51483. * @param texture defines the texture to update
  51484. * @param canvas defines the canvas containing the source
  51485. * @param invertY defines if data must be stored with Y axis inverted
  51486. * @param premulAlpha defines if alpha is stored as premultiplied
  51487. * @param format defines the format of the data
  51488. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51489. */
  51490. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51491. /**
  51492. * Gets a boolean indicating if all created effects are ready
  51493. * @returns true if all effects are ready
  51494. */
  51495. areAllEffectsReady(): boolean;
  51496. /**
  51497. * @hidden
  51498. * Get the current error code of the webGL context
  51499. * @returns the error code
  51500. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51501. */
  51502. getError(): number;
  51503. /** @hidden */
  51504. _getUnpackAlignement(): number;
  51505. /** @hidden */
  51506. _unpackFlipY(value: boolean): void;
  51507. /**
  51508. * Update a dynamic index buffer
  51509. * @param indexBuffer defines the target index buffer
  51510. * @param indices defines the data to update
  51511. * @param offset defines the offset in the target index buffer where update should start
  51512. */
  51513. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51514. /**
  51515. * Updates a dynamic vertex buffer.
  51516. * @param vertexBuffer the vertex buffer to update
  51517. * @param vertices the data used to update the vertex buffer
  51518. * @param byteOffset the byte offset of the data (optional)
  51519. * @param byteLength the byte length of the data (optional)
  51520. */
  51521. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51522. /** @hidden */
  51523. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51524. /** @hidden */
  51525. _bindTexture(channel: number, texture: InternalTexture): void;
  51526. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51527. /**
  51528. * 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
  51529. */
  51530. releaseEffects(): void;
  51531. displayLoadingUI(): void;
  51532. hideLoadingUI(): void;
  51533. /** @hidden */
  51534. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51535. /** @hidden */
  51536. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51537. /** @hidden */
  51538. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51539. /** @hidden */
  51540. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51541. }
  51542. }
  51543. declare module BABYLON {
  51544. /**
  51545. * @hidden
  51546. **/
  51547. export class _TimeToken {
  51548. _startTimeQuery: Nullable<WebGLQuery>;
  51549. _endTimeQuery: Nullable<WebGLQuery>;
  51550. _timeElapsedQuery: Nullable<WebGLQuery>;
  51551. _timeElapsedQueryEnded: boolean;
  51552. }
  51553. }
  51554. declare module BABYLON {
  51555. /** @hidden */
  51556. export class _OcclusionDataStorage {
  51557. /** @hidden */
  51558. occlusionInternalRetryCounter: number;
  51559. /** @hidden */
  51560. isOcclusionQueryInProgress: boolean;
  51561. /** @hidden */
  51562. isOccluded: boolean;
  51563. /** @hidden */
  51564. occlusionRetryCount: number;
  51565. /** @hidden */
  51566. occlusionType: number;
  51567. /** @hidden */
  51568. occlusionQueryAlgorithmType: number;
  51569. }
  51570. interface Engine {
  51571. /**
  51572. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51573. * @return the new query
  51574. */
  51575. createQuery(): WebGLQuery;
  51576. /**
  51577. * Delete and release a webGL query
  51578. * @param query defines the query to delete
  51579. * @return the current engine
  51580. */
  51581. deleteQuery(query: WebGLQuery): Engine;
  51582. /**
  51583. * Check if a given query has resolved and got its value
  51584. * @param query defines the query to check
  51585. * @returns true if the query got its value
  51586. */
  51587. isQueryResultAvailable(query: WebGLQuery): boolean;
  51588. /**
  51589. * Gets the value of a given query
  51590. * @param query defines the query to check
  51591. * @returns the value of the query
  51592. */
  51593. getQueryResult(query: WebGLQuery): number;
  51594. /**
  51595. * Initiates an occlusion query
  51596. * @param algorithmType defines the algorithm to use
  51597. * @param query defines the query to use
  51598. * @returns the current engine
  51599. * @see https://doc.babylonjs.com/features/occlusionquery
  51600. */
  51601. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51602. /**
  51603. * Ends an occlusion query
  51604. * @see https://doc.babylonjs.com/features/occlusionquery
  51605. * @param algorithmType defines the algorithm to use
  51606. * @returns the current engine
  51607. */
  51608. endOcclusionQuery(algorithmType: number): Engine;
  51609. /**
  51610. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51611. * Please note that only one query can be issued at a time
  51612. * @returns a time token used to track the time span
  51613. */
  51614. startTimeQuery(): Nullable<_TimeToken>;
  51615. /**
  51616. * Ends a time query
  51617. * @param token defines the token used to measure the time span
  51618. * @returns the time spent (in ns)
  51619. */
  51620. endTimeQuery(token: _TimeToken): int;
  51621. /** @hidden */
  51622. _currentNonTimestampToken: Nullable<_TimeToken>;
  51623. /** @hidden */
  51624. _createTimeQuery(): WebGLQuery;
  51625. /** @hidden */
  51626. _deleteTimeQuery(query: WebGLQuery): void;
  51627. /** @hidden */
  51628. _getGlAlgorithmType(algorithmType: number): number;
  51629. /** @hidden */
  51630. _getTimeQueryResult(query: WebGLQuery): any;
  51631. /** @hidden */
  51632. _getTimeQueryAvailability(query: WebGLQuery): any;
  51633. }
  51634. interface AbstractMesh {
  51635. /**
  51636. * Backing filed
  51637. * @hidden
  51638. */
  51639. __occlusionDataStorage: _OcclusionDataStorage;
  51640. /**
  51641. * Access property
  51642. * @hidden
  51643. */
  51644. _occlusionDataStorage: _OcclusionDataStorage;
  51645. /**
  51646. * 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.
  51647. * The default value is -1 which means don't break the query and wait till the result
  51648. * @see https://doc.babylonjs.com/features/occlusionquery
  51649. */
  51650. occlusionRetryCount: number;
  51651. /**
  51652. * 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:
  51653. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51654. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51655. * * 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.
  51656. * @see https://doc.babylonjs.com/features/occlusionquery
  51657. */
  51658. occlusionType: number;
  51659. /**
  51660. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51661. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51662. * * 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.
  51663. * @see https://doc.babylonjs.com/features/occlusionquery
  51664. */
  51665. occlusionQueryAlgorithmType: number;
  51666. /**
  51667. * 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
  51668. * @see https://doc.babylonjs.com/features/occlusionquery
  51669. */
  51670. isOccluded: boolean;
  51671. /**
  51672. * Flag to check the progress status of the query
  51673. * @see https://doc.babylonjs.com/features/occlusionquery
  51674. */
  51675. isOcclusionQueryInProgress: boolean;
  51676. }
  51677. }
  51678. declare module BABYLON {
  51679. /** @hidden */
  51680. export var _forceTransformFeedbackToBundle: boolean;
  51681. interface Engine {
  51682. /**
  51683. * Creates a webGL transform feedback object
  51684. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51685. * @returns the webGL transform feedback object
  51686. */
  51687. createTransformFeedback(): WebGLTransformFeedback;
  51688. /**
  51689. * Delete a webGL transform feedback object
  51690. * @param value defines the webGL transform feedback object to delete
  51691. */
  51692. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51693. /**
  51694. * Bind a webGL transform feedback object to the webgl context
  51695. * @param value defines the webGL transform feedback object to bind
  51696. */
  51697. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51698. /**
  51699. * Begins a transform feedback operation
  51700. * @param usePoints defines if points or triangles must be used
  51701. */
  51702. beginTransformFeedback(usePoints: boolean): void;
  51703. /**
  51704. * Ends a transform feedback operation
  51705. */
  51706. endTransformFeedback(): void;
  51707. /**
  51708. * Specify the varyings to use with transform feedback
  51709. * @param program defines the associated webGL program
  51710. * @param value defines the list of strings representing the varying names
  51711. */
  51712. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51713. /**
  51714. * Bind a webGL buffer for a transform feedback operation
  51715. * @param value defines the webGL buffer to bind
  51716. */
  51717. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51718. }
  51719. }
  51720. declare module BABYLON {
  51721. /**
  51722. * Class used to define an additional view for the engine
  51723. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51724. */
  51725. export class EngineView {
  51726. /** Defines the canvas where to render the view */
  51727. target: HTMLCanvasElement;
  51728. /** Defines an optional camera used to render the view (will use active camera else) */
  51729. camera?: Camera;
  51730. }
  51731. interface Engine {
  51732. /**
  51733. * Gets or sets the HTML element to use for attaching events
  51734. */
  51735. inputElement: Nullable<HTMLElement>;
  51736. /**
  51737. * Gets the current engine view
  51738. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51739. */
  51740. activeView: Nullable<EngineView>;
  51741. /** Gets or sets the list of views */
  51742. views: EngineView[];
  51743. /**
  51744. * Register a new child canvas
  51745. * @param canvas defines the canvas to register
  51746. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51747. * @returns the associated view
  51748. */
  51749. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51750. /**
  51751. * Remove a registered child canvas
  51752. * @param canvas defines the canvas to remove
  51753. * @returns the current engine
  51754. */
  51755. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51756. }
  51757. }
  51758. declare module BABYLON {
  51759. interface Engine {
  51760. /** @hidden */
  51761. _excludedCompressedTextures: string[];
  51762. /** @hidden */
  51763. _textureFormatInUse: string;
  51764. /**
  51765. * Gets the list of texture formats supported
  51766. */
  51767. readonly texturesSupported: Array<string>;
  51768. /**
  51769. * Gets the texture format in use
  51770. */
  51771. readonly textureFormatInUse: Nullable<string>;
  51772. /**
  51773. * Set the compressed texture extensions or file names to skip.
  51774. *
  51775. * @param skippedFiles defines the list of those texture files you want to skip
  51776. * Example: [".dds", ".env", "myfile.png"]
  51777. */
  51778. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51779. /**
  51780. * Set the compressed texture format to use, based on the formats you have, and the formats
  51781. * supported by the hardware / browser.
  51782. *
  51783. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51784. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51785. * to API arguments needed to compressed textures. This puts the burden on the container
  51786. * generator to house the arcane code for determining these for current & future formats.
  51787. *
  51788. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51789. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51790. *
  51791. * Note: The result of this call is not taken into account when a texture is base64.
  51792. *
  51793. * @param formatsAvailable defines the list of those format families you have created
  51794. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51795. *
  51796. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51797. * @returns The extension selected.
  51798. */
  51799. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51800. }
  51801. }
  51802. declare module BABYLON {
  51803. /**
  51804. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51805. */
  51806. export interface CubeMapInfo {
  51807. /**
  51808. * The pixel array for the front face.
  51809. * This is stored in format, left to right, up to down format.
  51810. */
  51811. front: Nullable<ArrayBufferView>;
  51812. /**
  51813. * The pixel array for the back face.
  51814. * This is stored in format, left to right, up to down format.
  51815. */
  51816. back: Nullable<ArrayBufferView>;
  51817. /**
  51818. * The pixel array for the left face.
  51819. * This is stored in format, left to right, up to down format.
  51820. */
  51821. left: Nullable<ArrayBufferView>;
  51822. /**
  51823. * The pixel array for the right face.
  51824. * This is stored in format, left to right, up to down format.
  51825. */
  51826. right: Nullable<ArrayBufferView>;
  51827. /**
  51828. * The pixel array for the up face.
  51829. * This is stored in format, left to right, up to down format.
  51830. */
  51831. up: Nullable<ArrayBufferView>;
  51832. /**
  51833. * The pixel array for the down face.
  51834. * This is stored in format, left to right, up to down format.
  51835. */
  51836. down: Nullable<ArrayBufferView>;
  51837. /**
  51838. * The size of the cubemap stored.
  51839. *
  51840. * Each faces will be size * size pixels.
  51841. */
  51842. size: number;
  51843. /**
  51844. * The format of the texture.
  51845. *
  51846. * RGBA, RGB.
  51847. */
  51848. format: number;
  51849. /**
  51850. * The type of the texture data.
  51851. *
  51852. * UNSIGNED_INT, FLOAT.
  51853. */
  51854. type: number;
  51855. /**
  51856. * Specifies whether the texture is in gamma space.
  51857. */
  51858. gammaSpace: boolean;
  51859. }
  51860. /**
  51861. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51862. */
  51863. export class PanoramaToCubeMapTools {
  51864. private static FACE_LEFT;
  51865. private static FACE_RIGHT;
  51866. private static FACE_FRONT;
  51867. private static FACE_BACK;
  51868. private static FACE_DOWN;
  51869. private static FACE_UP;
  51870. /**
  51871. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51872. *
  51873. * @param float32Array The source data.
  51874. * @param inputWidth The width of the input panorama.
  51875. * @param inputHeight The height of the input panorama.
  51876. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51877. * @return The cubemap data
  51878. */
  51879. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51880. private static CreateCubemapTexture;
  51881. private static CalcProjectionSpherical;
  51882. }
  51883. }
  51884. declare module BABYLON {
  51885. /**
  51886. * Helper class dealing with the extraction of spherical polynomial dataArray
  51887. * from a cube map.
  51888. */
  51889. export class CubeMapToSphericalPolynomialTools {
  51890. private static FileFaces;
  51891. /**
  51892. * Converts a texture to the according Spherical Polynomial data.
  51893. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51894. *
  51895. * @param texture The texture to extract the information from.
  51896. * @return The Spherical Polynomial data.
  51897. */
  51898. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51899. /**
  51900. * Converts a cubemap to the according Spherical Polynomial data.
  51901. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51902. *
  51903. * @param cubeInfo The Cube map to extract the information from.
  51904. * @return The Spherical Polynomial data.
  51905. */
  51906. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51907. }
  51908. }
  51909. declare module BABYLON {
  51910. interface BaseTexture {
  51911. /**
  51912. * Get the polynomial representation of the texture data.
  51913. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51914. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51915. */
  51916. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51917. }
  51918. }
  51919. declare module BABYLON {
  51920. /** @hidden */
  51921. export var rgbdEncodePixelShader: {
  51922. name: string;
  51923. shader: string;
  51924. };
  51925. }
  51926. declare module BABYLON {
  51927. /** @hidden */
  51928. export var rgbdDecodePixelShader: {
  51929. name: string;
  51930. shader: string;
  51931. };
  51932. }
  51933. declare module BABYLON {
  51934. /**
  51935. * Raw texture data and descriptor sufficient for WebGL texture upload
  51936. */
  51937. export interface EnvironmentTextureInfo {
  51938. /**
  51939. * Version of the environment map
  51940. */
  51941. version: number;
  51942. /**
  51943. * Width of image
  51944. */
  51945. width: number;
  51946. /**
  51947. * Irradiance information stored in the file.
  51948. */
  51949. irradiance: any;
  51950. /**
  51951. * Specular information stored in the file.
  51952. */
  51953. specular: any;
  51954. }
  51955. /**
  51956. * Defines One Image in the file. It requires only the position in the file
  51957. * as well as the length.
  51958. */
  51959. interface BufferImageData {
  51960. /**
  51961. * Length of the image data.
  51962. */
  51963. length: number;
  51964. /**
  51965. * Position of the data from the null terminator delimiting the end of the JSON.
  51966. */
  51967. position: number;
  51968. }
  51969. /**
  51970. * Defines the specular data enclosed in the file.
  51971. * This corresponds to the version 1 of the data.
  51972. */
  51973. export interface EnvironmentTextureSpecularInfoV1 {
  51974. /**
  51975. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51976. */
  51977. specularDataPosition?: number;
  51978. /**
  51979. * This contains all the images data needed to reconstruct the cubemap.
  51980. */
  51981. mipmaps: Array<BufferImageData>;
  51982. /**
  51983. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51984. */
  51985. lodGenerationScale: number;
  51986. }
  51987. /**
  51988. * Sets of helpers addressing the serialization and deserialization of environment texture
  51989. * stored in a BabylonJS env file.
  51990. * Those files are usually stored as .env files.
  51991. */
  51992. export class EnvironmentTextureTools {
  51993. /**
  51994. * Magic number identifying the env file.
  51995. */
  51996. private static _MagicBytes;
  51997. /**
  51998. * Gets the environment info from an env file.
  51999. * @param data The array buffer containing the .env bytes.
  52000. * @returns the environment file info (the json header) if successfully parsed.
  52001. */
  52002. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52003. /**
  52004. * Creates an environment texture from a loaded cube texture.
  52005. * @param texture defines the cube texture to convert in env file
  52006. * @return a promise containing the environment data if succesfull.
  52007. */
  52008. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52009. /**
  52010. * Creates a JSON representation of the spherical data.
  52011. * @param texture defines the texture containing the polynomials
  52012. * @return the JSON representation of the spherical info
  52013. */
  52014. private static _CreateEnvTextureIrradiance;
  52015. /**
  52016. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52017. * @param data the image data
  52018. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52019. * @return the views described by info providing access to the underlying buffer
  52020. */
  52021. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52022. /**
  52023. * Uploads the texture info contained in the env file to the GPU.
  52024. * @param texture defines the internal texture to upload to
  52025. * @param data defines the data to load
  52026. * @param info defines the texture info retrieved through the GetEnvInfo method
  52027. * @returns a promise
  52028. */
  52029. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52030. private static _OnImageReadyAsync;
  52031. /**
  52032. * Uploads the levels of image data to the GPU.
  52033. * @param texture defines the internal texture to upload to
  52034. * @param imageData defines the array buffer views of image data [mipmap][face]
  52035. * @returns a promise
  52036. */
  52037. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52038. /**
  52039. * Uploads spherical polynomials information to the texture.
  52040. * @param texture defines the texture we are trying to upload the information to
  52041. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52042. */
  52043. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52044. /** @hidden */
  52045. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52046. }
  52047. }
  52048. declare module BABYLON {
  52049. /**
  52050. * Class used to inline functions in shader code
  52051. */
  52052. export class ShaderCodeInliner {
  52053. private static readonly _RegexpFindFunctionNameAndType;
  52054. private _sourceCode;
  52055. private _functionDescr;
  52056. private _numMaxIterations;
  52057. /** Gets or sets the token used to mark the functions to inline */
  52058. inlineToken: string;
  52059. /** Gets or sets the debug mode */
  52060. debug: boolean;
  52061. /** Gets the code after the inlining process */
  52062. get code(): string;
  52063. /**
  52064. * Initializes the inliner
  52065. * @param sourceCode shader code source to inline
  52066. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52067. */
  52068. constructor(sourceCode: string, numMaxIterations?: number);
  52069. /**
  52070. * Start the processing of the shader code
  52071. */
  52072. processCode(): void;
  52073. private _collectFunctions;
  52074. private _processInlining;
  52075. private _extractBetweenMarkers;
  52076. private _skipWhitespaces;
  52077. private _removeComments;
  52078. private _replaceFunctionCallsByCode;
  52079. private _findBackward;
  52080. private _escapeRegExp;
  52081. private _replaceNames;
  52082. }
  52083. }
  52084. declare module BABYLON {
  52085. /**
  52086. * Container for accessors for natively-stored mesh data buffers.
  52087. */
  52088. class NativeDataBuffer extends DataBuffer {
  52089. /**
  52090. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52091. */
  52092. nativeIndexBuffer?: any;
  52093. /**
  52094. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52095. */
  52096. nativeVertexBuffer?: any;
  52097. }
  52098. /** @hidden */
  52099. class NativeTexture extends InternalTexture {
  52100. getInternalTexture(): InternalTexture;
  52101. getViewCount(): number;
  52102. }
  52103. /** @hidden */
  52104. export class NativeEngine extends Engine {
  52105. private readonly _native;
  52106. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52107. private readonly INVALID_HANDLE;
  52108. getHardwareScalingLevel(): number;
  52109. constructor();
  52110. dispose(): void;
  52111. /**
  52112. * Can be used to override the current requestAnimationFrame requester.
  52113. * @hidden
  52114. */
  52115. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52116. /**
  52117. * Override default engine behavior.
  52118. * @param color
  52119. * @param backBuffer
  52120. * @param depth
  52121. * @param stencil
  52122. */
  52123. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52124. /**
  52125. * Gets host document
  52126. * @returns the host document object
  52127. */
  52128. getHostDocument(): Nullable<Document>;
  52129. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52130. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52131. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52132. recordVertexArrayObject(vertexBuffers: {
  52133. [key: string]: VertexBuffer;
  52134. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52135. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52136. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52137. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52138. /**
  52139. * Draw a list of indexed primitives
  52140. * @param fillMode defines the primitive to use
  52141. * @param indexStart defines the starting index
  52142. * @param indexCount defines the number of index to draw
  52143. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52144. */
  52145. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52146. /**
  52147. * Draw a list of unindexed primitives
  52148. * @param fillMode defines the primitive to use
  52149. * @param verticesStart defines the index of first vertex to draw
  52150. * @param verticesCount defines the count of vertices to draw
  52151. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52152. */
  52153. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52154. createPipelineContext(): IPipelineContext;
  52155. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52156. /** @hidden */
  52157. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52158. /** @hidden */
  52159. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52160. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52161. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52162. protected _setProgram(program: WebGLProgram): void;
  52163. _releaseEffect(effect: Effect): void;
  52164. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52165. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52166. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52167. bindSamplers(effect: Effect): void;
  52168. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52169. getRenderWidth(useScreen?: boolean): number;
  52170. getRenderHeight(useScreen?: boolean): number;
  52171. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52172. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52173. /**
  52174. * Set the z offset to apply to current rendering
  52175. * @param value defines the offset to apply
  52176. */
  52177. setZOffset(value: number): void;
  52178. /**
  52179. * Gets the current value of the zOffset
  52180. * @returns the current zOffset state
  52181. */
  52182. getZOffset(): number;
  52183. /**
  52184. * Enable or disable depth buffering
  52185. * @param enable defines the state to set
  52186. */
  52187. setDepthBuffer(enable: boolean): void;
  52188. /**
  52189. * Gets a boolean indicating if depth writing is enabled
  52190. * @returns the current depth writing state
  52191. */
  52192. getDepthWrite(): boolean;
  52193. /**
  52194. * Enable or disable depth writing
  52195. * @param enable defines the state to set
  52196. */
  52197. setDepthWrite(enable: boolean): void;
  52198. /**
  52199. * Enable or disable color writing
  52200. * @param enable defines the state to set
  52201. */
  52202. setColorWrite(enable: boolean): void;
  52203. /**
  52204. * Gets a boolean indicating if color writing is enabled
  52205. * @returns the current color writing state
  52206. */
  52207. getColorWrite(): boolean;
  52208. /**
  52209. * Sets alpha constants used by some alpha blending modes
  52210. * @param r defines the red component
  52211. * @param g defines the green component
  52212. * @param b defines the blue component
  52213. * @param a defines the alpha component
  52214. */
  52215. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52216. /**
  52217. * Sets the current alpha mode
  52218. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52219. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52220. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52221. */
  52222. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52223. /**
  52224. * Gets the current alpha mode
  52225. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52226. * @returns the current alpha mode
  52227. */
  52228. getAlphaMode(): number;
  52229. setInt(uniform: WebGLUniformLocation, int: number): void;
  52230. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52231. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52232. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52233. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52234. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52235. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52236. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52237. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52238. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52239. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52240. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52241. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52242. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52243. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52244. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52245. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52246. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52247. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52248. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52249. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52250. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52251. wipeCaches(bruteForce?: boolean): void;
  52252. _createTexture(): WebGLTexture;
  52253. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52254. /**
  52255. * Usually called from Texture.ts.
  52256. * Passed information to create a WebGLTexture
  52257. * @param url defines a value which contains one of the following:
  52258. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52259. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52260. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52261. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52262. * @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)
  52263. * @param scene needed for loading to the correct scene
  52264. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52265. * @param onLoad optional callback to be called upon successful completion
  52266. * @param onError optional callback to be called upon failure
  52267. * @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
  52268. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52269. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52270. * @param forcedExtension defines the extension to use to pick the right loader
  52271. * @param mimeType defines an optional mime type
  52272. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52273. */
  52274. 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;
  52275. /**
  52276. * Creates a cube texture
  52277. * @param rootUrl defines the url where the files to load is located
  52278. * @param scene defines the current scene
  52279. * @param files defines the list of files to load (1 per face)
  52280. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52281. * @param onLoad defines an optional callback raised when the texture is loaded
  52282. * @param onError defines an optional callback raised if there is an issue to load the texture
  52283. * @param format defines the format of the data
  52284. * @param forcedExtension defines the extension to use to pick the right loader
  52285. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52286. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52287. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52288. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52289. * @returns the cube texture as an InternalTexture
  52290. */
  52291. 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;
  52292. private _getSamplingFilter;
  52293. private static _GetNativeTextureFormat;
  52294. createRenderTargetTexture(size: number | {
  52295. width: number;
  52296. height: number;
  52297. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52298. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52299. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52300. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52301. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52302. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52303. /**
  52304. * Updates a dynamic vertex buffer.
  52305. * @param vertexBuffer the vertex buffer to update
  52306. * @param data the data used to update the vertex buffer
  52307. * @param byteOffset the byte offset of the data (optional)
  52308. * @param byteLength the byte length of the data (optional)
  52309. */
  52310. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52311. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52312. private _updateAnisotropicLevel;
  52313. private _getAddressMode;
  52314. /** @hidden */
  52315. _bindTexture(channel: number, texture: InternalTexture): void;
  52316. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52317. releaseEffects(): void;
  52318. /** @hidden */
  52319. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52320. /** @hidden */
  52321. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52322. /** @hidden */
  52323. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52324. /** @hidden */
  52325. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52326. }
  52327. }
  52328. declare module BABYLON {
  52329. /**
  52330. * Gather the list of clipboard event types as constants.
  52331. */
  52332. export class ClipboardEventTypes {
  52333. /**
  52334. * The clipboard event is fired when a copy command is active (pressed).
  52335. */
  52336. static readonly COPY: number;
  52337. /**
  52338. * The clipboard event is fired when a cut command is active (pressed).
  52339. */
  52340. static readonly CUT: number;
  52341. /**
  52342. * The clipboard event is fired when a paste command is active (pressed).
  52343. */
  52344. static readonly PASTE: number;
  52345. }
  52346. /**
  52347. * This class is used to store clipboard related info for the onClipboardObservable event.
  52348. */
  52349. export class ClipboardInfo {
  52350. /**
  52351. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52352. */
  52353. type: number;
  52354. /**
  52355. * Defines the related dom event
  52356. */
  52357. event: ClipboardEvent;
  52358. /**
  52359. *Creates an instance of ClipboardInfo.
  52360. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52361. * @param event Defines the related dom event
  52362. */
  52363. constructor(
  52364. /**
  52365. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52366. */
  52367. type: number,
  52368. /**
  52369. * Defines the related dom event
  52370. */
  52371. event: ClipboardEvent);
  52372. /**
  52373. * Get the clipboard event's type from the keycode.
  52374. * @param keyCode Defines the keyCode for the current keyboard event.
  52375. * @return {number}
  52376. */
  52377. static GetTypeFromCharacter(keyCode: number): number;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * Google Daydream controller
  52383. */
  52384. export class DaydreamController extends WebVRController {
  52385. /**
  52386. * Base Url for the controller model.
  52387. */
  52388. static MODEL_BASE_URL: string;
  52389. /**
  52390. * File name for the controller model.
  52391. */
  52392. static MODEL_FILENAME: string;
  52393. /**
  52394. * Gamepad Id prefix used to identify Daydream Controller.
  52395. */
  52396. static readonly GAMEPAD_ID_PREFIX: string;
  52397. /**
  52398. * Creates a new DaydreamController from a gamepad
  52399. * @param vrGamepad the gamepad that the controller should be created from
  52400. */
  52401. constructor(vrGamepad: any);
  52402. /**
  52403. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52404. * @param scene scene in which to add meshes
  52405. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52406. */
  52407. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52408. /**
  52409. * Called once for each button that changed state since the last frame
  52410. * @param buttonIdx Which button index changed
  52411. * @param state New state of the button
  52412. * @param changes Which properties on the state changed since last frame
  52413. */
  52414. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52415. }
  52416. }
  52417. declare module BABYLON {
  52418. /**
  52419. * Gear VR Controller
  52420. */
  52421. export class GearVRController extends WebVRController {
  52422. /**
  52423. * Base Url for the controller model.
  52424. */
  52425. static MODEL_BASE_URL: string;
  52426. /**
  52427. * File name for the controller model.
  52428. */
  52429. static MODEL_FILENAME: string;
  52430. /**
  52431. * Gamepad Id prefix used to identify this controller.
  52432. */
  52433. static readonly GAMEPAD_ID_PREFIX: string;
  52434. private readonly _buttonIndexToObservableNameMap;
  52435. /**
  52436. * Creates a new GearVRController from a gamepad
  52437. * @param vrGamepad the gamepad that the controller should be created from
  52438. */
  52439. constructor(vrGamepad: any);
  52440. /**
  52441. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52442. * @param scene scene in which to add meshes
  52443. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52444. */
  52445. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52446. /**
  52447. * Called once for each button that changed state since the last frame
  52448. * @param buttonIdx Which button index changed
  52449. * @param state New state of the button
  52450. * @param changes Which properties on the state changed since last frame
  52451. */
  52452. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52453. }
  52454. }
  52455. declare module BABYLON {
  52456. /**
  52457. * Generic Controller
  52458. */
  52459. export class GenericController extends WebVRController {
  52460. /**
  52461. * Base Url for the controller model.
  52462. */
  52463. static readonly MODEL_BASE_URL: string;
  52464. /**
  52465. * File name for the controller model.
  52466. */
  52467. static readonly MODEL_FILENAME: string;
  52468. /**
  52469. * Creates a new GenericController from a gamepad
  52470. * @param vrGamepad the gamepad that the controller should be created from
  52471. */
  52472. constructor(vrGamepad: any);
  52473. /**
  52474. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52475. * @param scene scene in which to add meshes
  52476. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52477. */
  52478. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52479. /**
  52480. * Called once for each button that changed state since the last frame
  52481. * @param buttonIdx Which button index changed
  52482. * @param state New state of the button
  52483. * @param changes Which properties on the state changed since last frame
  52484. */
  52485. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52486. }
  52487. }
  52488. declare module BABYLON {
  52489. /**
  52490. * Oculus Touch Controller
  52491. */
  52492. export class OculusTouchController extends WebVRController {
  52493. /**
  52494. * Base Url for the controller model.
  52495. */
  52496. static MODEL_BASE_URL: string;
  52497. /**
  52498. * File name for the left controller model.
  52499. */
  52500. static MODEL_LEFT_FILENAME: string;
  52501. /**
  52502. * File name for the right controller model.
  52503. */
  52504. static MODEL_RIGHT_FILENAME: string;
  52505. /**
  52506. * Base Url for the Quest controller model.
  52507. */
  52508. static QUEST_MODEL_BASE_URL: string;
  52509. /**
  52510. * @hidden
  52511. * If the controllers are running on a device that needs the updated Quest controller models
  52512. */
  52513. static _IsQuest: boolean;
  52514. /**
  52515. * Fired when the secondary trigger on this controller is modified
  52516. */
  52517. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52518. /**
  52519. * Fired when the thumb rest on this controller is modified
  52520. */
  52521. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52522. /**
  52523. * Creates a new OculusTouchController from a gamepad
  52524. * @param vrGamepad the gamepad that the controller should be created from
  52525. */
  52526. constructor(vrGamepad: any);
  52527. /**
  52528. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52529. * @param scene scene in which to add meshes
  52530. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52531. */
  52532. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52533. /**
  52534. * Fired when the A button on this controller is modified
  52535. */
  52536. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52537. /**
  52538. * Fired when the B button on this controller is modified
  52539. */
  52540. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52541. /**
  52542. * Fired when the X button on this controller is modified
  52543. */
  52544. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52545. /**
  52546. * Fired when the Y button on this controller is modified
  52547. */
  52548. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52549. /**
  52550. * Called once for each button that changed state since the last frame
  52551. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52552. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52553. * 2) secondary trigger (same)
  52554. * 3) A (right) X (left), touch, pressed = value
  52555. * 4) B / Y
  52556. * 5) thumb rest
  52557. * @param buttonIdx Which button index changed
  52558. * @param state New state of the button
  52559. * @param changes Which properties on the state changed since last frame
  52560. */
  52561. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52562. }
  52563. }
  52564. declare module BABYLON {
  52565. /**
  52566. * Vive Controller
  52567. */
  52568. export class ViveController extends WebVRController {
  52569. /**
  52570. * Base Url for the controller model.
  52571. */
  52572. static MODEL_BASE_URL: string;
  52573. /**
  52574. * File name for the controller model.
  52575. */
  52576. static MODEL_FILENAME: string;
  52577. /**
  52578. * Creates a new ViveController from a gamepad
  52579. * @param vrGamepad the gamepad that the controller should be created from
  52580. */
  52581. constructor(vrGamepad: any);
  52582. /**
  52583. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52584. * @param scene scene in which to add meshes
  52585. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52586. */
  52587. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52588. /**
  52589. * Fired when the left button on this controller is modified
  52590. */
  52591. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52592. /**
  52593. * Fired when the right button on this controller is modified
  52594. */
  52595. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52596. /**
  52597. * Fired when the menu button on this controller is modified
  52598. */
  52599. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52600. /**
  52601. * Called once for each button that changed state since the last frame
  52602. * Vive mapping:
  52603. * 0: touchpad
  52604. * 1: trigger
  52605. * 2: left AND right buttons
  52606. * 3: menu button
  52607. * @param buttonIdx Which button index changed
  52608. * @param state New state of the button
  52609. * @param changes Which properties on the state changed since last frame
  52610. */
  52611. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52612. }
  52613. }
  52614. declare module BABYLON {
  52615. /**
  52616. * Defines the WindowsMotionController object that the state of the windows motion controller
  52617. */
  52618. export class WindowsMotionController extends WebVRController {
  52619. /**
  52620. * The base url used to load the left and right controller models
  52621. */
  52622. static MODEL_BASE_URL: string;
  52623. /**
  52624. * The name of the left controller model file
  52625. */
  52626. static MODEL_LEFT_FILENAME: string;
  52627. /**
  52628. * The name of the right controller model file
  52629. */
  52630. static MODEL_RIGHT_FILENAME: string;
  52631. /**
  52632. * The controller name prefix for this controller type
  52633. */
  52634. static readonly GAMEPAD_ID_PREFIX: string;
  52635. /**
  52636. * The controller id pattern for this controller type
  52637. */
  52638. private static readonly GAMEPAD_ID_PATTERN;
  52639. private _loadedMeshInfo;
  52640. protected readonly _mapping: {
  52641. buttons: string[];
  52642. buttonMeshNames: {
  52643. trigger: string;
  52644. menu: string;
  52645. grip: string;
  52646. thumbstick: string;
  52647. trackpad: string;
  52648. };
  52649. buttonObservableNames: {
  52650. trigger: string;
  52651. menu: string;
  52652. grip: string;
  52653. thumbstick: string;
  52654. trackpad: string;
  52655. };
  52656. axisMeshNames: string[];
  52657. pointingPoseMeshName: string;
  52658. };
  52659. /**
  52660. * Fired when the trackpad on this controller is clicked
  52661. */
  52662. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52663. /**
  52664. * Fired when the trackpad on this controller is modified
  52665. */
  52666. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52667. /**
  52668. * The current x and y values of this controller's trackpad
  52669. */
  52670. trackpad: StickValues;
  52671. /**
  52672. * Creates a new WindowsMotionController from a gamepad
  52673. * @param vrGamepad the gamepad that the controller should be created from
  52674. */
  52675. constructor(vrGamepad: any);
  52676. /**
  52677. * Fired when the trigger on this controller is modified
  52678. */
  52679. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52680. /**
  52681. * Fired when the menu button on this controller is modified
  52682. */
  52683. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52684. /**
  52685. * Fired when the grip button on this controller is modified
  52686. */
  52687. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52688. /**
  52689. * Fired when the thumbstick button on this controller is modified
  52690. */
  52691. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52692. /**
  52693. * Fired when the touchpad button on this controller is modified
  52694. */
  52695. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52696. /**
  52697. * Fired when the touchpad values on this controller are modified
  52698. */
  52699. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52700. protected _updateTrackpad(): void;
  52701. /**
  52702. * Called once per frame by the engine.
  52703. */
  52704. update(): void;
  52705. /**
  52706. * Called once for each button that changed state since the last frame
  52707. * @param buttonIdx Which button index changed
  52708. * @param state New state of the button
  52709. * @param changes Which properties on the state changed since last frame
  52710. */
  52711. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52712. /**
  52713. * Moves the buttons on the controller mesh based on their current state
  52714. * @param buttonName the name of the button to move
  52715. * @param buttonValue the value of the button which determines the buttons new position
  52716. */
  52717. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52718. /**
  52719. * Moves the axis on the controller mesh based on its current state
  52720. * @param axis the index of the axis
  52721. * @param axisValue the value of the axis which determines the meshes new position
  52722. * @hidden
  52723. */
  52724. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52725. /**
  52726. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52727. * @param scene scene in which to add meshes
  52728. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52729. */
  52730. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52731. /**
  52732. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52733. * can be transformed by button presses and axes values, based on this._mapping.
  52734. *
  52735. * @param scene scene in which the meshes exist
  52736. * @param meshes list of meshes that make up the controller model to process
  52737. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52738. */
  52739. private processModel;
  52740. private createMeshInfo;
  52741. /**
  52742. * Gets the ray of the controller in the direction the controller is pointing
  52743. * @param length the length the resulting ray should be
  52744. * @returns a ray in the direction the controller is pointing
  52745. */
  52746. getForwardRay(length?: number): Ray;
  52747. /**
  52748. * Disposes of the controller
  52749. */
  52750. dispose(): void;
  52751. }
  52752. /**
  52753. * This class represents a new windows motion controller in XR.
  52754. */
  52755. export class XRWindowsMotionController extends WindowsMotionController {
  52756. /**
  52757. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52758. */
  52759. protected readonly _mapping: {
  52760. buttons: string[];
  52761. buttonMeshNames: {
  52762. trigger: string;
  52763. menu: string;
  52764. grip: string;
  52765. thumbstick: string;
  52766. trackpad: string;
  52767. };
  52768. buttonObservableNames: {
  52769. trigger: string;
  52770. menu: string;
  52771. grip: string;
  52772. thumbstick: string;
  52773. trackpad: string;
  52774. };
  52775. axisMeshNames: string[];
  52776. pointingPoseMeshName: string;
  52777. };
  52778. /**
  52779. * Construct a new XR-Based windows motion controller
  52780. *
  52781. * @param gamepadInfo the gamepad object from the browser
  52782. */
  52783. constructor(gamepadInfo: any);
  52784. /**
  52785. * holds the thumbstick values (X,Y)
  52786. */
  52787. thumbstickValues: StickValues;
  52788. /**
  52789. * Fired when the thumbstick on this controller is clicked
  52790. */
  52791. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52792. /**
  52793. * Fired when the thumbstick on this controller is modified
  52794. */
  52795. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52796. /**
  52797. * Fired when the touchpad button on this controller is modified
  52798. */
  52799. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52800. /**
  52801. * Fired when the touchpad values on this controller are modified
  52802. */
  52803. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52804. /**
  52805. * Fired when the thumbstick button on this controller is modified
  52806. * here to prevent breaking changes
  52807. */
  52808. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52809. /**
  52810. * updating the thumbstick(!) and not the trackpad.
  52811. * This is named this way due to the difference between WebVR and XR and to avoid
  52812. * changing the parent class.
  52813. */
  52814. protected _updateTrackpad(): void;
  52815. /**
  52816. * Disposes the class with joy
  52817. */
  52818. dispose(): void;
  52819. }
  52820. }
  52821. declare module BABYLON {
  52822. /**
  52823. * Class containing static functions to help procedurally build meshes
  52824. */
  52825. export class PolyhedronBuilder {
  52826. /**
  52827. * Creates a polyhedron mesh
  52828. * * 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
  52829. * * The parameter `size` (positive float, default 1) sets the polygon size
  52830. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52831. * * 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`
  52832. * * 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
  52833. * * 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)`)
  52834. * * 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
  52835. * * 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
  52836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52837. * * 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
  52838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52839. * @param name defines the name of the mesh
  52840. * @param options defines the options used to create the mesh
  52841. * @param scene defines the hosting scene
  52842. * @returns the polyhedron mesh
  52843. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52844. */
  52845. static CreatePolyhedron(name: string, options: {
  52846. type?: number;
  52847. size?: number;
  52848. sizeX?: number;
  52849. sizeY?: number;
  52850. sizeZ?: number;
  52851. custom?: any;
  52852. faceUV?: Vector4[];
  52853. faceColors?: Color4[];
  52854. flat?: boolean;
  52855. updatable?: boolean;
  52856. sideOrientation?: number;
  52857. frontUVs?: Vector4;
  52858. backUVs?: Vector4;
  52859. }, scene?: Nullable<Scene>): Mesh;
  52860. }
  52861. }
  52862. declare module BABYLON {
  52863. /**
  52864. * Gizmo that enables scaling a mesh along 3 axis
  52865. */
  52866. export class ScaleGizmo extends Gizmo {
  52867. /**
  52868. * Internal gizmo used for interactions on the x axis
  52869. */
  52870. xGizmo: AxisScaleGizmo;
  52871. /**
  52872. * Internal gizmo used for interactions on the y axis
  52873. */
  52874. yGizmo: AxisScaleGizmo;
  52875. /**
  52876. * Internal gizmo used for interactions on the z axis
  52877. */
  52878. zGizmo: AxisScaleGizmo;
  52879. /**
  52880. * Internal gizmo used to scale all axis equally
  52881. */
  52882. uniformScaleGizmo: AxisScaleGizmo;
  52883. private _meshAttached;
  52884. private _nodeAttached;
  52885. private _updateGizmoRotationToMatchAttachedMesh;
  52886. private _snapDistance;
  52887. private _scaleRatio;
  52888. private _uniformScalingMesh;
  52889. private _octahedron;
  52890. private _sensitivity;
  52891. /** Fires an event when any of it's sub gizmos are dragged */
  52892. onDragStartObservable: Observable<unknown>;
  52893. /** Fires an event when any of it's sub gizmos are released from dragging */
  52894. onDragEndObservable: Observable<unknown>;
  52895. get attachedMesh(): Nullable<AbstractMesh>;
  52896. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52897. get attachedNode(): Nullable<Node>;
  52898. set attachedNode(node: Nullable<Node>);
  52899. /**
  52900. * Creates a ScaleGizmo
  52901. * @param gizmoLayer The utility layer the gizmo will be added to
  52902. * @param thickness display gizmo axis thickness
  52903. */
  52904. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52905. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52906. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52907. /**
  52908. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52909. */
  52910. set snapDistance(value: number);
  52911. get snapDistance(): number;
  52912. /**
  52913. * Ratio for the scale of the gizmo (Default: 1)
  52914. */
  52915. set scaleRatio(value: number);
  52916. get scaleRatio(): number;
  52917. /**
  52918. * Sensitivity factor for dragging (Default: 1)
  52919. */
  52920. set sensitivity(value: number);
  52921. get sensitivity(): number;
  52922. /**
  52923. * Disposes of the gizmo
  52924. */
  52925. dispose(): void;
  52926. }
  52927. }
  52928. declare module BABYLON {
  52929. /**
  52930. * Single axis scale gizmo
  52931. */
  52932. export class AxisScaleGizmo extends Gizmo {
  52933. /**
  52934. * Drag behavior responsible for the gizmos dragging interactions
  52935. */
  52936. dragBehavior: PointerDragBehavior;
  52937. private _pointerObserver;
  52938. /**
  52939. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52940. */
  52941. snapDistance: number;
  52942. /**
  52943. * Event that fires each time the gizmo snaps to a new location.
  52944. * * snapDistance is the the change in distance
  52945. */
  52946. onSnapObservable: Observable<{
  52947. snapDistance: number;
  52948. }>;
  52949. /**
  52950. * If the scaling operation should be done on all axis (default: false)
  52951. */
  52952. uniformScaling: boolean;
  52953. /**
  52954. * Custom sensitivity value for the drag strength
  52955. */
  52956. sensitivity: number;
  52957. private _isEnabled;
  52958. private _parent;
  52959. private _arrow;
  52960. private _coloredMaterial;
  52961. private _hoverMaterial;
  52962. /**
  52963. * Creates an AxisScaleGizmo
  52964. * @param gizmoLayer The utility layer the gizmo will be added to
  52965. * @param dragAxis The axis which the gizmo will be able to scale on
  52966. * @param color The color of the gizmo
  52967. * @param thickness display gizmo axis thickness
  52968. */
  52969. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  52970. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52971. /**
  52972. * If the gizmo is enabled
  52973. */
  52974. set isEnabled(value: boolean);
  52975. get isEnabled(): boolean;
  52976. /**
  52977. * Disposes of the gizmo
  52978. */
  52979. dispose(): void;
  52980. /**
  52981. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52982. * @param mesh The mesh to replace the default mesh of the gizmo
  52983. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52984. */
  52985. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52986. }
  52987. }
  52988. declare module BABYLON {
  52989. /**
  52990. * Bounding box gizmo
  52991. */
  52992. export class BoundingBoxGizmo extends Gizmo {
  52993. private _lineBoundingBox;
  52994. private _rotateSpheresParent;
  52995. private _scaleBoxesParent;
  52996. private _boundingDimensions;
  52997. private _renderObserver;
  52998. private _pointerObserver;
  52999. private _scaleDragSpeed;
  53000. private _tmpQuaternion;
  53001. private _tmpVector;
  53002. private _tmpRotationMatrix;
  53003. /**
  53004. * 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)
  53005. */
  53006. ignoreChildren: boolean;
  53007. /**
  53008. * 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)
  53009. */
  53010. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53011. /**
  53012. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53013. */
  53014. rotationSphereSize: number;
  53015. /**
  53016. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53017. */
  53018. scaleBoxSize: number;
  53019. /**
  53020. * 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)
  53021. */
  53022. fixedDragMeshScreenSize: boolean;
  53023. /**
  53024. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53025. */
  53026. fixedDragMeshScreenSizeDistanceFactor: number;
  53027. /**
  53028. * Fired when a rotation sphere or scale box is dragged
  53029. */
  53030. onDragStartObservable: Observable<{}>;
  53031. /**
  53032. * Fired when a scale box is dragged
  53033. */
  53034. onScaleBoxDragObservable: Observable<{}>;
  53035. /**
  53036. * Fired when a scale box drag is ended
  53037. */
  53038. onScaleBoxDragEndObservable: Observable<{}>;
  53039. /**
  53040. * Fired when a rotation sphere is dragged
  53041. */
  53042. onRotationSphereDragObservable: Observable<{}>;
  53043. /**
  53044. * Fired when a rotation sphere drag is ended
  53045. */
  53046. onRotationSphereDragEndObservable: Observable<{}>;
  53047. /**
  53048. * 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)
  53049. */
  53050. scalePivot: Nullable<Vector3>;
  53051. /**
  53052. * Mesh used as a pivot to rotate the attached node
  53053. */
  53054. private _anchorMesh;
  53055. private _existingMeshScale;
  53056. private _dragMesh;
  53057. private pointerDragBehavior;
  53058. private coloredMaterial;
  53059. private hoverColoredMaterial;
  53060. /**
  53061. * Sets the color of the bounding box gizmo
  53062. * @param color the color to set
  53063. */
  53064. setColor(color: Color3): void;
  53065. /**
  53066. * Creates an BoundingBoxGizmo
  53067. * @param gizmoLayer The utility layer the gizmo will be added to
  53068. * @param color The color of the gizmo
  53069. */
  53070. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53071. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53072. private _selectNode;
  53073. /**
  53074. * Updates the bounding box information for the Gizmo
  53075. */
  53076. updateBoundingBox(): void;
  53077. private _updateRotationSpheres;
  53078. private _updateScaleBoxes;
  53079. /**
  53080. * Enables rotation on the specified axis and disables rotation on the others
  53081. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53082. */
  53083. setEnabledRotationAxis(axis: string): void;
  53084. /**
  53085. * Enables/disables scaling
  53086. * @param enable if scaling should be enabled
  53087. * @param homogeneousScaling defines if scaling should only be homogeneous
  53088. */
  53089. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53090. private _updateDummy;
  53091. /**
  53092. * Enables a pointer drag behavior on the bounding box of the gizmo
  53093. */
  53094. enableDragBehavior(): void;
  53095. /**
  53096. * Disposes of the gizmo
  53097. */
  53098. dispose(): void;
  53099. /**
  53100. * 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)
  53101. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53102. * @returns the bounding box mesh with the passed in mesh as a child
  53103. */
  53104. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53105. /**
  53106. * CustomMeshes are not supported by this gizmo
  53107. * @param mesh The mesh to replace the default mesh of the gizmo
  53108. */
  53109. setCustomMesh(mesh: Mesh): void;
  53110. }
  53111. }
  53112. declare module BABYLON {
  53113. /**
  53114. * Single plane rotation gizmo
  53115. */
  53116. export class PlaneRotationGizmo extends Gizmo {
  53117. /**
  53118. * Drag behavior responsible for the gizmos dragging interactions
  53119. */
  53120. dragBehavior: PointerDragBehavior;
  53121. private _pointerObserver;
  53122. /**
  53123. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53124. */
  53125. snapDistance: number;
  53126. /**
  53127. * Event that fires each time the gizmo snaps to a new location.
  53128. * * snapDistance is the the change in distance
  53129. */
  53130. onSnapObservable: Observable<{
  53131. snapDistance: number;
  53132. }>;
  53133. private _isEnabled;
  53134. private _parent;
  53135. /**
  53136. * Creates a PlaneRotationGizmo
  53137. * @param gizmoLayer The utility layer the gizmo will be added to
  53138. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53139. * @param color The color of the gizmo
  53140. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53141. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53142. * @param thickness display gizmo axis thickness
  53143. */
  53144. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53145. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53146. /**
  53147. * If the gizmo is enabled
  53148. */
  53149. set isEnabled(value: boolean);
  53150. get isEnabled(): boolean;
  53151. /**
  53152. * Disposes of the gizmo
  53153. */
  53154. dispose(): void;
  53155. }
  53156. }
  53157. declare module BABYLON {
  53158. /**
  53159. * Gizmo that enables rotating a mesh along 3 axis
  53160. */
  53161. export class RotationGizmo extends Gizmo {
  53162. /**
  53163. * Internal gizmo used for interactions on the x axis
  53164. */
  53165. xGizmo: PlaneRotationGizmo;
  53166. /**
  53167. * Internal gizmo used for interactions on the y axis
  53168. */
  53169. yGizmo: PlaneRotationGizmo;
  53170. /**
  53171. * Internal gizmo used for interactions on the z axis
  53172. */
  53173. zGizmo: PlaneRotationGizmo;
  53174. /** Fires an event when any of it's sub gizmos are dragged */
  53175. onDragStartObservable: Observable<unknown>;
  53176. /** Fires an event when any of it's sub gizmos are released from dragging */
  53177. onDragEndObservable: Observable<unknown>;
  53178. private _meshAttached;
  53179. private _nodeAttached;
  53180. get attachedMesh(): Nullable<AbstractMesh>;
  53181. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53182. get attachedNode(): Nullable<Node>;
  53183. set attachedNode(node: Nullable<Node>);
  53184. /**
  53185. * Creates a RotationGizmo
  53186. * @param gizmoLayer The utility layer the gizmo will be added to
  53187. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53188. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53189. * @param thickness display gizmo axis thickness
  53190. */
  53191. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53192. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53193. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53194. /**
  53195. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53196. */
  53197. set snapDistance(value: number);
  53198. get snapDistance(): number;
  53199. /**
  53200. * Ratio for the scale of the gizmo (Default: 1)
  53201. */
  53202. set scaleRatio(value: number);
  53203. get scaleRatio(): number;
  53204. /**
  53205. * Disposes of the gizmo
  53206. */
  53207. dispose(): void;
  53208. /**
  53209. * CustomMeshes are not supported by this gizmo
  53210. * @param mesh The mesh to replace the default mesh of the gizmo
  53211. */
  53212. setCustomMesh(mesh: Mesh): void;
  53213. }
  53214. }
  53215. declare module BABYLON {
  53216. /**
  53217. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53218. */
  53219. export class GizmoManager implements IDisposable {
  53220. private scene;
  53221. /**
  53222. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53223. */
  53224. gizmos: {
  53225. positionGizmo: Nullable<PositionGizmo>;
  53226. rotationGizmo: Nullable<RotationGizmo>;
  53227. scaleGizmo: Nullable<ScaleGizmo>;
  53228. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53229. };
  53230. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53231. clearGizmoOnEmptyPointerEvent: boolean;
  53232. /** Fires an event when the manager is attached to a mesh */
  53233. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53234. private _gizmosEnabled;
  53235. private _pointerObserver;
  53236. private _attachedMesh;
  53237. private _boundingBoxColor;
  53238. private _defaultUtilityLayer;
  53239. private _defaultKeepDepthUtilityLayer;
  53240. private _thickness;
  53241. /**
  53242. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53243. */
  53244. boundingBoxDragBehavior: SixDofDragBehavior;
  53245. /**
  53246. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53247. */
  53248. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53249. /**
  53250. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53251. */
  53252. usePointerToAttachGizmos: boolean;
  53253. /**
  53254. * Utility layer that the bounding box gizmo belongs to
  53255. */
  53256. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53257. /**
  53258. * Utility layer that all gizmos besides bounding box belong to
  53259. */
  53260. get utilityLayer(): UtilityLayerRenderer;
  53261. /**
  53262. * Instatiates a gizmo manager
  53263. * @param scene the scene to overlay the gizmos on top of
  53264. * @param thickness display gizmo axis thickness
  53265. */
  53266. constructor(scene: Scene, thickness?: number);
  53267. /**
  53268. * Attaches a set of gizmos to the specified mesh
  53269. * @param mesh The mesh the gizmo's should be attached to
  53270. */
  53271. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53272. /**
  53273. * If the position gizmo is enabled
  53274. */
  53275. set positionGizmoEnabled(value: boolean);
  53276. get positionGizmoEnabled(): boolean;
  53277. /**
  53278. * If the rotation gizmo is enabled
  53279. */
  53280. set rotationGizmoEnabled(value: boolean);
  53281. get rotationGizmoEnabled(): boolean;
  53282. /**
  53283. * If the scale gizmo is enabled
  53284. */
  53285. set scaleGizmoEnabled(value: boolean);
  53286. get scaleGizmoEnabled(): boolean;
  53287. /**
  53288. * If the boundingBox gizmo is enabled
  53289. */
  53290. set boundingBoxGizmoEnabled(value: boolean);
  53291. get boundingBoxGizmoEnabled(): boolean;
  53292. /**
  53293. * Disposes of the gizmo manager
  53294. */
  53295. dispose(): void;
  53296. }
  53297. }
  53298. declare module BABYLON {
  53299. /**
  53300. * A directional light is defined by a direction (what a surprise!).
  53301. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53302. * 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.
  53303. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53304. */
  53305. export class DirectionalLight extends ShadowLight {
  53306. private _shadowFrustumSize;
  53307. /**
  53308. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53309. */
  53310. get shadowFrustumSize(): number;
  53311. /**
  53312. * Specifies a fix frustum size for the shadow generation.
  53313. */
  53314. set shadowFrustumSize(value: number);
  53315. private _shadowOrthoScale;
  53316. /**
  53317. * Gets the shadow projection scale against the optimal computed one.
  53318. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53319. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53320. */
  53321. get shadowOrthoScale(): number;
  53322. /**
  53323. * Sets the shadow projection scale against the optimal computed one.
  53324. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53325. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53326. */
  53327. set shadowOrthoScale(value: number);
  53328. /**
  53329. * Automatically compute the projection matrix to best fit (including all the casters)
  53330. * on each frame.
  53331. */
  53332. autoUpdateExtends: boolean;
  53333. /**
  53334. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53335. * on each frame. autoUpdateExtends must be set to true for this to work
  53336. */
  53337. autoCalcShadowZBounds: boolean;
  53338. private _orthoLeft;
  53339. private _orthoRight;
  53340. private _orthoTop;
  53341. private _orthoBottom;
  53342. /**
  53343. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53344. * The directional light is emitted from everywhere in the given direction.
  53345. * It can cast shadows.
  53346. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53347. * @param name The friendly name of the light
  53348. * @param direction The direction of the light
  53349. * @param scene The scene the light belongs to
  53350. */
  53351. constructor(name: string, direction: Vector3, scene: Scene);
  53352. /**
  53353. * Returns the string "DirectionalLight".
  53354. * @return The class name
  53355. */
  53356. getClassName(): string;
  53357. /**
  53358. * Returns the integer 1.
  53359. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53360. */
  53361. getTypeID(): number;
  53362. /**
  53363. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53364. * Returns the DirectionalLight Shadow projection matrix.
  53365. */
  53366. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53367. /**
  53368. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53369. * Returns the DirectionalLight Shadow projection matrix.
  53370. */
  53371. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53372. /**
  53373. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53374. * Returns the DirectionalLight Shadow projection matrix.
  53375. */
  53376. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53377. protected _buildUniformLayout(): void;
  53378. /**
  53379. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53380. * @param effect The effect to update
  53381. * @param lightIndex The index of the light in the effect to update
  53382. * @returns The directional light
  53383. */
  53384. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53385. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53386. /**
  53387. * Gets the minZ used for shadow according to both the scene and the light.
  53388. *
  53389. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53390. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53391. * @param activeCamera The camera we are returning the min for
  53392. * @returns the depth min z
  53393. */
  53394. getDepthMinZ(activeCamera: Camera): number;
  53395. /**
  53396. * Gets the maxZ used for shadow according to both the scene and the light.
  53397. *
  53398. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53399. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53400. * @param activeCamera The camera we are returning the max for
  53401. * @returns the depth max z
  53402. */
  53403. getDepthMaxZ(activeCamera: Camera): number;
  53404. /**
  53405. * Prepares the list of defines specific to the light type.
  53406. * @param defines the list of defines
  53407. * @param lightIndex defines the index of the light for the effect
  53408. */
  53409. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53410. }
  53411. }
  53412. declare module BABYLON {
  53413. /**
  53414. * Class containing static functions to help procedurally build meshes
  53415. */
  53416. export class HemisphereBuilder {
  53417. /**
  53418. * Creates a hemisphere mesh
  53419. * @param name defines the name of the mesh
  53420. * @param options defines the options used to create the mesh
  53421. * @param scene defines the hosting scene
  53422. * @returns the hemisphere mesh
  53423. */
  53424. static CreateHemisphere(name: string, options: {
  53425. segments?: number;
  53426. diameter?: number;
  53427. sideOrientation?: number;
  53428. }, scene: any): Mesh;
  53429. }
  53430. }
  53431. declare module BABYLON {
  53432. /**
  53433. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53434. * These values define a cone of light starting from the position, emitting toward the direction.
  53435. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53436. * and the exponent defines the speed of the decay of the light with distance (reach).
  53437. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53438. */
  53439. export class SpotLight extends ShadowLight {
  53440. private _angle;
  53441. private _innerAngle;
  53442. private _cosHalfAngle;
  53443. private _lightAngleScale;
  53444. private _lightAngleOffset;
  53445. /**
  53446. * Gets the cone angle of the spot light in Radians.
  53447. */
  53448. get angle(): number;
  53449. /**
  53450. * Sets the cone angle of the spot light in Radians.
  53451. */
  53452. set angle(value: number);
  53453. /**
  53454. * Only used in gltf falloff mode, this defines the angle where
  53455. * the directional falloff will start before cutting at angle which could be seen
  53456. * as outer angle.
  53457. */
  53458. get innerAngle(): number;
  53459. /**
  53460. * Only used in gltf falloff mode, this defines the angle where
  53461. * the directional falloff will start before cutting at angle which could be seen
  53462. * as outer angle.
  53463. */
  53464. set innerAngle(value: number);
  53465. private _shadowAngleScale;
  53466. /**
  53467. * Allows scaling the angle of the light for shadow generation only.
  53468. */
  53469. get shadowAngleScale(): number;
  53470. /**
  53471. * Allows scaling the angle of the light for shadow generation only.
  53472. */
  53473. set shadowAngleScale(value: number);
  53474. /**
  53475. * The light decay speed with the distance from the emission spot.
  53476. */
  53477. exponent: number;
  53478. private _projectionTextureMatrix;
  53479. /**
  53480. * Allows reading the projecton texture
  53481. */
  53482. get projectionTextureMatrix(): Matrix;
  53483. protected _projectionTextureLightNear: number;
  53484. /**
  53485. * Gets the near clip of the Spotlight for texture projection.
  53486. */
  53487. get projectionTextureLightNear(): number;
  53488. /**
  53489. * Sets the near clip of the Spotlight for texture projection.
  53490. */
  53491. set projectionTextureLightNear(value: number);
  53492. protected _projectionTextureLightFar: number;
  53493. /**
  53494. * Gets the far clip of the Spotlight for texture projection.
  53495. */
  53496. get projectionTextureLightFar(): number;
  53497. /**
  53498. * Sets the far clip of the Spotlight for texture projection.
  53499. */
  53500. set projectionTextureLightFar(value: number);
  53501. protected _projectionTextureUpDirection: Vector3;
  53502. /**
  53503. * Gets the Up vector of the Spotlight for texture projection.
  53504. */
  53505. get projectionTextureUpDirection(): Vector3;
  53506. /**
  53507. * Sets the Up vector of the Spotlight for texture projection.
  53508. */
  53509. set projectionTextureUpDirection(value: Vector3);
  53510. private _projectionTexture;
  53511. /**
  53512. * Gets the projection texture of the light.
  53513. */
  53514. get projectionTexture(): Nullable<BaseTexture>;
  53515. /**
  53516. * Sets the projection texture of the light.
  53517. */
  53518. set projectionTexture(value: Nullable<BaseTexture>);
  53519. private _projectionTextureViewLightDirty;
  53520. private _projectionTextureProjectionLightDirty;
  53521. private _projectionTextureDirty;
  53522. private _projectionTextureViewTargetVector;
  53523. private _projectionTextureViewLightMatrix;
  53524. private _projectionTextureProjectionLightMatrix;
  53525. private _projectionTextureScalingMatrix;
  53526. /**
  53527. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53528. * It can cast shadows.
  53529. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53530. * @param name The light friendly name
  53531. * @param position The position of the spot light in the scene
  53532. * @param direction The direction of the light in the scene
  53533. * @param angle The cone angle of the light in Radians
  53534. * @param exponent The light decay speed with the distance from the emission spot
  53535. * @param scene The scene the lights belongs to
  53536. */
  53537. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53538. /**
  53539. * Returns the string "SpotLight".
  53540. * @returns the class name
  53541. */
  53542. getClassName(): string;
  53543. /**
  53544. * Returns the integer 2.
  53545. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53546. */
  53547. getTypeID(): number;
  53548. /**
  53549. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53550. */
  53551. protected _setDirection(value: Vector3): void;
  53552. /**
  53553. * Overrides the position setter to recompute the projection texture view light Matrix.
  53554. */
  53555. protected _setPosition(value: Vector3): void;
  53556. /**
  53557. * 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.
  53558. * Returns the SpotLight.
  53559. */
  53560. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53561. protected _computeProjectionTextureViewLightMatrix(): void;
  53562. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53563. /**
  53564. * Main function for light texture projection matrix computing.
  53565. */
  53566. protected _computeProjectionTextureMatrix(): void;
  53567. protected _buildUniformLayout(): void;
  53568. private _computeAngleValues;
  53569. /**
  53570. * Sets the passed Effect "effect" with the Light textures.
  53571. * @param effect The effect to update
  53572. * @param lightIndex The index of the light in the effect to update
  53573. * @returns The light
  53574. */
  53575. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53576. /**
  53577. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53578. * @param effect The effect to update
  53579. * @param lightIndex The index of the light in the effect to update
  53580. * @returns The spot light
  53581. */
  53582. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53583. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53584. /**
  53585. * Disposes the light and the associated resources.
  53586. */
  53587. dispose(): void;
  53588. /**
  53589. * Prepares the list of defines specific to the light type.
  53590. * @param defines the list of defines
  53591. * @param lightIndex defines the index of the light for the effect
  53592. */
  53593. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53594. }
  53595. }
  53596. declare module BABYLON {
  53597. /**
  53598. * Gizmo that enables viewing a light
  53599. */
  53600. export class LightGizmo extends Gizmo {
  53601. private _lightMesh;
  53602. private _material;
  53603. private _cachedPosition;
  53604. private _cachedForward;
  53605. private _attachedMeshParent;
  53606. /**
  53607. * Creates a LightGizmo
  53608. * @param gizmoLayer The utility layer the gizmo will be added to
  53609. */
  53610. constructor(gizmoLayer?: UtilityLayerRenderer);
  53611. private _light;
  53612. /**
  53613. * The light that the gizmo is attached to
  53614. */
  53615. set light(light: Nullable<Light>);
  53616. get light(): Nullable<Light>;
  53617. /**
  53618. * Gets the material used to render the light gizmo
  53619. */
  53620. get material(): StandardMaterial;
  53621. /**
  53622. * @hidden
  53623. * Updates the gizmo to match the attached mesh's position/rotation
  53624. */
  53625. protected _update(): void;
  53626. private static _Scale;
  53627. /**
  53628. * Creates the lines for a light mesh
  53629. */
  53630. private static _CreateLightLines;
  53631. /**
  53632. * Disposes of the light gizmo
  53633. */
  53634. dispose(): void;
  53635. private static _CreateHemisphericLightMesh;
  53636. private static _CreatePointLightMesh;
  53637. private static _CreateSpotLightMesh;
  53638. private static _CreateDirectionalLightMesh;
  53639. }
  53640. }
  53641. declare module BABYLON {
  53642. /** @hidden */
  53643. export var backgroundFragmentDeclaration: {
  53644. name: string;
  53645. shader: string;
  53646. };
  53647. }
  53648. declare module BABYLON {
  53649. /** @hidden */
  53650. export var backgroundUboDeclaration: {
  53651. name: string;
  53652. shader: string;
  53653. };
  53654. }
  53655. declare module BABYLON {
  53656. /** @hidden */
  53657. export var backgroundPixelShader: {
  53658. name: string;
  53659. shader: string;
  53660. };
  53661. }
  53662. declare module BABYLON {
  53663. /** @hidden */
  53664. export var backgroundVertexDeclaration: {
  53665. name: string;
  53666. shader: string;
  53667. };
  53668. }
  53669. declare module BABYLON {
  53670. /** @hidden */
  53671. export var backgroundVertexShader: {
  53672. name: string;
  53673. shader: string;
  53674. };
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * Background material used to create an efficient environement around your scene.
  53679. */
  53680. export class BackgroundMaterial extends PushMaterial {
  53681. /**
  53682. * Standard reflectance value at parallel view angle.
  53683. */
  53684. static StandardReflectance0: number;
  53685. /**
  53686. * Standard reflectance value at grazing angle.
  53687. */
  53688. static StandardReflectance90: number;
  53689. protected _primaryColor: Color3;
  53690. /**
  53691. * Key light Color (multiply against the environement texture)
  53692. */
  53693. primaryColor: Color3;
  53694. protected __perceptualColor: Nullable<Color3>;
  53695. /**
  53696. * Experimental Internal Use Only.
  53697. *
  53698. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53699. * This acts as a helper to set the primary color to a more "human friendly" value.
  53700. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53701. * output color as close as possible from the chosen value.
  53702. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53703. * part of lighting setup.)
  53704. */
  53705. get _perceptualColor(): Nullable<Color3>;
  53706. set _perceptualColor(value: Nullable<Color3>);
  53707. protected _primaryColorShadowLevel: float;
  53708. /**
  53709. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53710. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53711. */
  53712. get primaryColorShadowLevel(): float;
  53713. set primaryColorShadowLevel(value: float);
  53714. protected _primaryColorHighlightLevel: float;
  53715. /**
  53716. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53717. * The primary color is used at the level chosen to define what the white area would look.
  53718. */
  53719. get primaryColorHighlightLevel(): float;
  53720. set primaryColorHighlightLevel(value: float);
  53721. protected _reflectionTexture: Nullable<BaseTexture>;
  53722. /**
  53723. * Reflection Texture used in the material.
  53724. * Should be author in a specific way for the best result (refer to the documentation).
  53725. */
  53726. reflectionTexture: Nullable<BaseTexture>;
  53727. protected _reflectionBlur: float;
  53728. /**
  53729. * Reflection Texture level of blur.
  53730. *
  53731. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53732. * texture twice.
  53733. */
  53734. reflectionBlur: float;
  53735. protected _diffuseTexture: Nullable<BaseTexture>;
  53736. /**
  53737. * Diffuse Texture used in the material.
  53738. * Should be author in a specific way for the best result (refer to the documentation).
  53739. */
  53740. diffuseTexture: Nullable<BaseTexture>;
  53741. protected _shadowLights: Nullable<IShadowLight[]>;
  53742. /**
  53743. * Specify the list of lights casting shadow on the material.
  53744. * All scene shadow lights will be included if null.
  53745. */
  53746. shadowLights: Nullable<IShadowLight[]>;
  53747. protected _shadowLevel: float;
  53748. /**
  53749. * Helps adjusting the shadow to a softer level if required.
  53750. * 0 means black shadows and 1 means no shadows.
  53751. */
  53752. shadowLevel: float;
  53753. protected _sceneCenter: Vector3;
  53754. /**
  53755. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53756. * It is usually zero but might be interesting to modify according to your setup.
  53757. */
  53758. sceneCenter: Vector3;
  53759. protected _opacityFresnel: boolean;
  53760. /**
  53761. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53762. * This helps ensuring a nice transition when the camera goes under the ground.
  53763. */
  53764. opacityFresnel: boolean;
  53765. protected _reflectionFresnel: boolean;
  53766. /**
  53767. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53768. * This helps adding a mirror texture on the ground.
  53769. */
  53770. reflectionFresnel: boolean;
  53771. protected _reflectionFalloffDistance: number;
  53772. /**
  53773. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53774. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53775. */
  53776. reflectionFalloffDistance: number;
  53777. protected _reflectionAmount: number;
  53778. /**
  53779. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53780. */
  53781. reflectionAmount: number;
  53782. protected _reflectionReflectance0: number;
  53783. /**
  53784. * This specifies the weight of the reflection at grazing angle.
  53785. */
  53786. reflectionReflectance0: number;
  53787. protected _reflectionReflectance90: number;
  53788. /**
  53789. * This specifies the weight of the reflection at a perpendicular point of view.
  53790. */
  53791. reflectionReflectance90: number;
  53792. /**
  53793. * Sets the reflection reflectance fresnel values according to the default standard
  53794. * empirically know to work well :-)
  53795. */
  53796. set reflectionStandardFresnelWeight(value: number);
  53797. protected _useRGBColor: boolean;
  53798. /**
  53799. * Helps to directly use the maps channels instead of their level.
  53800. */
  53801. useRGBColor: boolean;
  53802. protected _enableNoise: boolean;
  53803. /**
  53804. * This helps reducing the banding effect that could occur on the background.
  53805. */
  53806. enableNoise: boolean;
  53807. /**
  53808. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53809. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53810. * Recommended to be keep at 1.0 except for special cases.
  53811. */
  53812. get fovMultiplier(): number;
  53813. set fovMultiplier(value: number);
  53814. private _fovMultiplier;
  53815. /**
  53816. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53817. */
  53818. useEquirectangularFOV: boolean;
  53819. private _maxSimultaneousLights;
  53820. /**
  53821. * Number of Simultaneous lights allowed on the material.
  53822. */
  53823. maxSimultaneousLights: int;
  53824. private _shadowOnly;
  53825. /**
  53826. * Make the material only render shadows
  53827. */
  53828. shadowOnly: boolean;
  53829. /**
  53830. * Default configuration related to image processing available in the Background Material.
  53831. */
  53832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53833. /**
  53834. * Keep track of the image processing observer to allow dispose and replace.
  53835. */
  53836. private _imageProcessingObserver;
  53837. /**
  53838. * Attaches a new image processing configuration to the PBR Material.
  53839. * @param configuration (if null the scene configuration will be use)
  53840. */
  53841. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53842. /**
  53843. * Gets the image processing configuration used either in this material.
  53844. */
  53845. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53846. /**
  53847. * Sets the Default image processing configuration used either in the this material.
  53848. *
  53849. * If sets to null, the scene one is in use.
  53850. */
  53851. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53852. /**
  53853. * Gets wether the color curves effect is enabled.
  53854. */
  53855. get cameraColorCurvesEnabled(): boolean;
  53856. /**
  53857. * Sets wether the color curves effect is enabled.
  53858. */
  53859. set cameraColorCurvesEnabled(value: boolean);
  53860. /**
  53861. * Gets wether the color grading effect is enabled.
  53862. */
  53863. get cameraColorGradingEnabled(): boolean;
  53864. /**
  53865. * Gets wether the color grading effect is enabled.
  53866. */
  53867. set cameraColorGradingEnabled(value: boolean);
  53868. /**
  53869. * Gets wether tonemapping is enabled or not.
  53870. */
  53871. get cameraToneMappingEnabled(): boolean;
  53872. /**
  53873. * Sets wether tonemapping is enabled or not
  53874. */
  53875. set cameraToneMappingEnabled(value: boolean);
  53876. /**
  53877. * The camera exposure used on this material.
  53878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53879. * This corresponds to a photographic exposure.
  53880. */
  53881. get cameraExposure(): float;
  53882. /**
  53883. * The camera exposure used on this material.
  53884. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53885. * This corresponds to a photographic exposure.
  53886. */
  53887. set cameraExposure(value: float);
  53888. /**
  53889. * Gets The camera contrast used on this material.
  53890. */
  53891. get cameraContrast(): float;
  53892. /**
  53893. * Sets The camera contrast used on this material.
  53894. */
  53895. set cameraContrast(value: float);
  53896. /**
  53897. * Gets the Color Grading 2D Lookup Texture.
  53898. */
  53899. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53900. /**
  53901. * Sets the Color Grading 2D Lookup Texture.
  53902. */
  53903. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53904. /**
  53905. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53906. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53907. * 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;
  53908. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53909. */
  53910. get cameraColorCurves(): Nullable<ColorCurves>;
  53911. /**
  53912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53914. * 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;
  53915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53916. */
  53917. set cameraColorCurves(value: Nullable<ColorCurves>);
  53918. /**
  53919. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53920. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53921. */
  53922. switchToBGR: boolean;
  53923. private _renderTargets;
  53924. private _reflectionControls;
  53925. private _white;
  53926. private _primaryShadowColor;
  53927. private _primaryHighlightColor;
  53928. /**
  53929. * Instantiates a Background Material in the given scene
  53930. * @param name The friendly name of the material
  53931. * @param scene The scene to add the material to
  53932. */
  53933. constructor(name: string, scene: Scene);
  53934. /**
  53935. * Gets a boolean indicating that current material needs to register RTT
  53936. */
  53937. get hasRenderTargetTextures(): boolean;
  53938. /**
  53939. * The entire material has been created in order to prevent overdraw.
  53940. * @returns false
  53941. */
  53942. needAlphaTesting(): boolean;
  53943. /**
  53944. * The entire material has been created in order to prevent overdraw.
  53945. * @returns true if blending is enable
  53946. */
  53947. needAlphaBlending(): boolean;
  53948. /**
  53949. * Checks wether the material is ready to be rendered for a given mesh.
  53950. * @param mesh The mesh to render
  53951. * @param subMesh The submesh to check against
  53952. * @param useInstances Specify wether or not the material is used with instances
  53953. * @returns true if all the dependencies are ready (Textures, Effects...)
  53954. */
  53955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53956. /**
  53957. * Compute the primary color according to the chosen perceptual color.
  53958. */
  53959. private _computePrimaryColorFromPerceptualColor;
  53960. /**
  53961. * Compute the highlights and shadow colors according to their chosen levels.
  53962. */
  53963. private _computePrimaryColors;
  53964. /**
  53965. * Build the uniform buffer used in the material.
  53966. */
  53967. buildUniformLayout(): void;
  53968. /**
  53969. * Unbind the material.
  53970. */
  53971. unbind(): void;
  53972. /**
  53973. * Bind only the world matrix to the material.
  53974. * @param world The world matrix to bind.
  53975. */
  53976. bindOnlyWorldMatrix(world: Matrix): void;
  53977. /**
  53978. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53979. * @param world The world matrix to bind.
  53980. * @param subMesh The submesh to bind for.
  53981. */
  53982. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53983. /**
  53984. * Checks to see if a texture is used in the material.
  53985. * @param texture - Base texture to use.
  53986. * @returns - Boolean specifying if a texture is used in the material.
  53987. */
  53988. hasTexture(texture: BaseTexture): boolean;
  53989. /**
  53990. * Dispose the material.
  53991. * @param forceDisposeEffect Force disposal of the associated effect.
  53992. * @param forceDisposeTextures Force disposal of the associated textures.
  53993. */
  53994. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53995. /**
  53996. * Clones the material.
  53997. * @param name The cloned name.
  53998. * @returns The cloned material.
  53999. */
  54000. clone(name: string): BackgroundMaterial;
  54001. /**
  54002. * Serializes the current material to its JSON representation.
  54003. * @returns The JSON representation.
  54004. */
  54005. serialize(): any;
  54006. /**
  54007. * Gets the class name of the material
  54008. * @returns "BackgroundMaterial"
  54009. */
  54010. getClassName(): string;
  54011. /**
  54012. * Parse a JSON input to create back a background material.
  54013. * @param source The JSON data to parse
  54014. * @param scene The scene to create the parsed material in
  54015. * @param rootUrl The root url of the assets the material depends upon
  54016. * @returns the instantiated BackgroundMaterial.
  54017. */
  54018. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54019. }
  54020. }
  54021. declare module BABYLON {
  54022. /**
  54023. * Represents the different options available during the creation of
  54024. * a Environment helper.
  54025. *
  54026. * This can control the default ground, skybox and image processing setup of your scene.
  54027. */
  54028. export interface IEnvironmentHelperOptions {
  54029. /**
  54030. * Specifies whether or not to create a ground.
  54031. * True by default.
  54032. */
  54033. createGround: boolean;
  54034. /**
  54035. * Specifies the ground size.
  54036. * 15 by default.
  54037. */
  54038. groundSize: number;
  54039. /**
  54040. * The texture used on the ground for the main color.
  54041. * Comes from the BabylonJS CDN by default.
  54042. *
  54043. * Remarks: Can be either a texture or a url.
  54044. */
  54045. groundTexture: string | BaseTexture;
  54046. /**
  54047. * The color mixed in the ground texture by default.
  54048. * BabylonJS clearColor by default.
  54049. */
  54050. groundColor: Color3;
  54051. /**
  54052. * Specifies the ground opacity.
  54053. * 1 by default.
  54054. */
  54055. groundOpacity: number;
  54056. /**
  54057. * Enables the ground to receive shadows.
  54058. * True by default.
  54059. */
  54060. enableGroundShadow: boolean;
  54061. /**
  54062. * Helps preventing the shadow to be fully black on the ground.
  54063. * 0.5 by default.
  54064. */
  54065. groundShadowLevel: number;
  54066. /**
  54067. * Creates a mirror texture attach to the ground.
  54068. * false by default.
  54069. */
  54070. enableGroundMirror: boolean;
  54071. /**
  54072. * Specifies the ground mirror size ratio.
  54073. * 0.3 by default as the default kernel is 64.
  54074. */
  54075. groundMirrorSizeRatio: number;
  54076. /**
  54077. * Specifies the ground mirror blur kernel size.
  54078. * 64 by default.
  54079. */
  54080. groundMirrorBlurKernel: number;
  54081. /**
  54082. * Specifies the ground mirror visibility amount.
  54083. * 1 by default
  54084. */
  54085. groundMirrorAmount: number;
  54086. /**
  54087. * Specifies the ground mirror reflectance weight.
  54088. * This uses the standard weight of the background material to setup the fresnel effect
  54089. * of the mirror.
  54090. * 1 by default.
  54091. */
  54092. groundMirrorFresnelWeight: number;
  54093. /**
  54094. * Specifies the ground mirror Falloff distance.
  54095. * This can helps reducing the size of the reflection.
  54096. * 0 by Default.
  54097. */
  54098. groundMirrorFallOffDistance: number;
  54099. /**
  54100. * Specifies the ground mirror texture type.
  54101. * Unsigned Int by Default.
  54102. */
  54103. groundMirrorTextureType: number;
  54104. /**
  54105. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54106. * the shown objects.
  54107. */
  54108. groundYBias: number;
  54109. /**
  54110. * Specifies whether or not to create a skybox.
  54111. * True by default.
  54112. */
  54113. createSkybox: boolean;
  54114. /**
  54115. * Specifies the skybox size.
  54116. * 20 by default.
  54117. */
  54118. skyboxSize: number;
  54119. /**
  54120. * The texture used on the skybox for the main color.
  54121. * Comes from the BabylonJS CDN by default.
  54122. *
  54123. * Remarks: Can be either a texture or a url.
  54124. */
  54125. skyboxTexture: string | BaseTexture;
  54126. /**
  54127. * The color mixed in the skybox texture by default.
  54128. * BabylonJS clearColor by default.
  54129. */
  54130. skyboxColor: Color3;
  54131. /**
  54132. * The background rotation around the Y axis of the scene.
  54133. * This helps aligning the key lights of your scene with the background.
  54134. * 0 by default.
  54135. */
  54136. backgroundYRotation: number;
  54137. /**
  54138. * Compute automatically the size of the elements to best fit with the scene.
  54139. */
  54140. sizeAuto: boolean;
  54141. /**
  54142. * Default position of the rootMesh if autoSize is not true.
  54143. */
  54144. rootPosition: Vector3;
  54145. /**
  54146. * Sets up the image processing in the scene.
  54147. * true by default.
  54148. */
  54149. setupImageProcessing: boolean;
  54150. /**
  54151. * The texture used as your environment texture in the scene.
  54152. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54153. *
  54154. * Remarks: Can be either a texture or a url.
  54155. */
  54156. environmentTexture: string | BaseTexture;
  54157. /**
  54158. * The value of the exposure to apply to the scene.
  54159. * 0.6 by default if setupImageProcessing is true.
  54160. */
  54161. cameraExposure: number;
  54162. /**
  54163. * The value of the contrast to apply to the scene.
  54164. * 1.6 by default if setupImageProcessing is true.
  54165. */
  54166. cameraContrast: number;
  54167. /**
  54168. * Specifies whether or not tonemapping should be enabled in the scene.
  54169. * true by default if setupImageProcessing is true.
  54170. */
  54171. toneMappingEnabled: boolean;
  54172. }
  54173. /**
  54174. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54175. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54176. * It also helps with the default setup of your imageProcessing configuration.
  54177. */
  54178. export class EnvironmentHelper {
  54179. /**
  54180. * Default ground texture URL.
  54181. */
  54182. private static _groundTextureCDNUrl;
  54183. /**
  54184. * Default skybox texture URL.
  54185. */
  54186. private static _skyboxTextureCDNUrl;
  54187. /**
  54188. * Default environment texture URL.
  54189. */
  54190. private static _environmentTextureCDNUrl;
  54191. /**
  54192. * Creates the default options for the helper.
  54193. */
  54194. private static _getDefaultOptions;
  54195. private _rootMesh;
  54196. /**
  54197. * Gets the root mesh created by the helper.
  54198. */
  54199. get rootMesh(): Mesh;
  54200. private _skybox;
  54201. /**
  54202. * Gets the skybox created by the helper.
  54203. */
  54204. get skybox(): Nullable<Mesh>;
  54205. private _skyboxTexture;
  54206. /**
  54207. * Gets the skybox texture created by the helper.
  54208. */
  54209. get skyboxTexture(): Nullable<BaseTexture>;
  54210. private _skyboxMaterial;
  54211. /**
  54212. * Gets the skybox material created by the helper.
  54213. */
  54214. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54215. private _ground;
  54216. /**
  54217. * Gets the ground mesh created by the helper.
  54218. */
  54219. get ground(): Nullable<Mesh>;
  54220. private _groundTexture;
  54221. /**
  54222. * Gets the ground texture created by the helper.
  54223. */
  54224. get groundTexture(): Nullable<BaseTexture>;
  54225. private _groundMirror;
  54226. /**
  54227. * Gets the ground mirror created by the helper.
  54228. */
  54229. get groundMirror(): Nullable<MirrorTexture>;
  54230. /**
  54231. * Gets the ground mirror render list to helps pushing the meshes
  54232. * you wish in the ground reflection.
  54233. */
  54234. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54235. private _groundMaterial;
  54236. /**
  54237. * Gets the ground material created by the helper.
  54238. */
  54239. get groundMaterial(): Nullable<BackgroundMaterial>;
  54240. /**
  54241. * Stores the creation options.
  54242. */
  54243. private readonly _scene;
  54244. private _options;
  54245. /**
  54246. * This observable will be notified with any error during the creation of the environment,
  54247. * mainly texture creation errors.
  54248. */
  54249. onErrorObservable: Observable<{
  54250. message?: string;
  54251. exception?: any;
  54252. }>;
  54253. /**
  54254. * constructor
  54255. * @param options Defines the options we want to customize the helper
  54256. * @param scene The scene to add the material to
  54257. */
  54258. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54259. /**
  54260. * Updates the background according to the new options
  54261. * @param options
  54262. */
  54263. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54264. /**
  54265. * Sets the primary color of all the available elements.
  54266. * @param color the main color to affect to the ground and the background
  54267. */
  54268. setMainColor(color: Color3): void;
  54269. /**
  54270. * Setup the image processing according to the specified options.
  54271. */
  54272. private _setupImageProcessing;
  54273. /**
  54274. * Setup the environment texture according to the specified options.
  54275. */
  54276. private _setupEnvironmentTexture;
  54277. /**
  54278. * Setup the background according to the specified options.
  54279. */
  54280. private _setupBackground;
  54281. /**
  54282. * Get the scene sizes according to the setup.
  54283. */
  54284. private _getSceneSize;
  54285. /**
  54286. * Setup the ground according to the specified options.
  54287. */
  54288. private _setupGround;
  54289. /**
  54290. * Setup the ground material according to the specified options.
  54291. */
  54292. private _setupGroundMaterial;
  54293. /**
  54294. * Setup the ground diffuse texture according to the specified options.
  54295. */
  54296. private _setupGroundDiffuseTexture;
  54297. /**
  54298. * Setup the ground mirror texture according to the specified options.
  54299. */
  54300. private _setupGroundMirrorTexture;
  54301. /**
  54302. * Setup the ground to receive the mirror texture.
  54303. */
  54304. private _setupMirrorInGroundMaterial;
  54305. /**
  54306. * Setup the skybox according to the specified options.
  54307. */
  54308. private _setupSkybox;
  54309. /**
  54310. * Setup the skybox material according to the specified options.
  54311. */
  54312. private _setupSkyboxMaterial;
  54313. /**
  54314. * Setup the skybox reflection texture according to the specified options.
  54315. */
  54316. private _setupSkyboxReflectionTexture;
  54317. private _errorHandler;
  54318. /**
  54319. * Dispose all the elements created by the Helper.
  54320. */
  54321. dispose(): void;
  54322. }
  54323. }
  54324. declare module BABYLON {
  54325. /**
  54326. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54327. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54328. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54329. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54330. */
  54331. export class PhotoDome extends TransformNode {
  54332. /**
  54333. * Define the image as a Monoscopic panoramic 360 image.
  54334. */
  54335. static readonly MODE_MONOSCOPIC: number;
  54336. /**
  54337. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54338. */
  54339. static readonly MODE_TOPBOTTOM: number;
  54340. /**
  54341. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54342. */
  54343. static readonly MODE_SIDEBYSIDE: number;
  54344. private _useDirectMapping;
  54345. /**
  54346. * The texture being displayed on the sphere
  54347. */
  54348. protected _photoTexture: Texture;
  54349. /**
  54350. * Gets or sets the texture being displayed on the sphere
  54351. */
  54352. get photoTexture(): Texture;
  54353. set photoTexture(value: Texture);
  54354. /**
  54355. * Observable raised when an error occured while loading the 360 image
  54356. */
  54357. onLoadErrorObservable: Observable<string>;
  54358. /**
  54359. * The skybox material
  54360. */
  54361. protected _material: BackgroundMaterial;
  54362. /**
  54363. * The surface used for the skybox
  54364. */
  54365. protected _mesh: Mesh;
  54366. /**
  54367. * Gets the mesh used for the skybox.
  54368. */
  54369. get mesh(): Mesh;
  54370. /**
  54371. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54372. * Also see the options.resolution property.
  54373. */
  54374. get fovMultiplier(): number;
  54375. set fovMultiplier(value: number);
  54376. private _imageMode;
  54377. /**
  54378. * Gets or set the current video mode for the video. It can be:
  54379. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54380. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54381. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54382. */
  54383. get imageMode(): number;
  54384. set imageMode(value: number);
  54385. /**
  54386. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54387. * @param name Element's name, child elements will append suffixes for their own names.
  54388. * @param urlsOfPhoto defines the url of the photo to display
  54389. * @param options defines an object containing optional or exposed sub element properties
  54390. * @param onError defines a callback called when an error occured while loading the texture
  54391. */
  54392. constructor(name: string, urlOfPhoto: string, options: {
  54393. resolution?: number;
  54394. size?: number;
  54395. useDirectMapping?: boolean;
  54396. faceForward?: boolean;
  54397. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54398. private _onBeforeCameraRenderObserver;
  54399. private _changeImageMode;
  54400. /**
  54401. * Releases resources associated with this node.
  54402. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54403. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54404. */
  54405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54406. }
  54407. }
  54408. declare module BABYLON {
  54409. /**
  54410. * Class used to host RGBD texture specific utilities
  54411. */
  54412. export class RGBDTextureTools {
  54413. /**
  54414. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54415. * @param texture the texture to expand.
  54416. */
  54417. static ExpandRGBDTexture(texture: Texture): void;
  54418. }
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * Class used to host texture specific utilities
  54423. */
  54424. export class BRDFTextureTools {
  54425. /**
  54426. * Prevents texture cache collision
  54427. */
  54428. private static _instanceNumber;
  54429. /**
  54430. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54431. * @param scene defines the hosting scene
  54432. * @returns the environment BRDF texture
  54433. */
  54434. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54435. private static _environmentBRDFBase64Texture;
  54436. }
  54437. }
  54438. declare module BABYLON {
  54439. /**
  54440. * @hidden
  54441. */
  54442. export interface IMaterialClearCoatDefines {
  54443. CLEARCOAT: boolean;
  54444. CLEARCOAT_DEFAULTIOR: boolean;
  54445. CLEARCOAT_TEXTURE: boolean;
  54446. CLEARCOAT_TEXTUREDIRECTUV: number;
  54447. CLEARCOAT_BUMP: boolean;
  54448. CLEARCOAT_BUMPDIRECTUV: number;
  54449. CLEARCOAT_TINT: boolean;
  54450. CLEARCOAT_TINT_TEXTURE: boolean;
  54451. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54452. /** @hidden */
  54453. _areTexturesDirty: boolean;
  54454. }
  54455. /**
  54456. * Define the code related to the clear coat parameters of the pbr material.
  54457. */
  54458. export class PBRClearCoatConfiguration {
  54459. /**
  54460. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54461. * The default fits with a polyurethane material.
  54462. */
  54463. private static readonly _DefaultIndexOfRefraction;
  54464. private _isEnabled;
  54465. /**
  54466. * Defines if the clear coat is enabled in the material.
  54467. */
  54468. isEnabled: boolean;
  54469. /**
  54470. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54471. */
  54472. intensity: number;
  54473. /**
  54474. * Defines the clear coat layer roughness.
  54475. */
  54476. roughness: number;
  54477. private _indexOfRefraction;
  54478. /**
  54479. * Defines the index of refraction of the clear coat.
  54480. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54481. * The default fits with a polyurethane material.
  54482. * Changing the default value is more performance intensive.
  54483. */
  54484. indexOfRefraction: number;
  54485. private _texture;
  54486. /**
  54487. * Stores the clear coat values in a texture.
  54488. */
  54489. texture: Nullable<BaseTexture>;
  54490. private _bumpTexture;
  54491. /**
  54492. * Define the clear coat specific bump texture.
  54493. */
  54494. bumpTexture: Nullable<BaseTexture>;
  54495. private _isTintEnabled;
  54496. /**
  54497. * Defines if the clear coat tint is enabled in the material.
  54498. */
  54499. isTintEnabled: boolean;
  54500. /**
  54501. * Defines the clear coat tint of the material.
  54502. * This is only use if tint is enabled
  54503. */
  54504. tintColor: Color3;
  54505. /**
  54506. * Defines the distance at which the tint color should be found in the
  54507. * clear coat media.
  54508. * This is only use if tint is enabled
  54509. */
  54510. tintColorAtDistance: number;
  54511. /**
  54512. * Defines the clear coat layer thickness.
  54513. * This is only use if tint is enabled
  54514. */
  54515. tintThickness: number;
  54516. private _tintTexture;
  54517. /**
  54518. * Stores the clear tint values in a texture.
  54519. * rgb is tint
  54520. * a is a thickness factor
  54521. */
  54522. tintTexture: Nullable<BaseTexture>;
  54523. /** @hidden */
  54524. private _internalMarkAllSubMeshesAsTexturesDirty;
  54525. /** @hidden */
  54526. _markAllSubMeshesAsTexturesDirty(): void;
  54527. /**
  54528. * Instantiate a new istance of clear coat configuration.
  54529. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54530. */
  54531. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54532. /**
  54533. * Gets wehter the submesh is ready to be used or not.
  54534. * @param defines the list of "defines" to update.
  54535. * @param scene defines the scene the material belongs to.
  54536. * @param engine defines the engine the material belongs to.
  54537. * @param disableBumpMap defines wether the material disables bump or not.
  54538. * @returns - boolean indicating that the submesh is ready or not.
  54539. */
  54540. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54541. /**
  54542. * Checks to see if a texture is used in the material.
  54543. * @param defines the list of "defines" to update.
  54544. * @param scene defines the scene to the material belongs to.
  54545. */
  54546. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54547. /**
  54548. * Binds the material data.
  54549. * @param uniformBuffer defines the Uniform buffer to fill in.
  54550. * @param scene defines the scene the material belongs to.
  54551. * @param engine defines the engine the material belongs to.
  54552. * @param disableBumpMap defines wether the material disables bump or not.
  54553. * @param isFrozen defines wether the material is frozen or not.
  54554. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54555. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54556. */
  54557. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54558. /**
  54559. * Checks to see if a texture is used in the material.
  54560. * @param texture - Base texture to use.
  54561. * @returns - Boolean specifying if a texture is used in the material.
  54562. */
  54563. hasTexture(texture: BaseTexture): boolean;
  54564. /**
  54565. * Returns an array of the actively used textures.
  54566. * @param activeTextures Array of BaseTextures
  54567. */
  54568. getActiveTextures(activeTextures: BaseTexture[]): void;
  54569. /**
  54570. * Returns the animatable textures.
  54571. * @param animatables Array of animatable textures.
  54572. */
  54573. getAnimatables(animatables: IAnimatable[]): void;
  54574. /**
  54575. * Disposes the resources of the material.
  54576. * @param forceDisposeTextures - Forces the disposal of all textures.
  54577. */
  54578. dispose(forceDisposeTextures?: boolean): void;
  54579. /**
  54580. * Get the current class name of the texture useful for serialization or dynamic coding.
  54581. * @returns "PBRClearCoatConfiguration"
  54582. */
  54583. getClassName(): string;
  54584. /**
  54585. * Add fallbacks to the effect fallbacks list.
  54586. * @param defines defines the Base texture to use.
  54587. * @param fallbacks defines the current fallback list.
  54588. * @param currentRank defines the current fallback rank.
  54589. * @returns the new fallback rank.
  54590. */
  54591. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54592. /**
  54593. * Add the required uniforms to the current list.
  54594. * @param uniforms defines the current uniform list.
  54595. */
  54596. static AddUniforms(uniforms: string[]): void;
  54597. /**
  54598. * Add the required samplers to the current list.
  54599. * @param samplers defines the current sampler list.
  54600. */
  54601. static AddSamplers(samplers: string[]): void;
  54602. /**
  54603. * Add the required uniforms to the current buffer.
  54604. * @param uniformBuffer defines the current uniform buffer.
  54605. */
  54606. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54607. /**
  54608. * Makes a duplicate of the current configuration into another one.
  54609. * @param clearCoatConfiguration define the config where to copy the info
  54610. */
  54611. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54612. /**
  54613. * Serializes this clear coat configuration.
  54614. * @returns - An object with the serialized config.
  54615. */
  54616. serialize(): any;
  54617. /**
  54618. * Parses a anisotropy Configuration from a serialized object.
  54619. * @param source - Serialized object.
  54620. * @param scene Defines the scene we are parsing for
  54621. * @param rootUrl Defines the rootUrl to load from
  54622. */
  54623. parse(source: any, scene: Scene, rootUrl: string): void;
  54624. }
  54625. }
  54626. declare module BABYLON {
  54627. /**
  54628. * @hidden
  54629. */
  54630. export interface IMaterialAnisotropicDefines {
  54631. ANISOTROPIC: boolean;
  54632. ANISOTROPIC_TEXTURE: boolean;
  54633. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54634. MAINUV1: boolean;
  54635. _areTexturesDirty: boolean;
  54636. _needUVs: boolean;
  54637. }
  54638. /**
  54639. * Define the code related to the anisotropic parameters of the pbr material.
  54640. */
  54641. export class PBRAnisotropicConfiguration {
  54642. private _isEnabled;
  54643. /**
  54644. * Defines if the anisotropy is enabled in the material.
  54645. */
  54646. isEnabled: boolean;
  54647. /**
  54648. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54649. */
  54650. intensity: number;
  54651. /**
  54652. * Defines if the effect is along the tangents, bitangents or in between.
  54653. * By default, the effect is "strectching" the highlights along the tangents.
  54654. */
  54655. direction: Vector2;
  54656. private _texture;
  54657. /**
  54658. * Stores the anisotropy values in a texture.
  54659. * rg is direction (like normal from -1 to 1)
  54660. * b is a intensity
  54661. */
  54662. texture: Nullable<BaseTexture>;
  54663. /** @hidden */
  54664. private _internalMarkAllSubMeshesAsTexturesDirty;
  54665. /** @hidden */
  54666. _markAllSubMeshesAsTexturesDirty(): void;
  54667. /**
  54668. * Instantiate a new istance of anisotropy configuration.
  54669. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54670. */
  54671. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54672. /**
  54673. * Specifies that the submesh is ready to be used.
  54674. * @param defines the list of "defines" to update.
  54675. * @param scene defines the scene the material belongs to.
  54676. * @returns - boolean indicating that the submesh is ready or not.
  54677. */
  54678. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54679. /**
  54680. * Checks to see if a texture is used in the material.
  54681. * @param defines the list of "defines" to update.
  54682. * @param mesh the mesh we are preparing the defines for.
  54683. * @param scene defines the scene the material belongs to.
  54684. */
  54685. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54686. /**
  54687. * Binds the material data.
  54688. * @param uniformBuffer defines the Uniform buffer to fill in.
  54689. * @param scene defines the scene the material belongs to.
  54690. * @param isFrozen defines wether the material is frozen or not.
  54691. */
  54692. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54693. /**
  54694. * Checks to see if a texture is used in the material.
  54695. * @param texture - Base texture to use.
  54696. * @returns - Boolean specifying if a texture is used in the material.
  54697. */
  54698. hasTexture(texture: BaseTexture): boolean;
  54699. /**
  54700. * Returns an array of the actively used textures.
  54701. * @param activeTextures Array of BaseTextures
  54702. */
  54703. getActiveTextures(activeTextures: BaseTexture[]): void;
  54704. /**
  54705. * Returns the animatable textures.
  54706. * @param animatables Array of animatable textures.
  54707. */
  54708. getAnimatables(animatables: IAnimatable[]): void;
  54709. /**
  54710. * Disposes the resources of the material.
  54711. * @param forceDisposeTextures - Forces the disposal of all textures.
  54712. */
  54713. dispose(forceDisposeTextures?: boolean): void;
  54714. /**
  54715. * Get the current class name of the texture useful for serialization or dynamic coding.
  54716. * @returns "PBRAnisotropicConfiguration"
  54717. */
  54718. getClassName(): string;
  54719. /**
  54720. * Add fallbacks to the effect fallbacks list.
  54721. * @param defines defines the Base texture to use.
  54722. * @param fallbacks defines the current fallback list.
  54723. * @param currentRank defines the current fallback rank.
  54724. * @returns the new fallback rank.
  54725. */
  54726. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54727. /**
  54728. * Add the required uniforms to the current list.
  54729. * @param uniforms defines the current uniform list.
  54730. */
  54731. static AddUniforms(uniforms: string[]): void;
  54732. /**
  54733. * Add the required uniforms to the current buffer.
  54734. * @param uniformBuffer defines the current uniform buffer.
  54735. */
  54736. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54737. /**
  54738. * Add the required samplers to the current list.
  54739. * @param samplers defines the current sampler list.
  54740. */
  54741. static AddSamplers(samplers: string[]): void;
  54742. /**
  54743. * Makes a duplicate of the current configuration into another one.
  54744. * @param anisotropicConfiguration define the config where to copy the info
  54745. */
  54746. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54747. /**
  54748. * Serializes this anisotropy configuration.
  54749. * @returns - An object with the serialized config.
  54750. */
  54751. serialize(): any;
  54752. /**
  54753. * Parses a anisotropy Configuration from a serialized object.
  54754. * @param source - Serialized object.
  54755. * @param scene Defines the scene we are parsing for
  54756. * @param rootUrl Defines the rootUrl to load from
  54757. */
  54758. parse(source: any, scene: Scene, rootUrl: string): void;
  54759. }
  54760. }
  54761. declare module BABYLON {
  54762. /**
  54763. * @hidden
  54764. */
  54765. export interface IMaterialBRDFDefines {
  54766. BRDF_V_HEIGHT_CORRELATED: boolean;
  54767. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54768. SPHERICAL_HARMONICS: boolean;
  54769. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54770. /** @hidden */
  54771. _areMiscDirty: boolean;
  54772. }
  54773. /**
  54774. * Define the code related to the BRDF parameters of the pbr material.
  54775. */
  54776. export class PBRBRDFConfiguration {
  54777. /**
  54778. * Default value used for the energy conservation.
  54779. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54780. */
  54781. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54782. /**
  54783. * Default value used for the Smith Visibility Height Correlated mode.
  54784. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54785. */
  54786. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54787. /**
  54788. * Default value used for the IBL diffuse part.
  54789. * This can help switching back to the polynomials mode globally which is a tiny bit
  54790. * less GPU intensive at the drawback of a lower quality.
  54791. */
  54792. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54793. /**
  54794. * Default value used for activating energy conservation for the specular workflow.
  54795. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54796. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54797. */
  54798. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54799. private _useEnergyConservation;
  54800. /**
  54801. * Defines if the material uses energy conservation.
  54802. */
  54803. useEnergyConservation: boolean;
  54804. private _useSmithVisibilityHeightCorrelated;
  54805. /**
  54806. * LEGACY Mode set to false
  54807. * Defines if the material uses height smith correlated visibility term.
  54808. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54809. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54810. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54811. * Not relying on height correlated will also disable energy conservation.
  54812. */
  54813. useSmithVisibilityHeightCorrelated: boolean;
  54814. private _useSphericalHarmonics;
  54815. /**
  54816. * LEGACY Mode set to false
  54817. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54818. * diffuse part of the IBL.
  54819. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54820. * to the ground truth.
  54821. */
  54822. useSphericalHarmonics: boolean;
  54823. private _useSpecularGlossinessInputEnergyConservation;
  54824. /**
  54825. * Defines if the material uses energy conservation, when the specular workflow is active.
  54826. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54827. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54828. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54829. */
  54830. useSpecularGlossinessInputEnergyConservation: boolean;
  54831. /** @hidden */
  54832. private _internalMarkAllSubMeshesAsMiscDirty;
  54833. /** @hidden */
  54834. _markAllSubMeshesAsMiscDirty(): void;
  54835. /**
  54836. * Instantiate a new istance of clear coat configuration.
  54837. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54838. */
  54839. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54840. /**
  54841. * Checks to see if a texture is used in the material.
  54842. * @param defines the list of "defines" to update.
  54843. */
  54844. prepareDefines(defines: IMaterialBRDFDefines): void;
  54845. /**
  54846. * Get the current class name of the texture useful for serialization or dynamic coding.
  54847. * @returns "PBRClearCoatConfiguration"
  54848. */
  54849. getClassName(): string;
  54850. /**
  54851. * Makes a duplicate of the current configuration into another one.
  54852. * @param brdfConfiguration define the config where to copy the info
  54853. */
  54854. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54855. /**
  54856. * Serializes this BRDF configuration.
  54857. * @returns - An object with the serialized config.
  54858. */
  54859. serialize(): any;
  54860. /**
  54861. * Parses a anisotropy Configuration from a serialized object.
  54862. * @param source - Serialized object.
  54863. * @param scene Defines the scene we are parsing for
  54864. * @param rootUrl Defines the rootUrl to load from
  54865. */
  54866. parse(source: any, scene: Scene, rootUrl: string): void;
  54867. }
  54868. }
  54869. declare module BABYLON {
  54870. /**
  54871. * @hidden
  54872. */
  54873. export interface IMaterialSheenDefines {
  54874. SHEEN: boolean;
  54875. SHEEN_TEXTURE: boolean;
  54876. SHEEN_TEXTUREDIRECTUV: number;
  54877. SHEEN_LINKWITHALBEDO: boolean;
  54878. SHEEN_ROUGHNESS: boolean;
  54879. SHEEN_ALBEDOSCALING: boolean;
  54880. /** @hidden */
  54881. _areTexturesDirty: boolean;
  54882. }
  54883. /**
  54884. * Define the code related to the Sheen parameters of the pbr material.
  54885. */
  54886. export class PBRSheenConfiguration {
  54887. private _isEnabled;
  54888. /**
  54889. * Defines if the material uses sheen.
  54890. */
  54891. isEnabled: boolean;
  54892. private _linkSheenWithAlbedo;
  54893. /**
  54894. * Defines if the sheen is linked to the sheen color.
  54895. */
  54896. linkSheenWithAlbedo: boolean;
  54897. /**
  54898. * Defines the sheen intensity.
  54899. */
  54900. intensity: number;
  54901. /**
  54902. * Defines the sheen color.
  54903. */
  54904. color: Color3;
  54905. private _texture;
  54906. /**
  54907. * Stores the sheen tint values in a texture.
  54908. * rgb is tint
  54909. * a is a intensity or roughness if roughness has been defined
  54910. */
  54911. texture: Nullable<BaseTexture>;
  54912. private _roughness;
  54913. /**
  54914. * Defines the sheen roughness.
  54915. * It is not taken into account if linkSheenWithAlbedo is true.
  54916. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54917. */
  54918. roughness: Nullable<number>;
  54919. private _albedoScaling;
  54920. /**
  54921. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54922. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54923. * making it easier to setup and tweak the effect
  54924. */
  54925. albedoScaling: boolean;
  54926. /** @hidden */
  54927. private _internalMarkAllSubMeshesAsTexturesDirty;
  54928. /** @hidden */
  54929. _markAllSubMeshesAsTexturesDirty(): void;
  54930. /**
  54931. * Instantiate a new istance of clear coat configuration.
  54932. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54933. */
  54934. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54935. /**
  54936. * Specifies that the submesh is ready to be used.
  54937. * @param defines the list of "defines" to update.
  54938. * @param scene defines the scene the material belongs to.
  54939. * @returns - boolean indicating that the submesh is ready or not.
  54940. */
  54941. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54942. /**
  54943. * Checks to see if a texture is used in the material.
  54944. * @param defines the list of "defines" to update.
  54945. * @param scene defines the scene the material belongs to.
  54946. */
  54947. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54948. /**
  54949. * Binds the material data.
  54950. * @param uniformBuffer defines the Uniform buffer to fill in.
  54951. * @param scene defines the scene the material belongs to.
  54952. * @param isFrozen defines wether the material is frozen or not.
  54953. */
  54954. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54955. /**
  54956. * Checks to see if a texture is used in the material.
  54957. * @param texture - Base texture to use.
  54958. * @returns - Boolean specifying if a texture is used in the material.
  54959. */
  54960. hasTexture(texture: BaseTexture): boolean;
  54961. /**
  54962. * Returns an array of the actively used textures.
  54963. * @param activeTextures Array of BaseTextures
  54964. */
  54965. getActiveTextures(activeTextures: BaseTexture[]): void;
  54966. /**
  54967. * Returns the animatable textures.
  54968. * @param animatables Array of animatable textures.
  54969. */
  54970. getAnimatables(animatables: IAnimatable[]): void;
  54971. /**
  54972. * Disposes the resources of the material.
  54973. * @param forceDisposeTextures - Forces the disposal of all textures.
  54974. */
  54975. dispose(forceDisposeTextures?: boolean): void;
  54976. /**
  54977. * Get the current class name of the texture useful for serialization or dynamic coding.
  54978. * @returns "PBRSheenConfiguration"
  54979. */
  54980. getClassName(): string;
  54981. /**
  54982. * Add fallbacks to the effect fallbacks list.
  54983. * @param defines defines the Base texture to use.
  54984. * @param fallbacks defines the current fallback list.
  54985. * @param currentRank defines the current fallback rank.
  54986. * @returns the new fallback rank.
  54987. */
  54988. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54989. /**
  54990. * Add the required uniforms to the current list.
  54991. * @param uniforms defines the current uniform list.
  54992. */
  54993. static AddUniforms(uniforms: string[]): void;
  54994. /**
  54995. * Add the required uniforms to the current buffer.
  54996. * @param uniformBuffer defines the current uniform buffer.
  54997. */
  54998. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54999. /**
  55000. * Add the required samplers to the current list.
  55001. * @param samplers defines the current sampler list.
  55002. */
  55003. static AddSamplers(samplers: string[]): void;
  55004. /**
  55005. * Makes a duplicate of the current configuration into another one.
  55006. * @param sheenConfiguration define the config where to copy the info
  55007. */
  55008. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55009. /**
  55010. * Serializes this BRDF configuration.
  55011. * @returns - An object with the serialized config.
  55012. */
  55013. serialize(): any;
  55014. /**
  55015. * Parses a anisotropy Configuration from a serialized object.
  55016. * @param source - Serialized object.
  55017. * @param scene Defines the scene we are parsing for
  55018. * @param rootUrl Defines the rootUrl to load from
  55019. */
  55020. parse(source: any, scene: Scene, rootUrl: string): void;
  55021. }
  55022. }
  55023. declare module BABYLON {
  55024. /**
  55025. * @hidden
  55026. */
  55027. export interface IMaterialSubSurfaceDefines {
  55028. SUBSURFACE: boolean;
  55029. SS_REFRACTION: boolean;
  55030. SS_TRANSLUCENCY: boolean;
  55031. SS_SCATTERING: boolean;
  55032. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55033. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55034. SS_REFRACTIONMAP_3D: boolean;
  55035. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55036. SS_LODINREFRACTIONALPHA: boolean;
  55037. SS_GAMMAREFRACTION: boolean;
  55038. SS_RGBDREFRACTION: boolean;
  55039. SS_LINEARSPECULARREFRACTION: boolean;
  55040. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55041. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55042. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55043. /** @hidden */
  55044. _areTexturesDirty: boolean;
  55045. }
  55046. /**
  55047. * Define the code related to the sub surface parameters of the pbr material.
  55048. */
  55049. export class PBRSubSurfaceConfiguration {
  55050. private _isRefractionEnabled;
  55051. /**
  55052. * Defines if the refraction is enabled in the material.
  55053. */
  55054. isRefractionEnabled: boolean;
  55055. private _isTranslucencyEnabled;
  55056. /**
  55057. * Defines if the translucency is enabled in the material.
  55058. */
  55059. isTranslucencyEnabled: boolean;
  55060. private _isScatteringEnabled;
  55061. /**
  55062. * Defines if the sub surface scattering is enabled in the material.
  55063. */
  55064. isScatteringEnabled: boolean;
  55065. private _scatteringDiffusionProfileIndex;
  55066. /**
  55067. * Diffusion profile for subsurface scattering.
  55068. * Useful for better scattering in the skins or foliages.
  55069. */
  55070. get scatteringDiffusionProfile(): Nullable<Color3>;
  55071. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55072. /**
  55073. * Defines the refraction intensity of the material.
  55074. * The refraction when enabled replaces the Diffuse part of the material.
  55075. * The intensity helps transitionning between diffuse and refraction.
  55076. */
  55077. refractionIntensity: number;
  55078. /**
  55079. * Defines the translucency intensity of the material.
  55080. * When translucency has been enabled, this defines how much of the "translucency"
  55081. * is addded to the diffuse part of the material.
  55082. */
  55083. translucencyIntensity: number;
  55084. /**
  55085. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55086. */
  55087. useAlbedoToTintRefraction: boolean;
  55088. private _thicknessTexture;
  55089. /**
  55090. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55091. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55092. * 0 would mean minimumThickness
  55093. * 1 would mean maximumThickness
  55094. * The other channels might be use as a mask to vary the different effects intensity.
  55095. */
  55096. thicknessTexture: Nullable<BaseTexture>;
  55097. private _refractionTexture;
  55098. /**
  55099. * Defines the texture to use for refraction.
  55100. */
  55101. refractionTexture: Nullable<BaseTexture>;
  55102. private _indexOfRefraction;
  55103. /**
  55104. * Index of refraction of the material base layer.
  55105. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55106. *
  55107. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55108. *
  55109. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55110. */
  55111. indexOfRefraction: number;
  55112. private _volumeIndexOfRefraction;
  55113. /**
  55114. * Index of refraction of the material's volume.
  55115. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55116. *
  55117. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55118. * the volume will use the same IOR as the surface.
  55119. */
  55120. get volumeIndexOfRefraction(): number;
  55121. set volumeIndexOfRefraction(value: number);
  55122. private _invertRefractionY;
  55123. /**
  55124. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55125. */
  55126. invertRefractionY: boolean;
  55127. private _linkRefractionWithTransparency;
  55128. /**
  55129. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55130. * Materials half opaque for instance using refraction could benefit from this control.
  55131. */
  55132. linkRefractionWithTransparency: boolean;
  55133. /**
  55134. * Defines the minimum thickness stored in the thickness map.
  55135. * If no thickness map is defined, this value will be used to simulate thickness.
  55136. */
  55137. minimumThickness: number;
  55138. /**
  55139. * Defines the maximum thickness stored in the thickness map.
  55140. */
  55141. maximumThickness: number;
  55142. /**
  55143. * Defines the volume tint of the material.
  55144. * This is used for both translucency and scattering.
  55145. */
  55146. tintColor: Color3;
  55147. /**
  55148. * Defines the distance at which the tint color should be found in the media.
  55149. * This is used for refraction only.
  55150. */
  55151. tintColorAtDistance: number;
  55152. /**
  55153. * Defines how far each channel transmit through the media.
  55154. * It is defined as a color to simplify it selection.
  55155. */
  55156. diffusionDistance: Color3;
  55157. private _useMaskFromThicknessTexture;
  55158. /**
  55159. * Stores the intensity of the different subsurface effects in the thickness texture.
  55160. * * the green channel is the translucency intensity.
  55161. * * the blue channel is the scattering intensity.
  55162. * * the alpha channel is the refraction intensity.
  55163. */
  55164. useMaskFromThicknessTexture: boolean;
  55165. private _scene;
  55166. /** @hidden */
  55167. private _internalMarkAllSubMeshesAsTexturesDirty;
  55168. private _internalMarkScenePrePassDirty;
  55169. /** @hidden */
  55170. _markAllSubMeshesAsTexturesDirty(): void;
  55171. /** @hidden */
  55172. _markScenePrePassDirty(): void;
  55173. /**
  55174. * Instantiate a new istance of sub surface configuration.
  55175. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55176. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55177. * @param scene The scene
  55178. */
  55179. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55180. /**
  55181. * Gets wehter the submesh is ready to be used or not.
  55182. * @param defines the list of "defines" to update.
  55183. * @param scene defines the scene the material belongs to.
  55184. * @returns - boolean indicating that the submesh is ready or not.
  55185. */
  55186. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55187. /**
  55188. * Checks to see if a texture is used in the material.
  55189. * @param defines the list of "defines" to update.
  55190. * @param scene defines the scene to the material belongs to.
  55191. */
  55192. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55193. /**
  55194. * Binds the material data.
  55195. * @param uniformBuffer defines the Uniform buffer to fill in.
  55196. * @param scene defines the scene the material belongs to.
  55197. * @param engine defines the engine the material belongs to.
  55198. * @param isFrozen defines whether the material is frozen or not.
  55199. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55200. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55201. */
  55202. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55203. /**
  55204. * Unbinds the material from the mesh.
  55205. * @param activeEffect defines the effect that should be unbound from.
  55206. * @returns true if unbound, otherwise false
  55207. */
  55208. unbind(activeEffect: Effect): boolean;
  55209. /**
  55210. * Returns the texture used for refraction or null if none is used.
  55211. * @param scene defines the scene the material belongs to.
  55212. * @returns - Refraction texture if present. If no refraction texture and refraction
  55213. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55214. */
  55215. private _getRefractionTexture;
  55216. /**
  55217. * Returns true if alpha blending should be disabled.
  55218. */
  55219. get disableAlphaBlending(): boolean;
  55220. /**
  55221. * Fills the list of render target textures.
  55222. * @param renderTargets the list of render targets to update
  55223. */
  55224. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55225. /**
  55226. * Checks to see if a texture is used in the material.
  55227. * @param texture - Base texture to use.
  55228. * @returns - Boolean specifying if a texture is used in the material.
  55229. */
  55230. hasTexture(texture: BaseTexture): boolean;
  55231. /**
  55232. * Gets a boolean indicating that current material needs to register RTT
  55233. * @returns true if this uses a render target otherwise false.
  55234. */
  55235. hasRenderTargetTextures(): boolean;
  55236. /**
  55237. * Returns an array of the actively used textures.
  55238. * @param activeTextures Array of BaseTextures
  55239. */
  55240. getActiveTextures(activeTextures: BaseTexture[]): void;
  55241. /**
  55242. * Returns the animatable textures.
  55243. * @param animatables Array of animatable textures.
  55244. */
  55245. getAnimatables(animatables: IAnimatable[]): void;
  55246. /**
  55247. * Disposes the resources of the material.
  55248. * @param forceDisposeTextures - Forces the disposal of all textures.
  55249. */
  55250. dispose(forceDisposeTextures?: boolean): void;
  55251. /**
  55252. * Get the current class name of the texture useful for serialization or dynamic coding.
  55253. * @returns "PBRSubSurfaceConfiguration"
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Add fallbacks to the effect fallbacks list.
  55258. * @param defines defines the Base texture to use.
  55259. * @param fallbacks defines the current fallback list.
  55260. * @param currentRank defines the current fallback rank.
  55261. * @returns the new fallback rank.
  55262. */
  55263. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55264. /**
  55265. * Add the required uniforms to the current list.
  55266. * @param uniforms defines the current uniform list.
  55267. */
  55268. static AddUniforms(uniforms: string[]): void;
  55269. /**
  55270. * Add the required samplers to the current list.
  55271. * @param samplers defines the current sampler list.
  55272. */
  55273. static AddSamplers(samplers: string[]): void;
  55274. /**
  55275. * Add the required uniforms to the current buffer.
  55276. * @param uniformBuffer defines the current uniform buffer.
  55277. */
  55278. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55279. /**
  55280. * Makes a duplicate of the current configuration into another one.
  55281. * @param configuration define the config where to copy the info
  55282. */
  55283. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55284. /**
  55285. * Serializes this Sub Surface configuration.
  55286. * @returns - An object with the serialized config.
  55287. */
  55288. serialize(): any;
  55289. /**
  55290. * Parses a anisotropy Configuration from a serialized object.
  55291. * @param source - Serialized object.
  55292. * @param scene Defines the scene we are parsing for
  55293. * @param rootUrl Defines the rootUrl to load from
  55294. */
  55295. parse(source: any, scene: Scene, rootUrl: string): void;
  55296. }
  55297. }
  55298. declare module BABYLON {
  55299. /** @hidden */
  55300. export var pbrFragmentDeclaration: {
  55301. name: string;
  55302. shader: string;
  55303. };
  55304. }
  55305. declare module BABYLON {
  55306. /** @hidden */
  55307. export var pbrUboDeclaration: {
  55308. name: string;
  55309. shader: string;
  55310. };
  55311. }
  55312. declare module BABYLON {
  55313. /** @hidden */
  55314. export var pbrFragmentExtraDeclaration: {
  55315. name: string;
  55316. shader: string;
  55317. };
  55318. }
  55319. declare module BABYLON {
  55320. /** @hidden */
  55321. export var pbrFragmentSamplersDeclaration: {
  55322. name: string;
  55323. shader: string;
  55324. };
  55325. }
  55326. declare module BABYLON {
  55327. /** @hidden */
  55328. export var importanceSampling: {
  55329. name: string;
  55330. shader: string;
  55331. };
  55332. }
  55333. declare module BABYLON {
  55334. /** @hidden */
  55335. export var pbrHelperFunctions: {
  55336. name: string;
  55337. shader: string;
  55338. };
  55339. }
  55340. declare module BABYLON {
  55341. /** @hidden */
  55342. export var harmonicsFunctions: {
  55343. name: string;
  55344. shader: string;
  55345. };
  55346. }
  55347. declare module BABYLON {
  55348. /** @hidden */
  55349. export var pbrDirectLightingSetupFunctions: {
  55350. name: string;
  55351. shader: string;
  55352. };
  55353. }
  55354. declare module BABYLON {
  55355. /** @hidden */
  55356. export var pbrDirectLightingFalloffFunctions: {
  55357. name: string;
  55358. shader: string;
  55359. };
  55360. }
  55361. declare module BABYLON {
  55362. /** @hidden */
  55363. export var pbrBRDFFunctions: {
  55364. name: string;
  55365. shader: string;
  55366. };
  55367. }
  55368. declare module BABYLON {
  55369. /** @hidden */
  55370. export var hdrFilteringFunctions: {
  55371. name: string;
  55372. shader: string;
  55373. };
  55374. }
  55375. declare module BABYLON {
  55376. /** @hidden */
  55377. export var pbrDirectLightingFunctions: {
  55378. name: string;
  55379. shader: string;
  55380. };
  55381. }
  55382. declare module BABYLON {
  55383. /** @hidden */
  55384. export var pbrIBLFunctions: {
  55385. name: string;
  55386. shader: string;
  55387. };
  55388. }
  55389. declare module BABYLON {
  55390. /** @hidden */
  55391. export var pbrBlockAlbedoOpacity: {
  55392. name: string;
  55393. shader: string;
  55394. };
  55395. }
  55396. declare module BABYLON {
  55397. /** @hidden */
  55398. export var pbrBlockReflectivity: {
  55399. name: string;
  55400. shader: string;
  55401. };
  55402. }
  55403. declare module BABYLON {
  55404. /** @hidden */
  55405. export var pbrBlockAmbientOcclusion: {
  55406. name: string;
  55407. shader: string;
  55408. };
  55409. }
  55410. declare module BABYLON {
  55411. /** @hidden */
  55412. export var pbrBlockAlphaFresnel: {
  55413. name: string;
  55414. shader: string;
  55415. };
  55416. }
  55417. declare module BABYLON {
  55418. /** @hidden */
  55419. export var pbrBlockAnisotropic: {
  55420. name: string;
  55421. shader: string;
  55422. };
  55423. }
  55424. declare module BABYLON {
  55425. /** @hidden */
  55426. export var pbrBlockReflection: {
  55427. name: string;
  55428. shader: string;
  55429. };
  55430. }
  55431. declare module BABYLON {
  55432. /** @hidden */
  55433. export var pbrBlockSheen: {
  55434. name: string;
  55435. shader: string;
  55436. };
  55437. }
  55438. declare module BABYLON {
  55439. /** @hidden */
  55440. export var pbrBlockClearcoat: {
  55441. name: string;
  55442. shader: string;
  55443. };
  55444. }
  55445. declare module BABYLON {
  55446. /** @hidden */
  55447. export var pbrBlockSubSurface: {
  55448. name: string;
  55449. shader: string;
  55450. };
  55451. }
  55452. declare module BABYLON {
  55453. /** @hidden */
  55454. export var pbrBlockNormalGeometric: {
  55455. name: string;
  55456. shader: string;
  55457. };
  55458. }
  55459. declare module BABYLON {
  55460. /** @hidden */
  55461. export var pbrBlockNormalFinal: {
  55462. name: string;
  55463. shader: string;
  55464. };
  55465. }
  55466. declare module BABYLON {
  55467. /** @hidden */
  55468. export var pbrBlockLightmapInit: {
  55469. name: string;
  55470. shader: string;
  55471. };
  55472. }
  55473. declare module BABYLON {
  55474. /** @hidden */
  55475. export var pbrBlockGeometryInfo: {
  55476. name: string;
  55477. shader: string;
  55478. };
  55479. }
  55480. declare module BABYLON {
  55481. /** @hidden */
  55482. export var pbrBlockReflectance0: {
  55483. name: string;
  55484. shader: string;
  55485. };
  55486. }
  55487. declare module BABYLON {
  55488. /** @hidden */
  55489. export var pbrBlockReflectance: {
  55490. name: string;
  55491. shader: string;
  55492. };
  55493. }
  55494. declare module BABYLON {
  55495. /** @hidden */
  55496. export var pbrBlockDirectLighting: {
  55497. name: string;
  55498. shader: string;
  55499. };
  55500. }
  55501. declare module BABYLON {
  55502. /** @hidden */
  55503. export var pbrBlockFinalLitComponents: {
  55504. name: string;
  55505. shader: string;
  55506. };
  55507. }
  55508. declare module BABYLON {
  55509. /** @hidden */
  55510. export var pbrBlockFinalUnlitComponents: {
  55511. name: string;
  55512. shader: string;
  55513. };
  55514. }
  55515. declare module BABYLON {
  55516. /** @hidden */
  55517. export var pbrBlockFinalColorComposition: {
  55518. name: string;
  55519. shader: string;
  55520. };
  55521. }
  55522. declare module BABYLON {
  55523. /** @hidden */
  55524. export var pbrBlockImageProcessing: {
  55525. name: string;
  55526. shader: string;
  55527. };
  55528. }
  55529. declare module BABYLON {
  55530. /** @hidden */
  55531. export var pbrDebug: {
  55532. name: string;
  55533. shader: string;
  55534. };
  55535. }
  55536. declare module BABYLON {
  55537. /** @hidden */
  55538. export var pbrPixelShader: {
  55539. name: string;
  55540. shader: string;
  55541. };
  55542. }
  55543. declare module BABYLON {
  55544. /** @hidden */
  55545. export var pbrVertexDeclaration: {
  55546. name: string;
  55547. shader: string;
  55548. };
  55549. }
  55550. declare module BABYLON {
  55551. /** @hidden */
  55552. export var pbrVertexShader: {
  55553. name: string;
  55554. shader: string;
  55555. };
  55556. }
  55557. declare module BABYLON {
  55558. /**
  55559. * Manages the defines for the PBR Material.
  55560. * @hidden
  55561. */
  55562. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55563. PBR: boolean;
  55564. NUM_SAMPLES: string;
  55565. REALTIME_FILTERING: boolean;
  55566. MAINUV1: boolean;
  55567. MAINUV2: boolean;
  55568. UV1: boolean;
  55569. UV2: boolean;
  55570. ALBEDO: boolean;
  55571. GAMMAALBEDO: boolean;
  55572. ALBEDODIRECTUV: number;
  55573. VERTEXCOLOR: boolean;
  55574. DETAIL: boolean;
  55575. DETAILDIRECTUV: number;
  55576. DETAIL_NORMALBLENDMETHOD: number;
  55577. AMBIENT: boolean;
  55578. AMBIENTDIRECTUV: number;
  55579. AMBIENTINGRAYSCALE: boolean;
  55580. OPACITY: boolean;
  55581. VERTEXALPHA: boolean;
  55582. OPACITYDIRECTUV: number;
  55583. OPACITYRGB: boolean;
  55584. ALPHATEST: boolean;
  55585. DEPTHPREPASS: boolean;
  55586. ALPHABLEND: boolean;
  55587. ALPHAFROMALBEDO: boolean;
  55588. ALPHATESTVALUE: string;
  55589. SPECULAROVERALPHA: boolean;
  55590. RADIANCEOVERALPHA: boolean;
  55591. ALPHAFRESNEL: boolean;
  55592. LINEARALPHAFRESNEL: boolean;
  55593. PREMULTIPLYALPHA: boolean;
  55594. EMISSIVE: boolean;
  55595. EMISSIVEDIRECTUV: number;
  55596. REFLECTIVITY: boolean;
  55597. REFLECTIVITYDIRECTUV: number;
  55598. SPECULARTERM: boolean;
  55599. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55600. MICROSURFACEAUTOMATIC: boolean;
  55601. LODBASEDMICROSFURACE: boolean;
  55602. MICROSURFACEMAP: boolean;
  55603. MICROSURFACEMAPDIRECTUV: number;
  55604. METALLICWORKFLOW: boolean;
  55605. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55606. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55607. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55608. AOSTOREINMETALMAPRED: boolean;
  55609. METALLIC_REFLECTANCE: boolean;
  55610. METALLIC_REFLECTANCEDIRECTUV: number;
  55611. ENVIRONMENTBRDF: boolean;
  55612. ENVIRONMENTBRDF_RGBD: boolean;
  55613. NORMAL: boolean;
  55614. TANGENT: boolean;
  55615. BUMP: boolean;
  55616. BUMPDIRECTUV: number;
  55617. OBJECTSPACE_NORMALMAP: boolean;
  55618. PARALLAX: boolean;
  55619. PARALLAXOCCLUSION: boolean;
  55620. NORMALXYSCALE: boolean;
  55621. LIGHTMAP: boolean;
  55622. LIGHTMAPDIRECTUV: number;
  55623. USELIGHTMAPASSHADOWMAP: boolean;
  55624. GAMMALIGHTMAP: boolean;
  55625. RGBDLIGHTMAP: boolean;
  55626. REFLECTION: boolean;
  55627. REFLECTIONMAP_3D: boolean;
  55628. REFLECTIONMAP_SPHERICAL: boolean;
  55629. REFLECTIONMAP_PLANAR: boolean;
  55630. REFLECTIONMAP_CUBIC: boolean;
  55631. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55632. REFLECTIONMAP_PROJECTION: boolean;
  55633. REFLECTIONMAP_SKYBOX: boolean;
  55634. REFLECTIONMAP_EXPLICIT: boolean;
  55635. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55636. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55637. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55638. INVERTCUBICMAP: boolean;
  55639. USESPHERICALFROMREFLECTIONMAP: boolean;
  55640. USEIRRADIANCEMAP: boolean;
  55641. SPHERICAL_HARMONICS: boolean;
  55642. USESPHERICALINVERTEX: boolean;
  55643. REFLECTIONMAP_OPPOSITEZ: boolean;
  55644. LODINREFLECTIONALPHA: boolean;
  55645. GAMMAREFLECTION: boolean;
  55646. RGBDREFLECTION: boolean;
  55647. LINEARSPECULARREFLECTION: boolean;
  55648. RADIANCEOCCLUSION: boolean;
  55649. HORIZONOCCLUSION: boolean;
  55650. INSTANCES: boolean;
  55651. THIN_INSTANCES: boolean;
  55652. PREPASS: boolean;
  55653. SCENE_MRT_COUNT: number;
  55654. NUM_BONE_INFLUENCERS: number;
  55655. BonesPerMesh: number;
  55656. BONETEXTURE: boolean;
  55657. NONUNIFORMSCALING: boolean;
  55658. MORPHTARGETS: boolean;
  55659. MORPHTARGETS_NORMAL: boolean;
  55660. MORPHTARGETS_TANGENT: boolean;
  55661. MORPHTARGETS_UV: boolean;
  55662. NUM_MORPH_INFLUENCERS: number;
  55663. IMAGEPROCESSING: boolean;
  55664. VIGNETTE: boolean;
  55665. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55666. VIGNETTEBLENDMODEOPAQUE: boolean;
  55667. TONEMAPPING: boolean;
  55668. TONEMAPPING_ACES: boolean;
  55669. CONTRAST: boolean;
  55670. COLORCURVES: boolean;
  55671. COLORGRADING: boolean;
  55672. COLORGRADING3D: boolean;
  55673. SAMPLER3DGREENDEPTH: boolean;
  55674. SAMPLER3DBGRMAP: boolean;
  55675. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55676. EXPOSURE: boolean;
  55677. MULTIVIEW: boolean;
  55678. USEPHYSICALLIGHTFALLOFF: boolean;
  55679. USEGLTFLIGHTFALLOFF: boolean;
  55680. TWOSIDEDLIGHTING: boolean;
  55681. SHADOWFLOAT: boolean;
  55682. CLIPPLANE: boolean;
  55683. CLIPPLANE2: boolean;
  55684. CLIPPLANE3: boolean;
  55685. CLIPPLANE4: boolean;
  55686. CLIPPLANE5: boolean;
  55687. CLIPPLANE6: boolean;
  55688. POINTSIZE: boolean;
  55689. FOG: boolean;
  55690. LOGARITHMICDEPTH: boolean;
  55691. FORCENORMALFORWARD: boolean;
  55692. SPECULARAA: boolean;
  55693. CLEARCOAT: boolean;
  55694. CLEARCOAT_DEFAULTIOR: boolean;
  55695. CLEARCOAT_TEXTURE: boolean;
  55696. CLEARCOAT_TEXTUREDIRECTUV: number;
  55697. CLEARCOAT_BUMP: boolean;
  55698. CLEARCOAT_BUMPDIRECTUV: number;
  55699. CLEARCOAT_TINT: boolean;
  55700. CLEARCOAT_TINT_TEXTURE: boolean;
  55701. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55702. ANISOTROPIC: boolean;
  55703. ANISOTROPIC_TEXTURE: boolean;
  55704. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55705. BRDF_V_HEIGHT_CORRELATED: boolean;
  55706. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55707. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55708. SHEEN: boolean;
  55709. SHEEN_TEXTURE: boolean;
  55710. SHEEN_TEXTUREDIRECTUV: number;
  55711. SHEEN_LINKWITHALBEDO: boolean;
  55712. SHEEN_ROUGHNESS: boolean;
  55713. SHEEN_ALBEDOSCALING: boolean;
  55714. SUBSURFACE: boolean;
  55715. SS_REFRACTION: boolean;
  55716. SS_TRANSLUCENCY: boolean;
  55717. SS_SCATTERING: boolean;
  55718. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55719. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55720. SS_REFRACTIONMAP_3D: boolean;
  55721. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55722. SS_LODINREFRACTIONALPHA: boolean;
  55723. SS_GAMMAREFRACTION: boolean;
  55724. SS_RGBDREFRACTION: boolean;
  55725. SS_LINEARSPECULARREFRACTION: boolean;
  55726. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55727. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55728. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55729. UNLIT: boolean;
  55730. DEBUGMODE: number;
  55731. /**
  55732. * Initializes the PBR Material defines.
  55733. */
  55734. constructor();
  55735. /**
  55736. * Resets the PBR Material defines.
  55737. */
  55738. reset(): void;
  55739. }
  55740. /**
  55741. * The Physically based material base class of BJS.
  55742. *
  55743. * This offers the main features of a standard PBR material.
  55744. * For more information, please refer to the documentation :
  55745. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55746. */
  55747. export abstract class PBRBaseMaterial extends PushMaterial {
  55748. /**
  55749. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55750. */
  55751. static readonly PBRMATERIAL_OPAQUE: number;
  55752. /**
  55753. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55754. */
  55755. static readonly PBRMATERIAL_ALPHATEST: number;
  55756. /**
  55757. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55758. */
  55759. static readonly PBRMATERIAL_ALPHABLEND: number;
  55760. /**
  55761. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55762. * They are also discarded below the alpha cutoff threshold to improve performances.
  55763. */
  55764. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55765. /**
  55766. * Defines the default value of how much AO map is occluding the analytical lights
  55767. * (point spot...).
  55768. */
  55769. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55770. /**
  55771. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55772. */
  55773. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55774. /**
  55775. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55776. * to enhance interoperability with other engines.
  55777. */
  55778. static readonly LIGHTFALLOFF_GLTF: number;
  55779. /**
  55780. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55781. * to enhance interoperability with other materials.
  55782. */
  55783. static readonly LIGHTFALLOFF_STANDARD: number;
  55784. /**
  55785. * Intensity of the direct lights e.g. the four lights available in your scene.
  55786. * This impacts both the direct diffuse and specular highlights.
  55787. */
  55788. protected _directIntensity: number;
  55789. /**
  55790. * Intensity of the emissive part of the material.
  55791. * This helps controlling the emissive effect without modifying the emissive color.
  55792. */
  55793. protected _emissiveIntensity: number;
  55794. /**
  55795. * Intensity of the environment e.g. how much the environment will light the object
  55796. * either through harmonics for rough material or through the refelction for shiny ones.
  55797. */
  55798. protected _environmentIntensity: number;
  55799. /**
  55800. * This is a special control allowing the reduction of the specular highlights coming from the
  55801. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55802. */
  55803. protected _specularIntensity: number;
  55804. /**
  55805. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55806. */
  55807. private _lightingInfos;
  55808. /**
  55809. * Debug Control allowing disabling the bump map on this material.
  55810. */
  55811. protected _disableBumpMap: boolean;
  55812. /**
  55813. * AKA Diffuse Texture in standard nomenclature.
  55814. */
  55815. protected _albedoTexture: Nullable<BaseTexture>;
  55816. /**
  55817. * AKA Occlusion Texture in other nomenclature.
  55818. */
  55819. protected _ambientTexture: Nullable<BaseTexture>;
  55820. /**
  55821. * AKA Occlusion Texture Intensity in other nomenclature.
  55822. */
  55823. protected _ambientTextureStrength: number;
  55824. /**
  55825. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55826. * 1 means it completely occludes it
  55827. * 0 mean it has no impact
  55828. */
  55829. protected _ambientTextureImpactOnAnalyticalLights: number;
  55830. /**
  55831. * Stores the alpha values in a texture.
  55832. */
  55833. protected _opacityTexture: Nullable<BaseTexture>;
  55834. /**
  55835. * Stores the reflection values in a texture.
  55836. */
  55837. protected _reflectionTexture: Nullable<BaseTexture>;
  55838. /**
  55839. * Stores the emissive values in a texture.
  55840. */
  55841. protected _emissiveTexture: Nullable<BaseTexture>;
  55842. /**
  55843. * AKA Specular texture in other nomenclature.
  55844. */
  55845. protected _reflectivityTexture: Nullable<BaseTexture>;
  55846. /**
  55847. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55848. */
  55849. protected _metallicTexture: Nullable<BaseTexture>;
  55850. /**
  55851. * Specifies the metallic scalar of the metallic/roughness workflow.
  55852. * Can also be used to scale the metalness values of the metallic texture.
  55853. */
  55854. protected _metallic: Nullable<number>;
  55855. /**
  55856. * Specifies the roughness scalar of the metallic/roughness workflow.
  55857. * Can also be used to scale the roughness values of the metallic texture.
  55858. */
  55859. protected _roughness: Nullable<number>;
  55860. /**
  55861. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55862. * By default the indexOfrefraction is used to compute F0;
  55863. *
  55864. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55865. *
  55866. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55867. * F90 = metallicReflectanceColor;
  55868. */
  55869. protected _metallicF0Factor: number;
  55870. /**
  55871. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55872. * By default the F90 is always 1;
  55873. *
  55874. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55875. *
  55876. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55877. * F90 = metallicReflectanceColor;
  55878. */
  55879. protected _metallicReflectanceColor: Color3;
  55880. /**
  55881. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55882. * This is multiply against the scalar values defined in the material.
  55883. */
  55884. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55885. /**
  55886. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55887. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55888. */
  55889. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55890. /**
  55891. * Stores surface normal data used to displace a mesh in a texture.
  55892. */
  55893. protected _bumpTexture: Nullable<BaseTexture>;
  55894. /**
  55895. * Stores the pre-calculated light information of a mesh in a texture.
  55896. */
  55897. protected _lightmapTexture: Nullable<BaseTexture>;
  55898. /**
  55899. * The color of a material in ambient lighting.
  55900. */
  55901. protected _ambientColor: Color3;
  55902. /**
  55903. * AKA Diffuse Color in other nomenclature.
  55904. */
  55905. protected _albedoColor: Color3;
  55906. /**
  55907. * AKA Specular Color in other nomenclature.
  55908. */
  55909. protected _reflectivityColor: Color3;
  55910. /**
  55911. * The color applied when light is reflected from a material.
  55912. */
  55913. protected _reflectionColor: Color3;
  55914. /**
  55915. * The color applied when light is emitted from a material.
  55916. */
  55917. protected _emissiveColor: Color3;
  55918. /**
  55919. * AKA Glossiness in other nomenclature.
  55920. */
  55921. protected _microSurface: number;
  55922. /**
  55923. * Specifies that the material will use the light map as a show map.
  55924. */
  55925. protected _useLightmapAsShadowmap: boolean;
  55926. /**
  55927. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55928. * makes the reflect vector face the model (under horizon).
  55929. */
  55930. protected _useHorizonOcclusion: boolean;
  55931. /**
  55932. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55933. * too much the area relying on ambient texture to define their ambient occlusion.
  55934. */
  55935. protected _useRadianceOcclusion: boolean;
  55936. /**
  55937. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55938. */
  55939. protected _useAlphaFromAlbedoTexture: boolean;
  55940. /**
  55941. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55942. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55943. */
  55944. protected _useSpecularOverAlpha: boolean;
  55945. /**
  55946. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55947. */
  55948. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55949. /**
  55950. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55951. */
  55952. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55953. /**
  55954. * Specifies if the metallic texture contains the roughness information in its green channel.
  55955. */
  55956. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55957. /**
  55958. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55959. */
  55960. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55961. /**
  55962. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55963. */
  55964. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55965. /**
  55966. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55967. */
  55968. protected _useAmbientInGrayScale: boolean;
  55969. /**
  55970. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55971. * The material will try to infer what glossiness each pixel should be.
  55972. */
  55973. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55974. /**
  55975. * Defines the falloff type used in this material.
  55976. * It by default is Physical.
  55977. */
  55978. protected _lightFalloff: number;
  55979. /**
  55980. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55981. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55982. */
  55983. protected _useRadianceOverAlpha: boolean;
  55984. /**
  55985. * Allows using an object space normal map (instead of tangent space).
  55986. */
  55987. protected _useObjectSpaceNormalMap: boolean;
  55988. /**
  55989. * Allows using the bump map in parallax mode.
  55990. */
  55991. protected _useParallax: boolean;
  55992. /**
  55993. * Allows using the bump map in parallax occlusion mode.
  55994. */
  55995. protected _useParallaxOcclusion: boolean;
  55996. /**
  55997. * Controls the scale bias of the parallax mode.
  55998. */
  55999. protected _parallaxScaleBias: number;
  56000. /**
  56001. * If sets to true, disables all the lights affecting the material.
  56002. */
  56003. protected _disableLighting: boolean;
  56004. /**
  56005. * Number of Simultaneous lights allowed on the material.
  56006. */
  56007. protected _maxSimultaneousLights: number;
  56008. /**
  56009. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56010. */
  56011. protected _invertNormalMapX: boolean;
  56012. /**
  56013. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56014. */
  56015. protected _invertNormalMapY: boolean;
  56016. /**
  56017. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56018. */
  56019. protected _twoSidedLighting: boolean;
  56020. /**
  56021. * Defines the alpha limits in alpha test mode.
  56022. */
  56023. protected _alphaCutOff: number;
  56024. /**
  56025. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56026. */
  56027. protected _forceAlphaTest: boolean;
  56028. /**
  56029. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56030. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56031. */
  56032. protected _useAlphaFresnel: boolean;
  56033. /**
  56034. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56035. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56036. */
  56037. protected _useLinearAlphaFresnel: boolean;
  56038. /**
  56039. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56040. * from cos thetav and roughness:
  56041. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56042. */
  56043. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56044. /**
  56045. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56046. */
  56047. protected _forceIrradianceInFragment: boolean;
  56048. private _realTimeFiltering;
  56049. /**
  56050. * Enables realtime filtering on the texture.
  56051. */
  56052. get realTimeFiltering(): boolean;
  56053. set realTimeFiltering(b: boolean);
  56054. private _realTimeFilteringQuality;
  56055. /**
  56056. * Quality switch for realtime filtering
  56057. */
  56058. get realTimeFilteringQuality(): number;
  56059. set realTimeFilteringQuality(n: number);
  56060. /**
  56061. * Can this material render to several textures at once
  56062. */
  56063. get canRenderToMRT(): boolean;
  56064. /**
  56065. * Force normal to face away from face.
  56066. */
  56067. protected _forceNormalForward: boolean;
  56068. /**
  56069. * Enables specular anti aliasing in the PBR shader.
  56070. * It will both interacts on the Geometry for analytical and IBL lighting.
  56071. * It also prefilter the roughness map based on the bump values.
  56072. */
  56073. protected _enableSpecularAntiAliasing: boolean;
  56074. /**
  56075. * Default configuration related to image processing available in the PBR Material.
  56076. */
  56077. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56078. /**
  56079. * Keep track of the image processing observer to allow dispose and replace.
  56080. */
  56081. private _imageProcessingObserver;
  56082. /**
  56083. * Attaches a new image processing configuration to the PBR Material.
  56084. * @param configuration
  56085. */
  56086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56087. /**
  56088. * Stores the available render targets.
  56089. */
  56090. private _renderTargets;
  56091. /**
  56092. * Sets the global ambient color for the material used in lighting calculations.
  56093. */
  56094. private _globalAmbientColor;
  56095. /**
  56096. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56097. */
  56098. private _useLogarithmicDepth;
  56099. /**
  56100. * If set to true, no lighting calculations will be applied.
  56101. */
  56102. private _unlit;
  56103. private _debugMode;
  56104. /**
  56105. * @hidden
  56106. * This is reserved for the inspector.
  56107. * Defines the material debug mode.
  56108. * It helps seeing only some components of the material while troubleshooting.
  56109. */
  56110. debugMode: number;
  56111. /**
  56112. * @hidden
  56113. * This is reserved for the inspector.
  56114. * Specify from where on screen the debug mode should start.
  56115. * The value goes from -1 (full screen) to 1 (not visible)
  56116. * It helps with side by side comparison against the final render
  56117. * This defaults to -1
  56118. */
  56119. private debugLimit;
  56120. /**
  56121. * @hidden
  56122. * This is reserved for the inspector.
  56123. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56124. * You can use the factor to better multiply the final value.
  56125. */
  56126. private debugFactor;
  56127. /**
  56128. * Defines the clear coat layer parameters for the material.
  56129. */
  56130. readonly clearCoat: PBRClearCoatConfiguration;
  56131. /**
  56132. * Defines the anisotropic parameters for the material.
  56133. */
  56134. readonly anisotropy: PBRAnisotropicConfiguration;
  56135. /**
  56136. * Defines the BRDF parameters for the material.
  56137. */
  56138. readonly brdf: PBRBRDFConfiguration;
  56139. /**
  56140. * Defines the Sheen parameters for the material.
  56141. */
  56142. readonly sheen: PBRSheenConfiguration;
  56143. /**
  56144. * Defines the SubSurface parameters for the material.
  56145. */
  56146. readonly subSurface: PBRSubSurfaceConfiguration;
  56147. /**
  56148. * Defines the detail map parameters for the material.
  56149. */
  56150. readonly detailMap: DetailMapConfiguration;
  56151. protected _rebuildInParallel: boolean;
  56152. /**
  56153. * Instantiates a new PBRMaterial instance.
  56154. *
  56155. * @param name The material name
  56156. * @param scene The scene the material will be use in.
  56157. */
  56158. constructor(name: string, scene: Scene);
  56159. /**
  56160. * Gets a boolean indicating that current material needs to register RTT
  56161. */
  56162. get hasRenderTargetTextures(): boolean;
  56163. /**
  56164. * Gets the name of the material class.
  56165. */
  56166. getClassName(): string;
  56167. /**
  56168. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56169. */
  56170. get useLogarithmicDepth(): boolean;
  56171. /**
  56172. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56173. */
  56174. set useLogarithmicDepth(value: boolean);
  56175. /**
  56176. * Returns true if alpha blending should be disabled.
  56177. */
  56178. protected get _disableAlphaBlending(): boolean;
  56179. /**
  56180. * Specifies whether or not this material should be rendered in alpha blend mode.
  56181. */
  56182. needAlphaBlending(): boolean;
  56183. /**
  56184. * Specifies whether or not this material should be rendered in alpha test mode.
  56185. */
  56186. needAlphaTesting(): boolean;
  56187. /**
  56188. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56189. */
  56190. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56191. /**
  56192. * Gets the texture used for the alpha test.
  56193. */
  56194. getAlphaTestTexture(): Nullable<BaseTexture>;
  56195. /**
  56196. * Specifies that the submesh is ready to be used.
  56197. * @param mesh - BJS mesh.
  56198. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56199. * @param useInstances - Specifies that instances should be used.
  56200. * @returns - boolean indicating that the submesh is ready or not.
  56201. */
  56202. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56203. /**
  56204. * Specifies if the material uses metallic roughness workflow.
  56205. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56206. */
  56207. isMetallicWorkflow(): boolean;
  56208. private _prepareEffect;
  56209. private _prepareDefines;
  56210. /**
  56211. * Force shader compilation
  56212. */
  56213. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56214. /**
  56215. * Initializes the uniform buffer layout for the shader.
  56216. */
  56217. buildUniformLayout(): void;
  56218. /**
  56219. * Unbinds the material from the mesh
  56220. */
  56221. unbind(): void;
  56222. /**
  56223. * Binds the submesh data.
  56224. * @param world - The world matrix.
  56225. * @param mesh - The BJS mesh.
  56226. * @param subMesh - A submesh of the BJS mesh.
  56227. */
  56228. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56229. /**
  56230. * Returns the animatable textures.
  56231. * @returns - Array of animatable textures.
  56232. */
  56233. getAnimatables(): IAnimatable[];
  56234. /**
  56235. * Returns the texture used for reflections.
  56236. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56237. */
  56238. private _getReflectionTexture;
  56239. /**
  56240. * Returns an array of the actively used textures.
  56241. * @returns - Array of BaseTextures
  56242. */
  56243. getActiveTextures(): BaseTexture[];
  56244. /**
  56245. * Checks to see if a texture is used in the material.
  56246. * @param texture - Base texture to use.
  56247. * @returns - Boolean specifying if a texture is used in the material.
  56248. */
  56249. hasTexture(texture: BaseTexture): boolean;
  56250. /**
  56251. * Sets the required values to the prepass renderer.
  56252. * @param prePassRenderer defines the prepass renderer to setup
  56253. */
  56254. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56255. /**
  56256. * Disposes the resources of the material.
  56257. * @param forceDisposeEffect - Forces the disposal of effects.
  56258. * @param forceDisposeTextures - Forces the disposal of all textures.
  56259. */
  56260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56261. }
  56262. }
  56263. declare module BABYLON {
  56264. /**
  56265. * The Physically based material of BJS.
  56266. *
  56267. * This offers the main features of a standard PBR material.
  56268. * For more information, please refer to the documentation :
  56269. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56270. */
  56271. export class PBRMaterial extends PBRBaseMaterial {
  56272. /**
  56273. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56274. */
  56275. static readonly PBRMATERIAL_OPAQUE: number;
  56276. /**
  56277. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56278. */
  56279. static readonly PBRMATERIAL_ALPHATEST: number;
  56280. /**
  56281. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56282. */
  56283. static readonly PBRMATERIAL_ALPHABLEND: number;
  56284. /**
  56285. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56286. * They are also discarded below the alpha cutoff threshold to improve performances.
  56287. */
  56288. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56289. /**
  56290. * Defines the default value of how much AO map is occluding the analytical lights
  56291. * (point spot...).
  56292. */
  56293. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56294. /**
  56295. * Intensity of the direct lights e.g. the four lights available in your scene.
  56296. * This impacts both the direct diffuse and specular highlights.
  56297. */
  56298. directIntensity: number;
  56299. /**
  56300. * Intensity of the emissive part of the material.
  56301. * This helps controlling the emissive effect without modifying the emissive color.
  56302. */
  56303. emissiveIntensity: number;
  56304. /**
  56305. * Intensity of the environment e.g. how much the environment will light the object
  56306. * either through harmonics for rough material or through the refelction for shiny ones.
  56307. */
  56308. environmentIntensity: number;
  56309. /**
  56310. * This is a special control allowing the reduction of the specular highlights coming from the
  56311. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56312. */
  56313. specularIntensity: number;
  56314. /**
  56315. * Debug Control allowing disabling the bump map on this material.
  56316. */
  56317. disableBumpMap: boolean;
  56318. /**
  56319. * AKA Diffuse Texture in standard nomenclature.
  56320. */
  56321. albedoTexture: BaseTexture;
  56322. /**
  56323. * AKA Occlusion Texture in other nomenclature.
  56324. */
  56325. ambientTexture: BaseTexture;
  56326. /**
  56327. * AKA Occlusion Texture Intensity in other nomenclature.
  56328. */
  56329. ambientTextureStrength: number;
  56330. /**
  56331. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56332. * 1 means it completely occludes it
  56333. * 0 mean it has no impact
  56334. */
  56335. ambientTextureImpactOnAnalyticalLights: number;
  56336. /**
  56337. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56338. */
  56339. opacityTexture: BaseTexture;
  56340. /**
  56341. * Stores the reflection values in a texture.
  56342. */
  56343. reflectionTexture: Nullable<BaseTexture>;
  56344. /**
  56345. * Stores the emissive values in a texture.
  56346. */
  56347. emissiveTexture: BaseTexture;
  56348. /**
  56349. * AKA Specular texture in other nomenclature.
  56350. */
  56351. reflectivityTexture: BaseTexture;
  56352. /**
  56353. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56354. */
  56355. metallicTexture: BaseTexture;
  56356. /**
  56357. * Specifies the metallic scalar of the metallic/roughness workflow.
  56358. * Can also be used to scale the metalness values of the metallic texture.
  56359. */
  56360. metallic: Nullable<number>;
  56361. /**
  56362. * Specifies the roughness scalar of the metallic/roughness workflow.
  56363. * Can also be used to scale the roughness values of the metallic texture.
  56364. */
  56365. roughness: Nullable<number>;
  56366. /**
  56367. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56368. * By default the indexOfrefraction is used to compute F0;
  56369. *
  56370. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56371. *
  56372. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56373. * F90 = metallicReflectanceColor;
  56374. */
  56375. metallicF0Factor: number;
  56376. /**
  56377. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56378. * By default the F90 is always 1;
  56379. *
  56380. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56381. *
  56382. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56383. * F90 = metallicReflectanceColor;
  56384. */
  56385. metallicReflectanceColor: Color3;
  56386. /**
  56387. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56388. * This is multiply against the scalar values defined in the material.
  56389. */
  56390. metallicReflectanceTexture: Nullable<BaseTexture>;
  56391. /**
  56392. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56393. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56394. */
  56395. microSurfaceTexture: BaseTexture;
  56396. /**
  56397. * Stores surface normal data used to displace a mesh in a texture.
  56398. */
  56399. bumpTexture: BaseTexture;
  56400. /**
  56401. * Stores the pre-calculated light information of a mesh in a texture.
  56402. */
  56403. lightmapTexture: BaseTexture;
  56404. /**
  56405. * Stores the refracted light information in a texture.
  56406. */
  56407. get refractionTexture(): Nullable<BaseTexture>;
  56408. set refractionTexture(value: Nullable<BaseTexture>);
  56409. /**
  56410. * The color of a material in ambient lighting.
  56411. */
  56412. ambientColor: Color3;
  56413. /**
  56414. * AKA Diffuse Color in other nomenclature.
  56415. */
  56416. albedoColor: Color3;
  56417. /**
  56418. * AKA Specular Color in other nomenclature.
  56419. */
  56420. reflectivityColor: Color3;
  56421. /**
  56422. * The color reflected from the material.
  56423. */
  56424. reflectionColor: Color3;
  56425. /**
  56426. * The color emitted from the material.
  56427. */
  56428. emissiveColor: Color3;
  56429. /**
  56430. * AKA Glossiness in other nomenclature.
  56431. */
  56432. microSurface: number;
  56433. /**
  56434. * Index of refraction of the material base layer.
  56435. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56436. *
  56437. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56438. *
  56439. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56440. */
  56441. get indexOfRefraction(): number;
  56442. set indexOfRefraction(value: number);
  56443. /**
  56444. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56445. */
  56446. get invertRefractionY(): boolean;
  56447. set invertRefractionY(value: boolean);
  56448. /**
  56449. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56450. * Materials half opaque for instance using refraction could benefit from this control.
  56451. */
  56452. get linkRefractionWithTransparency(): boolean;
  56453. set linkRefractionWithTransparency(value: boolean);
  56454. /**
  56455. * If true, the light map contains occlusion information instead of lighting info.
  56456. */
  56457. useLightmapAsShadowmap: boolean;
  56458. /**
  56459. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56460. */
  56461. useAlphaFromAlbedoTexture: boolean;
  56462. /**
  56463. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56464. */
  56465. forceAlphaTest: boolean;
  56466. /**
  56467. * Defines the alpha limits in alpha test mode.
  56468. */
  56469. alphaCutOff: number;
  56470. /**
  56471. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56472. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56473. */
  56474. useSpecularOverAlpha: boolean;
  56475. /**
  56476. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56477. */
  56478. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56479. /**
  56480. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56481. */
  56482. useRoughnessFromMetallicTextureAlpha: boolean;
  56483. /**
  56484. * Specifies if the metallic texture contains the roughness information in its green channel.
  56485. */
  56486. useRoughnessFromMetallicTextureGreen: boolean;
  56487. /**
  56488. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56489. */
  56490. useMetallnessFromMetallicTextureBlue: boolean;
  56491. /**
  56492. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56493. */
  56494. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56495. /**
  56496. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56497. */
  56498. useAmbientInGrayScale: boolean;
  56499. /**
  56500. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56501. * The material will try to infer what glossiness each pixel should be.
  56502. */
  56503. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56504. /**
  56505. * BJS is using an harcoded light falloff based on a manually sets up range.
  56506. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56507. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56508. */
  56509. get usePhysicalLightFalloff(): boolean;
  56510. /**
  56511. * BJS is using an harcoded light falloff based on a manually sets up range.
  56512. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56513. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56514. */
  56515. set usePhysicalLightFalloff(value: boolean);
  56516. /**
  56517. * In order to support the falloff compatibility with gltf, a special mode has been added
  56518. * to reproduce the gltf light falloff.
  56519. */
  56520. get useGLTFLightFalloff(): boolean;
  56521. /**
  56522. * In order to support the falloff compatibility with gltf, a special mode has been added
  56523. * to reproduce the gltf light falloff.
  56524. */
  56525. set useGLTFLightFalloff(value: boolean);
  56526. /**
  56527. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56528. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56529. */
  56530. useRadianceOverAlpha: boolean;
  56531. /**
  56532. * Allows using an object space normal map (instead of tangent space).
  56533. */
  56534. useObjectSpaceNormalMap: boolean;
  56535. /**
  56536. * Allows using the bump map in parallax mode.
  56537. */
  56538. useParallax: boolean;
  56539. /**
  56540. * Allows using the bump map in parallax occlusion mode.
  56541. */
  56542. useParallaxOcclusion: boolean;
  56543. /**
  56544. * Controls the scale bias of the parallax mode.
  56545. */
  56546. parallaxScaleBias: number;
  56547. /**
  56548. * If sets to true, disables all the lights affecting the material.
  56549. */
  56550. disableLighting: boolean;
  56551. /**
  56552. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56553. */
  56554. forceIrradianceInFragment: boolean;
  56555. /**
  56556. * Number of Simultaneous lights allowed on the material.
  56557. */
  56558. maxSimultaneousLights: number;
  56559. /**
  56560. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56561. */
  56562. invertNormalMapX: boolean;
  56563. /**
  56564. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56565. */
  56566. invertNormalMapY: boolean;
  56567. /**
  56568. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56569. */
  56570. twoSidedLighting: boolean;
  56571. /**
  56572. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56573. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56574. */
  56575. useAlphaFresnel: boolean;
  56576. /**
  56577. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56578. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56579. */
  56580. useLinearAlphaFresnel: boolean;
  56581. /**
  56582. * Let user defines the brdf lookup texture used for IBL.
  56583. * A default 8bit version is embedded but you could point at :
  56584. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56585. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56586. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56587. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56588. */
  56589. environmentBRDFTexture: Nullable<BaseTexture>;
  56590. /**
  56591. * Force normal to face away from face.
  56592. */
  56593. forceNormalForward: boolean;
  56594. /**
  56595. * Enables specular anti aliasing in the PBR shader.
  56596. * It will both interacts on the Geometry for analytical and IBL lighting.
  56597. * It also prefilter the roughness map based on the bump values.
  56598. */
  56599. enableSpecularAntiAliasing: boolean;
  56600. /**
  56601. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56602. * makes the reflect vector face the model (under horizon).
  56603. */
  56604. useHorizonOcclusion: boolean;
  56605. /**
  56606. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56607. * too much the area relying on ambient texture to define their ambient occlusion.
  56608. */
  56609. useRadianceOcclusion: boolean;
  56610. /**
  56611. * If set to true, no lighting calculations will be applied.
  56612. */
  56613. unlit: boolean;
  56614. /**
  56615. * Gets the image processing configuration used either in this material.
  56616. */
  56617. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56618. /**
  56619. * Sets the Default image processing configuration used either in the this material.
  56620. *
  56621. * If sets to null, the scene one is in use.
  56622. */
  56623. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56624. /**
  56625. * Gets wether the color curves effect is enabled.
  56626. */
  56627. get cameraColorCurvesEnabled(): boolean;
  56628. /**
  56629. * Sets wether the color curves effect is enabled.
  56630. */
  56631. set cameraColorCurvesEnabled(value: boolean);
  56632. /**
  56633. * Gets wether the color grading effect is enabled.
  56634. */
  56635. get cameraColorGradingEnabled(): boolean;
  56636. /**
  56637. * Gets wether the color grading effect is enabled.
  56638. */
  56639. set cameraColorGradingEnabled(value: boolean);
  56640. /**
  56641. * Gets wether tonemapping is enabled or not.
  56642. */
  56643. get cameraToneMappingEnabled(): boolean;
  56644. /**
  56645. * Sets wether tonemapping is enabled or not
  56646. */
  56647. set cameraToneMappingEnabled(value: boolean);
  56648. /**
  56649. * The camera exposure used on this material.
  56650. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56651. * This corresponds to a photographic exposure.
  56652. */
  56653. get cameraExposure(): number;
  56654. /**
  56655. * The camera exposure used on this material.
  56656. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56657. * This corresponds to a photographic exposure.
  56658. */
  56659. set cameraExposure(value: number);
  56660. /**
  56661. * Gets The camera contrast used on this material.
  56662. */
  56663. get cameraContrast(): number;
  56664. /**
  56665. * Sets The camera contrast used on this material.
  56666. */
  56667. set cameraContrast(value: number);
  56668. /**
  56669. * Gets the Color Grading 2D Lookup Texture.
  56670. */
  56671. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56672. /**
  56673. * Sets the Color Grading 2D Lookup Texture.
  56674. */
  56675. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56676. /**
  56677. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56678. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56679. * 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;
  56680. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56681. */
  56682. get cameraColorCurves(): Nullable<ColorCurves>;
  56683. /**
  56684. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56685. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56686. * 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;
  56687. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56688. */
  56689. set cameraColorCurves(value: Nullable<ColorCurves>);
  56690. /**
  56691. * Instantiates a new PBRMaterial instance.
  56692. *
  56693. * @param name The material name
  56694. * @param scene The scene the material will be use in.
  56695. */
  56696. constructor(name: string, scene: Scene);
  56697. /**
  56698. * Returns the name of this material class.
  56699. */
  56700. getClassName(): string;
  56701. /**
  56702. * Makes a duplicate of the current material.
  56703. * @param name - name to use for the new material.
  56704. */
  56705. clone(name: string): PBRMaterial;
  56706. /**
  56707. * Serializes this PBR Material.
  56708. * @returns - An object with the serialized material.
  56709. */
  56710. serialize(): any;
  56711. /**
  56712. * Parses a PBR Material from a serialized object.
  56713. * @param source - Serialized object.
  56714. * @param scene - BJS scene instance.
  56715. * @param rootUrl - url for the scene object
  56716. * @returns - PBRMaterial
  56717. */
  56718. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56719. }
  56720. }
  56721. declare module BABYLON {
  56722. /**
  56723. * Direct draw surface info
  56724. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56725. */
  56726. export interface DDSInfo {
  56727. /**
  56728. * Width of the texture
  56729. */
  56730. width: number;
  56731. /**
  56732. * Width of the texture
  56733. */
  56734. height: number;
  56735. /**
  56736. * Number of Mipmaps for the texture
  56737. * @see https://en.wikipedia.org/wiki/Mipmap
  56738. */
  56739. mipmapCount: number;
  56740. /**
  56741. * If the textures format is a known fourCC format
  56742. * @see https://www.fourcc.org/
  56743. */
  56744. isFourCC: boolean;
  56745. /**
  56746. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56747. */
  56748. isRGB: boolean;
  56749. /**
  56750. * If the texture is a lumincance format
  56751. */
  56752. isLuminance: boolean;
  56753. /**
  56754. * If this is a cube texture
  56755. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56756. */
  56757. isCube: boolean;
  56758. /**
  56759. * If the texture is a compressed format eg. FOURCC_DXT1
  56760. */
  56761. isCompressed: boolean;
  56762. /**
  56763. * The dxgiFormat of the texture
  56764. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56765. */
  56766. dxgiFormat: number;
  56767. /**
  56768. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56769. */
  56770. textureType: number;
  56771. /**
  56772. * Sphericle polynomial created for the dds texture
  56773. */
  56774. sphericalPolynomial?: SphericalPolynomial;
  56775. }
  56776. /**
  56777. * Class used to provide DDS decompression tools
  56778. */
  56779. export class DDSTools {
  56780. /**
  56781. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56782. */
  56783. static StoreLODInAlphaChannel: boolean;
  56784. /**
  56785. * Gets DDS information from an array buffer
  56786. * @param data defines the array buffer view to read data from
  56787. * @returns the DDS information
  56788. */
  56789. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56790. private static _FloatView;
  56791. private static _Int32View;
  56792. private static _ToHalfFloat;
  56793. private static _FromHalfFloat;
  56794. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56795. private static _GetHalfFloatRGBAArrayBuffer;
  56796. private static _GetFloatRGBAArrayBuffer;
  56797. private static _GetFloatAsUIntRGBAArrayBuffer;
  56798. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56799. private static _GetRGBAArrayBuffer;
  56800. private static _ExtractLongWordOrder;
  56801. private static _GetRGBArrayBuffer;
  56802. private static _GetLuminanceArrayBuffer;
  56803. /**
  56804. * Uploads DDS Levels to a Babylon Texture
  56805. * @hidden
  56806. */
  56807. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56808. }
  56809. interface ThinEngine {
  56810. /**
  56811. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56812. * @param rootUrl defines the url where the file to load is located
  56813. * @param scene defines the current scene
  56814. * @param lodScale defines scale to apply to the mip map selection
  56815. * @param lodOffset defines offset to apply to the mip map selection
  56816. * @param onLoad defines an optional callback raised when the texture is loaded
  56817. * @param onError defines an optional callback raised if there is an issue to load the texture
  56818. * @param format defines the format of the data
  56819. * @param forcedExtension defines the extension to use to pick the right loader
  56820. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56821. * @returns the cube texture as an InternalTexture
  56822. */
  56823. 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;
  56824. }
  56825. }
  56826. declare module BABYLON {
  56827. /**
  56828. * Implementation of the DDS Texture Loader.
  56829. * @hidden
  56830. */
  56831. export class _DDSTextureLoader implements IInternalTextureLoader {
  56832. /**
  56833. * Defines wether the loader supports cascade loading the different faces.
  56834. */
  56835. readonly supportCascades: boolean;
  56836. /**
  56837. * This returns if the loader support the current file information.
  56838. * @param extension defines the file extension of the file being loaded
  56839. * @returns true if the loader can load the specified file
  56840. */
  56841. canLoad(extension: string): boolean;
  56842. /**
  56843. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56844. * @param data contains the texture data
  56845. * @param texture defines the BabylonJS internal texture
  56846. * @param createPolynomials will be true if polynomials have been requested
  56847. * @param onLoad defines the callback to trigger once the texture is ready
  56848. * @param onError defines the callback to trigger in case of error
  56849. */
  56850. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56851. /**
  56852. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56853. * @param data contains the texture data
  56854. * @param texture defines the BabylonJS internal texture
  56855. * @param callback defines the method to call once ready to upload
  56856. */
  56857. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56858. }
  56859. }
  56860. declare module BABYLON {
  56861. /**
  56862. * Implementation of the ENV Texture Loader.
  56863. * @hidden
  56864. */
  56865. export class _ENVTextureLoader implements IInternalTextureLoader {
  56866. /**
  56867. * Defines wether the loader supports cascade loading the different faces.
  56868. */
  56869. readonly supportCascades: boolean;
  56870. /**
  56871. * This returns if the loader support the current file information.
  56872. * @param extension defines the file extension of the file being loaded
  56873. * @returns true if the loader can load the specified file
  56874. */
  56875. canLoad(extension: string): boolean;
  56876. /**
  56877. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56878. * @param data contains the texture data
  56879. * @param texture defines the BabylonJS internal texture
  56880. * @param createPolynomials will be true if polynomials have been requested
  56881. * @param onLoad defines the callback to trigger once the texture is ready
  56882. * @param onError defines the callback to trigger in case of error
  56883. */
  56884. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56885. /**
  56886. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56887. * @param data contains the texture data
  56888. * @param texture defines the BabylonJS internal texture
  56889. * @param callback defines the method to call once ready to upload
  56890. */
  56891. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56892. }
  56893. }
  56894. declare module BABYLON {
  56895. /**
  56896. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56897. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56898. */
  56899. export class KhronosTextureContainer {
  56900. /** contents of the KTX container file */
  56901. data: ArrayBufferView;
  56902. private static HEADER_LEN;
  56903. private static COMPRESSED_2D;
  56904. private static COMPRESSED_3D;
  56905. private static TEX_2D;
  56906. private static TEX_3D;
  56907. /**
  56908. * Gets the openGL type
  56909. */
  56910. glType: number;
  56911. /**
  56912. * Gets the openGL type size
  56913. */
  56914. glTypeSize: number;
  56915. /**
  56916. * Gets the openGL format
  56917. */
  56918. glFormat: number;
  56919. /**
  56920. * Gets the openGL internal format
  56921. */
  56922. glInternalFormat: number;
  56923. /**
  56924. * Gets the base internal format
  56925. */
  56926. glBaseInternalFormat: number;
  56927. /**
  56928. * Gets image width in pixel
  56929. */
  56930. pixelWidth: number;
  56931. /**
  56932. * Gets image height in pixel
  56933. */
  56934. pixelHeight: number;
  56935. /**
  56936. * Gets image depth in pixels
  56937. */
  56938. pixelDepth: number;
  56939. /**
  56940. * Gets the number of array elements
  56941. */
  56942. numberOfArrayElements: number;
  56943. /**
  56944. * Gets the number of faces
  56945. */
  56946. numberOfFaces: number;
  56947. /**
  56948. * Gets the number of mipmap levels
  56949. */
  56950. numberOfMipmapLevels: number;
  56951. /**
  56952. * Gets the bytes of key value data
  56953. */
  56954. bytesOfKeyValueData: number;
  56955. /**
  56956. * Gets the load type
  56957. */
  56958. loadType: number;
  56959. /**
  56960. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56961. */
  56962. isInvalid: boolean;
  56963. /**
  56964. * Creates a new KhronosTextureContainer
  56965. * @param data contents of the KTX container file
  56966. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56967. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56968. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56969. */
  56970. constructor(
  56971. /** contents of the KTX container file */
  56972. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56973. /**
  56974. * Uploads KTX content to a Babylon Texture.
  56975. * It is assumed that the texture has already been created & is currently bound
  56976. * @hidden
  56977. */
  56978. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56979. private _upload2DCompressedLevels;
  56980. /**
  56981. * Checks if the given data starts with a KTX file identifier.
  56982. * @param data the data to check
  56983. * @returns true if the data is a KTX file or false otherwise
  56984. */
  56985. static IsValid(data: ArrayBufferView): boolean;
  56986. }
  56987. }
  56988. declare module BABYLON {
  56989. /**
  56990. * Class for loading KTX2 files
  56991. * !!! Experimental Extension Subject to Changes !!!
  56992. * @hidden
  56993. */
  56994. export class KhronosTextureContainer2 {
  56995. private static _ModulePromise;
  56996. private static _TranscodeFormat;
  56997. constructor(engine: ThinEngine);
  56998. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56999. private _determineTranscodeFormat;
  57000. /**
  57001. * Checks if the given data starts with a KTX2 file identifier.
  57002. * @param data the data to check
  57003. * @returns true if the data is a KTX2 file or false otherwise
  57004. */
  57005. static IsValid(data: ArrayBufferView): boolean;
  57006. }
  57007. }
  57008. declare module BABYLON {
  57009. /**
  57010. * Implementation of the KTX Texture Loader.
  57011. * @hidden
  57012. */
  57013. export class _KTXTextureLoader implements IInternalTextureLoader {
  57014. /**
  57015. * Defines wether the loader supports cascade loading the different faces.
  57016. */
  57017. readonly supportCascades: boolean;
  57018. /**
  57019. * This returns if the loader support the current file information.
  57020. * @param extension defines the file extension of the file being loaded
  57021. * @param mimeType defines the optional mime type of the file being loaded
  57022. * @returns true if the loader can load the specified file
  57023. */
  57024. canLoad(extension: string, mimeType?: string): boolean;
  57025. /**
  57026. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57027. * @param data contains the texture data
  57028. * @param texture defines the BabylonJS internal texture
  57029. * @param createPolynomials will be true if polynomials have been requested
  57030. * @param onLoad defines the callback to trigger once the texture is ready
  57031. * @param onError defines the callback to trigger in case of error
  57032. */
  57033. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57034. /**
  57035. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57036. * @param data contains the texture data
  57037. * @param texture defines the BabylonJS internal texture
  57038. * @param callback defines the method to call once ready to upload
  57039. */
  57040. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57041. }
  57042. }
  57043. declare module BABYLON {
  57044. /** @hidden */
  57045. export var _forceSceneHelpersToBundle: boolean;
  57046. interface Scene {
  57047. /**
  57048. * Creates a default light for the scene.
  57049. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57050. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57051. */
  57052. createDefaultLight(replace?: boolean): void;
  57053. /**
  57054. * Creates a default camera for the scene.
  57055. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57056. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57057. * @param replace has default false, when true replaces the active camera in the scene
  57058. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57059. */
  57060. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57061. /**
  57062. * Creates a default camera and a default light.
  57063. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57064. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57065. * @param replace has the default false, when true replaces the active camera/light in the scene
  57066. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57067. */
  57068. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57069. /**
  57070. * Creates a new sky box
  57071. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57072. * @param environmentTexture defines the texture to use as environment texture
  57073. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57074. * @param scale defines the overall scale of the skybox
  57075. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57076. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57077. * @returns a new mesh holding the sky box
  57078. */
  57079. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57080. /**
  57081. * Creates a new environment
  57082. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57083. * @param options defines the options you can use to configure the environment
  57084. * @returns the new EnvironmentHelper
  57085. */
  57086. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57087. /**
  57088. * Creates a new VREXperienceHelper
  57089. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57090. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57091. * @returns a new VREXperienceHelper
  57092. */
  57093. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57094. /**
  57095. * Creates a new WebXRDefaultExperience
  57096. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57097. * @param options experience options
  57098. * @returns a promise for a new WebXRDefaultExperience
  57099. */
  57100. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57101. }
  57102. }
  57103. declare module BABYLON {
  57104. /**
  57105. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57106. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57107. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57108. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57109. */
  57110. export class VideoDome extends TransformNode {
  57111. /**
  57112. * Define the video source as a Monoscopic panoramic 360 video.
  57113. */
  57114. static readonly MODE_MONOSCOPIC: number;
  57115. /**
  57116. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57117. */
  57118. static readonly MODE_TOPBOTTOM: number;
  57119. /**
  57120. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57121. */
  57122. static readonly MODE_SIDEBYSIDE: number;
  57123. private _halfDome;
  57124. private _useDirectMapping;
  57125. /**
  57126. * The video texture being displayed on the sphere
  57127. */
  57128. protected _videoTexture: VideoTexture;
  57129. /**
  57130. * Gets the video texture being displayed on the sphere
  57131. */
  57132. get videoTexture(): VideoTexture;
  57133. /**
  57134. * The skybox material
  57135. */
  57136. protected _material: BackgroundMaterial;
  57137. /**
  57138. * The surface used for the video dome
  57139. */
  57140. protected _mesh: Mesh;
  57141. /**
  57142. * Gets the mesh used for the video dome.
  57143. */
  57144. get mesh(): Mesh;
  57145. /**
  57146. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57147. */
  57148. private _halfDomeMask;
  57149. /**
  57150. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57151. * Also see the options.resolution property.
  57152. */
  57153. get fovMultiplier(): number;
  57154. set fovMultiplier(value: number);
  57155. private _videoMode;
  57156. /**
  57157. * Gets or set the current video mode for the video. It can be:
  57158. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57159. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57160. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57161. */
  57162. get videoMode(): number;
  57163. set videoMode(value: number);
  57164. /**
  57165. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57166. *
  57167. */
  57168. get halfDome(): boolean;
  57169. /**
  57170. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57171. */
  57172. set halfDome(enabled: boolean);
  57173. /**
  57174. * Oberserver used in Stereoscopic VR Mode.
  57175. */
  57176. private _onBeforeCameraRenderObserver;
  57177. /**
  57178. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57179. * @param name Element's name, child elements will append suffixes for their own names.
  57180. * @param urlsOrVideo defines the url(s) or the video element to use
  57181. * @param options An object containing optional or exposed sub element properties
  57182. */
  57183. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57184. resolution?: number;
  57185. clickToPlay?: boolean;
  57186. autoPlay?: boolean;
  57187. loop?: boolean;
  57188. size?: number;
  57189. poster?: string;
  57190. faceForward?: boolean;
  57191. useDirectMapping?: boolean;
  57192. halfDomeMode?: boolean;
  57193. }, scene: Scene);
  57194. private _changeVideoMode;
  57195. /**
  57196. * Releases resources associated with this node.
  57197. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57198. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57199. */
  57200. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57201. }
  57202. }
  57203. declare module BABYLON {
  57204. /**
  57205. * This class can be used to get instrumentation data from a Babylon engine
  57206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57207. */
  57208. export class EngineInstrumentation implements IDisposable {
  57209. /**
  57210. * Define the instrumented engine.
  57211. */
  57212. engine: Engine;
  57213. private _captureGPUFrameTime;
  57214. private _gpuFrameTimeToken;
  57215. private _gpuFrameTime;
  57216. private _captureShaderCompilationTime;
  57217. private _shaderCompilationTime;
  57218. private _onBeginFrameObserver;
  57219. private _onEndFrameObserver;
  57220. private _onBeforeShaderCompilationObserver;
  57221. private _onAfterShaderCompilationObserver;
  57222. /**
  57223. * Gets the perf counter used for GPU frame time
  57224. */
  57225. get gpuFrameTimeCounter(): PerfCounter;
  57226. /**
  57227. * Gets the GPU frame time capture status
  57228. */
  57229. get captureGPUFrameTime(): boolean;
  57230. /**
  57231. * Enable or disable the GPU frame time capture
  57232. */
  57233. set captureGPUFrameTime(value: boolean);
  57234. /**
  57235. * Gets the perf counter used for shader compilation time
  57236. */
  57237. get shaderCompilationTimeCounter(): PerfCounter;
  57238. /**
  57239. * Gets the shader compilation time capture status
  57240. */
  57241. get captureShaderCompilationTime(): boolean;
  57242. /**
  57243. * Enable or disable the shader compilation time capture
  57244. */
  57245. set captureShaderCompilationTime(value: boolean);
  57246. /**
  57247. * Instantiates a new engine instrumentation.
  57248. * This class can be used to get instrumentation data from a Babylon engine
  57249. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57250. * @param engine Defines the engine to instrument
  57251. */
  57252. constructor(
  57253. /**
  57254. * Define the instrumented engine.
  57255. */
  57256. engine: Engine);
  57257. /**
  57258. * Dispose and release associated resources.
  57259. */
  57260. dispose(): void;
  57261. }
  57262. }
  57263. declare module BABYLON {
  57264. /**
  57265. * This class can be used to get instrumentation data from a Babylon engine
  57266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57267. */
  57268. export class SceneInstrumentation implements IDisposable {
  57269. /**
  57270. * Defines the scene to instrument
  57271. */
  57272. scene: Scene;
  57273. private _captureActiveMeshesEvaluationTime;
  57274. private _activeMeshesEvaluationTime;
  57275. private _captureRenderTargetsRenderTime;
  57276. private _renderTargetsRenderTime;
  57277. private _captureFrameTime;
  57278. private _frameTime;
  57279. private _captureRenderTime;
  57280. private _renderTime;
  57281. private _captureInterFrameTime;
  57282. private _interFrameTime;
  57283. private _captureParticlesRenderTime;
  57284. private _particlesRenderTime;
  57285. private _captureSpritesRenderTime;
  57286. private _spritesRenderTime;
  57287. private _capturePhysicsTime;
  57288. private _physicsTime;
  57289. private _captureAnimationsTime;
  57290. private _animationsTime;
  57291. private _captureCameraRenderTime;
  57292. private _cameraRenderTime;
  57293. private _onBeforeActiveMeshesEvaluationObserver;
  57294. private _onAfterActiveMeshesEvaluationObserver;
  57295. private _onBeforeRenderTargetsRenderObserver;
  57296. private _onAfterRenderTargetsRenderObserver;
  57297. private _onAfterRenderObserver;
  57298. private _onBeforeDrawPhaseObserver;
  57299. private _onAfterDrawPhaseObserver;
  57300. private _onBeforeAnimationsObserver;
  57301. private _onBeforeParticlesRenderingObserver;
  57302. private _onAfterParticlesRenderingObserver;
  57303. private _onBeforeSpritesRenderingObserver;
  57304. private _onAfterSpritesRenderingObserver;
  57305. private _onBeforePhysicsObserver;
  57306. private _onAfterPhysicsObserver;
  57307. private _onAfterAnimationsObserver;
  57308. private _onBeforeCameraRenderObserver;
  57309. private _onAfterCameraRenderObserver;
  57310. /**
  57311. * Gets the perf counter used for active meshes evaluation time
  57312. */
  57313. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57314. /**
  57315. * Gets the active meshes evaluation time capture status
  57316. */
  57317. get captureActiveMeshesEvaluationTime(): boolean;
  57318. /**
  57319. * Enable or disable the active meshes evaluation time capture
  57320. */
  57321. set captureActiveMeshesEvaluationTime(value: boolean);
  57322. /**
  57323. * Gets the perf counter used for render targets render time
  57324. */
  57325. get renderTargetsRenderTimeCounter(): PerfCounter;
  57326. /**
  57327. * Gets the render targets render time capture status
  57328. */
  57329. get captureRenderTargetsRenderTime(): boolean;
  57330. /**
  57331. * Enable or disable the render targets render time capture
  57332. */
  57333. set captureRenderTargetsRenderTime(value: boolean);
  57334. /**
  57335. * Gets the perf counter used for particles render time
  57336. */
  57337. get particlesRenderTimeCounter(): PerfCounter;
  57338. /**
  57339. * Gets the particles render time capture status
  57340. */
  57341. get captureParticlesRenderTime(): boolean;
  57342. /**
  57343. * Enable or disable the particles render time capture
  57344. */
  57345. set captureParticlesRenderTime(value: boolean);
  57346. /**
  57347. * Gets the perf counter used for sprites render time
  57348. */
  57349. get spritesRenderTimeCounter(): PerfCounter;
  57350. /**
  57351. * Gets the sprites render time capture status
  57352. */
  57353. get captureSpritesRenderTime(): boolean;
  57354. /**
  57355. * Enable or disable the sprites render time capture
  57356. */
  57357. set captureSpritesRenderTime(value: boolean);
  57358. /**
  57359. * Gets the perf counter used for physics time
  57360. */
  57361. get physicsTimeCounter(): PerfCounter;
  57362. /**
  57363. * Gets the physics time capture status
  57364. */
  57365. get capturePhysicsTime(): boolean;
  57366. /**
  57367. * Enable or disable the physics time capture
  57368. */
  57369. set capturePhysicsTime(value: boolean);
  57370. /**
  57371. * Gets the perf counter used for animations time
  57372. */
  57373. get animationsTimeCounter(): PerfCounter;
  57374. /**
  57375. * Gets the animations time capture status
  57376. */
  57377. get captureAnimationsTime(): boolean;
  57378. /**
  57379. * Enable or disable the animations time capture
  57380. */
  57381. set captureAnimationsTime(value: boolean);
  57382. /**
  57383. * Gets the perf counter used for frame time capture
  57384. */
  57385. get frameTimeCounter(): PerfCounter;
  57386. /**
  57387. * Gets the frame time capture status
  57388. */
  57389. get captureFrameTime(): boolean;
  57390. /**
  57391. * Enable or disable the frame time capture
  57392. */
  57393. set captureFrameTime(value: boolean);
  57394. /**
  57395. * Gets the perf counter used for inter-frames time capture
  57396. */
  57397. get interFrameTimeCounter(): PerfCounter;
  57398. /**
  57399. * Gets the inter-frames time capture status
  57400. */
  57401. get captureInterFrameTime(): boolean;
  57402. /**
  57403. * Enable or disable the inter-frames time capture
  57404. */
  57405. set captureInterFrameTime(value: boolean);
  57406. /**
  57407. * Gets the perf counter used for render time capture
  57408. */
  57409. get renderTimeCounter(): PerfCounter;
  57410. /**
  57411. * Gets the render time capture status
  57412. */
  57413. get captureRenderTime(): boolean;
  57414. /**
  57415. * Enable or disable the render time capture
  57416. */
  57417. set captureRenderTime(value: boolean);
  57418. /**
  57419. * Gets the perf counter used for camera render time capture
  57420. */
  57421. get cameraRenderTimeCounter(): PerfCounter;
  57422. /**
  57423. * Gets the camera render time capture status
  57424. */
  57425. get captureCameraRenderTime(): boolean;
  57426. /**
  57427. * Enable or disable the camera render time capture
  57428. */
  57429. set captureCameraRenderTime(value: boolean);
  57430. /**
  57431. * Gets the perf counter used for draw calls
  57432. */
  57433. get drawCallsCounter(): PerfCounter;
  57434. /**
  57435. * Instantiates a new scene instrumentation.
  57436. * This class can be used to get instrumentation data from a Babylon engine
  57437. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57438. * @param scene Defines the scene to instrument
  57439. */
  57440. constructor(
  57441. /**
  57442. * Defines the scene to instrument
  57443. */
  57444. scene: Scene);
  57445. /**
  57446. * Dispose and release associated resources.
  57447. */
  57448. dispose(): void;
  57449. }
  57450. }
  57451. declare module BABYLON {
  57452. /** @hidden */
  57453. export var glowMapGenerationPixelShader: {
  57454. name: string;
  57455. shader: string;
  57456. };
  57457. }
  57458. declare module BABYLON {
  57459. /** @hidden */
  57460. export var glowMapGenerationVertexShader: {
  57461. name: string;
  57462. shader: string;
  57463. };
  57464. }
  57465. declare module BABYLON {
  57466. /**
  57467. * Effect layer options. This helps customizing the behaviour
  57468. * of the effect layer.
  57469. */
  57470. export interface IEffectLayerOptions {
  57471. /**
  57472. * Multiplication factor apply to the canvas size to compute the render target size
  57473. * used to generated the objects (the smaller the faster).
  57474. */
  57475. mainTextureRatio: number;
  57476. /**
  57477. * Enforces a fixed size texture to ensure effect stability across devices.
  57478. */
  57479. mainTextureFixedSize?: number;
  57480. /**
  57481. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57482. */
  57483. alphaBlendingMode: number;
  57484. /**
  57485. * The camera attached to the layer.
  57486. */
  57487. camera: Nullable<Camera>;
  57488. /**
  57489. * The rendering group to draw the layer in.
  57490. */
  57491. renderingGroupId: number;
  57492. }
  57493. /**
  57494. * The effect layer Helps adding post process effect blended with the main pass.
  57495. *
  57496. * This can be for instance use to generate glow or higlight effects on the scene.
  57497. *
  57498. * The effect layer class can not be used directly and is intented to inherited from to be
  57499. * customized per effects.
  57500. */
  57501. export abstract class EffectLayer {
  57502. private _vertexBuffers;
  57503. private _indexBuffer;
  57504. private _cachedDefines;
  57505. private _effectLayerMapGenerationEffect;
  57506. private _effectLayerOptions;
  57507. private _mergeEffect;
  57508. protected _scene: Scene;
  57509. protected _engine: Engine;
  57510. protected _maxSize: number;
  57511. protected _mainTextureDesiredSize: ISize;
  57512. protected _mainTexture: RenderTargetTexture;
  57513. protected _shouldRender: boolean;
  57514. protected _postProcesses: PostProcess[];
  57515. protected _textures: BaseTexture[];
  57516. protected _emissiveTextureAndColor: {
  57517. texture: Nullable<BaseTexture>;
  57518. color: Color4;
  57519. };
  57520. /**
  57521. * The name of the layer
  57522. */
  57523. name: string;
  57524. /**
  57525. * The clear color of the texture used to generate the glow map.
  57526. */
  57527. neutralColor: Color4;
  57528. /**
  57529. * Specifies whether the highlight layer is enabled or not.
  57530. */
  57531. isEnabled: boolean;
  57532. /**
  57533. * Gets the camera attached to the layer.
  57534. */
  57535. get camera(): Nullable<Camera>;
  57536. /**
  57537. * Gets the rendering group id the layer should render in.
  57538. */
  57539. get renderingGroupId(): number;
  57540. set renderingGroupId(renderingGroupId: number);
  57541. /**
  57542. * An event triggered when the effect layer has been disposed.
  57543. */
  57544. onDisposeObservable: Observable<EffectLayer>;
  57545. /**
  57546. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57547. */
  57548. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57549. /**
  57550. * An event triggered when the generated texture is being merged in the scene.
  57551. */
  57552. onBeforeComposeObservable: Observable<EffectLayer>;
  57553. /**
  57554. * An event triggered when the mesh is rendered into the effect render target.
  57555. */
  57556. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57557. /**
  57558. * An event triggered after the mesh has been rendered into the effect render target.
  57559. */
  57560. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57561. /**
  57562. * An event triggered when the generated texture has been merged in the scene.
  57563. */
  57564. onAfterComposeObservable: Observable<EffectLayer>;
  57565. /**
  57566. * An event triggered when the efffect layer changes its size.
  57567. */
  57568. onSizeChangedObservable: Observable<EffectLayer>;
  57569. /** @hidden */
  57570. static _SceneComponentInitialization: (scene: Scene) => void;
  57571. /**
  57572. * Instantiates a new effect Layer and references it in the scene.
  57573. * @param name The name of the layer
  57574. * @param scene The scene to use the layer in
  57575. */
  57576. constructor(
  57577. /** The Friendly of the effect in the scene */
  57578. name: string, scene: Scene);
  57579. /**
  57580. * Get the effect name of the layer.
  57581. * @return The effect name
  57582. */
  57583. abstract getEffectName(): string;
  57584. /**
  57585. * Checks for the readiness of the element composing the layer.
  57586. * @param subMesh the mesh to check for
  57587. * @param useInstances specify whether or not to use instances to render the mesh
  57588. * @return true if ready otherwise, false
  57589. */
  57590. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57591. /**
  57592. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57593. * @returns true if the effect requires stencil during the main canvas render pass.
  57594. */
  57595. abstract needStencil(): boolean;
  57596. /**
  57597. * Create the merge effect. This is the shader use to blit the information back
  57598. * to the main canvas at the end of the scene rendering.
  57599. * @returns The effect containing the shader used to merge the effect on the main canvas
  57600. */
  57601. protected abstract _createMergeEffect(): Effect;
  57602. /**
  57603. * Creates the render target textures and post processes used in the effect layer.
  57604. */
  57605. protected abstract _createTextureAndPostProcesses(): void;
  57606. /**
  57607. * Implementation specific of rendering the generating effect on the main canvas.
  57608. * @param effect The effect used to render through
  57609. */
  57610. protected abstract _internalRender(effect: Effect): void;
  57611. /**
  57612. * Sets the required values for both the emissive texture and and the main color.
  57613. */
  57614. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57615. /**
  57616. * Free any resources and references associated to a mesh.
  57617. * Internal use
  57618. * @param mesh The mesh to free.
  57619. */
  57620. abstract _disposeMesh(mesh: Mesh): void;
  57621. /**
  57622. * Serializes this layer (Glow or Highlight for example)
  57623. * @returns a serialized layer object
  57624. */
  57625. abstract serialize?(): any;
  57626. /**
  57627. * Initializes the effect layer with the required options.
  57628. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57629. */
  57630. protected _init(options: Partial<IEffectLayerOptions>): void;
  57631. /**
  57632. * Generates the index buffer of the full screen quad blending to the main canvas.
  57633. */
  57634. private _generateIndexBuffer;
  57635. /**
  57636. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57637. */
  57638. private _generateVertexBuffer;
  57639. /**
  57640. * Sets the main texture desired size which is the closest power of two
  57641. * of the engine canvas size.
  57642. */
  57643. private _setMainTextureSize;
  57644. /**
  57645. * Creates the main texture for the effect layer.
  57646. */
  57647. protected _createMainTexture(): void;
  57648. /**
  57649. * Adds specific effects defines.
  57650. * @param defines The defines to add specifics to.
  57651. */
  57652. protected _addCustomEffectDefines(defines: string[]): void;
  57653. /**
  57654. * Checks for the readiness of the element composing the layer.
  57655. * @param subMesh the mesh to check for
  57656. * @param useInstances specify whether or not to use instances to render the mesh
  57657. * @param emissiveTexture the associated emissive texture used to generate the glow
  57658. * @return true if ready otherwise, false
  57659. */
  57660. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57661. /**
  57662. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57663. */
  57664. render(): void;
  57665. /**
  57666. * Determine if a given mesh will be used in the current effect.
  57667. * @param mesh mesh to test
  57668. * @returns true if the mesh will be used
  57669. */
  57670. hasMesh(mesh: AbstractMesh): boolean;
  57671. /**
  57672. * Returns true if the layer contains information to display, otherwise false.
  57673. * @returns true if the glow layer should be rendered
  57674. */
  57675. shouldRender(): boolean;
  57676. /**
  57677. * Returns true if the mesh should render, otherwise false.
  57678. * @param mesh The mesh to render
  57679. * @returns true if it should render otherwise false
  57680. */
  57681. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57682. /**
  57683. * Returns true if the mesh can be rendered, otherwise false.
  57684. * @param mesh The mesh to render
  57685. * @param material The material used on the mesh
  57686. * @returns true if it can be rendered otherwise false
  57687. */
  57688. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57689. /**
  57690. * Returns true if the mesh should render, otherwise false.
  57691. * @param mesh The mesh to render
  57692. * @returns true if it should render otherwise false
  57693. */
  57694. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57695. /**
  57696. * Renders the submesh passed in parameter to the generation map.
  57697. */
  57698. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57699. /**
  57700. * Defines whether the current material of the mesh should be use to render the effect.
  57701. * @param mesh defines the current mesh to render
  57702. */
  57703. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57704. /**
  57705. * Rebuild the required buffers.
  57706. * @hidden Internal use only.
  57707. */
  57708. _rebuild(): void;
  57709. /**
  57710. * Dispose only the render target textures and post process.
  57711. */
  57712. private _disposeTextureAndPostProcesses;
  57713. /**
  57714. * Dispose the highlight layer and free resources.
  57715. */
  57716. dispose(): void;
  57717. /**
  57718. * Gets the class name of the effect layer
  57719. * @returns the string with the class name of the effect layer
  57720. */
  57721. getClassName(): string;
  57722. /**
  57723. * Creates an effect layer from parsed effect layer data
  57724. * @param parsedEffectLayer defines effect layer data
  57725. * @param scene defines the current scene
  57726. * @param rootUrl defines the root URL containing the effect layer information
  57727. * @returns a parsed effect Layer
  57728. */
  57729. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57730. }
  57731. }
  57732. declare module BABYLON {
  57733. interface AbstractScene {
  57734. /**
  57735. * The list of effect layers (highlights/glow) added to the scene
  57736. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57737. * @see https://doc.babylonjs.com/how_to/glow_layer
  57738. */
  57739. effectLayers: Array<EffectLayer>;
  57740. /**
  57741. * Removes the given effect layer from this scene.
  57742. * @param toRemove defines the effect layer to remove
  57743. * @returns the index of the removed effect layer
  57744. */
  57745. removeEffectLayer(toRemove: EffectLayer): number;
  57746. /**
  57747. * Adds the given effect layer to this scene
  57748. * @param newEffectLayer defines the effect layer to add
  57749. */
  57750. addEffectLayer(newEffectLayer: EffectLayer): void;
  57751. }
  57752. /**
  57753. * Defines the layer scene component responsible to manage any effect layers
  57754. * in a given scene.
  57755. */
  57756. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57757. /**
  57758. * The component name helpfull to identify the component in the list of scene components.
  57759. */
  57760. readonly name: string;
  57761. /**
  57762. * The scene the component belongs to.
  57763. */
  57764. scene: Scene;
  57765. private _engine;
  57766. private _renderEffects;
  57767. private _needStencil;
  57768. private _previousStencilState;
  57769. /**
  57770. * Creates a new instance of the component for the given scene
  57771. * @param scene Defines the scene to register the component in
  57772. */
  57773. constructor(scene: Scene);
  57774. /**
  57775. * Registers the component in a given scene
  57776. */
  57777. register(): void;
  57778. /**
  57779. * Rebuilds the elements related to this component in case of
  57780. * context lost for instance.
  57781. */
  57782. rebuild(): void;
  57783. /**
  57784. * Serializes the component data to the specified json object
  57785. * @param serializationObject The object to serialize to
  57786. */
  57787. serialize(serializationObject: any): void;
  57788. /**
  57789. * Adds all the elements from the container to the scene
  57790. * @param container the container holding the elements
  57791. */
  57792. addFromContainer(container: AbstractScene): void;
  57793. /**
  57794. * Removes all the elements in the container from the scene
  57795. * @param container contains the elements to remove
  57796. * @param dispose if the removed element should be disposed (default: false)
  57797. */
  57798. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57799. /**
  57800. * Disposes the component and the associated ressources.
  57801. */
  57802. dispose(): void;
  57803. private _isReadyForMesh;
  57804. private _renderMainTexture;
  57805. private _setStencil;
  57806. private _setStencilBack;
  57807. private _draw;
  57808. private _drawCamera;
  57809. private _drawRenderingGroup;
  57810. }
  57811. }
  57812. declare module BABYLON {
  57813. /** @hidden */
  57814. export var glowMapMergePixelShader: {
  57815. name: string;
  57816. shader: string;
  57817. };
  57818. }
  57819. declare module BABYLON {
  57820. /** @hidden */
  57821. export var glowMapMergeVertexShader: {
  57822. name: string;
  57823. shader: string;
  57824. };
  57825. }
  57826. declare module BABYLON {
  57827. interface AbstractScene {
  57828. /**
  57829. * Return a the first highlight layer of the scene with a given name.
  57830. * @param name The name of the highlight layer to look for.
  57831. * @return The highlight layer if found otherwise null.
  57832. */
  57833. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57834. }
  57835. /**
  57836. * Glow layer options. This helps customizing the behaviour
  57837. * of the glow layer.
  57838. */
  57839. export interface IGlowLayerOptions {
  57840. /**
  57841. * Multiplication factor apply to the canvas size to compute the render target size
  57842. * used to generated the glowing objects (the smaller the faster).
  57843. */
  57844. mainTextureRatio: number;
  57845. /**
  57846. * Enforces a fixed size texture to ensure resize independant blur.
  57847. */
  57848. mainTextureFixedSize?: number;
  57849. /**
  57850. * How big is the kernel of the blur texture.
  57851. */
  57852. blurKernelSize: number;
  57853. /**
  57854. * The camera attached to the layer.
  57855. */
  57856. camera: Nullable<Camera>;
  57857. /**
  57858. * Enable MSAA by chosing the number of samples.
  57859. */
  57860. mainTextureSamples?: number;
  57861. /**
  57862. * The rendering group to draw the layer in.
  57863. */
  57864. renderingGroupId: number;
  57865. }
  57866. /**
  57867. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57868. *
  57869. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57870. *
  57871. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57872. */
  57873. export class GlowLayer extends EffectLayer {
  57874. /**
  57875. * Effect Name of the layer.
  57876. */
  57877. static readonly EffectName: string;
  57878. /**
  57879. * The default blur kernel size used for the glow.
  57880. */
  57881. static DefaultBlurKernelSize: number;
  57882. /**
  57883. * The default texture size ratio used for the glow.
  57884. */
  57885. static DefaultTextureRatio: number;
  57886. /**
  57887. * Sets the kernel size of the blur.
  57888. */
  57889. set blurKernelSize(value: number);
  57890. /**
  57891. * Gets the kernel size of the blur.
  57892. */
  57893. get blurKernelSize(): number;
  57894. /**
  57895. * Sets the glow intensity.
  57896. */
  57897. set intensity(value: number);
  57898. /**
  57899. * Gets the glow intensity.
  57900. */
  57901. get intensity(): number;
  57902. private _options;
  57903. private _intensity;
  57904. private _horizontalBlurPostprocess1;
  57905. private _verticalBlurPostprocess1;
  57906. private _horizontalBlurPostprocess2;
  57907. private _verticalBlurPostprocess2;
  57908. private _blurTexture1;
  57909. private _blurTexture2;
  57910. private _postProcesses1;
  57911. private _postProcesses2;
  57912. private _includedOnlyMeshes;
  57913. private _excludedMeshes;
  57914. private _meshesUsingTheirOwnMaterials;
  57915. /**
  57916. * Callback used to let the user override the color selection on a per mesh basis
  57917. */
  57918. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57919. /**
  57920. * Callback used to let the user override the texture selection on a per mesh basis
  57921. */
  57922. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57923. /**
  57924. * Instantiates a new glow Layer and references it to the scene.
  57925. * @param name The name of the layer
  57926. * @param scene The scene to use the layer in
  57927. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57928. */
  57929. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57930. /**
  57931. * Get the effect name of the layer.
  57932. * @return The effect name
  57933. */
  57934. getEffectName(): string;
  57935. /**
  57936. * Create the merge effect. This is the shader use to blit the information back
  57937. * to the main canvas at the end of the scene rendering.
  57938. */
  57939. protected _createMergeEffect(): Effect;
  57940. /**
  57941. * Creates the render target textures and post processes used in the glow layer.
  57942. */
  57943. protected _createTextureAndPostProcesses(): void;
  57944. /**
  57945. * Checks for the readiness of the element composing the layer.
  57946. * @param subMesh the mesh to check for
  57947. * @param useInstances specify wether or not to use instances to render the mesh
  57948. * @param emissiveTexture the associated emissive texture used to generate the glow
  57949. * @return true if ready otherwise, false
  57950. */
  57951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57952. /**
  57953. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57954. */
  57955. needStencil(): boolean;
  57956. /**
  57957. * Returns true if the mesh can be rendered, otherwise false.
  57958. * @param mesh The mesh to render
  57959. * @param material The material used on the mesh
  57960. * @returns true if it can be rendered otherwise false
  57961. */
  57962. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57963. /**
  57964. * Implementation specific of rendering the generating effect on the main canvas.
  57965. * @param effect The effect used to render through
  57966. */
  57967. protected _internalRender(effect: Effect): void;
  57968. /**
  57969. * Sets the required values for both the emissive texture and and the main color.
  57970. */
  57971. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57972. /**
  57973. * Returns true if the mesh should render, otherwise false.
  57974. * @param mesh The mesh to render
  57975. * @returns true if it should render otherwise false
  57976. */
  57977. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57978. /**
  57979. * Adds specific effects defines.
  57980. * @param defines The defines to add specifics to.
  57981. */
  57982. protected _addCustomEffectDefines(defines: string[]): void;
  57983. /**
  57984. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57985. * @param mesh The mesh to exclude from the glow layer
  57986. */
  57987. addExcludedMesh(mesh: Mesh): void;
  57988. /**
  57989. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57990. * @param mesh The mesh to remove
  57991. */
  57992. removeExcludedMesh(mesh: Mesh): void;
  57993. /**
  57994. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57995. * @param mesh The mesh to include in the glow layer
  57996. */
  57997. addIncludedOnlyMesh(mesh: Mesh): void;
  57998. /**
  57999. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58000. * @param mesh The mesh to remove
  58001. */
  58002. removeIncludedOnlyMesh(mesh: Mesh): void;
  58003. /**
  58004. * Determine if a given mesh will be used in the glow layer
  58005. * @param mesh The mesh to test
  58006. * @returns true if the mesh will be highlighted by the current glow layer
  58007. */
  58008. hasMesh(mesh: AbstractMesh): boolean;
  58009. /**
  58010. * Defines whether the current material of the mesh should be use to render the effect.
  58011. * @param mesh defines the current mesh to render
  58012. */
  58013. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58014. /**
  58015. * Add a mesh to be rendered through its own material and not with emissive only.
  58016. * @param mesh The mesh for which we need to use its material
  58017. */
  58018. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58019. /**
  58020. * Remove a mesh from being rendered through its own material and not with emissive only.
  58021. * @param mesh The mesh for which we need to not use its material
  58022. */
  58023. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58024. /**
  58025. * Free any resources and references associated to a mesh.
  58026. * Internal use
  58027. * @param mesh The mesh to free.
  58028. * @hidden
  58029. */
  58030. _disposeMesh(mesh: Mesh): void;
  58031. /**
  58032. * Gets the class name of the effect layer
  58033. * @returns the string with the class name of the effect layer
  58034. */
  58035. getClassName(): string;
  58036. /**
  58037. * Serializes this glow layer
  58038. * @returns a serialized glow layer object
  58039. */
  58040. serialize(): any;
  58041. /**
  58042. * Creates a Glow Layer from parsed glow layer data
  58043. * @param parsedGlowLayer defines glow layer data
  58044. * @param scene defines the current scene
  58045. * @param rootUrl defines the root URL containing the glow layer information
  58046. * @returns a parsed Glow Layer
  58047. */
  58048. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58049. }
  58050. }
  58051. declare module BABYLON {
  58052. /** @hidden */
  58053. export var glowBlurPostProcessPixelShader: {
  58054. name: string;
  58055. shader: string;
  58056. };
  58057. }
  58058. declare module BABYLON {
  58059. interface AbstractScene {
  58060. /**
  58061. * Return a the first highlight layer of the scene with a given name.
  58062. * @param name The name of the highlight layer to look for.
  58063. * @return The highlight layer if found otherwise null.
  58064. */
  58065. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58066. }
  58067. /**
  58068. * Highlight layer options. This helps customizing the behaviour
  58069. * of the highlight layer.
  58070. */
  58071. export interface IHighlightLayerOptions {
  58072. /**
  58073. * Multiplication factor apply to the canvas size to compute the render target size
  58074. * used to generated the glowing objects (the smaller the faster).
  58075. */
  58076. mainTextureRatio: number;
  58077. /**
  58078. * Enforces a fixed size texture to ensure resize independant blur.
  58079. */
  58080. mainTextureFixedSize?: number;
  58081. /**
  58082. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58083. * of the picture to blur (the smaller the faster).
  58084. */
  58085. blurTextureSizeRatio: number;
  58086. /**
  58087. * How big in texel of the blur texture is the vertical blur.
  58088. */
  58089. blurVerticalSize: number;
  58090. /**
  58091. * How big in texel of the blur texture is the horizontal blur.
  58092. */
  58093. blurHorizontalSize: number;
  58094. /**
  58095. * Alpha blending mode used to apply the blur. Default is combine.
  58096. */
  58097. alphaBlendingMode: number;
  58098. /**
  58099. * The camera attached to the layer.
  58100. */
  58101. camera: Nullable<Camera>;
  58102. /**
  58103. * Should we display highlight as a solid stroke?
  58104. */
  58105. isStroke?: boolean;
  58106. /**
  58107. * The rendering group to draw the layer in.
  58108. */
  58109. renderingGroupId: number;
  58110. }
  58111. /**
  58112. * The highlight layer Helps adding a glow effect around a mesh.
  58113. *
  58114. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58115. * glowy meshes to your scene.
  58116. *
  58117. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58118. */
  58119. export class HighlightLayer extends EffectLayer {
  58120. name: string;
  58121. /**
  58122. * Effect Name of the highlight layer.
  58123. */
  58124. static readonly EffectName: string;
  58125. /**
  58126. * The neutral color used during the preparation of the glow effect.
  58127. * This is black by default as the blend operation is a blend operation.
  58128. */
  58129. static NeutralColor: Color4;
  58130. /**
  58131. * Stencil value used for glowing meshes.
  58132. */
  58133. static GlowingMeshStencilReference: number;
  58134. /**
  58135. * Stencil value used for the other meshes in the scene.
  58136. */
  58137. static NormalMeshStencilReference: number;
  58138. /**
  58139. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58140. */
  58141. innerGlow: boolean;
  58142. /**
  58143. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58144. */
  58145. outerGlow: boolean;
  58146. /**
  58147. * Specifies the horizontal size of the blur.
  58148. */
  58149. set blurHorizontalSize(value: number);
  58150. /**
  58151. * Specifies the vertical size of the blur.
  58152. */
  58153. set blurVerticalSize(value: number);
  58154. /**
  58155. * Gets the horizontal size of the blur.
  58156. */
  58157. get blurHorizontalSize(): number;
  58158. /**
  58159. * Gets the vertical size of the blur.
  58160. */
  58161. get blurVerticalSize(): number;
  58162. /**
  58163. * An event triggered when the highlight layer is being blurred.
  58164. */
  58165. onBeforeBlurObservable: Observable<HighlightLayer>;
  58166. /**
  58167. * An event triggered when the highlight layer has been blurred.
  58168. */
  58169. onAfterBlurObservable: Observable<HighlightLayer>;
  58170. private _instanceGlowingMeshStencilReference;
  58171. private _options;
  58172. private _downSamplePostprocess;
  58173. private _horizontalBlurPostprocess;
  58174. private _verticalBlurPostprocess;
  58175. private _blurTexture;
  58176. private _meshes;
  58177. private _excludedMeshes;
  58178. /**
  58179. * Instantiates a new highlight Layer and references it to the scene..
  58180. * @param name The name of the layer
  58181. * @param scene The scene to use the layer in
  58182. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58183. */
  58184. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58185. /**
  58186. * Get the effect name of the layer.
  58187. * @return The effect name
  58188. */
  58189. getEffectName(): string;
  58190. /**
  58191. * Create the merge effect. This is the shader use to blit the information back
  58192. * to the main canvas at the end of the scene rendering.
  58193. */
  58194. protected _createMergeEffect(): Effect;
  58195. /**
  58196. * Creates the render target textures and post processes used in the highlight layer.
  58197. */
  58198. protected _createTextureAndPostProcesses(): void;
  58199. /**
  58200. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58201. */
  58202. needStencil(): boolean;
  58203. /**
  58204. * Checks for the readiness of the element composing the layer.
  58205. * @param subMesh the mesh to check for
  58206. * @param useInstances specify wether or not to use instances to render the mesh
  58207. * @param emissiveTexture the associated emissive texture used to generate the glow
  58208. * @return true if ready otherwise, false
  58209. */
  58210. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58211. /**
  58212. * Implementation specific of rendering the generating effect on the main canvas.
  58213. * @param effect The effect used to render through
  58214. */
  58215. protected _internalRender(effect: Effect): void;
  58216. /**
  58217. * Returns true if the layer contains information to display, otherwise false.
  58218. */
  58219. shouldRender(): boolean;
  58220. /**
  58221. * Returns true if the mesh should render, otherwise false.
  58222. * @param mesh The mesh to render
  58223. * @returns true if it should render otherwise false
  58224. */
  58225. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58226. /**
  58227. * Returns true if the mesh can be rendered, otherwise false.
  58228. * @param mesh The mesh to render
  58229. * @param material The material used on the mesh
  58230. * @returns true if it can be rendered otherwise false
  58231. */
  58232. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58233. /**
  58234. * Adds specific effects defines.
  58235. * @param defines The defines to add specifics to.
  58236. */
  58237. protected _addCustomEffectDefines(defines: string[]): void;
  58238. /**
  58239. * Sets the required values for both the emissive texture and and the main color.
  58240. */
  58241. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58242. /**
  58243. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58244. * @param mesh The mesh to exclude from the highlight layer
  58245. */
  58246. addExcludedMesh(mesh: Mesh): void;
  58247. /**
  58248. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58249. * @param mesh The mesh to highlight
  58250. */
  58251. removeExcludedMesh(mesh: Mesh): void;
  58252. /**
  58253. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58254. * @param mesh mesh to test
  58255. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58256. */
  58257. hasMesh(mesh: AbstractMesh): boolean;
  58258. /**
  58259. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58260. * @param mesh The mesh to highlight
  58261. * @param color The color of the highlight
  58262. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58263. */
  58264. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58265. /**
  58266. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58267. * @param mesh The mesh to highlight
  58268. */
  58269. removeMesh(mesh: Mesh): void;
  58270. /**
  58271. * Remove all the meshes currently referenced in the highlight layer
  58272. */
  58273. removeAllMeshes(): void;
  58274. /**
  58275. * Force the stencil to the normal expected value for none glowing parts
  58276. */
  58277. private _defaultStencilReference;
  58278. /**
  58279. * Free any resources and references associated to a mesh.
  58280. * Internal use
  58281. * @param mesh The mesh to free.
  58282. * @hidden
  58283. */
  58284. _disposeMesh(mesh: Mesh): void;
  58285. /**
  58286. * Dispose the highlight layer and free resources.
  58287. */
  58288. dispose(): void;
  58289. /**
  58290. * Gets the class name of the effect layer
  58291. * @returns the string with the class name of the effect layer
  58292. */
  58293. getClassName(): string;
  58294. /**
  58295. * Serializes this Highlight layer
  58296. * @returns a serialized Highlight layer object
  58297. */
  58298. serialize(): any;
  58299. /**
  58300. * Creates a Highlight layer from parsed Highlight layer data
  58301. * @param parsedHightlightLayer defines the Highlight layer data
  58302. * @param scene defines the current scene
  58303. * @param rootUrl defines the root URL containing the Highlight layer information
  58304. * @returns a parsed Highlight layer
  58305. */
  58306. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58307. }
  58308. }
  58309. declare module BABYLON {
  58310. interface AbstractScene {
  58311. /**
  58312. * The list of layers (background and foreground) of the scene
  58313. */
  58314. layers: Array<Layer>;
  58315. }
  58316. /**
  58317. * Defines the layer scene component responsible to manage any layers
  58318. * in a given scene.
  58319. */
  58320. export class LayerSceneComponent implements ISceneComponent {
  58321. /**
  58322. * The component name helpfull to identify the component in the list of scene components.
  58323. */
  58324. readonly name: string;
  58325. /**
  58326. * The scene the component belongs to.
  58327. */
  58328. scene: Scene;
  58329. private _engine;
  58330. /**
  58331. * Creates a new instance of the component for the given scene
  58332. * @param scene Defines the scene to register the component in
  58333. */
  58334. constructor(scene: Scene);
  58335. /**
  58336. * Registers the component in a given scene
  58337. */
  58338. register(): void;
  58339. /**
  58340. * Rebuilds the elements related to this component in case of
  58341. * context lost for instance.
  58342. */
  58343. rebuild(): void;
  58344. /**
  58345. * Disposes the component and the associated ressources.
  58346. */
  58347. dispose(): void;
  58348. private _draw;
  58349. private _drawCameraPredicate;
  58350. private _drawCameraBackground;
  58351. private _drawCameraForeground;
  58352. private _drawRenderTargetPredicate;
  58353. private _drawRenderTargetBackground;
  58354. private _drawRenderTargetForeground;
  58355. /**
  58356. * Adds all the elements from the container to the scene
  58357. * @param container the container holding the elements
  58358. */
  58359. addFromContainer(container: AbstractScene): void;
  58360. /**
  58361. * Removes all the elements in the container from the scene
  58362. * @param container contains the elements to remove
  58363. * @param dispose if the removed element should be disposed (default: false)
  58364. */
  58365. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58366. }
  58367. }
  58368. declare module BABYLON {
  58369. /** @hidden */
  58370. export var layerPixelShader: {
  58371. name: string;
  58372. shader: string;
  58373. };
  58374. }
  58375. declare module BABYLON {
  58376. /** @hidden */
  58377. export var layerVertexShader: {
  58378. name: string;
  58379. shader: string;
  58380. };
  58381. }
  58382. declare module BABYLON {
  58383. /**
  58384. * This represents a full screen 2d layer.
  58385. * This can be useful to display a picture in the background of your scene for instance.
  58386. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58387. */
  58388. export class Layer {
  58389. /**
  58390. * Define the name of the layer.
  58391. */
  58392. name: string;
  58393. /**
  58394. * Define the texture the layer should display.
  58395. */
  58396. texture: Nullable<Texture>;
  58397. /**
  58398. * Is the layer in background or foreground.
  58399. */
  58400. isBackground: boolean;
  58401. /**
  58402. * Define the color of the layer (instead of texture).
  58403. */
  58404. color: Color4;
  58405. /**
  58406. * Define the scale of the layer in order to zoom in out of the texture.
  58407. */
  58408. scale: Vector2;
  58409. /**
  58410. * Define an offset for the layer in order to shift the texture.
  58411. */
  58412. offset: Vector2;
  58413. /**
  58414. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58415. */
  58416. alphaBlendingMode: number;
  58417. /**
  58418. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58419. * Alpha test will not mix with the background color in case of transparency.
  58420. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58421. */
  58422. alphaTest: boolean;
  58423. /**
  58424. * Define a mask to restrict the layer to only some of the scene cameras.
  58425. */
  58426. layerMask: number;
  58427. /**
  58428. * Define the list of render target the layer is visible into.
  58429. */
  58430. renderTargetTextures: RenderTargetTexture[];
  58431. /**
  58432. * Define if the layer is only used in renderTarget or if it also
  58433. * renders in the main frame buffer of the canvas.
  58434. */
  58435. renderOnlyInRenderTargetTextures: boolean;
  58436. private _scene;
  58437. private _vertexBuffers;
  58438. private _indexBuffer;
  58439. private _effect;
  58440. private _previousDefines;
  58441. /**
  58442. * An event triggered when the layer is disposed.
  58443. */
  58444. onDisposeObservable: Observable<Layer>;
  58445. private _onDisposeObserver;
  58446. /**
  58447. * Back compatibility with callback before the onDisposeObservable existed.
  58448. * The set callback will be triggered when the layer has been disposed.
  58449. */
  58450. set onDispose(callback: () => void);
  58451. /**
  58452. * An event triggered before rendering the scene
  58453. */
  58454. onBeforeRenderObservable: Observable<Layer>;
  58455. private _onBeforeRenderObserver;
  58456. /**
  58457. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58458. * The set callback will be triggered just before rendering the layer.
  58459. */
  58460. set onBeforeRender(callback: () => void);
  58461. /**
  58462. * An event triggered after rendering the scene
  58463. */
  58464. onAfterRenderObservable: Observable<Layer>;
  58465. private _onAfterRenderObserver;
  58466. /**
  58467. * Back compatibility with callback before the onAfterRenderObservable existed.
  58468. * The set callback will be triggered just after rendering the layer.
  58469. */
  58470. set onAfterRender(callback: () => void);
  58471. /**
  58472. * Instantiates a new layer.
  58473. * This represents a full screen 2d layer.
  58474. * This can be useful to display a picture in the background of your scene for instance.
  58475. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58476. * @param name Define the name of the layer in the scene
  58477. * @param imgUrl Define the url of the texture to display in the layer
  58478. * @param scene Define the scene the layer belongs to
  58479. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58480. * @param color Defines a color for the layer
  58481. */
  58482. constructor(
  58483. /**
  58484. * Define the name of the layer.
  58485. */
  58486. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58487. private _createIndexBuffer;
  58488. /** @hidden */
  58489. _rebuild(): void;
  58490. /**
  58491. * Renders the layer in the scene.
  58492. */
  58493. render(): void;
  58494. /**
  58495. * Disposes and releases the associated ressources.
  58496. */
  58497. dispose(): void;
  58498. }
  58499. }
  58500. declare module BABYLON {
  58501. /** @hidden */
  58502. export var lensFlarePixelShader: {
  58503. name: string;
  58504. shader: string;
  58505. };
  58506. }
  58507. declare module BABYLON {
  58508. /** @hidden */
  58509. export var lensFlareVertexShader: {
  58510. name: string;
  58511. shader: string;
  58512. };
  58513. }
  58514. declare module BABYLON {
  58515. /**
  58516. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58517. * It is usually composed of several `lensFlare`.
  58518. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58519. */
  58520. export class LensFlareSystem {
  58521. /**
  58522. * Define the name of the lens flare system
  58523. */
  58524. name: string;
  58525. /**
  58526. * List of lens flares used in this system.
  58527. */
  58528. lensFlares: LensFlare[];
  58529. /**
  58530. * Define a limit from the border the lens flare can be visible.
  58531. */
  58532. borderLimit: number;
  58533. /**
  58534. * Define a viewport border we do not want to see the lens flare in.
  58535. */
  58536. viewportBorder: number;
  58537. /**
  58538. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58539. */
  58540. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58541. /**
  58542. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58543. */
  58544. layerMask: number;
  58545. /**
  58546. * Define the id of the lens flare system in the scene.
  58547. * (equal to name by default)
  58548. */
  58549. id: string;
  58550. private _scene;
  58551. private _emitter;
  58552. private _vertexBuffers;
  58553. private _indexBuffer;
  58554. private _effect;
  58555. private _positionX;
  58556. private _positionY;
  58557. private _isEnabled;
  58558. /** @hidden */
  58559. static _SceneComponentInitialization: (scene: Scene) => void;
  58560. /**
  58561. * Instantiates a lens flare system.
  58562. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58563. * It is usually composed of several `lensFlare`.
  58564. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58565. * @param name Define the name of the lens flare system in the scene
  58566. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58567. * @param scene Define the scene the lens flare system belongs to
  58568. */
  58569. constructor(
  58570. /**
  58571. * Define the name of the lens flare system
  58572. */
  58573. name: string, emitter: any, scene: Scene);
  58574. /**
  58575. * Define if the lens flare system is enabled.
  58576. */
  58577. get isEnabled(): boolean;
  58578. set isEnabled(value: boolean);
  58579. /**
  58580. * Get the scene the effects belongs to.
  58581. * @returns the scene holding the lens flare system
  58582. */
  58583. getScene(): Scene;
  58584. /**
  58585. * Get the emitter of the lens flare system.
  58586. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58587. * @returns the emitter of the lens flare system
  58588. */
  58589. getEmitter(): any;
  58590. /**
  58591. * Set the emitter of the lens flare system.
  58592. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58593. * @param newEmitter Define the new emitter of the system
  58594. */
  58595. setEmitter(newEmitter: any): void;
  58596. /**
  58597. * Get the lens flare system emitter position.
  58598. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58599. * @returns the position
  58600. */
  58601. getEmitterPosition(): Vector3;
  58602. /**
  58603. * @hidden
  58604. */
  58605. computeEffectivePosition(globalViewport: Viewport): boolean;
  58606. /** @hidden */
  58607. _isVisible(): boolean;
  58608. /**
  58609. * @hidden
  58610. */
  58611. render(): boolean;
  58612. /**
  58613. * Dispose and release the lens flare with its associated resources.
  58614. */
  58615. dispose(): void;
  58616. /**
  58617. * Parse a lens flare system from a JSON repressentation
  58618. * @param parsedLensFlareSystem Define the JSON to parse
  58619. * @param scene Define the scene the parsed system should be instantiated in
  58620. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58621. * @returns the parsed system
  58622. */
  58623. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58624. /**
  58625. * Serialize the current Lens Flare System into a JSON representation.
  58626. * @returns the serialized JSON
  58627. */
  58628. serialize(): any;
  58629. }
  58630. }
  58631. declare module BABYLON {
  58632. /**
  58633. * This represents one of the lens effect in a `lensFlareSystem`.
  58634. * It controls one of the indiviual texture used in the effect.
  58635. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58636. */
  58637. export class LensFlare {
  58638. /**
  58639. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58640. */
  58641. size: number;
  58642. /**
  58643. * 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.
  58644. */
  58645. position: number;
  58646. /**
  58647. * Define the lens color.
  58648. */
  58649. color: Color3;
  58650. /**
  58651. * Define the lens texture.
  58652. */
  58653. texture: Nullable<Texture>;
  58654. /**
  58655. * Define the alpha mode to render this particular lens.
  58656. */
  58657. alphaMode: number;
  58658. private _system;
  58659. /**
  58660. * Creates a new Lens Flare.
  58661. * This represents one of the lens effect in a `lensFlareSystem`.
  58662. * It controls one of the indiviual texture used in the effect.
  58663. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58664. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58665. * @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.
  58666. * @param color Define the lens color
  58667. * @param imgUrl Define the lens texture url
  58668. * @param system Define the `lensFlareSystem` this flare is part of
  58669. * @returns The newly created Lens Flare
  58670. */
  58671. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58672. /**
  58673. * Instantiates a new Lens Flare.
  58674. * This represents one of the lens effect in a `lensFlareSystem`.
  58675. * It controls one of the indiviual texture used in the effect.
  58676. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58677. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58678. * @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.
  58679. * @param color Define the lens color
  58680. * @param imgUrl Define the lens texture url
  58681. * @param system Define the `lensFlareSystem` this flare is part of
  58682. */
  58683. constructor(
  58684. /**
  58685. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58686. */
  58687. size: number,
  58688. /**
  58689. * 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.
  58690. */
  58691. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58692. /**
  58693. * Dispose and release the lens flare with its associated resources.
  58694. */
  58695. dispose(): void;
  58696. }
  58697. }
  58698. declare module BABYLON {
  58699. interface AbstractScene {
  58700. /**
  58701. * The list of lens flare system added to the scene
  58702. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58703. */
  58704. lensFlareSystems: Array<LensFlareSystem>;
  58705. /**
  58706. * Removes the given lens flare system from this scene.
  58707. * @param toRemove The lens flare system to remove
  58708. * @returns The index of the removed lens flare system
  58709. */
  58710. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58711. /**
  58712. * Adds the given lens flare system to this scene
  58713. * @param newLensFlareSystem The lens flare system to add
  58714. */
  58715. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58716. /**
  58717. * Gets a lens flare system using its name
  58718. * @param name defines the name to look for
  58719. * @returns the lens flare system or null if not found
  58720. */
  58721. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58722. /**
  58723. * Gets a lens flare system using its id
  58724. * @param id defines the id to look for
  58725. * @returns the lens flare system or null if not found
  58726. */
  58727. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58728. }
  58729. /**
  58730. * Defines the lens flare scene component responsible to manage any lens flares
  58731. * in a given scene.
  58732. */
  58733. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58734. /**
  58735. * The component name helpfull to identify the component in the list of scene components.
  58736. */
  58737. readonly name: string;
  58738. /**
  58739. * The scene the component belongs to.
  58740. */
  58741. scene: Scene;
  58742. /**
  58743. * Creates a new instance of the component for the given scene
  58744. * @param scene Defines the scene to register the component in
  58745. */
  58746. constructor(scene: Scene);
  58747. /**
  58748. * Registers the component in a given scene
  58749. */
  58750. register(): void;
  58751. /**
  58752. * Rebuilds the elements related to this component in case of
  58753. * context lost for instance.
  58754. */
  58755. rebuild(): void;
  58756. /**
  58757. * Adds all the elements from the container to the scene
  58758. * @param container the container holding the elements
  58759. */
  58760. addFromContainer(container: AbstractScene): void;
  58761. /**
  58762. * Removes all the elements in the container from the scene
  58763. * @param container contains the elements to remove
  58764. * @param dispose if the removed element should be disposed (default: false)
  58765. */
  58766. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58767. /**
  58768. * Serializes the component data to the specified json object
  58769. * @param serializationObject The object to serialize to
  58770. */
  58771. serialize(serializationObject: any): void;
  58772. /**
  58773. * Disposes the component and the associated ressources.
  58774. */
  58775. dispose(): void;
  58776. private _draw;
  58777. }
  58778. }
  58779. declare module BABYLON {
  58780. /** @hidden */
  58781. export var depthPixelShader: {
  58782. name: string;
  58783. shader: string;
  58784. };
  58785. }
  58786. declare module BABYLON {
  58787. /** @hidden */
  58788. export var depthVertexShader: {
  58789. name: string;
  58790. shader: string;
  58791. };
  58792. }
  58793. declare module BABYLON {
  58794. /**
  58795. * This represents a depth renderer in Babylon.
  58796. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58797. */
  58798. export class DepthRenderer {
  58799. private _scene;
  58800. private _depthMap;
  58801. private _effect;
  58802. private readonly _storeNonLinearDepth;
  58803. private readonly _clearColor;
  58804. /** Get if the depth renderer is using packed depth or not */
  58805. readonly isPacked: boolean;
  58806. private _cachedDefines;
  58807. private _camera;
  58808. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58809. enabled: boolean;
  58810. /**
  58811. * Specifiess that the depth renderer will only be used within
  58812. * the camera it is created for.
  58813. * This can help forcing its rendering during the camera processing.
  58814. */
  58815. useOnlyInActiveCamera: boolean;
  58816. /** @hidden */
  58817. static _SceneComponentInitialization: (scene: Scene) => void;
  58818. /**
  58819. * Instantiates a depth renderer
  58820. * @param scene The scene the renderer belongs to
  58821. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58822. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58823. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58824. */
  58825. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58826. /**
  58827. * Creates the depth rendering effect and checks if the effect is ready.
  58828. * @param subMesh The submesh to be used to render the depth map of
  58829. * @param useInstances If multiple world instances should be used
  58830. * @returns if the depth renderer is ready to render the depth map
  58831. */
  58832. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58833. /**
  58834. * Gets the texture which the depth map will be written to.
  58835. * @returns The depth map texture
  58836. */
  58837. getDepthMap(): RenderTargetTexture;
  58838. /**
  58839. * Disposes of the depth renderer.
  58840. */
  58841. dispose(): void;
  58842. }
  58843. }
  58844. declare module BABYLON {
  58845. /** @hidden */
  58846. export var minmaxReduxPixelShader: {
  58847. name: string;
  58848. shader: string;
  58849. };
  58850. }
  58851. declare module BABYLON {
  58852. /**
  58853. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58854. * and maximum values from all values of the texture.
  58855. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58856. * The source values are read from the red channel of the texture.
  58857. */
  58858. export class MinMaxReducer {
  58859. /**
  58860. * Observable triggered when the computation has been performed
  58861. */
  58862. onAfterReductionPerformed: Observable<{
  58863. min: number;
  58864. max: number;
  58865. }>;
  58866. protected _camera: Camera;
  58867. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58868. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58869. protected _postProcessManager: PostProcessManager;
  58870. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58871. protected _forceFullscreenViewport: boolean;
  58872. /**
  58873. * Creates a min/max reducer
  58874. * @param camera The camera to use for the post processes
  58875. */
  58876. constructor(camera: Camera);
  58877. /**
  58878. * Gets the texture used to read the values from.
  58879. */
  58880. get sourceTexture(): Nullable<RenderTargetTexture>;
  58881. /**
  58882. * Sets the source texture to read the values from.
  58883. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58884. * because in such textures '1' value must not be taken into account to compute the maximum
  58885. * as this value is used to clear the texture.
  58886. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58887. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58888. * @param depthRedux Indicates if the texture is a depth texture or not
  58889. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58890. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58891. */
  58892. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58893. /**
  58894. * Defines the refresh rate of the computation.
  58895. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58896. */
  58897. get refreshRate(): number;
  58898. set refreshRate(value: number);
  58899. protected _activated: boolean;
  58900. /**
  58901. * Gets the activation status of the reducer
  58902. */
  58903. get activated(): boolean;
  58904. /**
  58905. * Activates the reduction computation.
  58906. * When activated, the observers registered in onAfterReductionPerformed are
  58907. * called after the compuation is performed
  58908. */
  58909. activate(): void;
  58910. /**
  58911. * Deactivates the reduction computation.
  58912. */
  58913. deactivate(): void;
  58914. /**
  58915. * Disposes the min/max reducer
  58916. * @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.
  58917. */
  58918. dispose(disposeAll?: boolean): void;
  58919. }
  58920. }
  58921. declare module BABYLON {
  58922. /**
  58923. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58924. */
  58925. export class DepthReducer extends MinMaxReducer {
  58926. private _depthRenderer;
  58927. private _depthRendererId;
  58928. /**
  58929. * Gets the depth renderer used for the computation.
  58930. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58931. */
  58932. get depthRenderer(): Nullable<DepthRenderer>;
  58933. /**
  58934. * Creates a depth reducer
  58935. * @param camera The camera used to render the depth texture
  58936. */
  58937. constructor(camera: Camera);
  58938. /**
  58939. * Sets the depth renderer to use to generate the depth map
  58940. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58941. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58942. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58943. */
  58944. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58945. /** @hidden */
  58946. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58947. /**
  58948. * Activates the reduction computation.
  58949. * When activated, the observers registered in onAfterReductionPerformed are
  58950. * called after the compuation is performed
  58951. */
  58952. activate(): void;
  58953. /**
  58954. * Deactivates the reduction computation.
  58955. */
  58956. deactivate(): void;
  58957. /**
  58958. * Disposes the depth reducer
  58959. * @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.
  58960. */
  58961. dispose(disposeAll?: boolean): void;
  58962. }
  58963. }
  58964. declare module BABYLON {
  58965. /**
  58966. * A CSM implementation allowing casting shadows on large scenes.
  58967. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58968. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58969. */
  58970. export class CascadedShadowGenerator extends ShadowGenerator {
  58971. private static readonly frustumCornersNDCSpace;
  58972. /**
  58973. * Name of the CSM class
  58974. */
  58975. static CLASSNAME: string;
  58976. /**
  58977. * Defines the default number of cascades used by the CSM.
  58978. */
  58979. static readonly DEFAULT_CASCADES_COUNT: number;
  58980. /**
  58981. * Defines the minimum number of cascades used by the CSM.
  58982. */
  58983. static readonly MIN_CASCADES_COUNT: number;
  58984. /**
  58985. * Defines the maximum number of cascades used by the CSM.
  58986. */
  58987. static readonly MAX_CASCADES_COUNT: number;
  58988. protected _validateFilter(filter: number): number;
  58989. /**
  58990. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58991. */
  58992. penumbraDarkness: number;
  58993. private _numCascades;
  58994. /**
  58995. * Gets or set the number of cascades used by the CSM.
  58996. */
  58997. get numCascades(): number;
  58998. set numCascades(value: number);
  58999. /**
  59000. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59001. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59002. */
  59003. stabilizeCascades: boolean;
  59004. private _freezeShadowCastersBoundingInfo;
  59005. private _freezeShadowCastersBoundingInfoObservable;
  59006. /**
  59007. * Enables or disables the shadow casters bounding info computation.
  59008. * If your shadow casters don't move, you can disable this feature.
  59009. * If it is enabled, the bounding box computation is done every frame.
  59010. */
  59011. get freezeShadowCastersBoundingInfo(): boolean;
  59012. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59013. private _scbiMin;
  59014. private _scbiMax;
  59015. protected _computeShadowCastersBoundingInfo(): void;
  59016. protected _shadowCastersBoundingInfo: BoundingInfo;
  59017. /**
  59018. * Gets or sets the shadow casters bounding info.
  59019. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59020. * so that the system won't overwrite the bounds you provide
  59021. */
  59022. get shadowCastersBoundingInfo(): BoundingInfo;
  59023. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59024. protected _breaksAreDirty: boolean;
  59025. protected _minDistance: number;
  59026. protected _maxDistance: number;
  59027. /**
  59028. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59029. *
  59030. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59031. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59032. * @param min minimal distance for the breaks (default to 0.)
  59033. * @param max maximal distance for the breaks (default to 1.)
  59034. */
  59035. setMinMaxDistance(min: number, max: number): void;
  59036. /** Gets the minimal distance used in the cascade break computation */
  59037. get minDistance(): number;
  59038. /** Gets the maximal distance used in the cascade break computation */
  59039. get maxDistance(): number;
  59040. /**
  59041. * Gets the class name of that object
  59042. * @returns "CascadedShadowGenerator"
  59043. */
  59044. getClassName(): string;
  59045. private _cascadeMinExtents;
  59046. private _cascadeMaxExtents;
  59047. /**
  59048. * Gets a cascade minimum extents
  59049. * @param cascadeIndex index of the cascade
  59050. * @returns the minimum cascade extents
  59051. */
  59052. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59053. /**
  59054. * Gets a cascade maximum extents
  59055. * @param cascadeIndex index of the cascade
  59056. * @returns the maximum cascade extents
  59057. */
  59058. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59059. private _cascades;
  59060. private _currentLayer;
  59061. private _viewSpaceFrustumsZ;
  59062. private _viewMatrices;
  59063. private _projectionMatrices;
  59064. private _transformMatrices;
  59065. private _transformMatricesAsArray;
  59066. private _frustumLengths;
  59067. private _lightSizeUVCorrection;
  59068. private _depthCorrection;
  59069. private _frustumCornersWorldSpace;
  59070. private _frustumCenter;
  59071. private _shadowCameraPos;
  59072. private _shadowMaxZ;
  59073. /**
  59074. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59075. * It defaults to camera.maxZ
  59076. */
  59077. get shadowMaxZ(): number;
  59078. /**
  59079. * Sets the shadow max z distance.
  59080. */
  59081. set shadowMaxZ(value: number);
  59082. protected _debug: boolean;
  59083. /**
  59084. * Gets or sets the debug flag.
  59085. * When enabled, the cascades are materialized by different colors on the screen.
  59086. */
  59087. get debug(): boolean;
  59088. set debug(dbg: boolean);
  59089. private _depthClamp;
  59090. /**
  59091. * Gets or sets the depth clamping value.
  59092. *
  59093. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59094. * to account for the shadow casters far away.
  59095. *
  59096. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59097. */
  59098. get depthClamp(): boolean;
  59099. set depthClamp(value: boolean);
  59100. private _cascadeBlendPercentage;
  59101. /**
  59102. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59103. * It defaults to 0.1 (10% blending).
  59104. */
  59105. get cascadeBlendPercentage(): number;
  59106. set cascadeBlendPercentage(value: number);
  59107. private _lambda;
  59108. /**
  59109. * Gets or set the lambda parameter.
  59110. * This parameter is used to split the camera frustum and create the cascades.
  59111. * 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.
  59112. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59113. */
  59114. get lambda(): number;
  59115. set lambda(value: number);
  59116. /**
  59117. * Gets the view matrix corresponding to a given cascade
  59118. * @param cascadeNum cascade to retrieve the view matrix from
  59119. * @returns the cascade view matrix
  59120. */
  59121. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59122. /**
  59123. * Gets the projection matrix corresponding to a given cascade
  59124. * @param cascadeNum cascade to retrieve the projection matrix from
  59125. * @returns the cascade projection matrix
  59126. */
  59127. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59128. /**
  59129. * Gets the transformation matrix corresponding to a given cascade
  59130. * @param cascadeNum cascade to retrieve the transformation matrix from
  59131. * @returns the cascade transformation matrix
  59132. */
  59133. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59134. private _depthRenderer;
  59135. /**
  59136. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59137. *
  59138. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59139. *
  59140. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59141. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59142. * @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
  59143. */
  59144. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59145. private _depthReducer;
  59146. private _autoCalcDepthBounds;
  59147. /**
  59148. * Gets or sets the autoCalcDepthBounds property.
  59149. *
  59150. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59151. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59152. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59153. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59154. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59155. */
  59156. get autoCalcDepthBounds(): boolean;
  59157. set autoCalcDepthBounds(value: boolean);
  59158. /**
  59159. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59160. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59161. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59162. * for setting the refresh rate on the renderer yourself!
  59163. */
  59164. get autoCalcDepthBoundsRefreshRate(): number;
  59165. set autoCalcDepthBoundsRefreshRate(value: number);
  59166. /**
  59167. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59168. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59169. * you change the camera near/far planes!
  59170. */
  59171. splitFrustum(): void;
  59172. private _splitFrustum;
  59173. private _computeMatrices;
  59174. private _computeFrustumInWorldSpace;
  59175. private _computeCascadeFrustum;
  59176. /**
  59177. * Support test.
  59178. */
  59179. static get IsSupported(): boolean;
  59180. /** @hidden */
  59181. static _SceneComponentInitialization: (scene: Scene) => void;
  59182. /**
  59183. * Creates a Cascaded Shadow Generator object.
  59184. * A ShadowGenerator is the required tool to use the shadows.
  59185. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59186. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59187. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59188. * @param light The directional light object generating the shadows.
  59189. * @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.
  59190. */
  59191. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59192. protected _initializeGenerator(): void;
  59193. protected _createTargetRenderTexture(): void;
  59194. protected _initializeShadowMap(): void;
  59195. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59196. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59197. /**
  59198. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59199. * @param defines Defines of the material we want to update
  59200. * @param lightIndex Index of the light in the enabled light list of the material
  59201. */
  59202. prepareDefines(defines: any, lightIndex: number): void;
  59203. /**
  59204. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59205. * defined in the generator but impacting the effect).
  59206. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59207. * @param effect The effect we are binfing the information for
  59208. */
  59209. bindShadowLight(lightIndex: string, effect: Effect): void;
  59210. /**
  59211. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59212. * (eq to view projection * shadow projection matrices)
  59213. * @returns The transform matrix used to create the shadow map
  59214. */
  59215. getTransformMatrix(): Matrix;
  59216. /**
  59217. * Disposes the ShadowGenerator.
  59218. * Returns nothing.
  59219. */
  59220. dispose(): void;
  59221. /**
  59222. * Serializes the shadow generator setup to a json object.
  59223. * @returns The serialized JSON object
  59224. */
  59225. serialize(): any;
  59226. /**
  59227. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59228. * @param parsedShadowGenerator The JSON object to parse
  59229. * @param scene The scene to create the shadow map for
  59230. * @returns The parsed shadow generator
  59231. */
  59232. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59233. }
  59234. }
  59235. declare module BABYLON {
  59236. /**
  59237. * Defines the shadow generator component responsible to manage any shadow generators
  59238. * in a given scene.
  59239. */
  59240. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59241. /**
  59242. * The component name helpfull to identify the component in the list of scene components.
  59243. */
  59244. readonly name: string;
  59245. /**
  59246. * The scene the component belongs to.
  59247. */
  59248. scene: Scene;
  59249. /**
  59250. * Creates a new instance of the component for the given scene
  59251. * @param scene Defines the scene to register the component in
  59252. */
  59253. constructor(scene: Scene);
  59254. /**
  59255. * Registers the component in a given scene
  59256. */
  59257. register(): void;
  59258. /**
  59259. * Rebuilds the elements related to this component in case of
  59260. * context lost for instance.
  59261. */
  59262. rebuild(): void;
  59263. /**
  59264. * Serializes the component data to the specified json object
  59265. * @param serializationObject The object to serialize to
  59266. */
  59267. serialize(serializationObject: any): void;
  59268. /**
  59269. * Adds all the elements from the container to the scene
  59270. * @param container the container holding the elements
  59271. */
  59272. addFromContainer(container: AbstractScene): void;
  59273. /**
  59274. * Removes all the elements in the container from the scene
  59275. * @param container contains the elements to remove
  59276. * @param dispose if the removed element should be disposed (default: false)
  59277. */
  59278. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59279. /**
  59280. * Rebuilds the elements related to this component in case of
  59281. * context lost for instance.
  59282. */
  59283. dispose(): void;
  59284. private _gatherRenderTargets;
  59285. }
  59286. }
  59287. declare module BABYLON {
  59288. /**
  59289. * A point light is a light defined by an unique point in world space.
  59290. * The light is emitted in every direction from this point.
  59291. * A good example of a point light is a standard light bulb.
  59292. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59293. */
  59294. export class PointLight extends ShadowLight {
  59295. private _shadowAngle;
  59296. /**
  59297. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59298. * This specifies what angle the shadow will use to be created.
  59299. *
  59300. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59301. */
  59302. get shadowAngle(): number;
  59303. /**
  59304. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59305. * This specifies what angle the shadow will use to be created.
  59306. *
  59307. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59308. */
  59309. set shadowAngle(value: number);
  59310. /**
  59311. * Gets the direction if it has been set.
  59312. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59313. */
  59314. get direction(): Vector3;
  59315. /**
  59316. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59317. */
  59318. set direction(value: Vector3);
  59319. /**
  59320. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59321. * A PointLight emits the light in every direction.
  59322. * It can cast shadows.
  59323. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59324. * ```javascript
  59325. * var pointLight = new PointLight("pl", camera.position, scene);
  59326. * ```
  59327. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59328. * @param name The light friendly name
  59329. * @param position The position of the point light in the scene
  59330. * @param scene The scene the lights belongs to
  59331. */
  59332. constructor(name: string, position: Vector3, scene: Scene);
  59333. /**
  59334. * Returns the string "PointLight"
  59335. * @returns the class name
  59336. */
  59337. getClassName(): string;
  59338. /**
  59339. * Returns the integer 0.
  59340. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59341. */
  59342. getTypeID(): number;
  59343. /**
  59344. * Specifies wether or not the shadowmap should be a cube texture.
  59345. * @returns true if the shadowmap needs to be a cube texture.
  59346. */
  59347. needCube(): boolean;
  59348. /**
  59349. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59350. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59351. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59352. */
  59353. getShadowDirection(faceIndex?: number): Vector3;
  59354. /**
  59355. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59356. * - fov = PI / 2
  59357. * - aspect ratio : 1.0
  59358. * - z-near and far equal to the active camera minZ and maxZ.
  59359. * Returns the PointLight.
  59360. */
  59361. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59362. protected _buildUniformLayout(): void;
  59363. /**
  59364. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59365. * @param effect The effect to update
  59366. * @param lightIndex The index of the light in the effect to update
  59367. * @returns The point light
  59368. */
  59369. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59370. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59371. /**
  59372. * Prepares the list of defines specific to the light type.
  59373. * @param defines the list of defines
  59374. * @param lightIndex defines the index of the light for the effect
  59375. */
  59376. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59377. }
  59378. }
  59379. declare module BABYLON {
  59380. /**
  59381. * Header information of HDR texture files.
  59382. */
  59383. export interface HDRInfo {
  59384. /**
  59385. * The height of the texture in pixels.
  59386. */
  59387. height: number;
  59388. /**
  59389. * The width of the texture in pixels.
  59390. */
  59391. width: number;
  59392. /**
  59393. * The index of the beginning of the data in the binary file.
  59394. */
  59395. dataPosition: number;
  59396. }
  59397. /**
  59398. * This groups tools to convert HDR texture to native colors array.
  59399. */
  59400. export class HDRTools {
  59401. private static Ldexp;
  59402. private static Rgbe2float;
  59403. private static readStringLine;
  59404. /**
  59405. * Reads header information from an RGBE texture stored in a native array.
  59406. * More information on this format are available here:
  59407. * https://en.wikipedia.org/wiki/RGBE_image_format
  59408. *
  59409. * @param uint8array The binary file stored in native array.
  59410. * @return The header information.
  59411. */
  59412. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59413. /**
  59414. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59415. * This RGBE texture needs to store the information as a panorama.
  59416. *
  59417. * More information on this format are available here:
  59418. * https://en.wikipedia.org/wiki/RGBE_image_format
  59419. *
  59420. * @param buffer The binary file stored in an array buffer.
  59421. * @param size The expected size of the extracted cubemap.
  59422. * @return The Cube Map information.
  59423. */
  59424. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59425. /**
  59426. * Returns the pixels data extracted from an RGBE texture.
  59427. * This pixels will be stored left to right up to down in the R G B order in one array.
  59428. *
  59429. * More information on this format are available here:
  59430. * https://en.wikipedia.org/wiki/RGBE_image_format
  59431. *
  59432. * @param uint8array The binary file stored in an array buffer.
  59433. * @param hdrInfo The header information of the file.
  59434. * @return The pixels data in RGB right to left up to down order.
  59435. */
  59436. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59437. private static RGBE_ReadPixels_RLE;
  59438. private static RGBE_ReadPixels_NOT_RLE;
  59439. }
  59440. }
  59441. declare module BABYLON {
  59442. /**
  59443. * Effect Render Options
  59444. */
  59445. export interface IEffectRendererOptions {
  59446. /**
  59447. * Defines the vertices positions.
  59448. */
  59449. positions?: number[];
  59450. /**
  59451. * Defines the indices.
  59452. */
  59453. indices?: number[];
  59454. }
  59455. /**
  59456. * Helper class to render one or more effects.
  59457. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59458. */
  59459. export class EffectRenderer {
  59460. private engine;
  59461. private static _DefaultOptions;
  59462. private _vertexBuffers;
  59463. private _indexBuffer;
  59464. private _fullscreenViewport;
  59465. /**
  59466. * Creates an effect renderer
  59467. * @param engine the engine to use for rendering
  59468. * @param options defines the options of the effect renderer
  59469. */
  59470. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59471. /**
  59472. * Sets the current viewport in normalized coordinates 0-1
  59473. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59474. */
  59475. setViewport(viewport?: Viewport): void;
  59476. /**
  59477. * Binds the embedded attributes buffer to the effect.
  59478. * @param effect Defines the effect to bind the attributes for
  59479. */
  59480. bindBuffers(effect: Effect): void;
  59481. /**
  59482. * Sets the current effect wrapper to use during draw.
  59483. * The effect needs to be ready before calling this api.
  59484. * This also sets the default full screen position attribute.
  59485. * @param effectWrapper Defines the effect to draw with
  59486. */
  59487. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59488. /**
  59489. * Restores engine states
  59490. */
  59491. restoreStates(): void;
  59492. /**
  59493. * Draws a full screen quad.
  59494. */
  59495. draw(): void;
  59496. private isRenderTargetTexture;
  59497. /**
  59498. * renders one or more effects to a specified texture
  59499. * @param effectWrapper the effect to renderer
  59500. * @param outputTexture texture to draw to, if null it will render to the screen.
  59501. */
  59502. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59503. /**
  59504. * Disposes of the effect renderer
  59505. */
  59506. dispose(): void;
  59507. }
  59508. /**
  59509. * Options to create an EffectWrapper
  59510. */
  59511. interface EffectWrapperCreationOptions {
  59512. /**
  59513. * Engine to use to create the effect
  59514. */
  59515. engine: ThinEngine;
  59516. /**
  59517. * Fragment shader for the effect
  59518. */
  59519. fragmentShader: string;
  59520. /**
  59521. * Use the shader store instead of direct source code
  59522. */
  59523. useShaderStore?: boolean;
  59524. /**
  59525. * Vertex shader for the effect
  59526. */
  59527. vertexShader?: string;
  59528. /**
  59529. * Attributes to use in the shader
  59530. */
  59531. attributeNames?: Array<string>;
  59532. /**
  59533. * Uniforms to use in the shader
  59534. */
  59535. uniformNames?: Array<string>;
  59536. /**
  59537. * Texture sampler names to use in the shader
  59538. */
  59539. samplerNames?: Array<string>;
  59540. /**
  59541. * Defines to use in the shader
  59542. */
  59543. defines?: Array<string>;
  59544. /**
  59545. * Callback when effect is compiled
  59546. */
  59547. onCompiled?: Nullable<(effect: Effect) => void>;
  59548. /**
  59549. * The friendly name of the effect displayed in Spector.
  59550. */
  59551. name?: string;
  59552. }
  59553. /**
  59554. * Wraps an effect to be used for rendering
  59555. */
  59556. export class EffectWrapper {
  59557. /**
  59558. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59559. */
  59560. onApplyObservable: Observable<{}>;
  59561. /**
  59562. * The underlying effect
  59563. */
  59564. effect: Effect;
  59565. /**
  59566. * Creates an effect to be renderer
  59567. * @param creationOptions options to create the effect
  59568. */
  59569. constructor(creationOptions: EffectWrapperCreationOptions);
  59570. /**
  59571. * Disposes of the effect wrapper
  59572. */
  59573. dispose(): void;
  59574. }
  59575. }
  59576. declare module BABYLON {
  59577. /** @hidden */
  59578. export var hdrFilteringVertexShader: {
  59579. name: string;
  59580. shader: string;
  59581. };
  59582. }
  59583. declare module BABYLON {
  59584. /** @hidden */
  59585. export var hdrFilteringPixelShader: {
  59586. name: string;
  59587. shader: string;
  59588. };
  59589. }
  59590. declare module BABYLON {
  59591. /**
  59592. * Options for texture filtering
  59593. */
  59594. interface IHDRFilteringOptions {
  59595. /**
  59596. * Scales pixel intensity for the input HDR map.
  59597. */
  59598. hdrScale?: number;
  59599. /**
  59600. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59601. */
  59602. quality?: number;
  59603. }
  59604. /**
  59605. * Filters HDR maps to get correct renderings of PBR reflections
  59606. */
  59607. export class HDRFiltering {
  59608. private _engine;
  59609. private _effectRenderer;
  59610. private _effectWrapper;
  59611. private _lodGenerationOffset;
  59612. private _lodGenerationScale;
  59613. /**
  59614. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59615. * you care about baking speed.
  59616. */
  59617. quality: number;
  59618. /**
  59619. * Scales pixel intensity for the input HDR map.
  59620. */
  59621. hdrScale: number;
  59622. /**
  59623. * Instantiates HDR filter for reflection maps
  59624. *
  59625. * @param engine Thin engine
  59626. * @param options Options
  59627. */
  59628. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59629. private _createRenderTarget;
  59630. private _prefilterInternal;
  59631. private _createEffect;
  59632. /**
  59633. * Get a value indicating if the filter is ready to be used
  59634. * @param texture Texture to filter
  59635. * @returns true if the filter is ready
  59636. */
  59637. isReady(texture: BaseTexture): boolean;
  59638. /**
  59639. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59640. * Prefiltering will be invoked at the end of next rendering pass.
  59641. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59642. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59643. * @param texture Texture to filter
  59644. * @param onFinished Callback when filtering is done
  59645. * @return Promise called when prefiltering is done
  59646. */
  59647. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59648. }
  59649. }
  59650. declare module BABYLON {
  59651. /**
  59652. * This represents a texture coming from an HDR input.
  59653. *
  59654. * The only supported format is currently panorama picture stored in RGBE format.
  59655. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59656. */
  59657. export class HDRCubeTexture extends BaseTexture {
  59658. private static _facesMapping;
  59659. private _generateHarmonics;
  59660. private _noMipmap;
  59661. private _prefilterOnLoad;
  59662. private _textureMatrix;
  59663. private _size;
  59664. private _onLoad;
  59665. private _onError;
  59666. /**
  59667. * The texture URL.
  59668. */
  59669. url: string;
  59670. /**
  59671. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59672. */
  59673. coordinatesMode: number;
  59674. protected _isBlocking: boolean;
  59675. /**
  59676. * Sets wether or not the texture is blocking during loading.
  59677. */
  59678. set isBlocking(value: boolean);
  59679. /**
  59680. * Gets wether or not the texture is blocking during loading.
  59681. */
  59682. get isBlocking(): boolean;
  59683. protected _rotationY: number;
  59684. /**
  59685. * Sets texture matrix rotation angle around Y axis in radians.
  59686. */
  59687. set rotationY(value: number);
  59688. /**
  59689. * Gets texture matrix rotation angle around Y axis radians.
  59690. */
  59691. get rotationY(): number;
  59692. /**
  59693. * Gets or sets the center of the bounding box associated with the cube texture
  59694. * It must define where the camera used to render the texture was set
  59695. */
  59696. boundingBoxPosition: Vector3;
  59697. private _boundingBoxSize;
  59698. /**
  59699. * Gets or sets the size of the bounding box associated with the cube texture
  59700. * When defined, the cubemap will switch to local mode
  59701. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59702. * @example https://www.babylonjs-playground.com/#RNASML
  59703. */
  59704. set boundingBoxSize(value: Vector3);
  59705. get boundingBoxSize(): Vector3;
  59706. /**
  59707. * Instantiates an HDRTexture from the following parameters.
  59708. *
  59709. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59710. * @param sceneOrEngine The scene or engine the texture will be used in
  59711. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59712. * @param noMipmap Forces to not generate the mipmap if true
  59713. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59714. * @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)
  59715. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59716. */
  59717. 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>);
  59718. /**
  59719. * Get the current class name of the texture useful for serialization or dynamic coding.
  59720. * @returns "HDRCubeTexture"
  59721. */
  59722. getClassName(): string;
  59723. /**
  59724. * Occurs when the file is raw .hdr file.
  59725. */
  59726. private loadTexture;
  59727. clone(): HDRCubeTexture;
  59728. delayLoad(): void;
  59729. /**
  59730. * Get the texture reflection matrix used to rotate/transform the reflection.
  59731. * @returns the reflection matrix
  59732. */
  59733. getReflectionTextureMatrix(): Matrix;
  59734. /**
  59735. * Set the texture reflection matrix used to rotate/transform the reflection.
  59736. * @param value Define the reflection matrix to set
  59737. */
  59738. setReflectionTextureMatrix(value: Matrix): void;
  59739. /**
  59740. * Parses a JSON representation of an HDR Texture in order to create the texture
  59741. * @param parsedTexture Define the JSON representation
  59742. * @param scene Define the scene the texture should be created in
  59743. * @param rootUrl Define the root url in case we need to load relative dependencies
  59744. * @returns the newly created texture after parsing
  59745. */
  59746. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59747. serialize(): any;
  59748. }
  59749. }
  59750. declare module BABYLON {
  59751. /**
  59752. * Class used to control physics engine
  59753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59754. */
  59755. export class PhysicsEngine implements IPhysicsEngine {
  59756. private _physicsPlugin;
  59757. /**
  59758. * Global value used to control the smallest number supported by the simulation
  59759. */
  59760. static Epsilon: number;
  59761. private _impostors;
  59762. private _joints;
  59763. private _subTimeStep;
  59764. /**
  59765. * Gets the gravity vector used by the simulation
  59766. */
  59767. gravity: Vector3;
  59768. /**
  59769. * Factory used to create the default physics plugin.
  59770. * @returns The default physics plugin
  59771. */
  59772. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59773. /**
  59774. * Creates a new Physics Engine
  59775. * @param gravity defines the gravity vector used by the simulation
  59776. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59777. */
  59778. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59779. /**
  59780. * Sets the gravity vector used by the simulation
  59781. * @param gravity defines the gravity vector to use
  59782. */
  59783. setGravity(gravity: Vector3): void;
  59784. /**
  59785. * Set the time step of the physics engine.
  59786. * Default is 1/60.
  59787. * To slow it down, enter 1/600 for example.
  59788. * To speed it up, 1/30
  59789. * @param newTimeStep defines the new timestep to apply to this world.
  59790. */
  59791. setTimeStep(newTimeStep?: number): void;
  59792. /**
  59793. * Get the time step of the physics engine.
  59794. * @returns the current time step
  59795. */
  59796. getTimeStep(): number;
  59797. /**
  59798. * Set the sub time step of the physics engine.
  59799. * Default is 0 meaning there is no sub steps
  59800. * To increase physics resolution precision, set a small value (like 1 ms)
  59801. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59802. */
  59803. setSubTimeStep(subTimeStep?: number): void;
  59804. /**
  59805. * Get the sub time step of the physics engine.
  59806. * @returns the current sub time step
  59807. */
  59808. getSubTimeStep(): number;
  59809. /**
  59810. * Release all resources
  59811. */
  59812. dispose(): void;
  59813. /**
  59814. * Gets the name of the current physics plugin
  59815. * @returns the name of the plugin
  59816. */
  59817. getPhysicsPluginName(): string;
  59818. /**
  59819. * Adding a new impostor for the impostor tracking.
  59820. * This will be done by the impostor itself.
  59821. * @param impostor the impostor to add
  59822. */
  59823. addImpostor(impostor: PhysicsImpostor): void;
  59824. /**
  59825. * Remove an impostor from the engine.
  59826. * This impostor and its mesh will not longer be updated by the physics engine.
  59827. * @param impostor the impostor to remove
  59828. */
  59829. removeImpostor(impostor: PhysicsImpostor): void;
  59830. /**
  59831. * Add a joint to the physics engine
  59832. * @param mainImpostor defines the main impostor to which the joint is added.
  59833. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59834. * @param joint defines the joint that will connect both impostors.
  59835. */
  59836. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59837. /**
  59838. * Removes a joint from the simulation
  59839. * @param mainImpostor defines the impostor used with the joint
  59840. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59841. * @param joint defines the joint to remove
  59842. */
  59843. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59844. /**
  59845. * Called by the scene. No need to call it.
  59846. * @param delta defines the timespam between frames
  59847. */
  59848. _step(delta: number): void;
  59849. /**
  59850. * Gets the current plugin used to run the simulation
  59851. * @returns current plugin
  59852. */
  59853. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59854. /**
  59855. * Gets the list of physic impostors
  59856. * @returns an array of PhysicsImpostor
  59857. */
  59858. getImpostors(): Array<PhysicsImpostor>;
  59859. /**
  59860. * Gets the impostor for a physics enabled object
  59861. * @param object defines the object impersonated by the impostor
  59862. * @returns the PhysicsImpostor or null if not found
  59863. */
  59864. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59865. /**
  59866. * Gets the impostor for a physics body object
  59867. * @param body defines physics body used by the impostor
  59868. * @returns the PhysicsImpostor or null if not found
  59869. */
  59870. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59871. /**
  59872. * Does a raycast in the physics world
  59873. * @param from when should the ray start?
  59874. * @param to when should the ray end?
  59875. * @returns PhysicsRaycastResult
  59876. */
  59877. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59878. }
  59879. }
  59880. declare module BABYLON {
  59881. /** @hidden */
  59882. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59883. private _useDeltaForWorldStep;
  59884. world: any;
  59885. name: string;
  59886. private _physicsMaterials;
  59887. private _fixedTimeStep;
  59888. private _cannonRaycastResult;
  59889. private _raycastResult;
  59890. private _physicsBodysToRemoveAfterStep;
  59891. private _firstFrame;
  59892. BJSCANNON: any;
  59893. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59894. setGravity(gravity: Vector3): void;
  59895. setTimeStep(timeStep: number): void;
  59896. getTimeStep(): number;
  59897. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59898. private _removeMarkedPhysicsBodiesFromWorld;
  59899. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59900. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59901. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59902. private _processChildMeshes;
  59903. removePhysicsBody(impostor: PhysicsImpostor): void;
  59904. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59905. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59906. private _addMaterial;
  59907. private _checkWithEpsilon;
  59908. private _createShape;
  59909. private _createHeightmap;
  59910. private _minus90X;
  59911. private _plus90X;
  59912. private _tmpPosition;
  59913. private _tmpDeltaPosition;
  59914. private _tmpUnityRotation;
  59915. private _updatePhysicsBodyTransformation;
  59916. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59917. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59918. isSupported(): boolean;
  59919. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59920. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59921. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59922. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59923. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59924. getBodyMass(impostor: PhysicsImpostor): number;
  59925. getBodyFriction(impostor: PhysicsImpostor): number;
  59926. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59927. getBodyRestitution(impostor: PhysicsImpostor): number;
  59928. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59929. sleepBody(impostor: PhysicsImpostor): void;
  59930. wakeUpBody(impostor: PhysicsImpostor): void;
  59931. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59932. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59933. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59934. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59935. getRadius(impostor: PhysicsImpostor): number;
  59936. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59937. dispose(): void;
  59938. private _extendNamespace;
  59939. /**
  59940. * Does a raycast in the physics world
  59941. * @param from when should the ray start?
  59942. * @param to when should the ray end?
  59943. * @returns PhysicsRaycastResult
  59944. */
  59945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59946. }
  59947. }
  59948. declare module BABYLON {
  59949. /** @hidden */
  59950. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59951. private _useDeltaForWorldStep;
  59952. world: any;
  59953. name: string;
  59954. BJSOIMO: any;
  59955. private _raycastResult;
  59956. private _fixedTimeStep;
  59957. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59958. setGravity(gravity: Vector3): void;
  59959. setTimeStep(timeStep: number): void;
  59960. getTimeStep(): number;
  59961. private _tmpImpostorsArray;
  59962. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59963. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59964. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59965. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59966. private _tmpPositionVector;
  59967. removePhysicsBody(impostor: PhysicsImpostor): void;
  59968. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59969. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59970. isSupported(): boolean;
  59971. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59972. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59973. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59974. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59975. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59976. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59977. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59978. getBodyMass(impostor: PhysicsImpostor): number;
  59979. getBodyFriction(impostor: PhysicsImpostor): number;
  59980. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59981. getBodyRestitution(impostor: PhysicsImpostor): number;
  59982. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59983. sleepBody(impostor: PhysicsImpostor): void;
  59984. wakeUpBody(impostor: PhysicsImpostor): void;
  59985. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59986. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59987. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59988. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59989. getRadius(impostor: PhysicsImpostor): number;
  59990. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59991. dispose(): void;
  59992. /**
  59993. * Does a raycast in the physics world
  59994. * @param from when should the ray start?
  59995. * @param to when should the ray end?
  59996. * @returns PhysicsRaycastResult
  59997. */
  59998. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59999. }
  60000. }
  60001. declare module BABYLON {
  60002. /**
  60003. * Class containing static functions to help procedurally build meshes
  60004. */
  60005. export class RibbonBuilder {
  60006. /**
  60007. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60008. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60009. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60010. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60011. * * 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
  60012. * * 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
  60013. * * 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
  60014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60015. * * 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
  60016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60017. * * 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
  60018. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60019. * * 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
  60020. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60022. * @param name defines the name of the mesh
  60023. * @param options defines the options used to create the mesh
  60024. * @param scene defines the hosting scene
  60025. * @returns the ribbon mesh
  60026. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60027. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60028. */
  60029. static CreateRibbon(name: string, options: {
  60030. pathArray: Vector3[][];
  60031. closeArray?: boolean;
  60032. closePath?: boolean;
  60033. offset?: number;
  60034. updatable?: boolean;
  60035. sideOrientation?: number;
  60036. frontUVs?: Vector4;
  60037. backUVs?: Vector4;
  60038. instance?: Mesh;
  60039. invertUV?: boolean;
  60040. uvs?: Vector2[];
  60041. colors?: Color4[];
  60042. }, scene?: Nullable<Scene>): Mesh;
  60043. }
  60044. }
  60045. declare module BABYLON {
  60046. /**
  60047. * Class containing static functions to help procedurally build meshes
  60048. */
  60049. export class ShapeBuilder {
  60050. /**
  60051. * 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.
  60052. * * 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.
  60053. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60054. * * 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.
  60055. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60056. * * 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
  60057. * * 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
  60058. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60060. * * 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
  60061. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60063. * @param name defines the name of the mesh
  60064. * @param options defines the options used to create the mesh
  60065. * @param scene defines the hosting scene
  60066. * @returns the extruded shape mesh
  60067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60069. */
  60070. static ExtrudeShape(name: string, options: {
  60071. shape: Vector3[];
  60072. path: Vector3[];
  60073. scale?: number;
  60074. rotation?: number;
  60075. cap?: number;
  60076. updatable?: boolean;
  60077. sideOrientation?: number;
  60078. frontUVs?: Vector4;
  60079. backUVs?: Vector4;
  60080. instance?: Mesh;
  60081. invertUV?: boolean;
  60082. }, scene?: Nullable<Scene>): Mesh;
  60083. /**
  60084. * Creates an custom extruded shape mesh.
  60085. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60086. * * 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.
  60087. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60088. * * 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
  60089. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60090. * * 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
  60091. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60092. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60093. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60094. * * 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
  60095. * * 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
  60096. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60098. * * 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
  60099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60101. * @param name defines the name of the mesh
  60102. * @param options defines the options used to create the mesh
  60103. * @param scene defines the hosting scene
  60104. * @returns the custom extruded shape mesh
  60105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60106. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60108. */
  60109. static ExtrudeShapeCustom(name: string, options: {
  60110. shape: Vector3[];
  60111. path: Vector3[];
  60112. scaleFunction?: any;
  60113. rotationFunction?: any;
  60114. ribbonCloseArray?: boolean;
  60115. ribbonClosePath?: boolean;
  60116. cap?: number;
  60117. updatable?: boolean;
  60118. sideOrientation?: number;
  60119. frontUVs?: Vector4;
  60120. backUVs?: Vector4;
  60121. instance?: Mesh;
  60122. invertUV?: boolean;
  60123. }, scene?: Nullable<Scene>): Mesh;
  60124. private static _ExtrudeShapeGeneric;
  60125. }
  60126. }
  60127. declare module BABYLON {
  60128. /**
  60129. * AmmoJS Physics plugin
  60130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60131. * @see https://github.com/kripken/ammo.js/
  60132. */
  60133. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60134. private _useDeltaForWorldStep;
  60135. /**
  60136. * Reference to the Ammo library
  60137. */
  60138. bjsAMMO: any;
  60139. /**
  60140. * Created ammoJS world which physics bodies are added to
  60141. */
  60142. world: any;
  60143. /**
  60144. * Name of the plugin
  60145. */
  60146. name: string;
  60147. private _timeStep;
  60148. private _fixedTimeStep;
  60149. private _maxSteps;
  60150. private _tmpQuaternion;
  60151. private _tmpAmmoTransform;
  60152. private _tmpAmmoQuaternion;
  60153. private _tmpAmmoConcreteContactResultCallback;
  60154. private _collisionConfiguration;
  60155. private _dispatcher;
  60156. private _overlappingPairCache;
  60157. private _solver;
  60158. private _softBodySolver;
  60159. private _tmpAmmoVectorA;
  60160. private _tmpAmmoVectorB;
  60161. private _tmpAmmoVectorC;
  60162. private _tmpAmmoVectorD;
  60163. private _tmpContactCallbackResult;
  60164. private _tmpAmmoVectorRCA;
  60165. private _tmpAmmoVectorRCB;
  60166. private _raycastResult;
  60167. private static readonly DISABLE_COLLISION_FLAG;
  60168. private static readonly KINEMATIC_FLAG;
  60169. private static readonly DISABLE_DEACTIVATION_FLAG;
  60170. /**
  60171. * Initializes the ammoJS plugin
  60172. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60173. * @param ammoInjection can be used to inject your own ammo reference
  60174. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60175. */
  60176. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60177. /**
  60178. * Sets the gravity of the physics world (m/(s^2))
  60179. * @param gravity Gravity to set
  60180. */
  60181. setGravity(gravity: Vector3): void;
  60182. /**
  60183. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60184. * @param timeStep timestep to use in seconds
  60185. */
  60186. setTimeStep(timeStep: number): void;
  60187. /**
  60188. * 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)
  60189. * @param fixedTimeStep fixedTimeStep to use in seconds
  60190. */
  60191. setFixedTimeStep(fixedTimeStep: number): void;
  60192. /**
  60193. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60194. * @param maxSteps the maximum number of steps by the physics engine per frame
  60195. */
  60196. setMaxSteps(maxSteps: number): void;
  60197. /**
  60198. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60199. * @returns the current timestep in seconds
  60200. */
  60201. getTimeStep(): number;
  60202. /**
  60203. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60204. */
  60205. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60206. private _isImpostorInContact;
  60207. private _isImpostorPairInContact;
  60208. private _stepSimulation;
  60209. /**
  60210. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60211. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60212. * After the step the babylon meshes are set to the position of the physics imposters
  60213. * @param delta amount of time to step forward
  60214. * @param impostors array of imposters to update before/after the step
  60215. */
  60216. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60217. /**
  60218. * Update babylon mesh to match physics world object
  60219. * @param impostor imposter to match
  60220. */
  60221. private _afterSoftStep;
  60222. /**
  60223. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60224. * @param impostor imposter to match
  60225. */
  60226. private _ropeStep;
  60227. /**
  60228. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60229. * @param impostor imposter to match
  60230. */
  60231. private _softbodyOrClothStep;
  60232. private _tmpMatrix;
  60233. /**
  60234. * Applies an impulse on the imposter
  60235. * @param impostor imposter to apply impulse to
  60236. * @param force amount of force to be applied to the imposter
  60237. * @param contactPoint the location to apply the impulse on the imposter
  60238. */
  60239. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60240. /**
  60241. * Applies a force on the imposter
  60242. * @param impostor imposter to apply force
  60243. * @param force amount of force to be applied to the imposter
  60244. * @param contactPoint the location to apply the force on the imposter
  60245. */
  60246. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60247. /**
  60248. * Creates a physics body using the plugin
  60249. * @param impostor the imposter to create the physics body on
  60250. */
  60251. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60252. /**
  60253. * Removes the physics body from the imposter and disposes of the body's memory
  60254. * @param impostor imposter to remove the physics body from
  60255. */
  60256. removePhysicsBody(impostor: PhysicsImpostor): void;
  60257. /**
  60258. * Generates a joint
  60259. * @param impostorJoint the imposter joint to create the joint with
  60260. */
  60261. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60262. /**
  60263. * Removes a joint
  60264. * @param impostorJoint the imposter joint to remove the joint from
  60265. */
  60266. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60267. private _addMeshVerts;
  60268. /**
  60269. * Initialise the soft body vertices to match its object's (mesh) vertices
  60270. * Softbody vertices (nodes) are in world space and to match this
  60271. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60272. * @param impostor to create the softbody for
  60273. */
  60274. private _softVertexData;
  60275. /**
  60276. * Create an impostor's soft body
  60277. * @param impostor to create the softbody for
  60278. */
  60279. private _createSoftbody;
  60280. /**
  60281. * Create cloth for an impostor
  60282. * @param impostor to create the softbody for
  60283. */
  60284. private _createCloth;
  60285. /**
  60286. * Create rope for an impostor
  60287. * @param impostor to create the softbody for
  60288. */
  60289. private _createRope;
  60290. /**
  60291. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60292. * @param impostor to create the custom physics shape for
  60293. */
  60294. private _createCustom;
  60295. private _addHullVerts;
  60296. private _createShape;
  60297. /**
  60298. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60299. * @param impostor imposter containing the physics body and babylon object
  60300. */
  60301. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60302. /**
  60303. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60304. * @param impostor imposter containing the physics body and babylon object
  60305. * @param newPosition new position
  60306. * @param newRotation new rotation
  60307. */
  60308. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60309. /**
  60310. * If this plugin is supported
  60311. * @returns true if its supported
  60312. */
  60313. isSupported(): boolean;
  60314. /**
  60315. * Sets the linear velocity of the physics body
  60316. * @param impostor imposter to set the velocity on
  60317. * @param velocity velocity to set
  60318. */
  60319. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60320. /**
  60321. * Sets the angular velocity of the physics body
  60322. * @param impostor imposter to set the velocity on
  60323. * @param velocity velocity to set
  60324. */
  60325. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60326. /**
  60327. * gets the linear velocity
  60328. * @param impostor imposter to get linear velocity from
  60329. * @returns linear velocity
  60330. */
  60331. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60332. /**
  60333. * gets the angular velocity
  60334. * @param impostor imposter to get angular velocity from
  60335. * @returns angular velocity
  60336. */
  60337. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60338. /**
  60339. * Sets the mass of physics body
  60340. * @param impostor imposter to set the mass on
  60341. * @param mass mass to set
  60342. */
  60343. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60344. /**
  60345. * Gets the mass of the physics body
  60346. * @param impostor imposter to get the mass from
  60347. * @returns mass
  60348. */
  60349. getBodyMass(impostor: PhysicsImpostor): number;
  60350. /**
  60351. * Gets friction of the impostor
  60352. * @param impostor impostor to get friction from
  60353. * @returns friction value
  60354. */
  60355. getBodyFriction(impostor: PhysicsImpostor): number;
  60356. /**
  60357. * Sets friction of the impostor
  60358. * @param impostor impostor to set friction on
  60359. * @param friction friction value
  60360. */
  60361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60362. /**
  60363. * Gets restitution of the impostor
  60364. * @param impostor impostor to get restitution from
  60365. * @returns restitution value
  60366. */
  60367. getBodyRestitution(impostor: PhysicsImpostor): number;
  60368. /**
  60369. * Sets resitution of the impostor
  60370. * @param impostor impostor to set resitution on
  60371. * @param restitution resitution value
  60372. */
  60373. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60374. /**
  60375. * Gets pressure inside the impostor
  60376. * @param impostor impostor to get pressure from
  60377. * @returns pressure value
  60378. */
  60379. getBodyPressure(impostor: PhysicsImpostor): number;
  60380. /**
  60381. * Sets pressure inside a soft body impostor
  60382. * Cloth and rope must remain 0 pressure
  60383. * @param impostor impostor to set pressure on
  60384. * @param pressure pressure value
  60385. */
  60386. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60387. /**
  60388. * Gets stiffness of the impostor
  60389. * @param impostor impostor to get stiffness from
  60390. * @returns pressure value
  60391. */
  60392. getBodyStiffness(impostor: PhysicsImpostor): number;
  60393. /**
  60394. * Sets stiffness of the impostor
  60395. * @param impostor impostor to set stiffness on
  60396. * @param stiffness stiffness value from 0 to 1
  60397. */
  60398. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60399. /**
  60400. * Gets velocityIterations of the impostor
  60401. * @param impostor impostor to get velocity iterations from
  60402. * @returns velocityIterations value
  60403. */
  60404. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60405. /**
  60406. * Sets velocityIterations of the impostor
  60407. * @param impostor impostor to set velocity iterations on
  60408. * @param velocityIterations velocityIterations value
  60409. */
  60410. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60411. /**
  60412. * Gets positionIterations of the impostor
  60413. * @param impostor impostor to get position iterations from
  60414. * @returns positionIterations value
  60415. */
  60416. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60417. /**
  60418. * Sets positionIterations of the impostor
  60419. * @param impostor impostor to set position on
  60420. * @param positionIterations positionIterations value
  60421. */
  60422. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60423. /**
  60424. * Append an anchor to a cloth object
  60425. * @param impostor is the cloth impostor to add anchor to
  60426. * @param otherImpostor is the rigid impostor to anchor to
  60427. * @param width ratio across width from 0 to 1
  60428. * @param height ratio up height from 0 to 1
  60429. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60430. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60431. */
  60432. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60433. /**
  60434. * Append an hook to a rope object
  60435. * @param impostor is the rope impostor to add hook to
  60436. * @param otherImpostor is the rigid impostor to hook to
  60437. * @param length ratio along the rope from 0 to 1
  60438. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60439. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60440. */
  60441. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60442. /**
  60443. * Sleeps the physics body and stops it from being active
  60444. * @param impostor impostor to sleep
  60445. */
  60446. sleepBody(impostor: PhysicsImpostor): void;
  60447. /**
  60448. * Activates the physics body
  60449. * @param impostor impostor to activate
  60450. */
  60451. wakeUpBody(impostor: PhysicsImpostor): void;
  60452. /**
  60453. * Updates the distance parameters of the joint
  60454. * @param joint joint to update
  60455. * @param maxDistance maximum distance of the joint
  60456. * @param minDistance minimum distance of the joint
  60457. */
  60458. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60459. /**
  60460. * Sets a motor on the joint
  60461. * @param joint joint to set motor on
  60462. * @param speed speed of the motor
  60463. * @param maxForce maximum force of the motor
  60464. * @param motorIndex index of the motor
  60465. */
  60466. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60467. /**
  60468. * Sets the motors limit
  60469. * @param joint joint to set limit on
  60470. * @param upperLimit upper limit
  60471. * @param lowerLimit lower limit
  60472. */
  60473. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60474. /**
  60475. * Syncs the position and rotation of a mesh with the impostor
  60476. * @param mesh mesh to sync
  60477. * @param impostor impostor to update the mesh with
  60478. */
  60479. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60480. /**
  60481. * Gets the radius of the impostor
  60482. * @param impostor impostor to get radius from
  60483. * @returns the radius
  60484. */
  60485. getRadius(impostor: PhysicsImpostor): number;
  60486. /**
  60487. * Gets the box size of the impostor
  60488. * @param impostor impostor to get box size from
  60489. * @param result the resulting box size
  60490. */
  60491. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60492. /**
  60493. * Disposes of the impostor
  60494. */
  60495. dispose(): void;
  60496. /**
  60497. * Does a raycast in the physics world
  60498. * @param from when should the ray start?
  60499. * @param to when should the ray end?
  60500. * @returns PhysicsRaycastResult
  60501. */
  60502. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60503. }
  60504. }
  60505. declare module BABYLON {
  60506. interface AbstractScene {
  60507. /**
  60508. * The list of reflection probes added to the scene
  60509. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60510. */
  60511. reflectionProbes: Array<ReflectionProbe>;
  60512. /**
  60513. * Removes the given reflection probe from this scene.
  60514. * @param toRemove The reflection probe to remove
  60515. * @returns The index of the removed reflection probe
  60516. */
  60517. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60518. /**
  60519. * Adds the given reflection probe to this scene.
  60520. * @param newReflectionProbe The reflection probe to add
  60521. */
  60522. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60523. }
  60524. /**
  60525. * Class used to generate realtime reflection / refraction cube textures
  60526. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60527. */
  60528. export class ReflectionProbe {
  60529. /** defines the name of the probe */
  60530. name: string;
  60531. private _scene;
  60532. private _renderTargetTexture;
  60533. private _projectionMatrix;
  60534. private _viewMatrix;
  60535. private _target;
  60536. private _add;
  60537. private _attachedMesh;
  60538. private _invertYAxis;
  60539. /** Gets or sets probe position (center of the cube map) */
  60540. position: Vector3;
  60541. /**
  60542. * Creates a new reflection probe
  60543. * @param name defines the name of the probe
  60544. * @param size defines the texture resolution (for each face)
  60545. * @param scene defines the hosting scene
  60546. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60547. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60548. */
  60549. constructor(
  60550. /** defines the name of the probe */
  60551. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60552. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60553. get samples(): number;
  60554. set samples(value: number);
  60555. /** Gets or sets the refresh rate to use (on every frame by default) */
  60556. get refreshRate(): number;
  60557. set refreshRate(value: number);
  60558. /**
  60559. * Gets the hosting scene
  60560. * @returns a Scene
  60561. */
  60562. getScene(): Scene;
  60563. /** Gets the internal CubeTexture used to render to */
  60564. get cubeTexture(): RenderTargetTexture;
  60565. /** Gets the list of meshes to render */
  60566. get renderList(): Nullable<AbstractMesh[]>;
  60567. /**
  60568. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60569. * @param mesh defines the mesh to attach to
  60570. */
  60571. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60572. /**
  60573. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60574. * @param renderingGroupId The rendering group id corresponding to its index
  60575. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60576. */
  60577. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60578. /**
  60579. * Clean all associated resources
  60580. */
  60581. dispose(): void;
  60582. /**
  60583. * Converts the reflection probe information to a readable string for debug purpose.
  60584. * @param fullDetails Supports for multiple levels of logging within scene loading
  60585. * @returns the human readable reflection probe info
  60586. */
  60587. toString(fullDetails?: boolean): string;
  60588. /**
  60589. * Get the class name of the relfection probe.
  60590. * @returns "ReflectionProbe"
  60591. */
  60592. getClassName(): string;
  60593. /**
  60594. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60595. * @returns The JSON representation of the texture
  60596. */
  60597. serialize(): any;
  60598. /**
  60599. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60600. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60601. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60602. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60603. * @returns The parsed reflection probe if successful
  60604. */
  60605. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60606. }
  60607. }
  60608. declare module BABYLON {
  60609. /** @hidden */
  60610. export var _BabylonLoaderRegistered: boolean;
  60611. /**
  60612. * Helps setting up some configuration for the babylon file loader.
  60613. */
  60614. export class BabylonFileLoaderConfiguration {
  60615. /**
  60616. * The loader does not allow injecting custom physix engine into the plugins.
  60617. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60618. * So you could set this variable to your engine import to make it work.
  60619. */
  60620. static LoaderInjectedPhysicsEngine: any;
  60621. }
  60622. }
  60623. declare module BABYLON {
  60624. /**
  60625. * The Physically based simple base material of BJS.
  60626. *
  60627. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60628. * It is used as the base class for both the specGloss and metalRough conventions.
  60629. */
  60630. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60631. /**
  60632. * Number of Simultaneous lights allowed on the material.
  60633. */
  60634. maxSimultaneousLights: number;
  60635. /**
  60636. * If sets to true, disables all the lights affecting the material.
  60637. */
  60638. disableLighting: boolean;
  60639. /**
  60640. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60641. */
  60642. environmentTexture: BaseTexture;
  60643. /**
  60644. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60645. */
  60646. invertNormalMapX: boolean;
  60647. /**
  60648. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60649. */
  60650. invertNormalMapY: boolean;
  60651. /**
  60652. * Normal map used in the model.
  60653. */
  60654. normalTexture: BaseTexture;
  60655. /**
  60656. * Emissivie color used to self-illuminate the model.
  60657. */
  60658. emissiveColor: Color3;
  60659. /**
  60660. * Emissivie texture used to self-illuminate the model.
  60661. */
  60662. emissiveTexture: BaseTexture;
  60663. /**
  60664. * Occlusion Channel Strenght.
  60665. */
  60666. occlusionStrength: number;
  60667. /**
  60668. * Occlusion Texture of the material (adding extra occlusion effects).
  60669. */
  60670. occlusionTexture: BaseTexture;
  60671. /**
  60672. * Defines the alpha limits in alpha test mode.
  60673. */
  60674. alphaCutOff: number;
  60675. /**
  60676. * Gets the current double sided mode.
  60677. */
  60678. get doubleSided(): boolean;
  60679. /**
  60680. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60681. */
  60682. set doubleSided(value: boolean);
  60683. /**
  60684. * Stores the pre-calculated light information of a mesh in a texture.
  60685. */
  60686. lightmapTexture: BaseTexture;
  60687. /**
  60688. * If true, the light map contains occlusion information instead of lighting info.
  60689. */
  60690. useLightmapAsShadowmap: boolean;
  60691. /**
  60692. * Instantiates a new PBRMaterial instance.
  60693. *
  60694. * @param name The material name
  60695. * @param scene The scene the material will be use in.
  60696. */
  60697. constructor(name: string, scene: Scene);
  60698. getClassName(): string;
  60699. }
  60700. }
  60701. declare module BABYLON {
  60702. /**
  60703. * The PBR material of BJS following the metal roughness convention.
  60704. *
  60705. * This fits to the PBR convention in the GLTF definition:
  60706. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60707. */
  60708. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60709. /**
  60710. * The base color has two different interpretations depending on the value of metalness.
  60711. * When the material is a metal, the base color is the specific measured reflectance value
  60712. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60713. * of the material.
  60714. */
  60715. baseColor: Color3;
  60716. /**
  60717. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60718. * well as opacity information in the alpha channel.
  60719. */
  60720. baseTexture: BaseTexture;
  60721. /**
  60722. * Specifies the metallic scalar value of the material.
  60723. * Can also be used to scale the metalness values of the metallic texture.
  60724. */
  60725. metallic: number;
  60726. /**
  60727. * Specifies the roughness scalar value of the material.
  60728. * Can also be used to scale the roughness values of the metallic texture.
  60729. */
  60730. roughness: number;
  60731. /**
  60732. * Texture containing both the metallic value in the B channel and the
  60733. * roughness value in the G channel to keep better precision.
  60734. */
  60735. metallicRoughnessTexture: BaseTexture;
  60736. /**
  60737. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60738. *
  60739. * @param name The material name
  60740. * @param scene The scene the material will be use in.
  60741. */
  60742. constructor(name: string, scene: Scene);
  60743. /**
  60744. * Return the currrent class name of the material.
  60745. */
  60746. getClassName(): string;
  60747. /**
  60748. * Makes a duplicate of the current material.
  60749. * @param name - name to use for the new material.
  60750. */
  60751. clone(name: string): PBRMetallicRoughnessMaterial;
  60752. /**
  60753. * Serialize the material to a parsable JSON object.
  60754. */
  60755. serialize(): any;
  60756. /**
  60757. * Parses a JSON object correponding to the serialize function.
  60758. */
  60759. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60760. }
  60761. }
  60762. declare module BABYLON {
  60763. /**
  60764. * The PBR material of BJS following the specular glossiness convention.
  60765. *
  60766. * This fits to the PBR convention in the GLTF definition:
  60767. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60768. */
  60769. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60770. /**
  60771. * Specifies the diffuse color of the material.
  60772. */
  60773. diffuseColor: Color3;
  60774. /**
  60775. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60776. * channel.
  60777. */
  60778. diffuseTexture: BaseTexture;
  60779. /**
  60780. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60781. */
  60782. specularColor: Color3;
  60783. /**
  60784. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60785. */
  60786. glossiness: number;
  60787. /**
  60788. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60789. */
  60790. specularGlossinessTexture: BaseTexture;
  60791. /**
  60792. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60793. *
  60794. * @param name The material name
  60795. * @param scene The scene the material will be use in.
  60796. */
  60797. constructor(name: string, scene: Scene);
  60798. /**
  60799. * Return the currrent class name of the material.
  60800. */
  60801. getClassName(): string;
  60802. /**
  60803. * Makes a duplicate of the current material.
  60804. * @param name - name to use for the new material.
  60805. */
  60806. clone(name: string): PBRSpecularGlossinessMaterial;
  60807. /**
  60808. * Serialize the material to a parsable JSON object.
  60809. */
  60810. serialize(): any;
  60811. /**
  60812. * Parses a JSON object correponding to the serialize function.
  60813. */
  60814. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60820. * It can help converting any input color in a desired output one. This can then be used to create effects
  60821. * from sepia, black and white to sixties or futuristic rendering...
  60822. *
  60823. * The only supported format is currently 3dl.
  60824. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60825. */
  60826. export class ColorGradingTexture extends BaseTexture {
  60827. /**
  60828. * The texture URL.
  60829. */
  60830. url: string;
  60831. /**
  60832. * Empty line regex stored for GC.
  60833. */
  60834. private static _noneEmptyLineRegex;
  60835. private _textureMatrix;
  60836. private _onLoad;
  60837. /**
  60838. * Instantiates a ColorGradingTexture from the following parameters.
  60839. *
  60840. * @param url The location of the color gradind data (currently only supporting 3dl)
  60841. * @param sceneOrEngine The scene or engine the texture will be used in
  60842. * @param onLoad defines a callback triggered when the texture has been loaded
  60843. */
  60844. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60845. /**
  60846. * Fires the onload event from the constructor if requested.
  60847. */
  60848. private _triggerOnLoad;
  60849. /**
  60850. * Returns the texture matrix used in most of the material.
  60851. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60852. */
  60853. getTextureMatrix(): Matrix;
  60854. /**
  60855. * Occurs when the file being loaded is a .3dl LUT file.
  60856. */
  60857. private load3dlTexture;
  60858. /**
  60859. * Starts the loading process of the texture.
  60860. */
  60861. private loadTexture;
  60862. /**
  60863. * Clones the color gradind texture.
  60864. */
  60865. clone(): ColorGradingTexture;
  60866. /**
  60867. * Called during delayed load for textures.
  60868. */
  60869. delayLoad(): void;
  60870. /**
  60871. * Parses a color grading texture serialized by Babylon.
  60872. * @param parsedTexture The texture information being parsedTexture
  60873. * @param scene The scene to load the texture in
  60874. * @param rootUrl The root url of the data assets to load
  60875. * @return A color gradind texture
  60876. */
  60877. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60878. /**
  60879. * Serializes the LUT texture to json format.
  60880. */
  60881. serialize(): any;
  60882. }
  60883. }
  60884. declare module BABYLON {
  60885. /**
  60886. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60887. */
  60888. export class EquiRectangularCubeTexture extends BaseTexture {
  60889. /** The six faces of the cube. */
  60890. private static _FacesMapping;
  60891. private _noMipmap;
  60892. private _onLoad;
  60893. private _onError;
  60894. /** The size of the cubemap. */
  60895. private _size;
  60896. /** The buffer of the image. */
  60897. private _buffer;
  60898. /** The width of the input image. */
  60899. private _width;
  60900. /** The height of the input image. */
  60901. private _height;
  60902. /** The URL to the image. */
  60903. url: string;
  60904. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60905. coordinatesMode: number;
  60906. /**
  60907. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60908. * @param url The location of the image
  60909. * @param scene The scene the texture will be used in
  60910. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60911. * @param noMipmap Forces to not generate the mipmap if true
  60912. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60913. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60914. * @param onLoad — defines a callback called when texture is loaded
  60915. * @param onError — defines a callback called if there is an error
  60916. */
  60917. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60918. /**
  60919. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60920. */
  60921. private loadImage;
  60922. /**
  60923. * Convert the image buffer into a cubemap and create a CubeTexture.
  60924. */
  60925. private loadTexture;
  60926. /**
  60927. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60928. * @param buffer The ArrayBuffer that should be converted.
  60929. * @returns The buffer as Float32Array.
  60930. */
  60931. private getFloat32ArrayFromArrayBuffer;
  60932. /**
  60933. * Get the current class name of the texture useful for serialization or dynamic coding.
  60934. * @returns "EquiRectangularCubeTexture"
  60935. */
  60936. getClassName(): string;
  60937. /**
  60938. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60939. * @returns A clone of the current EquiRectangularCubeTexture.
  60940. */
  60941. clone(): EquiRectangularCubeTexture;
  60942. }
  60943. }
  60944. declare module BABYLON {
  60945. /**
  60946. * Defines the options related to the creation of an HtmlElementTexture
  60947. */
  60948. export interface IHtmlElementTextureOptions {
  60949. /**
  60950. * Defines wether mip maps should be created or not.
  60951. */
  60952. generateMipMaps?: boolean;
  60953. /**
  60954. * Defines the sampling mode of the texture.
  60955. */
  60956. samplingMode?: number;
  60957. /**
  60958. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60959. */
  60960. engine: Nullable<ThinEngine>;
  60961. /**
  60962. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60963. */
  60964. scene: Nullable<Scene>;
  60965. }
  60966. /**
  60967. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60968. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60969. * is automatically managed.
  60970. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60971. * in your application.
  60972. *
  60973. * As the update is not automatic, you need to call them manually.
  60974. */
  60975. export class HtmlElementTexture extends BaseTexture {
  60976. /**
  60977. * The texture URL.
  60978. */
  60979. element: HTMLVideoElement | HTMLCanvasElement;
  60980. private static readonly DefaultOptions;
  60981. private _textureMatrix;
  60982. private _isVideo;
  60983. private _generateMipMaps;
  60984. private _samplingMode;
  60985. /**
  60986. * Instantiates a HtmlElementTexture from the following parameters.
  60987. *
  60988. * @param name Defines the name of the texture
  60989. * @param element Defines the video or canvas the texture is filled with
  60990. * @param options Defines the other none mandatory texture creation options
  60991. */
  60992. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60993. private _createInternalTexture;
  60994. /**
  60995. * Returns the texture matrix used in most of the material.
  60996. */
  60997. getTextureMatrix(): Matrix;
  60998. /**
  60999. * Updates the content of the texture.
  61000. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61001. */
  61002. update(invertY?: Nullable<boolean>): void;
  61003. }
  61004. }
  61005. declare module BABYLON {
  61006. /**
  61007. * Based on jsTGALoader - Javascript loader for TGA file
  61008. * By Vincent Thibault
  61009. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61010. */
  61011. export class TGATools {
  61012. private static _TYPE_INDEXED;
  61013. private static _TYPE_RGB;
  61014. private static _TYPE_GREY;
  61015. private static _TYPE_RLE_INDEXED;
  61016. private static _TYPE_RLE_RGB;
  61017. private static _TYPE_RLE_GREY;
  61018. private static _ORIGIN_MASK;
  61019. private static _ORIGIN_SHIFT;
  61020. private static _ORIGIN_BL;
  61021. private static _ORIGIN_BR;
  61022. private static _ORIGIN_UL;
  61023. private static _ORIGIN_UR;
  61024. /**
  61025. * Gets the header of a TGA file
  61026. * @param data defines the TGA data
  61027. * @returns the header
  61028. */
  61029. static GetTGAHeader(data: Uint8Array): any;
  61030. /**
  61031. * Uploads TGA content to a Babylon Texture
  61032. * @hidden
  61033. */
  61034. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61035. /** @hidden */
  61036. 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;
  61037. /** @hidden */
  61038. 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;
  61039. /** @hidden */
  61040. 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;
  61041. /** @hidden */
  61042. 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;
  61043. /** @hidden */
  61044. 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;
  61045. /** @hidden */
  61046. 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;
  61047. }
  61048. }
  61049. declare module BABYLON {
  61050. /**
  61051. * Implementation of the TGA Texture Loader.
  61052. * @hidden
  61053. */
  61054. export class _TGATextureLoader implements IInternalTextureLoader {
  61055. /**
  61056. * Defines wether the loader supports cascade loading the different faces.
  61057. */
  61058. readonly supportCascades: boolean;
  61059. /**
  61060. * This returns if the loader support the current file information.
  61061. * @param extension defines the file extension of the file being loaded
  61062. * @returns true if the loader can load the specified file
  61063. */
  61064. canLoad(extension: string): boolean;
  61065. /**
  61066. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61067. * @param data contains the texture data
  61068. * @param texture defines the BabylonJS internal texture
  61069. * @param createPolynomials will be true if polynomials have been requested
  61070. * @param onLoad defines the callback to trigger once the texture is ready
  61071. * @param onError defines the callback to trigger in case of error
  61072. */
  61073. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61074. /**
  61075. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61076. * @param data contains the texture data
  61077. * @param texture defines the BabylonJS internal texture
  61078. * @param callback defines the method to call once ready to upload
  61079. */
  61080. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61081. }
  61082. }
  61083. declare module BABYLON {
  61084. /**
  61085. * Info about the .basis files
  61086. */
  61087. class BasisFileInfo {
  61088. /**
  61089. * If the file has alpha
  61090. */
  61091. hasAlpha: boolean;
  61092. /**
  61093. * Info about each image of the basis file
  61094. */
  61095. images: Array<{
  61096. levels: Array<{
  61097. width: number;
  61098. height: number;
  61099. transcodedPixels: ArrayBufferView;
  61100. }>;
  61101. }>;
  61102. }
  61103. /**
  61104. * Result of transcoding a basis file
  61105. */
  61106. class TranscodeResult {
  61107. /**
  61108. * Info about the .basis file
  61109. */
  61110. fileInfo: BasisFileInfo;
  61111. /**
  61112. * Format to use when loading the file
  61113. */
  61114. format: number;
  61115. }
  61116. /**
  61117. * Configuration options for the Basis transcoder
  61118. */
  61119. export class BasisTranscodeConfiguration {
  61120. /**
  61121. * Supported compression formats used to determine the supported output format of the transcoder
  61122. */
  61123. supportedCompressionFormats?: {
  61124. /**
  61125. * etc1 compression format
  61126. */
  61127. etc1?: boolean;
  61128. /**
  61129. * s3tc compression format
  61130. */
  61131. s3tc?: boolean;
  61132. /**
  61133. * pvrtc compression format
  61134. */
  61135. pvrtc?: boolean;
  61136. /**
  61137. * etc2 compression format
  61138. */
  61139. etc2?: boolean;
  61140. };
  61141. /**
  61142. * If mipmap levels should be loaded for transcoded images (Default: true)
  61143. */
  61144. loadMipmapLevels?: boolean;
  61145. /**
  61146. * Index of a single image to load (Default: all images)
  61147. */
  61148. loadSingleImage?: number;
  61149. }
  61150. /**
  61151. * Used to load .Basis files
  61152. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61153. */
  61154. export class BasisTools {
  61155. private static _IgnoreSupportedFormats;
  61156. /**
  61157. * URL to use when loading the basis transcoder
  61158. */
  61159. static JSModuleURL: string;
  61160. /**
  61161. * URL to use when loading the wasm module for the transcoder
  61162. */
  61163. static WasmModuleURL: string;
  61164. /**
  61165. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61166. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61167. * @returns internal format corresponding to the Basis format
  61168. */
  61169. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61170. private static _WorkerPromise;
  61171. private static _Worker;
  61172. private static _actionId;
  61173. private static _CreateWorkerAsync;
  61174. /**
  61175. * Transcodes a loaded image file to compressed pixel data
  61176. * @param data image data to transcode
  61177. * @param config configuration options for the transcoding
  61178. * @returns a promise resulting in the transcoded image
  61179. */
  61180. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61181. /**
  61182. * Loads a texture from the transcode result
  61183. * @param texture texture load to
  61184. * @param transcodeResult the result of transcoding the basis file to load from
  61185. */
  61186. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61187. }
  61188. }
  61189. declare module BABYLON {
  61190. /**
  61191. * Loader for .basis file format
  61192. */
  61193. export class _BasisTextureLoader implements IInternalTextureLoader {
  61194. /**
  61195. * Defines whether the loader supports cascade loading the different faces.
  61196. */
  61197. readonly supportCascades: boolean;
  61198. /**
  61199. * This returns if the loader support the current file information.
  61200. * @param extension defines the file extension of the file being loaded
  61201. * @returns true if the loader can load the specified file
  61202. */
  61203. canLoad(extension: string): boolean;
  61204. /**
  61205. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61206. * @param data contains the texture data
  61207. * @param texture defines the BabylonJS internal texture
  61208. * @param createPolynomials will be true if polynomials have been requested
  61209. * @param onLoad defines the callback to trigger once the texture is ready
  61210. * @param onError defines the callback to trigger in case of error
  61211. */
  61212. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61213. /**
  61214. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61215. * @param data contains the texture data
  61216. * @param texture defines the BabylonJS internal texture
  61217. * @param callback defines the method to call once ready to upload
  61218. */
  61219. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61220. }
  61221. }
  61222. declare module BABYLON {
  61223. /**
  61224. * Defines the basic options interface of a TexturePacker Frame
  61225. */
  61226. export interface ITexturePackerFrame {
  61227. /**
  61228. * The frame ID
  61229. */
  61230. id: number;
  61231. /**
  61232. * The frames Scale
  61233. */
  61234. scale: Vector2;
  61235. /**
  61236. * The Frames offset
  61237. */
  61238. offset: Vector2;
  61239. }
  61240. /**
  61241. * This is a support class for frame Data on texture packer sets.
  61242. */
  61243. export class TexturePackerFrame implements ITexturePackerFrame {
  61244. /**
  61245. * The frame ID
  61246. */
  61247. id: number;
  61248. /**
  61249. * The frames Scale
  61250. */
  61251. scale: Vector2;
  61252. /**
  61253. * The Frames offset
  61254. */
  61255. offset: Vector2;
  61256. /**
  61257. * Initializes a texture package frame.
  61258. * @param id The numerical frame identifier
  61259. * @param scale Scalar Vector2 for UV frame
  61260. * @param offset Vector2 for the frame position in UV units.
  61261. * @returns TexturePackerFrame
  61262. */
  61263. constructor(id: number, scale: Vector2, offset: Vector2);
  61264. }
  61265. }
  61266. declare module BABYLON {
  61267. /**
  61268. * Defines the basic options interface of a TexturePacker
  61269. */
  61270. export interface ITexturePackerOptions {
  61271. /**
  61272. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61273. */
  61274. map?: string[];
  61275. /**
  61276. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61277. */
  61278. uvsIn?: string;
  61279. /**
  61280. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61281. */
  61282. uvsOut?: string;
  61283. /**
  61284. * number representing the layout style. Defaults to LAYOUT_STRIP
  61285. */
  61286. layout?: number;
  61287. /**
  61288. * number of columns if using custom column count layout(2). This defaults to 4.
  61289. */
  61290. colnum?: number;
  61291. /**
  61292. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61293. */
  61294. updateInputMeshes?: boolean;
  61295. /**
  61296. * boolean flag to dispose all the source textures. Defaults to true.
  61297. */
  61298. disposeSources?: boolean;
  61299. /**
  61300. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61301. */
  61302. fillBlanks?: boolean;
  61303. /**
  61304. * string value representing the context fill style color. Defaults to 'black'.
  61305. */
  61306. customFillColor?: string;
  61307. /**
  61308. * Width and Height Value of each Frame in the TexturePacker Sets
  61309. */
  61310. frameSize?: number;
  61311. /**
  61312. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61313. */
  61314. paddingRatio?: number;
  61315. /**
  61316. * Number that declares the fill method for the padding gutter.
  61317. */
  61318. paddingMode?: number;
  61319. /**
  61320. * If in SUBUV_COLOR padding mode what color to use.
  61321. */
  61322. paddingColor?: Color3 | Color4;
  61323. }
  61324. /**
  61325. * Defines the basic interface of a TexturePacker JSON File
  61326. */
  61327. export interface ITexturePackerJSON {
  61328. /**
  61329. * The frame ID
  61330. */
  61331. name: string;
  61332. /**
  61333. * The base64 channel data
  61334. */
  61335. sets: any;
  61336. /**
  61337. * The options of the Packer
  61338. */
  61339. options: ITexturePackerOptions;
  61340. /**
  61341. * The frame data of the Packer
  61342. */
  61343. frames: Array<number>;
  61344. }
  61345. /**
  61346. * This is a support class that generates a series of packed texture sets.
  61347. * @see https://doc.babylonjs.com/babylon101/materials
  61348. */
  61349. export class TexturePacker {
  61350. /** Packer Layout Constant 0 */
  61351. static readonly LAYOUT_STRIP: number;
  61352. /** Packer Layout Constant 1 */
  61353. static readonly LAYOUT_POWER2: number;
  61354. /** Packer Layout Constant 2 */
  61355. static readonly LAYOUT_COLNUM: number;
  61356. /** Packer Layout Constant 0 */
  61357. static readonly SUBUV_WRAP: number;
  61358. /** Packer Layout Constant 1 */
  61359. static readonly SUBUV_EXTEND: number;
  61360. /** Packer Layout Constant 2 */
  61361. static readonly SUBUV_COLOR: number;
  61362. /** The Name of the Texture Package */
  61363. name: string;
  61364. /** The scene scope of the TexturePacker */
  61365. scene: Scene;
  61366. /** The Meshes to target */
  61367. meshes: AbstractMesh[];
  61368. /** Arguments passed with the Constructor */
  61369. options: ITexturePackerOptions;
  61370. /** The promise that is started upon initialization */
  61371. promise: Nullable<Promise<TexturePacker | string>>;
  61372. /** The Container object for the channel sets that are generated */
  61373. sets: object;
  61374. /** The Container array for the frames that are generated */
  61375. frames: TexturePackerFrame[];
  61376. /** The expected number of textures the system is parsing. */
  61377. private _expecting;
  61378. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61379. private _paddingValue;
  61380. /**
  61381. * Initializes a texture package series from an array of meshes or a single mesh.
  61382. * @param name The name of the package
  61383. * @param meshes The target meshes to compose the package from
  61384. * @param options The arguments that texture packer should follow while building.
  61385. * @param scene The scene which the textures are scoped to.
  61386. * @returns TexturePacker
  61387. */
  61388. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61389. /**
  61390. * Starts the package process
  61391. * @param resolve The promises resolution function
  61392. * @returns TexturePacker
  61393. */
  61394. private _createFrames;
  61395. /**
  61396. * Calculates the Size of the Channel Sets
  61397. * @returns Vector2
  61398. */
  61399. private _calculateSize;
  61400. /**
  61401. * Calculates the UV data for the frames.
  61402. * @param baseSize the base frameSize
  61403. * @param padding the base frame padding
  61404. * @param dtSize size of the Dynamic Texture for that channel
  61405. * @param dtUnits is 1/dtSize
  61406. * @param update flag to update the input meshes
  61407. */
  61408. private _calculateMeshUVFrames;
  61409. /**
  61410. * Calculates the frames Offset.
  61411. * @param index of the frame
  61412. * @returns Vector2
  61413. */
  61414. private _getFrameOffset;
  61415. /**
  61416. * Updates a Mesh to the frame data
  61417. * @param mesh that is the target
  61418. * @param frameID or the frame index
  61419. */
  61420. private _updateMeshUV;
  61421. /**
  61422. * Updates a Meshes materials to use the texture packer channels
  61423. * @param m is the mesh to target
  61424. * @param force all channels on the packer to be set.
  61425. */
  61426. private _updateTextureReferences;
  61427. /**
  61428. * Public method to set a Mesh to a frame
  61429. * @param m that is the target
  61430. * @param frameID or the frame index
  61431. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61432. */
  61433. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61434. /**
  61435. * Starts the async promise to compile the texture packer.
  61436. * @returns Promise<void>
  61437. */
  61438. processAsync(): Promise<void>;
  61439. /**
  61440. * Disposes all textures associated with this packer
  61441. */
  61442. dispose(): void;
  61443. /**
  61444. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61445. * @param imageType is the image type to use.
  61446. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61447. */
  61448. download(imageType?: string, quality?: number): void;
  61449. /**
  61450. * Public method to load a texturePacker JSON file.
  61451. * @param data of the JSON file in string format.
  61452. */
  61453. updateFromJSON(data: string): void;
  61454. }
  61455. }
  61456. declare module BABYLON {
  61457. /**
  61458. * 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.
  61459. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61460. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61461. */
  61462. export class CustomProceduralTexture extends ProceduralTexture {
  61463. private _animate;
  61464. private _time;
  61465. private _config;
  61466. private _texturePath;
  61467. /**
  61468. * Instantiates a new Custom Procedural Texture.
  61469. * 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.
  61470. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61471. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61472. * @param name Define the name of the texture
  61473. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61474. * @param size Define the size of the texture to create
  61475. * @param scene Define the scene the texture belongs to
  61476. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61477. * @param generateMipMaps Define if the texture should creates mip maps or not
  61478. */
  61479. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61480. private _loadJson;
  61481. /**
  61482. * Is the texture ready to be used ? (rendered at least once)
  61483. * @returns true if ready, otherwise, false.
  61484. */
  61485. isReady(): boolean;
  61486. /**
  61487. * Render the texture to its associated render target.
  61488. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61489. */
  61490. render(useCameraPostProcess?: boolean): void;
  61491. /**
  61492. * Update the list of dependant textures samplers in the shader.
  61493. */
  61494. updateTextures(): void;
  61495. /**
  61496. * Update the uniform values of the procedural texture in the shader.
  61497. */
  61498. updateShaderUniforms(): void;
  61499. /**
  61500. * Define if the texture animates or not.
  61501. */
  61502. get animate(): boolean;
  61503. set animate(value: boolean);
  61504. }
  61505. }
  61506. declare module BABYLON {
  61507. /** @hidden */
  61508. export var noisePixelShader: {
  61509. name: string;
  61510. shader: string;
  61511. };
  61512. }
  61513. declare module BABYLON {
  61514. /**
  61515. * Class used to generate noise procedural textures
  61516. */
  61517. export class NoiseProceduralTexture extends ProceduralTexture {
  61518. private _time;
  61519. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61520. brightness: number;
  61521. /** Defines the number of octaves to process */
  61522. octaves: number;
  61523. /** Defines the level of persistence (0.8 by default) */
  61524. persistence: number;
  61525. /** Gets or sets animation speed factor (default is 1) */
  61526. animationSpeedFactor: number;
  61527. /**
  61528. * Creates a new NoiseProceduralTexture
  61529. * @param name defines the name fo the texture
  61530. * @param size defines the size of the texture (default is 256)
  61531. * @param scene defines the hosting scene
  61532. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61533. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61534. */
  61535. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61536. private _updateShaderUniforms;
  61537. protected _getDefines(): string;
  61538. /** Generate the current state of the procedural texture */
  61539. render(useCameraPostProcess?: boolean): void;
  61540. /**
  61541. * Serializes this noise procedural texture
  61542. * @returns a serialized noise procedural texture object
  61543. */
  61544. serialize(): any;
  61545. /**
  61546. * Clone the texture.
  61547. * @returns the cloned texture
  61548. */
  61549. clone(): NoiseProceduralTexture;
  61550. /**
  61551. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61552. * @param parsedTexture defines parsed texture data
  61553. * @param scene defines the current scene
  61554. * @param rootUrl defines the root URL containing noise procedural texture information
  61555. * @returns a parsed NoiseProceduralTexture
  61556. */
  61557. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61558. }
  61559. }
  61560. declare module BABYLON {
  61561. /**
  61562. * Raw cube texture where the raw buffers are passed in
  61563. */
  61564. export class RawCubeTexture extends CubeTexture {
  61565. /**
  61566. * Creates a cube texture where the raw buffers are passed in.
  61567. * @param scene defines the scene the texture is attached to
  61568. * @param data defines the array of data to use to create each face
  61569. * @param size defines the size of the textures
  61570. * @param format defines the format of the data
  61571. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61572. * @param generateMipMaps defines if the engine should generate the mip levels
  61573. * @param invertY defines if data must be stored with Y axis inverted
  61574. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61575. * @param compression defines the compression used (null by default)
  61576. */
  61577. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61578. /**
  61579. * Updates the raw cube texture.
  61580. * @param data defines the data to store
  61581. * @param format defines the data format
  61582. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61583. * @param invertY defines if data must be stored with Y axis inverted
  61584. * @param compression defines the compression used (null by default)
  61585. * @param level defines which level of the texture to update
  61586. */
  61587. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61588. /**
  61589. * Updates a raw cube texture with RGBD encoded data.
  61590. * @param data defines the array of data [mipmap][face] to use to create each face
  61591. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61592. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61593. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61594. * @returns a promsie that resolves when the operation is complete
  61595. */
  61596. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61597. /**
  61598. * Clones the raw cube texture.
  61599. * @return a new cube texture
  61600. */
  61601. clone(): CubeTexture;
  61602. /** @hidden */
  61603. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61604. }
  61605. }
  61606. declare module BABYLON {
  61607. /**
  61608. * Class used to store 2D array textures containing user data
  61609. */
  61610. export class RawTexture2DArray extends Texture {
  61611. /** Gets or sets the texture format to use */
  61612. format: number;
  61613. /**
  61614. * Create a new RawTexture2DArray
  61615. * @param data defines the data of the texture
  61616. * @param width defines the width of the texture
  61617. * @param height defines the height of the texture
  61618. * @param depth defines the number of layers of the texture
  61619. * @param format defines the texture format to use
  61620. * @param scene defines the hosting scene
  61621. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61622. * @param invertY defines if texture must be stored with Y axis inverted
  61623. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61624. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61625. */
  61626. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61627. /** Gets or sets the texture format to use */
  61628. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61629. /**
  61630. * Update the texture with new data
  61631. * @param data defines the data to store in the texture
  61632. */
  61633. update(data: ArrayBufferView): void;
  61634. }
  61635. }
  61636. declare module BABYLON {
  61637. /**
  61638. * Class used to store 3D textures containing user data
  61639. */
  61640. export class RawTexture3D extends Texture {
  61641. /** Gets or sets the texture format to use */
  61642. format: number;
  61643. /**
  61644. * Create a new RawTexture3D
  61645. * @param data defines the data of the texture
  61646. * @param width defines the width of the texture
  61647. * @param height defines the height of the texture
  61648. * @param depth defines the depth of the texture
  61649. * @param format defines the texture format to use
  61650. * @param scene defines the hosting scene
  61651. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61652. * @param invertY defines if texture must be stored with Y axis inverted
  61653. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61654. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61655. */
  61656. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61657. /** Gets or sets the texture format to use */
  61658. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61659. /**
  61660. * Update the texture with new data
  61661. * @param data defines the data to store in the texture
  61662. */
  61663. update(data: ArrayBufferView): void;
  61664. }
  61665. }
  61666. declare module BABYLON {
  61667. /**
  61668. * Creates a refraction texture used by refraction channel of the standard material.
  61669. * It is like a mirror but to see through a material.
  61670. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61671. */
  61672. export class RefractionTexture extends RenderTargetTexture {
  61673. /**
  61674. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61675. * 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.
  61676. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61677. */
  61678. refractionPlane: Plane;
  61679. /**
  61680. * Define how deep under the surface we should see.
  61681. */
  61682. depth: number;
  61683. /**
  61684. * Creates a refraction texture used by refraction channel of the standard material.
  61685. * It is like a mirror but to see through a material.
  61686. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61687. * @param name Define the texture name
  61688. * @param size Define the size of the underlying texture
  61689. * @param scene Define the scene the refraction belongs to
  61690. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61691. */
  61692. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61693. /**
  61694. * Clone the refraction texture.
  61695. * @returns the cloned texture
  61696. */
  61697. clone(): RefractionTexture;
  61698. /**
  61699. * Serialize the texture to a JSON representation you could use in Parse later on
  61700. * @returns the serialized JSON representation
  61701. */
  61702. serialize(): any;
  61703. }
  61704. }
  61705. declare module BABYLON {
  61706. /**
  61707. * Block used to add support for vertex skinning (bones)
  61708. */
  61709. export class BonesBlock extends NodeMaterialBlock {
  61710. /**
  61711. * Creates a new BonesBlock
  61712. * @param name defines the block name
  61713. */
  61714. constructor(name: string);
  61715. /**
  61716. * Initialize the block and prepare the context for build
  61717. * @param state defines the state that will be used for the build
  61718. */
  61719. initialize(state: NodeMaterialBuildState): void;
  61720. /**
  61721. * Gets the current class name
  61722. * @returns the class name
  61723. */
  61724. getClassName(): string;
  61725. /**
  61726. * Gets the matrix indices input component
  61727. */
  61728. get matricesIndices(): NodeMaterialConnectionPoint;
  61729. /**
  61730. * Gets the matrix weights input component
  61731. */
  61732. get matricesWeights(): NodeMaterialConnectionPoint;
  61733. /**
  61734. * Gets the extra matrix indices input component
  61735. */
  61736. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61737. /**
  61738. * Gets the extra matrix weights input component
  61739. */
  61740. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61741. /**
  61742. * Gets the world input component
  61743. */
  61744. get world(): NodeMaterialConnectionPoint;
  61745. /**
  61746. * Gets the output component
  61747. */
  61748. get output(): NodeMaterialConnectionPoint;
  61749. autoConfigure(material: NodeMaterial): void;
  61750. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61751. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61753. protected _buildBlock(state: NodeMaterialBuildState): this;
  61754. }
  61755. }
  61756. declare module BABYLON {
  61757. /**
  61758. * Block used to add support for instances
  61759. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61760. */
  61761. export class InstancesBlock extends NodeMaterialBlock {
  61762. /**
  61763. * Creates a new InstancesBlock
  61764. * @param name defines the block name
  61765. */
  61766. constructor(name: string);
  61767. /**
  61768. * Gets the current class name
  61769. * @returns the class name
  61770. */
  61771. getClassName(): string;
  61772. /**
  61773. * Gets the first world row input component
  61774. */
  61775. get world0(): NodeMaterialConnectionPoint;
  61776. /**
  61777. * Gets the second world row input component
  61778. */
  61779. get world1(): NodeMaterialConnectionPoint;
  61780. /**
  61781. * Gets the third world row input component
  61782. */
  61783. get world2(): NodeMaterialConnectionPoint;
  61784. /**
  61785. * Gets the forth world row input component
  61786. */
  61787. get world3(): NodeMaterialConnectionPoint;
  61788. /**
  61789. * Gets the world input component
  61790. */
  61791. get world(): NodeMaterialConnectionPoint;
  61792. /**
  61793. * Gets the output component
  61794. */
  61795. get output(): NodeMaterialConnectionPoint;
  61796. /**
  61797. * Gets the isntanceID component
  61798. */
  61799. get instanceID(): NodeMaterialConnectionPoint;
  61800. autoConfigure(material: NodeMaterial): void;
  61801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61802. protected _buildBlock(state: NodeMaterialBuildState): this;
  61803. }
  61804. }
  61805. declare module BABYLON {
  61806. /**
  61807. * Block used to add morph targets support to vertex shader
  61808. */
  61809. export class MorphTargetsBlock extends NodeMaterialBlock {
  61810. private _repeatableContentAnchor;
  61811. /**
  61812. * Create a new MorphTargetsBlock
  61813. * @param name defines the block name
  61814. */
  61815. constructor(name: string);
  61816. /**
  61817. * Gets the current class name
  61818. * @returns the class name
  61819. */
  61820. getClassName(): string;
  61821. /**
  61822. * Gets the position input component
  61823. */
  61824. get position(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the normal input component
  61827. */
  61828. get normal(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the tangent input component
  61831. */
  61832. get tangent(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the tangent input component
  61835. */
  61836. get uv(): NodeMaterialConnectionPoint;
  61837. /**
  61838. * Gets the position output component
  61839. */
  61840. get positionOutput(): NodeMaterialConnectionPoint;
  61841. /**
  61842. * Gets the normal output component
  61843. */
  61844. get normalOutput(): NodeMaterialConnectionPoint;
  61845. /**
  61846. * Gets the tangent output component
  61847. */
  61848. get tangentOutput(): NodeMaterialConnectionPoint;
  61849. /**
  61850. * Gets the tangent output component
  61851. */
  61852. get uvOutput(): NodeMaterialConnectionPoint;
  61853. initialize(state: NodeMaterialBuildState): void;
  61854. autoConfigure(material: NodeMaterial): void;
  61855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61857. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61858. protected _buildBlock(state: NodeMaterialBuildState): this;
  61859. }
  61860. }
  61861. declare module BABYLON {
  61862. /**
  61863. * Block used to get data information from a light
  61864. */
  61865. export class LightInformationBlock extends NodeMaterialBlock {
  61866. private _lightDataUniformName;
  61867. private _lightColorUniformName;
  61868. private _lightTypeDefineName;
  61869. /**
  61870. * Gets or sets the light associated with this block
  61871. */
  61872. light: Nullable<Light>;
  61873. /**
  61874. * Creates a new LightInformationBlock
  61875. * @param name defines the block name
  61876. */
  61877. constructor(name: string);
  61878. /**
  61879. * Gets the current class name
  61880. * @returns the class name
  61881. */
  61882. getClassName(): string;
  61883. /**
  61884. * Gets the world position input component
  61885. */
  61886. get worldPosition(): NodeMaterialConnectionPoint;
  61887. /**
  61888. * Gets the direction output component
  61889. */
  61890. get direction(): NodeMaterialConnectionPoint;
  61891. /**
  61892. * Gets the direction output component
  61893. */
  61894. get color(): NodeMaterialConnectionPoint;
  61895. /**
  61896. * Gets the direction output component
  61897. */
  61898. get intensity(): NodeMaterialConnectionPoint;
  61899. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61900. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61901. protected _buildBlock(state: NodeMaterialBuildState): this;
  61902. serialize(): any;
  61903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61904. }
  61905. }
  61906. declare module BABYLON {
  61907. /**
  61908. * Block used to add image processing support to fragment shader
  61909. */
  61910. export class ImageProcessingBlock extends NodeMaterialBlock {
  61911. /**
  61912. * Create a new ImageProcessingBlock
  61913. * @param name defines the block name
  61914. */
  61915. constructor(name: string);
  61916. /**
  61917. * Gets the current class name
  61918. * @returns the class name
  61919. */
  61920. getClassName(): string;
  61921. /**
  61922. * Gets the color input component
  61923. */
  61924. get color(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the output component
  61927. */
  61928. get output(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Initialize the block and prepare the context for build
  61931. * @param state defines the state that will be used for the build
  61932. */
  61933. initialize(state: NodeMaterialBuildState): void;
  61934. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61937. protected _buildBlock(state: NodeMaterialBuildState): this;
  61938. }
  61939. }
  61940. declare module BABYLON {
  61941. /**
  61942. * Block used to pertub normals based on a normal map
  61943. */
  61944. export class PerturbNormalBlock extends NodeMaterialBlock {
  61945. private _tangentSpaceParameterName;
  61946. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61947. invertX: boolean;
  61948. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61949. invertY: boolean;
  61950. /**
  61951. * Create a new PerturbNormalBlock
  61952. * @param name defines the block name
  61953. */
  61954. constructor(name: string);
  61955. /**
  61956. * Gets the current class name
  61957. * @returns the class name
  61958. */
  61959. getClassName(): string;
  61960. /**
  61961. * Gets the world position input component
  61962. */
  61963. get worldPosition(): NodeMaterialConnectionPoint;
  61964. /**
  61965. * Gets the world normal input component
  61966. */
  61967. get worldNormal(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the world tangent input component
  61970. */
  61971. get worldTangent(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the uv input component
  61974. */
  61975. get uv(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the normal map color input component
  61978. */
  61979. get normalMapColor(): NodeMaterialConnectionPoint;
  61980. /**
  61981. * Gets the strength input component
  61982. */
  61983. get strength(): NodeMaterialConnectionPoint;
  61984. /**
  61985. * Gets the output component
  61986. */
  61987. get output(): NodeMaterialConnectionPoint;
  61988. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61989. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61990. autoConfigure(material: NodeMaterial): void;
  61991. protected _buildBlock(state: NodeMaterialBuildState): this;
  61992. protected _dumpPropertiesCode(): string;
  61993. serialize(): any;
  61994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61995. }
  61996. }
  61997. declare module BABYLON {
  61998. /**
  61999. * Block used to discard a pixel if a value is smaller than a cutoff
  62000. */
  62001. export class DiscardBlock extends NodeMaterialBlock {
  62002. /**
  62003. * Create a new DiscardBlock
  62004. * @param name defines the block name
  62005. */
  62006. constructor(name: string);
  62007. /**
  62008. * Gets the current class name
  62009. * @returns the class name
  62010. */
  62011. getClassName(): string;
  62012. /**
  62013. * Gets the color input component
  62014. */
  62015. get value(): NodeMaterialConnectionPoint;
  62016. /**
  62017. * Gets the cutoff input component
  62018. */
  62019. get cutoff(): NodeMaterialConnectionPoint;
  62020. protected _buildBlock(state: NodeMaterialBuildState): this;
  62021. }
  62022. }
  62023. declare module BABYLON {
  62024. /**
  62025. * Block used to test if the fragment shader is front facing
  62026. */
  62027. export class FrontFacingBlock extends NodeMaterialBlock {
  62028. /**
  62029. * Creates a new FrontFacingBlock
  62030. * @param name defines the block name
  62031. */
  62032. constructor(name: string);
  62033. /**
  62034. * Gets the current class name
  62035. * @returns the class name
  62036. */
  62037. getClassName(): string;
  62038. /**
  62039. * Gets the output component
  62040. */
  62041. get output(): NodeMaterialConnectionPoint;
  62042. protected _buildBlock(state: NodeMaterialBuildState): this;
  62043. }
  62044. }
  62045. declare module BABYLON {
  62046. /**
  62047. * Block used to get the derivative value on x and y of a given input
  62048. */
  62049. export class DerivativeBlock extends NodeMaterialBlock {
  62050. /**
  62051. * Create a new DerivativeBlock
  62052. * @param name defines the block name
  62053. */
  62054. constructor(name: string);
  62055. /**
  62056. * Gets the current class name
  62057. * @returns the class name
  62058. */
  62059. getClassName(): string;
  62060. /**
  62061. * Gets the input component
  62062. */
  62063. get input(): NodeMaterialConnectionPoint;
  62064. /**
  62065. * Gets the derivative output on x
  62066. */
  62067. get dx(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the derivative output on y
  62070. */
  62071. get dy(): NodeMaterialConnectionPoint;
  62072. protected _buildBlock(state: NodeMaterialBuildState): this;
  62073. }
  62074. }
  62075. declare module BABYLON {
  62076. /**
  62077. * Block used to make gl_FragCoord available
  62078. */
  62079. export class FragCoordBlock extends NodeMaterialBlock {
  62080. /**
  62081. * Creates a new FragCoordBlock
  62082. * @param name defines the block name
  62083. */
  62084. constructor(name: string);
  62085. /**
  62086. * Gets the current class name
  62087. * @returns the class name
  62088. */
  62089. getClassName(): string;
  62090. /**
  62091. * Gets the xy component
  62092. */
  62093. get xy(): NodeMaterialConnectionPoint;
  62094. /**
  62095. * Gets the xyz component
  62096. */
  62097. get xyz(): NodeMaterialConnectionPoint;
  62098. /**
  62099. * Gets the xyzw component
  62100. */
  62101. get xyzw(): NodeMaterialConnectionPoint;
  62102. /**
  62103. * Gets the x component
  62104. */
  62105. get x(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the y component
  62108. */
  62109. get y(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the z component
  62112. */
  62113. get z(): NodeMaterialConnectionPoint;
  62114. /**
  62115. * Gets the w component
  62116. */
  62117. get output(): NodeMaterialConnectionPoint;
  62118. protected writeOutputs(state: NodeMaterialBuildState): string;
  62119. protected _buildBlock(state: NodeMaterialBuildState): this;
  62120. }
  62121. }
  62122. declare module BABYLON {
  62123. /**
  62124. * Block used to get the screen sizes
  62125. */
  62126. export class ScreenSizeBlock extends NodeMaterialBlock {
  62127. private _varName;
  62128. private _scene;
  62129. /**
  62130. * Creates a new ScreenSizeBlock
  62131. * @param name defines the block name
  62132. */
  62133. constructor(name: string);
  62134. /**
  62135. * Gets the current class name
  62136. * @returns the class name
  62137. */
  62138. getClassName(): string;
  62139. /**
  62140. * Gets the xy component
  62141. */
  62142. get xy(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the x component
  62145. */
  62146. get x(): NodeMaterialConnectionPoint;
  62147. /**
  62148. * Gets the y component
  62149. */
  62150. get y(): NodeMaterialConnectionPoint;
  62151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62152. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62153. protected _buildBlock(state: NodeMaterialBuildState): this;
  62154. }
  62155. }
  62156. declare module BABYLON {
  62157. /**
  62158. * Block used to add support for scene fog
  62159. */
  62160. export class FogBlock extends NodeMaterialBlock {
  62161. private _fogDistanceName;
  62162. private _fogParameters;
  62163. /**
  62164. * Create a new FogBlock
  62165. * @param name defines the block name
  62166. */
  62167. constructor(name: string);
  62168. /**
  62169. * Gets the current class name
  62170. * @returns the class name
  62171. */
  62172. getClassName(): string;
  62173. /**
  62174. * Gets the world position input component
  62175. */
  62176. get worldPosition(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the view input component
  62179. */
  62180. get view(): NodeMaterialConnectionPoint;
  62181. /**
  62182. * Gets the color input component
  62183. */
  62184. get input(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the fog color input component
  62187. */
  62188. get fogColor(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the output component
  62191. */
  62192. get output(): NodeMaterialConnectionPoint;
  62193. autoConfigure(material: NodeMaterial): void;
  62194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62195. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62196. protected _buildBlock(state: NodeMaterialBuildState): this;
  62197. }
  62198. }
  62199. declare module BABYLON {
  62200. /**
  62201. * Block used to add light in the fragment shader
  62202. */
  62203. export class LightBlock extends NodeMaterialBlock {
  62204. private _lightId;
  62205. /**
  62206. * Gets or sets the light associated with this block
  62207. */
  62208. light: Nullable<Light>;
  62209. /**
  62210. * Create a new LightBlock
  62211. * @param name defines the block name
  62212. */
  62213. constructor(name: string);
  62214. /**
  62215. * Gets the current class name
  62216. * @returns the class name
  62217. */
  62218. getClassName(): string;
  62219. /**
  62220. * Gets the world position input component
  62221. */
  62222. get worldPosition(): NodeMaterialConnectionPoint;
  62223. /**
  62224. * Gets the world normal input component
  62225. */
  62226. get worldNormal(): NodeMaterialConnectionPoint;
  62227. /**
  62228. * Gets the camera (or eye) position component
  62229. */
  62230. get cameraPosition(): NodeMaterialConnectionPoint;
  62231. /**
  62232. * Gets the glossiness component
  62233. */
  62234. get glossiness(): NodeMaterialConnectionPoint;
  62235. /**
  62236. * Gets the glossinness power component
  62237. */
  62238. get glossPower(): NodeMaterialConnectionPoint;
  62239. /**
  62240. * Gets the diffuse color component
  62241. */
  62242. get diffuseColor(): NodeMaterialConnectionPoint;
  62243. /**
  62244. * Gets the specular color component
  62245. */
  62246. get specularColor(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the diffuse output component
  62249. */
  62250. get diffuseOutput(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the specular output component
  62253. */
  62254. get specularOutput(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the shadow output component
  62257. */
  62258. get shadow(): NodeMaterialConnectionPoint;
  62259. autoConfigure(material: NodeMaterial): void;
  62260. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62261. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62262. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62263. private _injectVertexCode;
  62264. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62265. serialize(): any;
  62266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62267. }
  62268. }
  62269. declare module BABYLON {
  62270. /**
  62271. * Block used to read a reflection texture from a sampler
  62272. */
  62273. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62274. /**
  62275. * Create a new ReflectionTextureBlock
  62276. * @param name defines the block name
  62277. */
  62278. constructor(name: string);
  62279. /**
  62280. * Gets the current class name
  62281. * @returns the class name
  62282. */
  62283. getClassName(): string;
  62284. /**
  62285. * Gets the world position input component
  62286. */
  62287. get position(): NodeMaterialConnectionPoint;
  62288. /**
  62289. * Gets the world position input component
  62290. */
  62291. get worldPosition(): NodeMaterialConnectionPoint;
  62292. /**
  62293. * Gets the world normal input component
  62294. */
  62295. get worldNormal(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the world input component
  62298. */
  62299. get world(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the camera (or eye) position component
  62302. */
  62303. get cameraPosition(): NodeMaterialConnectionPoint;
  62304. /**
  62305. * Gets the view input component
  62306. */
  62307. get view(): NodeMaterialConnectionPoint;
  62308. /**
  62309. * Gets the rgb output component
  62310. */
  62311. get rgb(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the rgba output component
  62314. */
  62315. get rgba(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the r output component
  62318. */
  62319. get r(): NodeMaterialConnectionPoint;
  62320. /**
  62321. * Gets the g output component
  62322. */
  62323. get g(): NodeMaterialConnectionPoint;
  62324. /**
  62325. * Gets the b output component
  62326. */
  62327. get b(): NodeMaterialConnectionPoint;
  62328. /**
  62329. * Gets the a output component
  62330. */
  62331. get a(): NodeMaterialConnectionPoint;
  62332. autoConfigure(material: NodeMaterial): void;
  62333. protected _buildBlock(state: NodeMaterialBuildState): this;
  62334. }
  62335. }
  62336. declare module BABYLON {
  62337. /**
  62338. * Block used to add 2 vectors
  62339. */
  62340. export class AddBlock extends NodeMaterialBlock {
  62341. /**
  62342. * Creates a new AddBlock
  62343. * @param name defines the block name
  62344. */
  62345. constructor(name: string);
  62346. /**
  62347. * Gets the current class name
  62348. * @returns the class name
  62349. */
  62350. getClassName(): string;
  62351. /**
  62352. * Gets the left operand input component
  62353. */
  62354. get left(): NodeMaterialConnectionPoint;
  62355. /**
  62356. * Gets the right operand input component
  62357. */
  62358. get right(): NodeMaterialConnectionPoint;
  62359. /**
  62360. * Gets the output component
  62361. */
  62362. get output(): NodeMaterialConnectionPoint;
  62363. protected _buildBlock(state: NodeMaterialBuildState): this;
  62364. }
  62365. }
  62366. declare module BABYLON {
  62367. /**
  62368. * Block used to scale a vector by a float
  62369. */
  62370. export class ScaleBlock extends NodeMaterialBlock {
  62371. /**
  62372. * Creates a new ScaleBlock
  62373. * @param name defines the block name
  62374. */
  62375. constructor(name: string);
  62376. /**
  62377. * Gets the current class name
  62378. * @returns the class name
  62379. */
  62380. getClassName(): string;
  62381. /**
  62382. * Gets the input component
  62383. */
  62384. get input(): NodeMaterialConnectionPoint;
  62385. /**
  62386. * Gets the factor input component
  62387. */
  62388. get factor(): NodeMaterialConnectionPoint;
  62389. /**
  62390. * Gets the output component
  62391. */
  62392. get output(): NodeMaterialConnectionPoint;
  62393. protected _buildBlock(state: NodeMaterialBuildState): this;
  62394. }
  62395. }
  62396. declare module BABYLON {
  62397. /**
  62398. * Block used to clamp a float
  62399. */
  62400. export class ClampBlock extends NodeMaterialBlock {
  62401. /** Gets or sets the minimum range */
  62402. minimum: number;
  62403. /** Gets or sets the maximum range */
  62404. maximum: number;
  62405. /**
  62406. * Creates a new ClampBlock
  62407. * @param name defines the block name
  62408. */
  62409. constructor(name: string);
  62410. /**
  62411. * Gets the current class name
  62412. * @returns the class name
  62413. */
  62414. getClassName(): string;
  62415. /**
  62416. * Gets the value input component
  62417. */
  62418. get value(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the output component
  62421. */
  62422. get output(): NodeMaterialConnectionPoint;
  62423. protected _buildBlock(state: NodeMaterialBuildState): this;
  62424. protected _dumpPropertiesCode(): string;
  62425. serialize(): any;
  62426. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62427. }
  62428. }
  62429. declare module BABYLON {
  62430. /**
  62431. * Block used to apply a cross product between 2 vectors
  62432. */
  62433. export class CrossBlock extends NodeMaterialBlock {
  62434. /**
  62435. * Creates a new CrossBlock
  62436. * @param name defines the block name
  62437. */
  62438. constructor(name: string);
  62439. /**
  62440. * Gets the current class name
  62441. * @returns the class name
  62442. */
  62443. getClassName(): string;
  62444. /**
  62445. * Gets the left operand input component
  62446. */
  62447. get left(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the right operand input component
  62450. */
  62451. get right(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the output component
  62454. */
  62455. get output(): NodeMaterialConnectionPoint;
  62456. protected _buildBlock(state: NodeMaterialBuildState): this;
  62457. }
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * Block used to apply a dot product between 2 vectors
  62462. */
  62463. export class DotBlock extends NodeMaterialBlock {
  62464. /**
  62465. * Creates a new DotBlock
  62466. * @param name defines the block name
  62467. */
  62468. constructor(name: string);
  62469. /**
  62470. * Gets the current class name
  62471. * @returns the class name
  62472. */
  62473. getClassName(): string;
  62474. /**
  62475. * Gets the left operand input component
  62476. */
  62477. get left(): NodeMaterialConnectionPoint;
  62478. /**
  62479. * Gets the right operand input component
  62480. */
  62481. get right(): NodeMaterialConnectionPoint;
  62482. /**
  62483. * Gets the output component
  62484. */
  62485. get output(): NodeMaterialConnectionPoint;
  62486. protected _buildBlock(state: NodeMaterialBuildState): this;
  62487. }
  62488. }
  62489. declare module BABYLON {
  62490. /**
  62491. * Block used to normalize a vector
  62492. */
  62493. export class NormalizeBlock extends NodeMaterialBlock {
  62494. /**
  62495. * Creates a new NormalizeBlock
  62496. * @param name defines the block name
  62497. */
  62498. constructor(name: string);
  62499. /**
  62500. * Gets the current class name
  62501. * @returns the class name
  62502. */
  62503. getClassName(): string;
  62504. /**
  62505. * Gets the input component
  62506. */
  62507. get input(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the output component
  62510. */
  62511. get output(): NodeMaterialConnectionPoint;
  62512. protected _buildBlock(state: NodeMaterialBuildState): this;
  62513. }
  62514. }
  62515. declare module BABYLON {
  62516. /**
  62517. * Operations supported by the Trigonometry block
  62518. */
  62519. export enum TrigonometryBlockOperations {
  62520. /** Cos */
  62521. Cos = 0,
  62522. /** Sin */
  62523. Sin = 1,
  62524. /** Abs */
  62525. Abs = 2,
  62526. /** Exp */
  62527. Exp = 3,
  62528. /** Exp2 */
  62529. Exp2 = 4,
  62530. /** Round */
  62531. Round = 5,
  62532. /** Floor */
  62533. Floor = 6,
  62534. /** Ceiling */
  62535. Ceiling = 7,
  62536. /** Square root */
  62537. Sqrt = 8,
  62538. /** Log */
  62539. Log = 9,
  62540. /** Tangent */
  62541. Tan = 10,
  62542. /** Arc tangent */
  62543. ArcTan = 11,
  62544. /** Arc cosinus */
  62545. ArcCos = 12,
  62546. /** Arc sinus */
  62547. ArcSin = 13,
  62548. /** Fraction */
  62549. Fract = 14,
  62550. /** Sign */
  62551. Sign = 15,
  62552. /** To radians (from degrees) */
  62553. Radians = 16,
  62554. /** To degrees (from radians) */
  62555. Degrees = 17
  62556. }
  62557. /**
  62558. * Block used to apply trigonometry operation to floats
  62559. */
  62560. export class TrigonometryBlock extends NodeMaterialBlock {
  62561. /**
  62562. * Gets or sets the operation applied by the block
  62563. */
  62564. operation: TrigonometryBlockOperations;
  62565. /**
  62566. * Creates a new TrigonometryBlock
  62567. * @param name defines the block name
  62568. */
  62569. constructor(name: string);
  62570. /**
  62571. * Gets the current class name
  62572. * @returns the class name
  62573. */
  62574. getClassName(): string;
  62575. /**
  62576. * Gets the input component
  62577. */
  62578. get input(): NodeMaterialConnectionPoint;
  62579. /**
  62580. * Gets the output component
  62581. */
  62582. get output(): NodeMaterialConnectionPoint;
  62583. protected _buildBlock(state: NodeMaterialBuildState): this;
  62584. serialize(): any;
  62585. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62586. protected _dumpPropertiesCode(): string;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /**
  62591. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62592. */
  62593. export class ColorMergerBlock extends NodeMaterialBlock {
  62594. /**
  62595. * Create a new ColorMergerBlock
  62596. * @param name defines the block name
  62597. */
  62598. constructor(name: string);
  62599. /**
  62600. * Gets the current class name
  62601. * @returns the class name
  62602. */
  62603. getClassName(): string;
  62604. /**
  62605. * Gets the rgb component (input)
  62606. */
  62607. get rgbIn(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the r component (input)
  62610. */
  62611. get r(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the g component (input)
  62614. */
  62615. get g(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the b component (input)
  62618. */
  62619. get b(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the a component (input)
  62622. */
  62623. get a(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the rgba component (output)
  62626. */
  62627. get rgba(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the rgb component (output)
  62630. */
  62631. get rgbOut(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the rgb component (output)
  62634. * @deprecated Please use rgbOut instead.
  62635. */
  62636. get rgb(): NodeMaterialConnectionPoint;
  62637. protected _buildBlock(state: NodeMaterialBuildState): this;
  62638. }
  62639. }
  62640. declare module BABYLON {
  62641. /**
  62642. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62643. */
  62644. export class VectorSplitterBlock extends NodeMaterialBlock {
  62645. /**
  62646. * Create a new VectorSplitterBlock
  62647. * @param name defines the block name
  62648. */
  62649. constructor(name: string);
  62650. /**
  62651. * Gets the current class name
  62652. * @returns the class name
  62653. */
  62654. getClassName(): string;
  62655. /**
  62656. * Gets the xyzw component (input)
  62657. */
  62658. get xyzw(): NodeMaterialConnectionPoint;
  62659. /**
  62660. * Gets the xyz component (input)
  62661. */
  62662. get xyzIn(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the xy component (input)
  62665. */
  62666. get xyIn(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the xyz component (output)
  62669. */
  62670. get xyzOut(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the xy component (output)
  62673. */
  62674. get xyOut(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the x component (output)
  62677. */
  62678. get x(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the y component (output)
  62681. */
  62682. get y(): NodeMaterialConnectionPoint;
  62683. /**
  62684. * Gets the z component (output)
  62685. */
  62686. get z(): NodeMaterialConnectionPoint;
  62687. /**
  62688. * Gets the w component (output)
  62689. */
  62690. get w(): NodeMaterialConnectionPoint;
  62691. protected _inputRename(name: string): string;
  62692. protected _outputRename(name: string): string;
  62693. protected _buildBlock(state: NodeMaterialBuildState): this;
  62694. }
  62695. }
  62696. declare module BABYLON {
  62697. /**
  62698. * Block used to lerp between 2 values
  62699. */
  62700. export class LerpBlock extends NodeMaterialBlock {
  62701. /**
  62702. * Creates a new LerpBlock
  62703. * @param name defines the block name
  62704. */
  62705. constructor(name: string);
  62706. /**
  62707. * Gets the current class name
  62708. * @returns the class name
  62709. */
  62710. getClassName(): string;
  62711. /**
  62712. * Gets the left operand input component
  62713. */
  62714. get left(): NodeMaterialConnectionPoint;
  62715. /**
  62716. * Gets the right operand input component
  62717. */
  62718. get right(): NodeMaterialConnectionPoint;
  62719. /**
  62720. * Gets the gradient operand input component
  62721. */
  62722. get gradient(): NodeMaterialConnectionPoint;
  62723. /**
  62724. * Gets the output component
  62725. */
  62726. get output(): NodeMaterialConnectionPoint;
  62727. protected _buildBlock(state: NodeMaterialBuildState): this;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * Block used to divide 2 vectors
  62733. */
  62734. export class DivideBlock extends NodeMaterialBlock {
  62735. /**
  62736. * Creates a new DivideBlock
  62737. * @param name defines the block name
  62738. */
  62739. constructor(name: string);
  62740. /**
  62741. * Gets the current class name
  62742. * @returns the class name
  62743. */
  62744. getClassName(): string;
  62745. /**
  62746. * Gets the left operand input component
  62747. */
  62748. get left(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the right operand input component
  62751. */
  62752. get right(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the output component
  62755. */
  62756. get output(): NodeMaterialConnectionPoint;
  62757. protected _buildBlock(state: NodeMaterialBuildState): this;
  62758. }
  62759. }
  62760. declare module BABYLON {
  62761. /**
  62762. * Block used to subtract 2 vectors
  62763. */
  62764. export class SubtractBlock extends NodeMaterialBlock {
  62765. /**
  62766. * Creates a new SubtractBlock
  62767. * @param name defines the block name
  62768. */
  62769. constructor(name: string);
  62770. /**
  62771. * Gets the current class name
  62772. * @returns the class name
  62773. */
  62774. getClassName(): string;
  62775. /**
  62776. * Gets the left operand input component
  62777. */
  62778. get left(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the right operand input component
  62781. */
  62782. get right(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. }
  62789. }
  62790. declare module BABYLON {
  62791. /**
  62792. * Block used to step a value
  62793. */
  62794. export class StepBlock extends NodeMaterialBlock {
  62795. /**
  62796. * Creates a new StepBlock
  62797. * @param name defines the block name
  62798. */
  62799. constructor(name: string);
  62800. /**
  62801. * Gets the current class name
  62802. * @returns the class name
  62803. */
  62804. getClassName(): string;
  62805. /**
  62806. * Gets the value operand input component
  62807. */
  62808. get value(): NodeMaterialConnectionPoint;
  62809. /**
  62810. * Gets the edge operand input component
  62811. */
  62812. get edge(): NodeMaterialConnectionPoint;
  62813. /**
  62814. * Gets the output component
  62815. */
  62816. get output(): NodeMaterialConnectionPoint;
  62817. protected _buildBlock(state: NodeMaterialBuildState): this;
  62818. }
  62819. }
  62820. declare module BABYLON {
  62821. /**
  62822. * Block used to get the opposite (1 - x) of a value
  62823. */
  62824. export class OneMinusBlock extends NodeMaterialBlock {
  62825. /**
  62826. * Creates a new OneMinusBlock
  62827. * @param name defines the block name
  62828. */
  62829. constructor(name: string);
  62830. /**
  62831. * Gets the current class name
  62832. * @returns the class name
  62833. */
  62834. getClassName(): string;
  62835. /**
  62836. * Gets the input component
  62837. */
  62838. get input(): NodeMaterialConnectionPoint;
  62839. /**
  62840. * Gets the output component
  62841. */
  62842. get output(): NodeMaterialConnectionPoint;
  62843. protected _buildBlock(state: NodeMaterialBuildState): this;
  62844. }
  62845. }
  62846. declare module BABYLON {
  62847. /**
  62848. * Block used to get the view direction
  62849. */
  62850. export class ViewDirectionBlock extends NodeMaterialBlock {
  62851. /**
  62852. * Creates a new ViewDirectionBlock
  62853. * @param name defines the block name
  62854. */
  62855. constructor(name: string);
  62856. /**
  62857. * Gets the current class name
  62858. * @returns the class name
  62859. */
  62860. getClassName(): string;
  62861. /**
  62862. * Gets the world position component
  62863. */
  62864. get worldPosition(): NodeMaterialConnectionPoint;
  62865. /**
  62866. * Gets the camera position component
  62867. */
  62868. get cameraPosition(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the output component
  62871. */
  62872. get output(): NodeMaterialConnectionPoint;
  62873. autoConfigure(material: NodeMaterial): void;
  62874. protected _buildBlock(state: NodeMaterialBuildState): this;
  62875. }
  62876. }
  62877. declare module BABYLON {
  62878. /**
  62879. * Block used to compute fresnel value
  62880. */
  62881. export class FresnelBlock extends NodeMaterialBlock {
  62882. /**
  62883. * Create a new FresnelBlock
  62884. * @param name defines the block name
  62885. */
  62886. constructor(name: string);
  62887. /**
  62888. * Gets the current class name
  62889. * @returns the class name
  62890. */
  62891. getClassName(): string;
  62892. /**
  62893. * Gets the world normal input component
  62894. */
  62895. get worldNormal(): NodeMaterialConnectionPoint;
  62896. /**
  62897. * Gets the view direction input component
  62898. */
  62899. get viewDirection(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the bias input component
  62902. */
  62903. get bias(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the camera (or eye) position component
  62906. */
  62907. get power(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the fresnel output component
  62910. */
  62911. get fresnel(): NodeMaterialConnectionPoint;
  62912. autoConfigure(material: NodeMaterial): void;
  62913. protected _buildBlock(state: NodeMaterialBuildState): this;
  62914. }
  62915. }
  62916. declare module BABYLON {
  62917. /**
  62918. * Block used to get the max of 2 values
  62919. */
  62920. export class MaxBlock extends NodeMaterialBlock {
  62921. /**
  62922. * Creates a new MaxBlock
  62923. * @param name defines the block name
  62924. */
  62925. constructor(name: string);
  62926. /**
  62927. * Gets the current class name
  62928. * @returns the class name
  62929. */
  62930. getClassName(): string;
  62931. /**
  62932. * Gets the left operand input component
  62933. */
  62934. get left(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the right operand input component
  62937. */
  62938. get right(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the output component
  62941. */
  62942. get output(): NodeMaterialConnectionPoint;
  62943. protected _buildBlock(state: NodeMaterialBuildState): this;
  62944. }
  62945. }
  62946. declare module BABYLON {
  62947. /**
  62948. * Block used to get the min of 2 values
  62949. */
  62950. export class MinBlock extends NodeMaterialBlock {
  62951. /**
  62952. * Creates a new MinBlock
  62953. * @param name defines the block name
  62954. */
  62955. constructor(name: string);
  62956. /**
  62957. * Gets the current class name
  62958. * @returns the class name
  62959. */
  62960. getClassName(): string;
  62961. /**
  62962. * Gets the left operand input component
  62963. */
  62964. get left(): NodeMaterialConnectionPoint;
  62965. /**
  62966. * Gets the right operand input component
  62967. */
  62968. get right(): NodeMaterialConnectionPoint;
  62969. /**
  62970. * Gets the output component
  62971. */
  62972. get output(): NodeMaterialConnectionPoint;
  62973. protected _buildBlock(state: NodeMaterialBuildState): this;
  62974. }
  62975. }
  62976. declare module BABYLON {
  62977. /**
  62978. * Block used to get the distance between 2 values
  62979. */
  62980. export class DistanceBlock extends NodeMaterialBlock {
  62981. /**
  62982. * Creates a new DistanceBlock
  62983. * @param name defines the block name
  62984. */
  62985. constructor(name: string);
  62986. /**
  62987. * Gets the current class name
  62988. * @returns the class name
  62989. */
  62990. getClassName(): string;
  62991. /**
  62992. * Gets the left operand input component
  62993. */
  62994. get left(): NodeMaterialConnectionPoint;
  62995. /**
  62996. * Gets the right operand input component
  62997. */
  62998. get right(): NodeMaterialConnectionPoint;
  62999. /**
  63000. * Gets the output component
  63001. */
  63002. get output(): NodeMaterialConnectionPoint;
  63003. protected _buildBlock(state: NodeMaterialBuildState): this;
  63004. }
  63005. }
  63006. declare module BABYLON {
  63007. /**
  63008. * Block used to get the length of a vector
  63009. */
  63010. export class LengthBlock extends NodeMaterialBlock {
  63011. /**
  63012. * Creates a new LengthBlock
  63013. * @param name defines the block name
  63014. */
  63015. constructor(name: string);
  63016. /**
  63017. * Gets the current class name
  63018. * @returns the class name
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Gets the value input component
  63023. */
  63024. get value(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the output component
  63027. */
  63028. get output(): NodeMaterialConnectionPoint;
  63029. protected _buildBlock(state: NodeMaterialBuildState): this;
  63030. }
  63031. }
  63032. declare module BABYLON {
  63033. /**
  63034. * Block used to get negative version of a value (i.e. x * -1)
  63035. */
  63036. export class NegateBlock extends NodeMaterialBlock {
  63037. /**
  63038. * Creates a new NegateBlock
  63039. * @param name defines the block name
  63040. */
  63041. constructor(name: string);
  63042. /**
  63043. * Gets the current class name
  63044. * @returns the class name
  63045. */
  63046. getClassName(): string;
  63047. /**
  63048. * Gets the value input component
  63049. */
  63050. get value(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the output component
  63053. */
  63054. get output(): NodeMaterialConnectionPoint;
  63055. protected _buildBlock(state: NodeMaterialBuildState): this;
  63056. }
  63057. }
  63058. declare module BABYLON {
  63059. /**
  63060. * Block used to get the value of the first parameter raised to the power of the second
  63061. */
  63062. export class PowBlock extends NodeMaterialBlock {
  63063. /**
  63064. * Creates a new PowBlock
  63065. * @param name defines the block name
  63066. */
  63067. constructor(name: string);
  63068. /**
  63069. * Gets the current class name
  63070. * @returns the class name
  63071. */
  63072. getClassName(): string;
  63073. /**
  63074. * Gets the value operand input component
  63075. */
  63076. get value(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the power operand input component
  63079. */
  63080. get power(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the output component
  63083. */
  63084. get output(): NodeMaterialConnectionPoint;
  63085. protected _buildBlock(state: NodeMaterialBuildState): this;
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. /**
  63090. * Block used to get a random number
  63091. */
  63092. export class RandomNumberBlock extends NodeMaterialBlock {
  63093. /**
  63094. * Creates a new RandomNumberBlock
  63095. * @param name defines the block name
  63096. */
  63097. constructor(name: string);
  63098. /**
  63099. * Gets the current class name
  63100. * @returns the class name
  63101. */
  63102. getClassName(): string;
  63103. /**
  63104. * Gets the seed input component
  63105. */
  63106. get seed(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the output component
  63109. */
  63110. get output(): NodeMaterialConnectionPoint;
  63111. protected _buildBlock(state: NodeMaterialBuildState): this;
  63112. }
  63113. }
  63114. declare module BABYLON {
  63115. /**
  63116. * Block used to compute arc tangent of 2 values
  63117. */
  63118. export class ArcTan2Block extends NodeMaterialBlock {
  63119. /**
  63120. * Creates a new ArcTan2Block
  63121. * @param name defines the block name
  63122. */
  63123. constructor(name: string);
  63124. /**
  63125. * Gets the current class name
  63126. * @returns the class name
  63127. */
  63128. getClassName(): string;
  63129. /**
  63130. * Gets the x operand input component
  63131. */
  63132. get x(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the y operand input component
  63135. */
  63136. get y(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the output component
  63139. */
  63140. get output(): NodeMaterialConnectionPoint;
  63141. protected _buildBlock(state: NodeMaterialBuildState): this;
  63142. }
  63143. }
  63144. declare module BABYLON {
  63145. /**
  63146. * Block used to smooth step a value
  63147. */
  63148. export class SmoothStepBlock extends NodeMaterialBlock {
  63149. /**
  63150. * Creates a new SmoothStepBlock
  63151. * @param name defines the block name
  63152. */
  63153. constructor(name: string);
  63154. /**
  63155. * Gets the current class name
  63156. * @returns the class name
  63157. */
  63158. getClassName(): string;
  63159. /**
  63160. * Gets the value operand input component
  63161. */
  63162. get value(): NodeMaterialConnectionPoint;
  63163. /**
  63164. * Gets the first edge operand input component
  63165. */
  63166. get edge0(): NodeMaterialConnectionPoint;
  63167. /**
  63168. * Gets the second edge operand input component
  63169. */
  63170. get edge1(): NodeMaterialConnectionPoint;
  63171. /**
  63172. * Gets the output component
  63173. */
  63174. get output(): NodeMaterialConnectionPoint;
  63175. protected _buildBlock(state: NodeMaterialBuildState): this;
  63176. }
  63177. }
  63178. declare module BABYLON {
  63179. /**
  63180. * Block used to get the reciprocal (1 / x) of a value
  63181. */
  63182. export class ReciprocalBlock extends NodeMaterialBlock {
  63183. /**
  63184. * Creates a new ReciprocalBlock
  63185. * @param name defines the block name
  63186. */
  63187. constructor(name: string);
  63188. /**
  63189. * Gets the current class name
  63190. * @returns the class name
  63191. */
  63192. getClassName(): string;
  63193. /**
  63194. * Gets the input component
  63195. */
  63196. get input(): NodeMaterialConnectionPoint;
  63197. /**
  63198. * Gets the output component
  63199. */
  63200. get output(): NodeMaterialConnectionPoint;
  63201. protected _buildBlock(state: NodeMaterialBuildState): this;
  63202. }
  63203. }
  63204. declare module BABYLON {
  63205. /**
  63206. * Block used to replace a color by another one
  63207. */
  63208. export class ReplaceColorBlock extends NodeMaterialBlock {
  63209. /**
  63210. * Creates a new ReplaceColorBlock
  63211. * @param name defines the block name
  63212. */
  63213. constructor(name: string);
  63214. /**
  63215. * Gets the current class name
  63216. * @returns the class name
  63217. */
  63218. getClassName(): string;
  63219. /**
  63220. * Gets the value input component
  63221. */
  63222. get value(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the reference input component
  63225. */
  63226. get reference(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the distance input component
  63229. */
  63230. get distance(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the replacement input component
  63233. */
  63234. get replacement(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the output component
  63237. */
  63238. get output(): NodeMaterialConnectionPoint;
  63239. protected _buildBlock(state: NodeMaterialBuildState): this;
  63240. }
  63241. }
  63242. declare module BABYLON {
  63243. /**
  63244. * Block used to posterize a value
  63245. * @see https://en.wikipedia.org/wiki/Posterization
  63246. */
  63247. export class PosterizeBlock extends NodeMaterialBlock {
  63248. /**
  63249. * Creates a new PosterizeBlock
  63250. * @param name defines the block name
  63251. */
  63252. constructor(name: string);
  63253. /**
  63254. * Gets the current class name
  63255. * @returns the class name
  63256. */
  63257. getClassName(): string;
  63258. /**
  63259. * Gets the value input component
  63260. */
  63261. get value(): NodeMaterialConnectionPoint;
  63262. /**
  63263. * Gets the steps input component
  63264. */
  63265. get steps(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the output component
  63268. */
  63269. get output(): NodeMaterialConnectionPoint;
  63270. protected _buildBlock(state: NodeMaterialBuildState): this;
  63271. }
  63272. }
  63273. declare module BABYLON {
  63274. /**
  63275. * Operations supported by the Wave block
  63276. */
  63277. export enum WaveBlockKind {
  63278. /** SawTooth */
  63279. SawTooth = 0,
  63280. /** Square */
  63281. Square = 1,
  63282. /** Triangle */
  63283. Triangle = 2
  63284. }
  63285. /**
  63286. * Block used to apply wave operation to floats
  63287. */
  63288. export class WaveBlock extends NodeMaterialBlock {
  63289. /**
  63290. * Gets or sets the kibnd of wave to be applied by the block
  63291. */
  63292. kind: WaveBlockKind;
  63293. /**
  63294. * Creates a new WaveBlock
  63295. * @param name defines the block name
  63296. */
  63297. constructor(name: string);
  63298. /**
  63299. * Gets the current class name
  63300. * @returns the class name
  63301. */
  63302. getClassName(): string;
  63303. /**
  63304. * Gets the input component
  63305. */
  63306. get input(): NodeMaterialConnectionPoint;
  63307. /**
  63308. * Gets the output component
  63309. */
  63310. get output(): NodeMaterialConnectionPoint;
  63311. protected _buildBlock(state: NodeMaterialBuildState): this;
  63312. serialize(): any;
  63313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63314. }
  63315. }
  63316. declare module BABYLON {
  63317. /**
  63318. * Class used to store a color step for the GradientBlock
  63319. */
  63320. export class GradientBlockColorStep {
  63321. /**
  63322. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63323. */
  63324. step: number;
  63325. /**
  63326. * Gets or sets the color associated with this step
  63327. */
  63328. color: Color3;
  63329. /**
  63330. * Creates a new GradientBlockColorStep
  63331. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63332. * @param color defines the color associated with this step
  63333. */
  63334. constructor(
  63335. /**
  63336. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63337. */
  63338. step: number,
  63339. /**
  63340. * Gets or sets the color associated with this step
  63341. */
  63342. color: Color3);
  63343. }
  63344. /**
  63345. * Block used to return a color from a gradient based on an input value between 0 and 1
  63346. */
  63347. export class GradientBlock extends NodeMaterialBlock {
  63348. /**
  63349. * Gets or sets the list of color steps
  63350. */
  63351. colorSteps: GradientBlockColorStep[];
  63352. /**
  63353. * Creates a new GradientBlock
  63354. * @param name defines the block name
  63355. */
  63356. constructor(name: string);
  63357. /**
  63358. * Gets the current class name
  63359. * @returns the class name
  63360. */
  63361. getClassName(): string;
  63362. /**
  63363. * Gets the gradient input component
  63364. */
  63365. get gradient(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the output component
  63368. */
  63369. get output(): NodeMaterialConnectionPoint;
  63370. private _writeColorConstant;
  63371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63372. serialize(): any;
  63373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63374. protected _dumpPropertiesCode(): string;
  63375. }
  63376. }
  63377. declare module BABYLON {
  63378. /**
  63379. * Block used to normalize lerp between 2 values
  63380. */
  63381. export class NLerpBlock extends NodeMaterialBlock {
  63382. /**
  63383. * Creates a new NLerpBlock
  63384. * @param name defines the block name
  63385. */
  63386. constructor(name: string);
  63387. /**
  63388. * Gets the current class name
  63389. * @returns the class name
  63390. */
  63391. getClassName(): string;
  63392. /**
  63393. * Gets the left operand input component
  63394. */
  63395. get left(): NodeMaterialConnectionPoint;
  63396. /**
  63397. * Gets the right operand input component
  63398. */
  63399. get right(): NodeMaterialConnectionPoint;
  63400. /**
  63401. * Gets the gradient operand input component
  63402. */
  63403. get gradient(): NodeMaterialConnectionPoint;
  63404. /**
  63405. * Gets the output component
  63406. */
  63407. get output(): NodeMaterialConnectionPoint;
  63408. protected _buildBlock(state: NodeMaterialBuildState): this;
  63409. }
  63410. }
  63411. declare module BABYLON {
  63412. /**
  63413. * block used to Generate a Worley Noise 3D Noise Pattern
  63414. */
  63415. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63416. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63417. manhattanDistance: boolean;
  63418. /**
  63419. * Creates a new WorleyNoise3DBlock
  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 seed input component
  63430. */
  63431. get seed(): NodeMaterialConnectionPoint;
  63432. /**
  63433. * Gets the jitter input component
  63434. */
  63435. get jitter(): NodeMaterialConnectionPoint;
  63436. /**
  63437. * Gets the output component
  63438. */
  63439. get output(): NodeMaterialConnectionPoint;
  63440. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63441. /**
  63442. * Exposes the properties to the UI?
  63443. */
  63444. protected _dumpPropertiesCode(): string;
  63445. /**
  63446. * Exposes the properties to the Seralize?
  63447. */
  63448. serialize(): any;
  63449. /**
  63450. * Exposes the properties to the deseralize?
  63451. */
  63452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63453. }
  63454. }
  63455. declare module BABYLON {
  63456. /**
  63457. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63458. */
  63459. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63460. /**
  63461. * Creates a new SimplexPerlin3DBlock
  63462. * @param name defines the block name
  63463. */
  63464. constructor(name: string);
  63465. /**
  63466. * Gets the current class name
  63467. * @returns the class name
  63468. */
  63469. getClassName(): string;
  63470. /**
  63471. * Gets the seed operand input component
  63472. */
  63473. get seed(): NodeMaterialConnectionPoint;
  63474. /**
  63475. * Gets the output component
  63476. */
  63477. get output(): NodeMaterialConnectionPoint;
  63478. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63479. }
  63480. }
  63481. declare module BABYLON {
  63482. /**
  63483. * Block used to blend normals
  63484. */
  63485. export class NormalBlendBlock extends NodeMaterialBlock {
  63486. /**
  63487. * Creates a new NormalBlendBlock
  63488. * @param name defines the block name
  63489. */
  63490. constructor(name: string);
  63491. /**
  63492. * Gets the current class name
  63493. * @returns the class name
  63494. */
  63495. getClassName(): string;
  63496. /**
  63497. * Gets the first input component
  63498. */
  63499. get normalMap0(): NodeMaterialConnectionPoint;
  63500. /**
  63501. * Gets the second input component
  63502. */
  63503. get normalMap1(): NodeMaterialConnectionPoint;
  63504. /**
  63505. * Gets the output component
  63506. */
  63507. get output(): NodeMaterialConnectionPoint;
  63508. protected _buildBlock(state: NodeMaterialBuildState): this;
  63509. }
  63510. }
  63511. declare module BABYLON {
  63512. /**
  63513. * Block used to rotate a 2d vector by a given angle
  63514. */
  63515. export class Rotate2dBlock extends NodeMaterialBlock {
  63516. /**
  63517. * Creates a new Rotate2dBlock
  63518. * @param name defines the block name
  63519. */
  63520. constructor(name: string);
  63521. /**
  63522. * Gets the current class name
  63523. * @returns the class name
  63524. */
  63525. getClassName(): string;
  63526. /**
  63527. * Gets the input vector
  63528. */
  63529. get input(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the input angle
  63532. */
  63533. get angle(): NodeMaterialConnectionPoint;
  63534. /**
  63535. * Gets the output component
  63536. */
  63537. get output(): NodeMaterialConnectionPoint;
  63538. autoConfigure(material: NodeMaterial): void;
  63539. protected _buildBlock(state: NodeMaterialBuildState): this;
  63540. }
  63541. }
  63542. declare module BABYLON {
  63543. /**
  63544. * Block used to get the reflected vector from a direction and a normal
  63545. */
  63546. export class ReflectBlock extends NodeMaterialBlock {
  63547. /**
  63548. * Creates a new ReflectBlock
  63549. * @param name defines the block name
  63550. */
  63551. constructor(name: string);
  63552. /**
  63553. * Gets the current class name
  63554. * @returns the class name
  63555. */
  63556. getClassName(): string;
  63557. /**
  63558. * Gets the incident component
  63559. */
  63560. get incident(): NodeMaterialConnectionPoint;
  63561. /**
  63562. * Gets the normal component
  63563. */
  63564. get normal(): NodeMaterialConnectionPoint;
  63565. /**
  63566. * Gets the output component
  63567. */
  63568. get output(): NodeMaterialConnectionPoint;
  63569. protected _buildBlock(state: NodeMaterialBuildState): this;
  63570. }
  63571. }
  63572. declare module BABYLON {
  63573. /**
  63574. * Block used to get the refracted vector from a direction and a normal
  63575. */
  63576. export class RefractBlock extends NodeMaterialBlock {
  63577. /**
  63578. * Creates a new RefractBlock
  63579. * @param name defines the block name
  63580. */
  63581. constructor(name: string);
  63582. /**
  63583. * Gets the current class name
  63584. * @returns the class name
  63585. */
  63586. getClassName(): string;
  63587. /**
  63588. * Gets the incident component
  63589. */
  63590. get incident(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the normal component
  63593. */
  63594. get normal(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the index of refraction component
  63597. */
  63598. get ior(): NodeMaterialConnectionPoint;
  63599. /**
  63600. * Gets the output component
  63601. */
  63602. get output(): NodeMaterialConnectionPoint;
  63603. protected _buildBlock(state: NodeMaterialBuildState): this;
  63604. }
  63605. }
  63606. declare module BABYLON {
  63607. /**
  63608. * Block used to desaturate a color
  63609. */
  63610. export class DesaturateBlock extends NodeMaterialBlock {
  63611. /**
  63612. * Creates a new DesaturateBlock
  63613. * @param name defines the block name
  63614. */
  63615. constructor(name: string);
  63616. /**
  63617. * Gets the current class name
  63618. * @returns the class name
  63619. */
  63620. getClassName(): string;
  63621. /**
  63622. * Gets the color operand input component
  63623. */
  63624. get color(): NodeMaterialConnectionPoint;
  63625. /**
  63626. * Gets the level operand input component
  63627. */
  63628. get level(): NodeMaterialConnectionPoint;
  63629. /**
  63630. * Gets the output component
  63631. */
  63632. get output(): NodeMaterialConnectionPoint;
  63633. protected _buildBlock(state: NodeMaterialBuildState): this;
  63634. }
  63635. }
  63636. declare module BABYLON {
  63637. /**
  63638. * Block used to implement the ambient occlusion module of the PBR material
  63639. */
  63640. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63641. /**
  63642. * Create a new AmbientOcclusionBlock
  63643. * @param name defines the block name
  63644. */
  63645. constructor(name: string);
  63646. /**
  63647. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63648. */
  63649. useAmbientInGrayScale: boolean;
  63650. /**
  63651. * Initialize the block and prepare the context for build
  63652. * @param state defines the state that will be used for the build
  63653. */
  63654. initialize(state: NodeMaterialBuildState): void;
  63655. /**
  63656. * Gets the current class name
  63657. * @returns the class name
  63658. */
  63659. getClassName(): string;
  63660. /**
  63661. * Gets the texture input component
  63662. */
  63663. get texture(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the texture intensity component
  63666. */
  63667. get intensity(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the direct light intensity input component
  63670. */
  63671. get directLightIntensity(): NodeMaterialConnectionPoint;
  63672. /**
  63673. * Gets the ambient occlusion object output component
  63674. */
  63675. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the main code of the block (fragment side)
  63678. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63679. * @returns the shader code
  63680. */
  63681. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63682. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63683. protected _buildBlock(state: NodeMaterialBuildState): this;
  63684. protected _dumpPropertiesCode(): string;
  63685. serialize(): any;
  63686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63687. }
  63688. }
  63689. declare module BABYLON {
  63690. /**
  63691. * Block used to implement the reflection module of the PBR material
  63692. */
  63693. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63694. /** @hidden */
  63695. _defineLODReflectionAlpha: string;
  63696. /** @hidden */
  63697. _defineLinearSpecularReflection: string;
  63698. private _vEnvironmentIrradianceName;
  63699. /** @hidden */
  63700. _vReflectionMicrosurfaceInfosName: string;
  63701. /** @hidden */
  63702. _vReflectionInfosName: string;
  63703. /** @hidden */
  63704. _vReflectionFilteringInfoName: string;
  63705. private _scene;
  63706. /**
  63707. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63708. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63709. * It's less burden on the user side in the editor part.
  63710. */
  63711. /** @hidden */
  63712. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63713. /** @hidden */
  63714. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63715. /** @hidden */
  63716. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63717. /**
  63718. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63719. * diffuse part of the IBL.
  63720. */
  63721. useSphericalHarmonics: boolean;
  63722. /**
  63723. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63724. */
  63725. forceIrradianceInFragment: boolean;
  63726. /**
  63727. * Create a new ReflectionBlock
  63728. * @param name defines the block name
  63729. */
  63730. constructor(name: string);
  63731. /**
  63732. * Gets the current class name
  63733. * @returns the class name
  63734. */
  63735. getClassName(): string;
  63736. /**
  63737. * Gets the position input component
  63738. */
  63739. get position(): NodeMaterialConnectionPoint;
  63740. /**
  63741. * Gets the world position input component
  63742. */
  63743. get worldPosition(): NodeMaterialConnectionPoint;
  63744. /**
  63745. * Gets the world normal input component
  63746. */
  63747. get worldNormal(): NodeMaterialConnectionPoint;
  63748. /**
  63749. * Gets the world input component
  63750. */
  63751. get world(): NodeMaterialConnectionPoint;
  63752. /**
  63753. * Gets the camera (or eye) position component
  63754. */
  63755. get cameraPosition(): NodeMaterialConnectionPoint;
  63756. /**
  63757. * Gets the view input component
  63758. */
  63759. get view(): NodeMaterialConnectionPoint;
  63760. /**
  63761. * Gets the color input component
  63762. */
  63763. get color(): NodeMaterialConnectionPoint;
  63764. /**
  63765. * Gets the reflection object output component
  63766. */
  63767. get reflection(): NodeMaterialConnectionPoint;
  63768. /**
  63769. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63770. */
  63771. get hasTexture(): boolean;
  63772. /**
  63773. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63774. */
  63775. get reflectionColor(): string;
  63776. protected _getTexture(): Nullable<BaseTexture>;
  63777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63779. /**
  63780. * Gets the code to inject in the vertex shader
  63781. * @param state current state of the node material building
  63782. * @returns the shader code
  63783. */
  63784. handleVertexSide(state: NodeMaterialBuildState): string;
  63785. /**
  63786. * Gets the main code of the block (fragment side)
  63787. * @param state current state of the node material building
  63788. * @param normalVarName name of the existing variable corresponding to the normal
  63789. * @returns the shader code
  63790. */
  63791. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63792. protected _buildBlock(state: NodeMaterialBuildState): this;
  63793. protected _dumpPropertiesCode(): string;
  63794. serialize(): any;
  63795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63796. }
  63797. }
  63798. declare module BABYLON {
  63799. /**
  63800. * Block used to implement the sheen module of the PBR material
  63801. */
  63802. export class SheenBlock extends NodeMaterialBlock {
  63803. /**
  63804. * Create a new SheenBlock
  63805. * @param name defines the block name
  63806. */
  63807. constructor(name: string);
  63808. /**
  63809. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63810. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63811. * making it easier to setup and tweak the effect
  63812. */
  63813. albedoScaling: boolean;
  63814. /**
  63815. * Defines if the sheen is linked to the sheen color.
  63816. */
  63817. linkSheenWithAlbedo: boolean;
  63818. /**
  63819. * Initialize the block and prepare the context for build
  63820. * @param state defines the state that will be used for the build
  63821. */
  63822. initialize(state: NodeMaterialBuildState): void;
  63823. /**
  63824. * Gets the current class name
  63825. * @returns the class name
  63826. */
  63827. getClassName(): string;
  63828. /**
  63829. * Gets the intensity input component
  63830. */
  63831. get intensity(): NodeMaterialConnectionPoint;
  63832. /**
  63833. * Gets the color input component
  63834. */
  63835. get color(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the roughness input component
  63838. */
  63839. get roughness(): NodeMaterialConnectionPoint;
  63840. /**
  63841. * Gets the sheen object output component
  63842. */
  63843. get sheen(): NodeMaterialConnectionPoint;
  63844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63845. /**
  63846. * Gets the main code of the block (fragment side)
  63847. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63848. * @returns the shader code
  63849. */
  63850. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63851. protected _buildBlock(state: NodeMaterialBuildState): this;
  63852. protected _dumpPropertiesCode(): string;
  63853. serialize(): any;
  63854. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63855. }
  63856. }
  63857. declare module BABYLON {
  63858. /**
  63859. * Block used to implement the reflectivity module of the PBR material
  63860. */
  63861. export class ReflectivityBlock extends NodeMaterialBlock {
  63862. private _metallicReflectanceColor;
  63863. private _metallicF0Factor;
  63864. /** @hidden */
  63865. _vMetallicReflectanceFactorsName: string;
  63866. /**
  63867. * The property below is set by the main PBR block prior to calling methods of this class.
  63868. */
  63869. /** @hidden */
  63870. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63871. /**
  63872. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63873. */
  63874. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63875. /**
  63876. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63877. */
  63878. useMetallnessFromMetallicTextureBlue: boolean;
  63879. /**
  63880. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63881. */
  63882. useRoughnessFromMetallicTextureAlpha: boolean;
  63883. /**
  63884. * Specifies if the metallic texture contains the roughness information in its green channel.
  63885. */
  63886. useRoughnessFromMetallicTextureGreen: boolean;
  63887. /**
  63888. * Create a new ReflectivityBlock
  63889. * @param name defines the block name
  63890. */
  63891. constructor(name: string);
  63892. /**
  63893. * Initialize the block and prepare the context for build
  63894. * @param state defines the state that will be used for the build
  63895. */
  63896. initialize(state: NodeMaterialBuildState): void;
  63897. /**
  63898. * Gets the current class name
  63899. * @returns the class name
  63900. */
  63901. getClassName(): string;
  63902. /**
  63903. * Gets the metallic input component
  63904. */
  63905. get metallic(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the roughness input component
  63908. */
  63909. get roughness(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the texture input component
  63912. */
  63913. get texture(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the reflectivity object output component
  63916. */
  63917. get reflectivity(): NodeMaterialConnectionPoint;
  63918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63919. /**
  63920. * Gets the main code of the block (fragment side)
  63921. * @param state current state of the node material building
  63922. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63923. * @returns the shader code
  63924. */
  63925. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63927. protected _buildBlock(state: NodeMaterialBuildState): this;
  63928. protected _dumpPropertiesCode(): string;
  63929. serialize(): any;
  63930. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63931. }
  63932. }
  63933. declare module BABYLON {
  63934. /**
  63935. * Block used to implement the anisotropy module of the PBR material
  63936. */
  63937. export class AnisotropyBlock extends NodeMaterialBlock {
  63938. /**
  63939. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63940. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63941. * It's less burden on the user side in the editor part.
  63942. */
  63943. /** @hidden */
  63944. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63945. /** @hidden */
  63946. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63947. /**
  63948. * Create a new AnisotropyBlock
  63949. * @param name defines the block name
  63950. */
  63951. constructor(name: string);
  63952. /**
  63953. * Initialize the block and prepare the context for build
  63954. * @param state defines the state that will be used for the build
  63955. */
  63956. initialize(state: NodeMaterialBuildState): void;
  63957. /**
  63958. * Gets the current class name
  63959. * @returns the class name
  63960. */
  63961. getClassName(): string;
  63962. /**
  63963. * Gets the intensity input component
  63964. */
  63965. get intensity(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the direction input component
  63968. */
  63969. get direction(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the texture input component
  63972. */
  63973. get texture(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the uv input component
  63976. */
  63977. get uv(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the worldTangent input component
  63980. */
  63981. get worldTangent(): NodeMaterialConnectionPoint;
  63982. /**
  63983. * Gets the anisotropy object output component
  63984. */
  63985. get anisotropy(): NodeMaterialConnectionPoint;
  63986. private _generateTBNSpace;
  63987. /**
  63988. * Gets the main code of the block (fragment side)
  63989. * @param state current state of the node material building
  63990. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63991. * @returns the shader code
  63992. */
  63993. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63994. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63995. protected _buildBlock(state: NodeMaterialBuildState): this;
  63996. }
  63997. }
  63998. declare module BABYLON {
  63999. /**
  64000. * Block used to implement the clear coat module of the PBR material
  64001. */
  64002. export class ClearCoatBlock extends NodeMaterialBlock {
  64003. private _scene;
  64004. /**
  64005. * Create a new ClearCoatBlock
  64006. * @param name defines the block name
  64007. */
  64008. constructor(name: string);
  64009. /**
  64010. * Initialize the block and prepare the context for build
  64011. * @param state defines the state that will be used for the build
  64012. */
  64013. initialize(state: NodeMaterialBuildState): void;
  64014. /**
  64015. * Gets the current class name
  64016. * @returns the class name
  64017. */
  64018. getClassName(): string;
  64019. /**
  64020. * Gets the intensity input component
  64021. */
  64022. get intensity(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the roughness input component
  64025. */
  64026. get roughness(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the ior input component
  64029. */
  64030. get ior(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the texture input component
  64033. */
  64034. get texture(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the bump texture input component
  64037. */
  64038. get bumpTexture(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the uv input component
  64041. */
  64042. get uv(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the tint color input component
  64045. */
  64046. get tintColor(): NodeMaterialConnectionPoint;
  64047. /**
  64048. * Gets the tint "at distance" input component
  64049. */
  64050. get tintAtDistance(): NodeMaterialConnectionPoint;
  64051. /**
  64052. * Gets the tint thickness input component
  64053. */
  64054. get tintThickness(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the world tangent input component
  64057. */
  64058. get worldTangent(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the clear coat object output component
  64061. */
  64062. get clearcoat(): NodeMaterialConnectionPoint;
  64063. autoConfigure(material: NodeMaterial): void;
  64064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64066. private _generateTBNSpace;
  64067. /**
  64068. * Gets the main code of the block (fragment side)
  64069. * @param state current state of the node material building
  64070. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64071. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64072. * @param worldPosVarName name of the variable holding the world position
  64073. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64074. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64075. * @param worldNormalVarName name of the variable holding the world normal
  64076. * @returns the shader code
  64077. */
  64078. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64079. protected _buildBlock(state: NodeMaterialBuildState): this;
  64080. }
  64081. }
  64082. declare module BABYLON {
  64083. /**
  64084. * Block used to implement the sub surface module of the PBR material
  64085. */
  64086. export class SubSurfaceBlock extends NodeMaterialBlock {
  64087. /**
  64088. * Create a new SubSurfaceBlock
  64089. * @param name defines the block name
  64090. */
  64091. constructor(name: string);
  64092. /**
  64093. * Stores the intensity of the different subsurface effects in the thickness texture.
  64094. * * the green channel is the translucency intensity.
  64095. * * the blue channel is the scattering intensity.
  64096. * * the alpha channel is the refraction intensity.
  64097. */
  64098. useMaskFromThicknessTexture: boolean;
  64099. /**
  64100. * Initialize the block and prepare the context for build
  64101. * @param state defines the state that will be used for the build
  64102. */
  64103. initialize(state: NodeMaterialBuildState): void;
  64104. /**
  64105. * Gets the current class name
  64106. * @returns the class name
  64107. */
  64108. getClassName(): string;
  64109. /**
  64110. * Gets the min thickness input component
  64111. */
  64112. get minThickness(): NodeMaterialConnectionPoint;
  64113. /**
  64114. * Gets the max thickness input component
  64115. */
  64116. get maxThickness(): NodeMaterialConnectionPoint;
  64117. /**
  64118. * Gets the thickness texture component
  64119. */
  64120. get thicknessTexture(): NodeMaterialConnectionPoint;
  64121. /**
  64122. * Gets the tint color input component
  64123. */
  64124. get tintColor(): NodeMaterialConnectionPoint;
  64125. /**
  64126. * Gets the translucency intensity input component
  64127. */
  64128. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64129. /**
  64130. * Gets the translucency diffusion distance input component
  64131. */
  64132. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64133. /**
  64134. * Gets the refraction object parameters
  64135. */
  64136. get refraction(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the sub surface object output component
  64139. */
  64140. get subsurface(): NodeMaterialConnectionPoint;
  64141. autoConfigure(material: NodeMaterial): void;
  64142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64143. /**
  64144. * Gets the main code of the block (fragment side)
  64145. * @param state current state of the node material building
  64146. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64147. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64148. * @param worldPosVarName name of the variable holding the world position
  64149. * @returns the shader code
  64150. */
  64151. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64152. protected _buildBlock(state: NodeMaterialBuildState): this;
  64153. }
  64154. }
  64155. declare module BABYLON {
  64156. /**
  64157. * Block used to implement the PBR metallic/roughness model
  64158. */
  64159. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64160. /**
  64161. * Gets or sets the light associated with this block
  64162. */
  64163. light: Nullable<Light>;
  64164. private _lightId;
  64165. private _scene;
  64166. private _environmentBRDFTexture;
  64167. private _environmentBrdfSamplerName;
  64168. private _vNormalWName;
  64169. private _invertNormalName;
  64170. /**
  64171. * Create a new ReflectionBlock
  64172. * @param name defines the block name
  64173. */
  64174. constructor(name: string);
  64175. /**
  64176. * Intensity of the direct lights e.g. the four lights available in your scene.
  64177. * This impacts both the direct diffuse and specular highlights.
  64178. */
  64179. directIntensity: number;
  64180. /**
  64181. * Intensity of the environment e.g. how much the environment will light the object
  64182. * either through harmonics for rough material or through the refelction for shiny ones.
  64183. */
  64184. environmentIntensity: number;
  64185. /**
  64186. * This is a special control allowing the reduction of the specular highlights coming from the
  64187. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64188. */
  64189. specularIntensity: number;
  64190. /**
  64191. * Defines the falloff type used in this material.
  64192. * It by default is Physical.
  64193. */
  64194. lightFalloff: number;
  64195. /**
  64196. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64197. */
  64198. useAlphaFromAlbedoTexture: boolean;
  64199. /**
  64200. * Specifies that alpha test should be used
  64201. */
  64202. useAlphaTest: boolean;
  64203. /**
  64204. * Defines the alpha limits in alpha test mode.
  64205. */
  64206. alphaTestCutoff: number;
  64207. /**
  64208. * Specifies that alpha blending should be used
  64209. */
  64210. useAlphaBlending: boolean;
  64211. /**
  64212. * Defines if the alpha value should be determined via the rgb values.
  64213. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64214. */
  64215. opacityRGB: boolean;
  64216. /**
  64217. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64218. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64219. */
  64220. useRadianceOverAlpha: boolean;
  64221. /**
  64222. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64223. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64224. */
  64225. useSpecularOverAlpha: boolean;
  64226. /**
  64227. * Enables specular anti aliasing in the PBR shader.
  64228. * It will both interacts on the Geometry for analytical and IBL lighting.
  64229. * It also prefilter the roughness map based on the bump values.
  64230. */
  64231. enableSpecularAntiAliasing: boolean;
  64232. /**
  64233. * Enables realtime filtering on the texture.
  64234. */
  64235. realTimeFiltering: boolean;
  64236. /**
  64237. * Quality switch for realtime filtering
  64238. */
  64239. realTimeFilteringQuality: number;
  64240. /**
  64241. * Defines if the material uses energy conservation.
  64242. */
  64243. useEnergyConservation: boolean;
  64244. /**
  64245. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64246. * too much the area relying on ambient texture to define their ambient occlusion.
  64247. */
  64248. useRadianceOcclusion: boolean;
  64249. /**
  64250. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64251. * makes the reflect vector face the model (under horizon).
  64252. */
  64253. useHorizonOcclusion: boolean;
  64254. /**
  64255. * If set to true, no lighting calculations will be applied.
  64256. */
  64257. unlit: boolean;
  64258. /**
  64259. * Force normal to face away from face.
  64260. */
  64261. forceNormalForward: boolean;
  64262. /**
  64263. * Defines the material debug mode.
  64264. * It helps seeing only some components of the material while troubleshooting.
  64265. */
  64266. debugMode: number;
  64267. /**
  64268. * Specify from where on screen the debug mode should start.
  64269. * The value goes from -1 (full screen) to 1 (not visible)
  64270. * It helps with side by side comparison against the final render
  64271. * This defaults to 0
  64272. */
  64273. debugLimit: number;
  64274. /**
  64275. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64276. * You can use the factor to better multiply the final value.
  64277. */
  64278. debugFactor: number;
  64279. /**
  64280. * Initialize the block and prepare the context for build
  64281. * @param state defines the state that will be used for the build
  64282. */
  64283. initialize(state: NodeMaterialBuildState): void;
  64284. /**
  64285. * Gets the current class name
  64286. * @returns the class name
  64287. */
  64288. getClassName(): string;
  64289. /**
  64290. * Gets the world position input component
  64291. */
  64292. get worldPosition(): NodeMaterialConnectionPoint;
  64293. /**
  64294. * Gets the world normal input component
  64295. */
  64296. get worldNormal(): NodeMaterialConnectionPoint;
  64297. /**
  64298. * Gets the perturbed normal input component
  64299. */
  64300. get perturbedNormal(): NodeMaterialConnectionPoint;
  64301. /**
  64302. * Gets the camera position input component
  64303. */
  64304. get cameraPosition(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the base color input component
  64307. */
  64308. get baseColor(): NodeMaterialConnectionPoint;
  64309. /**
  64310. * Gets the opacity texture input component
  64311. */
  64312. get opacityTexture(): NodeMaterialConnectionPoint;
  64313. /**
  64314. * Gets the ambient color input component
  64315. */
  64316. get ambientColor(): NodeMaterialConnectionPoint;
  64317. /**
  64318. * Gets the reflectivity object parameters
  64319. */
  64320. get reflectivity(): NodeMaterialConnectionPoint;
  64321. /**
  64322. * Gets the ambient occlusion object parameters
  64323. */
  64324. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64325. /**
  64326. * Gets the reflection object parameters
  64327. */
  64328. get reflection(): NodeMaterialConnectionPoint;
  64329. /**
  64330. * Gets the sheen object parameters
  64331. */
  64332. get sheen(): NodeMaterialConnectionPoint;
  64333. /**
  64334. * Gets the clear coat object parameters
  64335. */
  64336. get clearcoat(): NodeMaterialConnectionPoint;
  64337. /**
  64338. * Gets the sub surface object parameters
  64339. */
  64340. get subsurface(): NodeMaterialConnectionPoint;
  64341. /**
  64342. * Gets the anisotropy object parameters
  64343. */
  64344. get anisotropy(): NodeMaterialConnectionPoint;
  64345. /**
  64346. * Gets the ambient output component
  64347. */
  64348. get ambient(): NodeMaterialConnectionPoint;
  64349. /**
  64350. * Gets the diffuse output component
  64351. */
  64352. get diffuse(): NodeMaterialConnectionPoint;
  64353. /**
  64354. * Gets the specular output component
  64355. */
  64356. get specular(): NodeMaterialConnectionPoint;
  64357. /**
  64358. * Gets the sheen output component
  64359. */
  64360. get sheenDir(): NodeMaterialConnectionPoint;
  64361. /**
  64362. * Gets the clear coat output component
  64363. */
  64364. get clearcoatDir(): NodeMaterialConnectionPoint;
  64365. /**
  64366. * Gets the indirect diffuse output component
  64367. */
  64368. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64369. /**
  64370. * Gets the indirect specular output component
  64371. */
  64372. get specularIndirect(): NodeMaterialConnectionPoint;
  64373. /**
  64374. * Gets the indirect sheen output component
  64375. */
  64376. get sheenIndirect(): NodeMaterialConnectionPoint;
  64377. /**
  64378. * Gets the indirect clear coat output component
  64379. */
  64380. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the refraction output component
  64383. */
  64384. get refraction(): NodeMaterialConnectionPoint;
  64385. /**
  64386. * Gets the global lighting output component
  64387. */
  64388. get lighting(): NodeMaterialConnectionPoint;
  64389. /**
  64390. * Gets the shadow output component
  64391. */
  64392. get shadow(): NodeMaterialConnectionPoint;
  64393. /**
  64394. * Gets the alpha output component
  64395. */
  64396. get alpha(): NodeMaterialConnectionPoint;
  64397. autoConfigure(material: NodeMaterial): void;
  64398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64399. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64400. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64401. private _injectVertexCode;
  64402. /**
  64403. * Gets the code corresponding to the albedo/opacity module
  64404. * @returns the shader code
  64405. */
  64406. getAlbedoOpacityCode(): string;
  64407. protected _buildBlock(state: NodeMaterialBuildState): this;
  64408. protected _dumpPropertiesCode(): string;
  64409. serialize(): any;
  64410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64411. }
  64412. }
  64413. declare module BABYLON {
  64414. /**
  64415. * Block used to compute value of one parameter modulo another
  64416. */
  64417. export class ModBlock extends NodeMaterialBlock {
  64418. /**
  64419. * Creates a new ModBlock
  64420. * @param name defines the block name
  64421. */
  64422. constructor(name: string);
  64423. /**
  64424. * Gets the current class name
  64425. * @returns the class name
  64426. */
  64427. getClassName(): string;
  64428. /**
  64429. * Gets the left operand input component
  64430. */
  64431. get left(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the right operand input component
  64434. */
  64435. get right(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the output component
  64438. */
  64439. get output(): NodeMaterialConnectionPoint;
  64440. protected _buildBlock(state: NodeMaterialBuildState): this;
  64441. }
  64442. }
  64443. declare module BABYLON {
  64444. /**
  64445. * Helper class to push actions to a pool of workers.
  64446. */
  64447. export class WorkerPool implements IDisposable {
  64448. private _workerInfos;
  64449. private _pendingActions;
  64450. /**
  64451. * Constructor
  64452. * @param workers Array of workers to use for actions
  64453. */
  64454. constructor(workers: Array<Worker>);
  64455. /**
  64456. * Terminates all workers and clears any pending actions.
  64457. */
  64458. dispose(): void;
  64459. /**
  64460. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64461. * pended until a worker has completed its action.
  64462. * @param action The action to perform. Call onComplete when the action is complete.
  64463. */
  64464. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64465. private _execute;
  64466. }
  64467. }
  64468. declare module BABYLON {
  64469. /**
  64470. * Configuration for Draco compression
  64471. */
  64472. export interface IDracoCompressionConfiguration {
  64473. /**
  64474. * Configuration for the decoder.
  64475. */
  64476. decoder: {
  64477. /**
  64478. * The url to the WebAssembly module.
  64479. */
  64480. wasmUrl?: string;
  64481. /**
  64482. * The url to the WebAssembly binary.
  64483. */
  64484. wasmBinaryUrl?: string;
  64485. /**
  64486. * The url to the fallback JavaScript module.
  64487. */
  64488. fallbackUrl?: string;
  64489. };
  64490. }
  64491. /**
  64492. * Draco compression (https://google.github.io/draco/)
  64493. *
  64494. * This class wraps the Draco module.
  64495. *
  64496. * **Encoder**
  64497. *
  64498. * The encoder is not currently implemented.
  64499. *
  64500. * **Decoder**
  64501. *
  64502. * 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.
  64503. *
  64504. * To update the configuration, use the following code:
  64505. * ```javascript
  64506. * DracoCompression.Configuration = {
  64507. * decoder: {
  64508. * wasmUrl: "<url to the WebAssembly library>",
  64509. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64510. * fallbackUrl: "<url to the fallback JavaScript library>",
  64511. * }
  64512. * };
  64513. * ```
  64514. *
  64515. * 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.
  64516. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64517. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64518. *
  64519. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64520. * ```javascript
  64521. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64522. * ```
  64523. *
  64524. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64525. */
  64526. export class DracoCompression implements IDisposable {
  64527. private _workerPoolPromise?;
  64528. private _decoderModulePromise?;
  64529. /**
  64530. * The configuration. Defaults to the following urls:
  64531. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64532. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64533. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64534. */
  64535. static Configuration: IDracoCompressionConfiguration;
  64536. /**
  64537. * Returns true if the decoder configuration is available.
  64538. */
  64539. static get DecoderAvailable(): boolean;
  64540. /**
  64541. * Default number of workers to create when creating the draco compression object.
  64542. */
  64543. static DefaultNumWorkers: number;
  64544. private static GetDefaultNumWorkers;
  64545. private static _Default;
  64546. /**
  64547. * Default instance for the draco compression object.
  64548. */
  64549. static get Default(): DracoCompression;
  64550. /**
  64551. * Constructor
  64552. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64553. */
  64554. constructor(numWorkers?: number);
  64555. /**
  64556. * Stop all async operations and release resources.
  64557. */
  64558. dispose(): void;
  64559. /**
  64560. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64561. * @returns a promise that resolves when ready
  64562. */
  64563. whenReadyAsync(): Promise<void>;
  64564. /**
  64565. * Decode Draco compressed mesh data to vertex data.
  64566. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64567. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64568. * @returns A promise that resolves with the decoded vertex data
  64569. */
  64570. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64571. [kind: string]: number;
  64572. }): Promise<VertexData>;
  64573. }
  64574. }
  64575. declare module BABYLON {
  64576. /**
  64577. * Class for building Constructive Solid Geometry
  64578. */
  64579. export class CSG {
  64580. private polygons;
  64581. /**
  64582. * The world matrix
  64583. */
  64584. matrix: Matrix;
  64585. /**
  64586. * Stores the position
  64587. */
  64588. position: Vector3;
  64589. /**
  64590. * Stores the rotation
  64591. */
  64592. rotation: Vector3;
  64593. /**
  64594. * Stores the rotation quaternion
  64595. */
  64596. rotationQuaternion: Nullable<Quaternion>;
  64597. /**
  64598. * Stores the scaling vector
  64599. */
  64600. scaling: Vector3;
  64601. /**
  64602. * Convert the Mesh to CSG
  64603. * @param mesh The Mesh to convert to CSG
  64604. * @returns A new CSG from the Mesh
  64605. */
  64606. static FromMesh(mesh: Mesh): CSG;
  64607. /**
  64608. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64609. * @param polygons Polygons used to construct a CSG solid
  64610. */
  64611. private static FromPolygons;
  64612. /**
  64613. * Clones, or makes a deep copy, of the CSG
  64614. * @returns A new CSG
  64615. */
  64616. clone(): CSG;
  64617. /**
  64618. * Unions this CSG with another CSG
  64619. * @param csg The CSG to union against this CSG
  64620. * @returns The unioned CSG
  64621. */
  64622. union(csg: CSG): CSG;
  64623. /**
  64624. * Unions this CSG with another CSG in place
  64625. * @param csg The CSG to union against this CSG
  64626. */
  64627. unionInPlace(csg: CSG): void;
  64628. /**
  64629. * Subtracts this CSG with another CSG
  64630. * @param csg The CSG to subtract against this CSG
  64631. * @returns A new CSG
  64632. */
  64633. subtract(csg: CSG): CSG;
  64634. /**
  64635. * Subtracts this CSG with another CSG in place
  64636. * @param csg The CSG to subtact against this CSG
  64637. */
  64638. subtractInPlace(csg: CSG): void;
  64639. /**
  64640. * Intersect this CSG with another CSG
  64641. * @param csg The CSG to intersect against this CSG
  64642. * @returns A new CSG
  64643. */
  64644. intersect(csg: CSG): CSG;
  64645. /**
  64646. * Intersects this CSG with another CSG in place
  64647. * @param csg The CSG to intersect against this CSG
  64648. */
  64649. intersectInPlace(csg: CSG): void;
  64650. /**
  64651. * Return a new CSG solid with solid and empty space switched. This solid is
  64652. * not modified.
  64653. * @returns A new CSG solid with solid and empty space switched
  64654. */
  64655. inverse(): CSG;
  64656. /**
  64657. * Inverses the CSG in place
  64658. */
  64659. inverseInPlace(): void;
  64660. /**
  64661. * This is used to keep meshes transformations so they can be restored
  64662. * when we build back a Babylon Mesh
  64663. * NB : All CSG operations are performed in world coordinates
  64664. * @param csg The CSG to copy the transform attributes from
  64665. * @returns This CSG
  64666. */
  64667. copyTransformAttributes(csg: CSG): CSG;
  64668. /**
  64669. * Build Raw mesh from CSG
  64670. * Coordinates here are in world space
  64671. * @param name The name of the mesh geometry
  64672. * @param scene The Scene
  64673. * @param keepSubMeshes Specifies if the submeshes should be kept
  64674. * @returns A new Mesh
  64675. */
  64676. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64677. /**
  64678. * Build Mesh from CSG taking material and transforms into account
  64679. * @param name The name of the Mesh
  64680. * @param material The material of the Mesh
  64681. * @param scene The Scene
  64682. * @param keepSubMeshes Specifies if submeshes should be kept
  64683. * @returns The new Mesh
  64684. */
  64685. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64686. }
  64687. }
  64688. declare module BABYLON {
  64689. /**
  64690. * Class used to create a trail following a mesh
  64691. */
  64692. export class TrailMesh extends Mesh {
  64693. private _generator;
  64694. private _autoStart;
  64695. private _running;
  64696. private _diameter;
  64697. private _length;
  64698. private _sectionPolygonPointsCount;
  64699. private _sectionVectors;
  64700. private _sectionNormalVectors;
  64701. private _beforeRenderObserver;
  64702. /**
  64703. * @constructor
  64704. * @param name The value used by scene.getMeshByName() to do a lookup.
  64705. * @param generator The mesh or transform node to generate a trail.
  64706. * @param scene The scene to add this mesh to.
  64707. * @param diameter Diameter of trailing mesh. Default is 1.
  64708. * @param length Length of trailing mesh. Default is 60.
  64709. * @param autoStart Automatically start trailing mesh. Default true.
  64710. */
  64711. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64712. /**
  64713. * "TrailMesh"
  64714. * @returns "TrailMesh"
  64715. */
  64716. getClassName(): string;
  64717. private _createMesh;
  64718. /**
  64719. * Start trailing mesh.
  64720. */
  64721. start(): void;
  64722. /**
  64723. * Stop trailing mesh.
  64724. */
  64725. stop(): void;
  64726. /**
  64727. * Update trailing mesh geometry.
  64728. */
  64729. update(): void;
  64730. /**
  64731. * Returns a new TrailMesh object.
  64732. * @param name is a string, the name given to the new mesh
  64733. * @param newGenerator use new generator object for cloned trail mesh
  64734. * @returns a new mesh
  64735. */
  64736. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64737. /**
  64738. * Serializes this trail mesh
  64739. * @param serializationObject object to write serialization to
  64740. */
  64741. serialize(serializationObject: any): void;
  64742. /**
  64743. * Parses a serialized trail mesh
  64744. * @param parsedMesh the serialized mesh
  64745. * @param scene the scene to create the trail mesh in
  64746. * @returns the created trail mesh
  64747. */
  64748. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64749. }
  64750. }
  64751. declare module BABYLON {
  64752. /**
  64753. * Class containing static functions to help procedurally build meshes
  64754. */
  64755. export class TiledBoxBuilder {
  64756. /**
  64757. * Creates a box mesh
  64758. * 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)
  64759. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64761. * * 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
  64762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64763. * @param name defines the name of the mesh
  64764. * @param options defines the options used to create the mesh
  64765. * @param scene defines the hosting scene
  64766. * @returns the box mesh
  64767. */
  64768. static CreateTiledBox(name: string, options: {
  64769. pattern?: number;
  64770. width?: number;
  64771. height?: number;
  64772. depth?: number;
  64773. tileSize?: number;
  64774. tileWidth?: number;
  64775. tileHeight?: number;
  64776. alignHorizontal?: number;
  64777. alignVertical?: number;
  64778. faceUV?: Vector4[];
  64779. faceColors?: Color4[];
  64780. sideOrientation?: number;
  64781. updatable?: boolean;
  64782. }, scene?: Nullable<Scene>): Mesh;
  64783. }
  64784. }
  64785. declare module BABYLON {
  64786. /**
  64787. * Class containing static functions to help procedurally build meshes
  64788. */
  64789. export class TorusKnotBuilder {
  64790. /**
  64791. * Creates a torus knot mesh
  64792. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64793. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64794. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64795. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64797. * * 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
  64798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64799. * @param name defines the name of the mesh
  64800. * @param options defines the options used to create the mesh
  64801. * @param scene defines the hosting scene
  64802. * @returns the torus knot mesh
  64803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64804. */
  64805. static CreateTorusKnot(name: string, options: {
  64806. radius?: number;
  64807. tube?: number;
  64808. radialSegments?: number;
  64809. tubularSegments?: number;
  64810. p?: number;
  64811. q?: number;
  64812. updatable?: boolean;
  64813. sideOrientation?: number;
  64814. frontUVs?: Vector4;
  64815. backUVs?: Vector4;
  64816. }, scene: any): Mesh;
  64817. }
  64818. }
  64819. declare module BABYLON {
  64820. /**
  64821. * Polygon
  64822. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64823. */
  64824. export class Polygon {
  64825. /**
  64826. * Creates a rectangle
  64827. * @param xmin bottom X coord
  64828. * @param ymin bottom Y coord
  64829. * @param xmax top X coord
  64830. * @param ymax top Y coord
  64831. * @returns points that make the resulting rectation
  64832. */
  64833. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64834. /**
  64835. * Creates a circle
  64836. * @param radius radius of circle
  64837. * @param cx scale in x
  64838. * @param cy scale in y
  64839. * @param numberOfSides number of sides that make up the circle
  64840. * @returns points that make the resulting circle
  64841. */
  64842. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64843. /**
  64844. * Creates a polygon from input string
  64845. * @param input Input polygon data
  64846. * @returns the parsed points
  64847. */
  64848. static Parse(input: string): Vector2[];
  64849. /**
  64850. * Starts building a polygon from x and y coordinates
  64851. * @param x x coordinate
  64852. * @param y y coordinate
  64853. * @returns the started path2
  64854. */
  64855. static StartingAt(x: number, y: number): Path2;
  64856. }
  64857. /**
  64858. * Builds a polygon
  64859. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64860. */
  64861. export class PolygonMeshBuilder {
  64862. private _points;
  64863. private _outlinepoints;
  64864. private _holes;
  64865. private _name;
  64866. private _scene;
  64867. private _epoints;
  64868. private _eholes;
  64869. private _addToepoint;
  64870. /**
  64871. * Babylon reference to the earcut plugin.
  64872. */
  64873. bjsEarcut: any;
  64874. /**
  64875. * Creates a PolygonMeshBuilder
  64876. * @param name name of the builder
  64877. * @param contours Path of the polygon
  64878. * @param scene scene to add to when creating the mesh
  64879. * @param earcutInjection can be used to inject your own earcut reference
  64880. */
  64881. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64882. /**
  64883. * Adds a whole within the polygon
  64884. * @param hole Array of points defining the hole
  64885. * @returns this
  64886. */
  64887. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64888. /**
  64889. * Creates the polygon
  64890. * @param updatable If the mesh should be updatable
  64891. * @param depth The depth of the mesh created
  64892. * @returns the created mesh
  64893. */
  64894. build(updatable?: boolean, depth?: number): Mesh;
  64895. /**
  64896. * Creates the polygon
  64897. * @param depth The depth of the mesh created
  64898. * @returns the created VertexData
  64899. */
  64900. buildVertexData(depth?: number): VertexData;
  64901. /**
  64902. * Adds a side to the polygon
  64903. * @param positions points that make the polygon
  64904. * @param normals normals of the polygon
  64905. * @param uvs uvs of the polygon
  64906. * @param indices indices of the polygon
  64907. * @param bounds bounds of the polygon
  64908. * @param points points of the polygon
  64909. * @param depth depth of the polygon
  64910. * @param flip flip of the polygon
  64911. */
  64912. private addSide;
  64913. }
  64914. }
  64915. declare module BABYLON {
  64916. /**
  64917. * Class containing static functions to help procedurally build meshes
  64918. */
  64919. export class PolygonBuilder {
  64920. /**
  64921. * Creates a polygon mesh
  64922. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64923. * * 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
  64924. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64926. * * 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)
  64927. * * Remember you can only change the shape positions, not their number when updating a polygon
  64928. * @param name defines the name of the mesh
  64929. * @param options defines the options used to create the mesh
  64930. * @param scene defines the hosting scene
  64931. * @param earcutInjection can be used to inject your own earcut reference
  64932. * @returns the polygon mesh
  64933. */
  64934. static CreatePolygon(name: string, options: {
  64935. shape: Vector3[];
  64936. holes?: Vector3[][];
  64937. depth?: number;
  64938. faceUV?: Vector4[];
  64939. faceColors?: Color4[];
  64940. updatable?: boolean;
  64941. sideOrientation?: number;
  64942. frontUVs?: Vector4;
  64943. backUVs?: Vector4;
  64944. wrap?: boolean;
  64945. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64946. /**
  64947. * Creates an extruded polygon mesh, with depth in the Y direction.
  64948. * * 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)
  64949. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64950. * @param name defines the name of the mesh
  64951. * @param options defines the options used to create the mesh
  64952. * @param scene defines the hosting scene
  64953. * @param earcutInjection can be used to inject your own earcut reference
  64954. * @returns the polygon mesh
  64955. */
  64956. static ExtrudePolygon(name: string, options: {
  64957. shape: Vector3[];
  64958. holes?: Vector3[][];
  64959. depth?: number;
  64960. faceUV?: Vector4[];
  64961. faceColors?: Color4[];
  64962. updatable?: boolean;
  64963. sideOrientation?: number;
  64964. frontUVs?: Vector4;
  64965. backUVs?: Vector4;
  64966. wrap?: boolean;
  64967. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64968. }
  64969. }
  64970. declare module BABYLON {
  64971. /**
  64972. * Class containing static functions to help procedurally build meshes
  64973. */
  64974. export class LatheBuilder {
  64975. /**
  64976. * Creates lathe mesh.
  64977. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64978. * * 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
  64979. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64980. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64981. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64982. * * 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
  64983. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64984. * * 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
  64985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64986. * * 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
  64987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64989. * @param name defines the name of the mesh
  64990. * @param options defines the options used to create the mesh
  64991. * @param scene defines the hosting scene
  64992. * @returns the lathe mesh
  64993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64994. */
  64995. static CreateLathe(name: string, options: {
  64996. shape: Vector3[];
  64997. radius?: number;
  64998. tessellation?: number;
  64999. clip?: number;
  65000. arc?: number;
  65001. closed?: boolean;
  65002. updatable?: boolean;
  65003. sideOrientation?: number;
  65004. frontUVs?: Vector4;
  65005. backUVs?: Vector4;
  65006. cap?: number;
  65007. invertUV?: boolean;
  65008. }, scene?: Nullable<Scene>): Mesh;
  65009. }
  65010. }
  65011. declare module BABYLON {
  65012. /**
  65013. * Class containing static functions to help procedurally build meshes
  65014. */
  65015. export class TiledPlaneBuilder {
  65016. /**
  65017. * Creates a tiled plane mesh
  65018. * * The parameter `pattern` will, depending on value, do nothing or
  65019. * * * flip (reflect about central vertical) alternate tiles across and up
  65020. * * * flip every tile on alternate rows
  65021. * * * rotate (180 degs) alternate tiles across and up
  65022. * * * rotate every tile on alternate rows
  65023. * * * flip and rotate alternate tiles across and up
  65024. * * * flip and rotate every tile on alternate rows
  65025. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65026. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65027. * * 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
  65028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65029. * * 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)
  65030. * * 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)
  65031. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65032. * @param name defines the name of the mesh
  65033. * @param options defines the options used to create the mesh
  65034. * @param scene defines the hosting scene
  65035. * @returns the box mesh
  65036. */
  65037. static CreateTiledPlane(name: string, options: {
  65038. pattern?: number;
  65039. tileSize?: number;
  65040. tileWidth?: number;
  65041. tileHeight?: number;
  65042. size?: number;
  65043. width?: number;
  65044. height?: number;
  65045. alignHorizontal?: number;
  65046. alignVertical?: number;
  65047. sideOrientation?: number;
  65048. frontUVs?: Vector4;
  65049. backUVs?: Vector4;
  65050. updatable?: boolean;
  65051. }, scene?: Nullable<Scene>): Mesh;
  65052. }
  65053. }
  65054. declare module BABYLON {
  65055. /**
  65056. * Class containing static functions to help procedurally build meshes
  65057. */
  65058. export class TubeBuilder {
  65059. /**
  65060. * Creates a tube mesh.
  65061. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65062. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65063. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65064. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65065. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65066. * * 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)
  65067. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65068. * * 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
  65069. * * 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
  65070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65071. * * 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
  65072. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65074. * @param name defines the name of the mesh
  65075. * @param options defines the options used to create the mesh
  65076. * @param scene defines the hosting scene
  65077. * @returns the tube mesh
  65078. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65079. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65080. */
  65081. static CreateTube(name: string, options: {
  65082. path: Vector3[];
  65083. radius?: number;
  65084. tessellation?: number;
  65085. radiusFunction?: {
  65086. (i: number, distance: number): number;
  65087. };
  65088. cap?: number;
  65089. arc?: number;
  65090. updatable?: boolean;
  65091. sideOrientation?: number;
  65092. frontUVs?: Vector4;
  65093. backUVs?: Vector4;
  65094. instance?: Mesh;
  65095. invertUV?: boolean;
  65096. }, scene?: Nullable<Scene>): Mesh;
  65097. }
  65098. }
  65099. declare module BABYLON {
  65100. /**
  65101. * Class containing static functions to help procedurally build meshes
  65102. */
  65103. export class IcoSphereBuilder {
  65104. /**
  65105. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65106. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65107. * * 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`)
  65108. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65109. * * 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
  65110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65111. * * 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
  65112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65113. * @param name defines the name of the mesh
  65114. * @param options defines the options used to create the mesh
  65115. * @param scene defines the hosting scene
  65116. * @returns the icosahedron mesh
  65117. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65118. */
  65119. static CreateIcoSphere(name: string, options: {
  65120. radius?: number;
  65121. radiusX?: number;
  65122. radiusY?: number;
  65123. radiusZ?: number;
  65124. flat?: boolean;
  65125. subdivisions?: number;
  65126. sideOrientation?: number;
  65127. frontUVs?: Vector4;
  65128. backUVs?: Vector4;
  65129. updatable?: boolean;
  65130. }, scene?: Nullable<Scene>): Mesh;
  65131. }
  65132. }
  65133. declare module BABYLON {
  65134. /**
  65135. * Class containing static functions to help procedurally build meshes
  65136. */
  65137. export class DecalBuilder {
  65138. /**
  65139. * Creates a decal mesh.
  65140. * 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
  65141. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65142. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65143. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65144. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65145. * @param name defines the name of the mesh
  65146. * @param sourceMesh defines the mesh where the decal must be applied
  65147. * @param options defines the options used to create the mesh
  65148. * @param scene defines the hosting scene
  65149. * @returns the decal mesh
  65150. * @see https://doc.babylonjs.com/how_to/decals
  65151. */
  65152. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65153. position?: Vector3;
  65154. normal?: Vector3;
  65155. size?: Vector3;
  65156. angle?: number;
  65157. }): Mesh;
  65158. }
  65159. }
  65160. declare module BABYLON {
  65161. /**
  65162. * Class containing static functions to help procedurally build meshes
  65163. */
  65164. export class MeshBuilder {
  65165. /**
  65166. * Creates a box mesh
  65167. * * The parameter `size` sets the size (float) of each box side (default 1)
  65168. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65169. * * 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)
  65170. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65172. * * 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
  65173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65174. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65175. * @param name defines the name of the mesh
  65176. * @param options defines the options used to create the mesh
  65177. * @param scene defines the hosting scene
  65178. * @returns the box mesh
  65179. */
  65180. static CreateBox(name: string, options: {
  65181. size?: number;
  65182. width?: number;
  65183. height?: number;
  65184. depth?: number;
  65185. faceUV?: Vector4[];
  65186. faceColors?: Color4[];
  65187. sideOrientation?: number;
  65188. frontUVs?: Vector4;
  65189. backUVs?: Vector4;
  65190. wrap?: boolean;
  65191. topBaseAt?: number;
  65192. bottomBaseAt?: number;
  65193. updatable?: boolean;
  65194. }, scene?: Nullable<Scene>): Mesh;
  65195. /**
  65196. * Creates a tiled box mesh
  65197. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65199. * @param name defines the name of the mesh
  65200. * @param options defines the options used to create the mesh
  65201. * @param scene defines the hosting scene
  65202. * @returns the tiled box mesh
  65203. */
  65204. static CreateTiledBox(name: string, options: {
  65205. pattern?: number;
  65206. size?: number;
  65207. width?: number;
  65208. height?: number;
  65209. depth: number;
  65210. tileSize?: number;
  65211. tileWidth?: number;
  65212. tileHeight?: number;
  65213. faceUV?: Vector4[];
  65214. faceColors?: Color4[];
  65215. alignHorizontal?: number;
  65216. alignVertical?: number;
  65217. sideOrientation?: number;
  65218. updatable?: boolean;
  65219. }, scene?: Nullable<Scene>): Mesh;
  65220. /**
  65221. * Creates a sphere mesh
  65222. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65223. * * 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`)
  65224. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65225. * * 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
  65226. * * 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)
  65227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65228. * * 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
  65229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65230. * @param name defines the name of the mesh
  65231. * @param options defines the options used to create the mesh
  65232. * @param scene defines the hosting scene
  65233. * @returns the sphere mesh
  65234. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65235. */
  65236. static CreateSphere(name: string, options: {
  65237. segments?: number;
  65238. diameter?: number;
  65239. diameterX?: number;
  65240. diameterY?: number;
  65241. diameterZ?: number;
  65242. arc?: number;
  65243. slice?: number;
  65244. sideOrientation?: number;
  65245. frontUVs?: Vector4;
  65246. backUVs?: Vector4;
  65247. updatable?: boolean;
  65248. }, scene?: Nullable<Scene>): Mesh;
  65249. /**
  65250. * Creates a plane polygonal mesh. By default, this is a disc
  65251. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65252. * * 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
  65253. * * 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
  65254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65255. * * 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
  65256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65257. * @param name defines the name of the mesh
  65258. * @param options defines the options used to create the mesh
  65259. * @param scene defines the hosting scene
  65260. * @returns the plane polygonal mesh
  65261. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65262. */
  65263. static CreateDisc(name: string, options: {
  65264. radius?: number;
  65265. tessellation?: number;
  65266. arc?: number;
  65267. updatable?: boolean;
  65268. sideOrientation?: number;
  65269. frontUVs?: Vector4;
  65270. backUVs?: Vector4;
  65271. }, scene?: Nullable<Scene>): Mesh;
  65272. /**
  65273. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65274. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65275. * * 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`)
  65276. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65277. * * 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
  65278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65279. * * 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
  65280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65281. * @param name defines the name of the mesh
  65282. * @param options defines the options used to create the mesh
  65283. * @param scene defines the hosting scene
  65284. * @returns the icosahedron mesh
  65285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65286. */
  65287. static CreateIcoSphere(name: string, options: {
  65288. radius?: number;
  65289. radiusX?: number;
  65290. radiusY?: number;
  65291. radiusZ?: number;
  65292. flat?: boolean;
  65293. subdivisions?: number;
  65294. sideOrientation?: number;
  65295. frontUVs?: Vector4;
  65296. backUVs?: Vector4;
  65297. updatable?: boolean;
  65298. }, scene?: Nullable<Scene>): Mesh;
  65299. /**
  65300. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65301. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65302. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65303. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65304. * * 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
  65305. * * 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
  65306. * * 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
  65307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65308. * * 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
  65309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65310. * * 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
  65311. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65312. * * 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
  65313. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65315. * @param name defines the name of the mesh
  65316. * @param options defines the options used to create the mesh
  65317. * @param scene defines the hosting scene
  65318. * @returns the ribbon mesh
  65319. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65320. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65321. */
  65322. static CreateRibbon(name: string, options: {
  65323. pathArray: Vector3[][];
  65324. closeArray?: boolean;
  65325. closePath?: boolean;
  65326. offset?: number;
  65327. updatable?: boolean;
  65328. sideOrientation?: number;
  65329. frontUVs?: Vector4;
  65330. backUVs?: Vector4;
  65331. instance?: Mesh;
  65332. invertUV?: boolean;
  65333. uvs?: Vector2[];
  65334. colors?: Color4[];
  65335. }, scene?: Nullable<Scene>): Mesh;
  65336. /**
  65337. * Creates a cylinder or a cone mesh
  65338. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65339. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65340. * * 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.
  65341. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65342. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65343. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65344. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65345. * * 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).
  65346. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65347. * * 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).
  65348. * * 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
  65349. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65350. * * 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
  65351. * * 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.
  65352. * * If `enclose` is false, a ring surface is one element.
  65353. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65354. * * 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
  65355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65356. * * 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
  65357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65358. * @param name defines the name of the mesh
  65359. * @param options defines the options used to create the mesh
  65360. * @param scene defines the hosting scene
  65361. * @returns the cylinder mesh
  65362. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65363. */
  65364. static CreateCylinder(name: string, options: {
  65365. height?: number;
  65366. diameterTop?: number;
  65367. diameterBottom?: number;
  65368. diameter?: number;
  65369. tessellation?: number;
  65370. subdivisions?: number;
  65371. arc?: number;
  65372. faceColors?: Color4[];
  65373. faceUV?: Vector4[];
  65374. updatable?: boolean;
  65375. hasRings?: boolean;
  65376. enclose?: boolean;
  65377. cap?: number;
  65378. sideOrientation?: number;
  65379. frontUVs?: Vector4;
  65380. backUVs?: Vector4;
  65381. }, scene?: Nullable<Scene>): Mesh;
  65382. /**
  65383. * Creates a torus mesh
  65384. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65385. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65386. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65388. * * 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
  65389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65390. * @param name defines the name of the mesh
  65391. * @param options defines the options used to create the mesh
  65392. * @param scene defines the hosting scene
  65393. * @returns the torus mesh
  65394. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65395. */
  65396. static CreateTorus(name: string, options: {
  65397. diameter?: number;
  65398. thickness?: number;
  65399. tessellation?: number;
  65400. updatable?: boolean;
  65401. sideOrientation?: number;
  65402. frontUVs?: Vector4;
  65403. backUVs?: Vector4;
  65404. }, scene?: Nullable<Scene>): Mesh;
  65405. /**
  65406. * Creates a torus knot mesh
  65407. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65408. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65409. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65410. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65412. * * 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
  65413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65414. * @param name defines the name of the mesh
  65415. * @param options defines the options used to create the mesh
  65416. * @param scene defines the hosting scene
  65417. * @returns the torus knot mesh
  65418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65419. */
  65420. static CreateTorusKnot(name: string, options: {
  65421. radius?: number;
  65422. tube?: number;
  65423. radialSegments?: number;
  65424. tubularSegments?: number;
  65425. p?: number;
  65426. q?: number;
  65427. updatable?: boolean;
  65428. sideOrientation?: number;
  65429. frontUVs?: Vector4;
  65430. backUVs?: Vector4;
  65431. }, scene?: Nullable<Scene>): Mesh;
  65432. /**
  65433. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65434. * * 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
  65435. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65436. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65437. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65438. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65439. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65440. * * 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
  65441. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65444. * @param name defines the name of the new line system
  65445. * @param options defines the options used to create the line system
  65446. * @param scene defines the hosting scene
  65447. * @returns a new line system mesh
  65448. */
  65449. static CreateLineSystem(name: string, options: {
  65450. lines: Vector3[][];
  65451. updatable?: boolean;
  65452. instance?: Nullable<LinesMesh>;
  65453. colors?: Nullable<Color4[][]>;
  65454. useVertexAlpha?: boolean;
  65455. }, scene: Nullable<Scene>): LinesMesh;
  65456. /**
  65457. * Creates a line mesh
  65458. * 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
  65459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65460. * * The parameter `points` is an array successive Vector3
  65461. * * 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
  65462. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65463. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65464. * * When updating an instance, remember that only point positions can change, not the number of points
  65465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65467. * @param name defines the name of the new line system
  65468. * @param options defines the options used to create the line system
  65469. * @param scene defines the hosting scene
  65470. * @returns a new line mesh
  65471. */
  65472. static CreateLines(name: string, options: {
  65473. points: Vector3[];
  65474. updatable?: boolean;
  65475. instance?: Nullable<LinesMesh>;
  65476. colors?: Color4[];
  65477. useVertexAlpha?: boolean;
  65478. }, scene?: Nullable<Scene>): LinesMesh;
  65479. /**
  65480. * Creates a dashed line mesh
  65481. * * 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
  65482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65483. * * The parameter `points` is an array successive Vector3
  65484. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65485. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65486. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65487. * * 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
  65488. * * When updating an instance, remember that only point positions can change, not the number of points
  65489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65490. * @param name defines the name of the mesh
  65491. * @param options defines the options used to create the mesh
  65492. * @param scene defines the hosting scene
  65493. * @returns the dashed line mesh
  65494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65495. */
  65496. static CreateDashedLines(name: string, options: {
  65497. points: Vector3[];
  65498. dashSize?: number;
  65499. gapSize?: number;
  65500. dashNb?: number;
  65501. updatable?: boolean;
  65502. instance?: LinesMesh;
  65503. }, scene?: Nullable<Scene>): LinesMesh;
  65504. /**
  65505. * 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.
  65506. * * 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.
  65507. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65508. * * 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.
  65509. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65510. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  65511. * * The optional parameter `instance` is an instance of an existing 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
  65512. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65514. * * 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
  65515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65517. * @param name defines the name of the mesh
  65518. * @param options defines the options used to create the mesh
  65519. * @param scene defines the hosting scene
  65520. * @returns the extruded shape mesh
  65521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65523. */
  65524. static ExtrudeShape(name: string, options: {
  65525. shape: Vector3[];
  65526. path: Vector3[];
  65527. scale?: number;
  65528. rotation?: number;
  65529. cap?: number;
  65530. updatable?: boolean;
  65531. sideOrientation?: number;
  65532. frontUVs?: Vector4;
  65533. backUVs?: Vector4;
  65534. instance?: Mesh;
  65535. invertUV?: boolean;
  65536. }, scene?: Nullable<Scene>): Mesh;
  65537. /**
  65538. * Creates an custom extruded shape mesh.
  65539. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65540. * * 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.
  65541. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65542. * * 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
  65543. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65544. * * 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
  65545. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65546. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65547. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65548. * * 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
  65549. * * 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
  65550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65552. * * 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
  65553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65555. * @param name defines the name of the mesh
  65556. * @param options defines the options used to create the mesh
  65557. * @param scene defines the hosting scene
  65558. * @returns the custom extruded shape mesh
  65559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65562. */
  65563. static ExtrudeShapeCustom(name: string, options: {
  65564. shape: Vector3[];
  65565. path: Vector3[];
  65566. scaleFunction?: any;
  65567. rotationFunction?: any;
  65568. ribbonCloseArray?: boolean;
  65569. ribbonClosePath?: boolean;
  65570. cap?: number;
  65571. updatable?: boolean;
  65572. sideOrientation?: number;
  65573. frontUVs?: Vector4;
  65574. backUVs?: Vector4;
  65575. instance?: Mesh;
  65576. invertUV?: boolean;
  65577. }, scene?: Nullable<Scene>): Mesh;
  65578. /**
  65579. * Creates lathe mesh.
  65580. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65581. * * 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
  65582. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65583. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65584. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65585. * * 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
  65586. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65587. * * 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
  65588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65589. * * 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
  65590. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65592. * @param name defines the name of the mesh
  65593. * @param options defines the options used to create the mesh
  65594. * @param scene defines the hosting scene
  65595. * @returns the lathe mesh
  65596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65597. */
  65598. static CreateLathe(name: string, options: {
  65599. shape: Vector3[];
  65600. radius?: number;
  65601. tessellation?: number;
  65602. clip?: number;
  65603. arc?: number;
  65604. closed?: boolean;
  65605. updatable?: boolean;
  65606. sideOrientation?: number;
  65607. frontUVs?: Vector4;
  65608. backUVs?: Vector4;
  65609. cap?: number;
  65610. invertUV?: boolean;
  65611. }, scene?: Nullable<Scene>): Mesh;
  65612. /**
  65613. * Creates a tiled plane mesh
  65614. * * You can set a limited pattern arrangement with the tiles
  65615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65618. * @param name defines the name of the mesh
  65619. * @param options defines the options used to create the mesh
  65620. * @param scene defines the hosting scene
  65621. * @returns the plane mesh
  65622. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65623. */
  65624. static CreateTiledPlane(name: string, options: {
  65625. pattern?: number;
  65626. tileSize?: number;
  65627. tileWidth?: number;
  65628. tileHeight?: number;
  65629. size?: number;
  65630. width?: number;
  65631. height?: number;
  65632. alignHorizontal?: number;
  65633. alignVertical?: number;
  65634. sideOrientation?: number;
  65635. frontUVs?: Vector4;
  65636. backUVs?: Vector4;
  65637. updatable?: boolean;
  65638. }, scene?: Nullable<Scene>): Mesh;
  65639. /**
  65640. * Creates a plane mesh
  65641. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65642. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65643. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65645. * * 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
  65646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65647. * @param name defines the name of the mesh
  65648. * @param options defines the options used to create the mesh
  65649. * @param scene defines the hosting scene
  65650. * @returns the plane mesh
  65651. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65652. */
  65653. static CreatePlane(name: string, options: {
  65654. size?: number;
  65655. width?: number;
  65656. height?: number;
  65657. sideOrientation?: number;
  65658. frontUVs?: Vector4;
  65659. backUVs?: Vector4;
  65660. updatable?: boolean;
  65661. sourcePlane?: Plane;
  65662. }, scene?: Nullable<Scene>): Mesh;
  65663. /**
  65664. * Creates a ground mesh
  65665. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65666. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65668. * @param name defines the name of the mesh
  65669. * @param options defines the options used to create the mesh
  65670. * @param scene defines the hosting scene
  65671. * @returns the ground mesh
  65672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65673. */
  65674. static CreateGround(name: string, options: {
  65675. width?: number;
  65676. height?: number;
  65677. subdivisions?: number;
  65678. subdivisionsX?: number;
  65679. subdivisionsY?: number;
  65680. updatable?: boolean;
  65681. }, scene?: Nullable<Scene>): Mesh;
  65682. /**
  65683. * Creates a tiled ground mesh
  65684. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65685. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65686. * * 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
  65687. * * 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
  65688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65689. * @param name defines the name of the mesh
  65690. * @param options defines the options used to create the mesh
  65691. * @param scene defines the hosting scene
  65692. * @returns the tiled ground mesh
  65693. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65694. */
  65695. static CreateTiledGround(name: string, options: {
  65696. xmin: number;
  65697. zmin: number;
  65698. xmax: number;
  65699. zmax: number;
  65700. subdivisions?: {
  65701. w: number;
  65702. h: number;
  65703. };
  65704. precision?: {
  65705. w: number;
  65706. h: number;
  65707. };
  65708. updatable?: boolean;
  65709. }, scene?: Nullable<Scene>): Mesh;
  65710. /**
  65711. * Creates a ground mesh from a height map
  65712. * * The parameter `url` sets the URL of the height map image resource.
  65713. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65714. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65715. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65716. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65717. * * 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.
  65718. * * 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).
  65719. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65721. * @param name defines the name of the mesh
  65722. * @param url defines the url to the height map
  65723. * @param options defines the options used to create the mesh
  65724. * @param scene defines the hosting scene
  65725. * @returns the ground mesh
  65726. * @see https://doc.babylonjs.com/babylon101/height_map
  65727. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65728. */
  65729. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65730. width?: number;
  65731. height?: number;
  65732. subdivisions?: number;
  65733. minHeight?: number;
  65734. maxHeight?: number;
  65735. colorFilter?: Color3;
  65736. alphaFilter?: number;
  65737. updatable?: boolean;
  65738. onReady?: (mesh: GroundMesh) => void;
  65739. }, scene?: Nullable<Scene>): GroundMesh;
  65740. /**
  65741. * Creates a polygon mesh
  65742. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65743. * * 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
  65744. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65746. * * 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)
  65747. * * Remember you can only change the shape positions, not their number when updating a polygon
  65748. * @param name defines the name of the mesh
  65749. * @param options defines the options used to create the mesh
  65750. * @param scene defines the hosting scene
  65751. * @param earcutInjection can be used to inject your own earcut reference
  65752. * @returns the polygon mesh
  65753. */
  65754. static CreatePolygon(name: string, options: {
  65755. shape: Vector3[];
  65756. holes?: Vector3[][];
  65757. depth?: number;
  65758. faceUV?: Vector4[];
  65759. faceColors?: Color4[];
  65760. updatable?: boolean;
  65761. sideOrientation?: number;
  65762. frontUVs?: Vector4;
  65763. backUVs?: Vector4;
  65764. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65765. /**
  65766. * Creates an extruded polygon mesh, with depth in the Y direction.
  65767. * * 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)
  65768. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65769. * @param name defines the name of the mesh
  65770. * @param options defines the options used to create the mesh
  65771. * @param scene defines the hosting scene
  65772. * @param earcutInjection can be used to inject your own earcut reference
  65773. * @returns the polygon mesh
  65774. */
  65775. static ExtrudePolygon(name: string, options: {
  65776. shape: Vector3[];
  65777. holes?: Vector3[][];
  65778. depth?: number;
  65779. faceUV?: Vector4[];
  65780. faceColors?: Color4[];
  65781. updatable?: boolean;
  65782. sideOrientation?: number;
  65783. frontUVs?: Vector4;
  65784. backUVs?: Vector4;
  65785. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65786. /**
  65787. * Creates a tube mesh.
  65788. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65789. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65790. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65791. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65792. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65793. * * 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)
  65794. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65795. * * 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
  65796. * * 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
  65797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65801. * @param name defines the name of the mesh
  65802. * @param options defines the options used to create the mesh
  65803. * @param scene defines the hosting scene
  65804. * @returns the tube mesh
  65805. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65806. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65807. */
  65808. static CreateTube(name: string, options: {
  65809. path: Vector3[];
  65810. radius?: number;
  65811. tessellation?: number;
  65812. radiusFunction?: {
  65813. (i: number, distance: number): number;
  65814. };
  65815. cap?: number;
  65816. arc?: number;
  65817. updatable?: boolean;
  65818. sideOrientation?: number;
  65819. frontUVs?: Vector4;
  65820. backUVs?: Vector4;
  65821. instance?: Mesh;
  65822. invertUV?: boolean;
  65823. }, scene?: Nullable<Scene>): Mesh;
  65824. /**
  65825. * Creates a polyhedron mesh
  65826. * * 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
  65827. * * The parameter `size` (positive float, default 1) sets the polygon size
  65828. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65829. * * 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`
  65830. * * 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
  65831. * * 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)`)
  65832. * * 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
  65833. * * 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
  65834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65835. * * 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
  65836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65837. * @param name defines the name of the mesh
  65838. * @param options defines the options used to create the mesh
  65839. * @param scene defines the hosting scene
  65840. * @returns the polyhedron mesh
  65841. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65842. */
  65843. static CreatePolyhedron(name: string, options: {
  65844. type?: number;
  65845. size?: number;
  65846. sizeX?: number;
  65847. sizeY?: number;
  65848. sizeZ?: number;
  65849. custom?: any;
  65850. faceUV?: Vector4[];
  65851. faceColors?: Color4[];
  65852. flat?: boolean;
  65853. updatable?: boolean;
  65854. sideOrientation?: number;
  65855. frontUVs?: Vector4;
  65856. backUVs?: Vector4;
  65857. }, scene?: Nullable<Scene>): Mesh;
  65858. /**
  65859. * Creates a decal mesh.
  65860. * 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
  65861. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65862. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65863. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65864. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65865. * @param name defines the name of the mesh
  65866. * @param sourceMesh defines the mesh where the decal must be applied
  65867. * @param options defines the options used to create the mesh
  65868. * @param scene defines the hosting scene
  65869. * @returns the decal mesh
  65870. * @see https://doc.babylonjs.com/how_to/decals
  65871. */
  65872. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65873. position?: Vector3;
  65874. normal?: Vector3;
  65875. size?: Vector3;
  65876. angle?: number;
  65877. }): Mesh;
  65878. }
  65879. }
  65880. declare module BABYLON {
  65881. /**
  65882. * A simplifier interface for future simplification implementations
  65883. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65884. */
  65885. export interface ISimplifier {
  65886. /**
  65887. * Simplification of a given mesh according to the given settings.
  65888. * Since this requires computation, it is assumed that the function runs async.
  65889. * @param settings The settings of the simplification, including quality and distance
  65890. * @param successCallback A callback that will be called after the mesh was simplified.
  65891. * @param errorCallback in case of an error, this callback will be called. optional.
  65892. */
  65893. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65894. }
  65895. /**
  65896. * Expected simplification settings.
  65897. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65898. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65899. */
  65900. export interface ISimplificationSettings {
  65901. /**
  65902. * Gets or sets the expected quality
  65903. */
  65904. quality: number;
  65905. /**
  65906. * Gets or sets the distance when this optimized version should be used
  65907. */
  65908. distance: number;
  65909. /**
  65910. * Gets an already optimized mesh
  65911. */
  65912. optimizeMesh?: boolean;
  65913. }
  65914. /**
  65915. * Class used to specify simplification options
  65916. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65917. */
  65918. export class SimplificationSettings implements ISimplificationSettings {
  65919. /** expected quality */
  65920. quality: number;
  65921. /** distance when this optimized version should be used */
  65922. distance: number;
  65923. /** already optimized mesh */
  65924. optimizeMesh?: boolean | undefined;
  65925. /**
  65926. * Creates a SimplificationSettings
  65927. * @param quality expected quality
  65928. * @param distance distance when this optimized version should be used
  65929. * @param optimizeMesh already optimized mesh
  65930. */
  65931. constructor(
  65932. /** expected quality */
  65933. quality: number,
  65934. /** distance when this optimized version should be used */
  65935. distance: number,
  65936. /** already optimized mesh */
  65937. optimizeMesh?: boolean | undefined);
  65938. }
  65939. /**
  65940. * Interface used to define a simplification task
  65941. */
  65942. export interface ISimplificationTask {
  65943. /**
  65944. * Array of settings
  65945. */
  65946. settings: Array<ISimplificationSettings>;
  65947. /**
  65948. * Simplification type
  65949. */
  65950. simplificationType: SimplificationType;
  65951. /**
  65952. * Mesh to simplify
  65953. */
  65954. mesh: Mesh;
  65955. /**
  65956. * Callback called on success
  65957. */
  65958. successCallback?: () => void;
  65959. /**
  65960. * Defines if parallel processing can be used
  65961. */
  65962. parallelProcessing: boolean;
  65963. }
  65964. /**
  65965. * Queue used to order the simplification tasks
  65966. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65967. */
  65968. export class SimplificationQueue {
  65969. private _simplificationArray;
  65970. /**
  65971. * Gets a boolean indicating that the process is still running
  65972. */
  65973. running: boolean;
  65974. /**
  65975. * Creates a new queue
  65976. */
  65977. constructor();
  65978. /**
  65979. * Adds a new simplification task
  65980. * @param task defines a task to add
  65981. */
  65982. addTask(task: ISimplificationTask): void;
  65983. /**
  65984. * Execute next task
  65985. */
  65986. executeNext(): void;
  65987. /**
  65988. * Execute a simplification task
  65989. * @param task defines the task to run
  65990. */
  65991. runSimplification(task: ISimplificationTask): void;
  65992. private getSimplifier;
  65993. }
  65994. /**
  65995. * The implemented types of simplification
  65996. * At the moment only Quadratic Error Decimation is implemented
  65997. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65998. */
  65999. export enum SimplificationType {
  66000. /** Quadratic error decimation */
  66001. QUADRATIC = 0
  66002. }
  66003. /**
  66004. * An implementation of the Quadratic Error simplification algorithm.
  66005. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66006. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66007. * @author RaananW
  66008. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66009. */
  66010. export class QuadraticErrorSimplification implements ISimplifier {
  66011. private _mesh;
  66012. private triangles;
  66013. private vertices;
  66014. private references;
  66015. private _reconstructedMesh;
  66016. /** Gets or sets the number pf sync interations */
  66017. syncIterations: number;
  66018. /** Gets or sets the aggressiveness of the simplifier */
  66019. aggressiveness: number;
  66020. /** Gets or sets the number of allowed iterations for decimation */
  66021. decimationIterations: number;
  66022. /** Gets or sets the espilon to use for bounding box computation */
  66023. boundingBoxEpsilon: number;
  66024. /**
  66025. * Creates a new QuadraticErrorSimplification
  66026. * @param _mesh defines the target mesh
  66027. */
  66028. constructor(_mesh: Mesh);
  66029. /**
  66030. * Simplification of a given mesh according to the given settings.
  66031. * Since this requires computation, it is assumed that the function runs async.
  66032. * @param settings The settings of the simplification, including quality and distance
  66033. * @param successCallback A callback that will be called after the mesh was simplified.
  66034. */
  66035. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66036. private runDecimation;
  66037. private initWithMesh;
  66038. private init;
  66039. private reconstructMesh;
  66040. private initDecimatedMesh;
  66041. private isFlipped;
  66042. private updateTriangles;
  66043. private identifyBorder;
  66044. private updateMesh;
  66045. private vertexError;
  66046. private calculateError;
  66047. }
  66048. }
  66049. declare module BABYLON {
  66050. interface Scene {
  66051. /** @hidden (Backing field) */
  66052. _simplificationQueue: SimplificationQueue;
  66053. /**
  66054. * Gets or sets the simplification queue attached to the scene
  66055. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66056. */
  66057. simplificationQueue: SimplificationQueue;
  66058. }
  66059. interface Mesh {
  66060. /**
  66061. * Simplify the mesh according to the given array of settings.
  66062. * Function will return immediately and will simplify async
  66063. * @param settings a collection of simplification settings
  66064. * @param parallelProcessing should all levels calculate parallel or one after the other
  66065. * @param simplificationType the type of simplification to run
  66066. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66067. * @returns the current mesh
  66068. */
  66069. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66070. }
  66071. /**
  66072. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66073. * created in a scene
  66074. */
  66075. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66076. /**
  66077. * The component name helpfull to identify the component in the list of scene components.
  66078. */
  66079. readonly name: string;
  66080. /**
  66081. * The scene the component belongs to.
  66082. */
  66083. scene: Scene;
  66084. /**
  66085. * Creates a new instance of the component for the given scene
  66086. * @param scene Defines the scene to register the component in
  66087. */
  66088. constructor(scene: Scene);
  66089. /**
  66090. * Registers the component in a given scene
  66091. */
  66092. register(): void;
  66093. /**
  66094. * Rebuilds the elements related to this component in case of
  66095. * context lost for instance.
  66096. */
  66097. rebuild(): void;
  66098. /**
  66099. * Disposes the component and the associated ressources
  66100. */
  66101. dispose(): void;
  66102. private _beforeCameraUpdate;
  66103. }
  66104. }
  66105. declare module BABYLON {
  66106. interface Mesh {
  66107. /**
  66108. * Creates a new thin instance
  66109. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66110. * @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
  66111. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66112. */
  66113. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66114. /**
  66115. * Adds the transformation (matrix) of the current mesh as a thin instance
  66116. * @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
  66117. * @returns the thin instance index number
  66118. */
  66119. thinInstanceAddSelf(refresh: boolean): number;
  66120. /**
  66121. * Registers a custom attribute to be used with thin instances
  66122. * @param kind name of the attribute
  66123. * @param stride size in floats of the attribute
  66124. */
  66125. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66126. /**
  66127. * Sets the matrix of a thin instance
  66128. * @param index index of the thin instance
  66129. * @param matrix matrix to set
  66130. * @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
  66131. */
  66132. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66133. /**
  66134. * Sets the value of a custom attribute for a thin instance
  66135. * @param kind name of the attribute
  66136. * @param index index of the thin instance
  66137. * @param value value to set
  66138. * @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
  66139. */
  66140. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66141. /**
  66142. * 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.
  66143. */
  66144. thinInstanceCount: number;
  66145. /**
  66146. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66147. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66148. * @param buffer buffer to set
  66149. * @param stride size in floats of each value of the buffer
  66150. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66151. */
  66152. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66153. /**
  66154. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66155. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66156. */
  66157. thinInstanceBufferUpdated(kind: string): void;
  66158. /**
  66159. * Refreshes the bounding info, taking into account all the thin instances defined
  66160. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66161. */
  66162. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66163. /** @hidden */
  66164. _thinInstanceInitializeUserStorage(): void;
  66165. /** @hidden */
  66166. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66167. /** @hidden */
  66168. _userThinInstanceBuffersStorage: {
  66169. data: {
  66170. [key: string]: Float32Array;
  66171. };
  66172. sizes: {
  66173. [key: string]: number;
  66174. };
  66175. vertexBuffers: {
  66176. [key: string]: Nullable<VertexBuffer>;
  66177. };
  66178. strides: {
  66179. [key: string]: number;
  66180. };
  66181. };
  66182. }
  66183. }
  66184. declare module BABYLON {
  66185. /**
  66186. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66187. */
  66188. export interface INavigationEnginePlugin {
  66189. /**
  66190. * plugin name
  66191. */
  66192. name: string;
  66193. /**
  66194. * Creates a navigation mesh
  66195. * @param meshes array of all the geometry used to compute the navigatio mesh
  66196. * @param parameters bunch of parameters used to filter geometry
  66197. */
  66198. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66199. /**
  66200. * Create a navigation mesh debug mesh
  66201. * @param scene is where the mesh will be added
  66202. * @returns debug display mesh
  66203. */
  66204. createDebugNavMesh(scene: Scene): Mesh;
  66205. /**
  66206. * Get a navigation mesh constrained position, closest to the parameter position
  66207. * @param position world position
  66208. * @returns the closest point to position constrained by the navigation mesh
  66209. */
  66210. getClosestPoint(position: Vector3): Vector3;
  66211. /**
  66212. * Get a navigation mesh constrained position, closest to the parameter position
  66213. * @param position world position
  66214. * @param result output the closest point to position constrained by the navigation mesh
  66215. */
  66216. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66217. /**
  66218. * Get a navigation mesh constrained position, within a particular radius
  66219. * @param position world position
  66220. * @param maxRadius the maximum distance to the constrained world position
  66221. * @returns the closest point to position constrained by the navigation mesh
  66222. */
  66223. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66224. /**
  66225. * Get a navigation mesh constrained position, within a particular radius
  66226. * @param position world position
  66227. * @param maxRadius the maximum distance to the constrained world position
  66228. * @param result output the closest point to position constrained by the navigation mesh
  66229. */
  66230. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66231. /**
  66232. * Compute the final position from a segment made of destination-position
  66233. * @param position world position
  66234. * @param destination world position
  66235. * @returns the resulting point along the navmesh
  66236. */
  66237. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66238. /**
  66239. * Compute the final position from a segment made of destination-position
  66240. * @param position world position
  66241. * @param destination world position
  66242. * @param result output the resulting point along the navmesh
  66243. */
  66244. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66245. /**
  66246. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66247. * @param start world position
  66248. * @param end world position
  66249. * @returns array containing world position composing the path
  66250. */
  66251. computePath(start: Vector3, end: Vector3): Vector3[];
  66252. /**
  66253. * If this plugin is supported
  66254. * @returns true if plugin is supported
  66255. */
  66256. isSupported(): boolean;
  66257. /**
  66258. * Create a new Crowd so you can add agents
  66259. * @param maxAgents the maximum agent count in the crowd
  66260. * @param maxAgentRadius the maximum radius an agent can have
  66261. * @param scene to attach the crowd to
  66262. * @returns the crowd you can add agents to
  66263. */
  66264. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66265. /**
  66266. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66267. * The queries will try to find a solution within those bounds
  66268. * default is (1,1,1)
  66269. * @param extent x,y,z value that define the extent around the queries point of reference
  66270. */
  66271. setDefaultQueryExtent(extent: Vector3): void;
  66272. /**
  66273. * Get the Bounding box extent specified by setDefaultQueryExtent
  66274. * @returns the box extent values
  66275. */
  66276. getDefaultQueryExtent(): Vector3;
  66277. /**
  66278. * build the navmesh from a previously saved state using getNavmeshData
  66279. * @param data the Uint8Array returned by getNavmeshData
  66280. */
  66281. buildFromNavmeshData(data: Uint8Array): void;
  66282. /**
  66283. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66284. * @returns data the Uint8Array that can be saved and reused
  66285. */
  66286. getNavmeshData(): Uint8Array;
  66287. /**
  66288. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66289. * @param result output the box extent values
  66290. */
  66291. getDefaultQueryExtentToRef(result: Vector3): void;
  66292. /**
  66293. * Release all resources
  66294. */
  66295. dispose(): void;
  66296. }
  66297. /**
  66298. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66299. */
  66300. export interface ICrowd {
  66301. /**
  66302. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66303. * You can attach anything to that node. The node position is updated in the scene update tick.
  66304. * @param pos world position that will be constrained by the navigation mesh
  66305. * @param parameters agent parameters
  66306. * @param transform hooked to the agent that will be update by the scene
  66307. * @returns agent index
  66308. */
  66309. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66310. /**
  66311. * Returns the agent position in world space
  66312. * @param index agent index returned by addAgent
  66313. * @returns world space position
  66314. */
  66315. getAgentPosition(index: number): Vector3;
  66316. /**
  66317. * Gets the agent position result in world space
  66318. * @param index agent index returned by addAgent
  66319. * @param result output world space position
  66320. */
  66321. getAgentPositionToRef(index: number, result: Vector3): void;
  66322. /**
  66323. * Gets the agent velocity in world space
  66324. * @param index agent index returned by addAgent
  66325. * @returns world space velocity
  66326. */
  66327. getAgentVelocity(index: number): Vector3;
  66328. /**
  66329. * Gets the agent velocity result in world space
  66330. * @param index agent index returned by addAgent
  66331. * @param result output world space velocity
  66332. */
  66333. getAgentVelocityToRef(index: number, result: Vector3): void;
  66334. /**
  66335. * remove a particular agent previously created
  66336. * @param index agent index returned by addAgent
  66337. */
  66338. removeAgent(index: number): void;
  66339. /**
  66340. * get the list of all agents attached to this crowd
  66341. * @returns list of agent indices
  66342. */
  66343. getAgents(): number[];
  66344. /**
  66345. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66346. * @param deltaTime in seconds
  66347. */
  66348. update(deltaTime: number): void;
  66349. /**
  66350. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66351. * @param index agent index returned by addAgent
  66352. * @param destination targeted world position
  66353. */
  66354. agentGoto(index: number, destination: Vector3): void;
  66355. /**
  66356. * Teleport the agent to a new position
  66357. * @param index agent index returned by addAgent
  66358. * @param destination targeted world position
  66359. */
  66360. agentTeleport(index: number, destination: Vector3): void;
  66361. /**
  66362. * Update agent parameters
  66363. * @param index agent index returned by addAgent
  66364. * @param parameters agent parameters
  66365. */
  66366. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66367. /**
  66368. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66369. * The queries will try to find a solution within those bounds
  66370. * default is (1,1,1)
  66371. * @param extent x,y,z value that define the extent around the queries point of reference
  66372. */
  66373. setDefaultQueryExtent(extent: Vector3): void;
  66374. /**
  66375. * Get the Bounding box extent specified by setDefaultQueryExtent
  66376. * @returns the box extent values
  66377. */
  66378. getDefaultQueryExtent(): Vector3;
  66379. /**
  66380. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66381. * @param result output the box extent values
  66382. */
  66383. getDefaultQueryExtentToRef(result: Vector3): void;
  66384. /**
  66385. * Release all resources
  66386. */
  66387. dispose(): void;
  66388. }
  66389. /**
  66390. * Configures an agent
  66391. */
  66392. export interface IAgentParameters {
  66393. /**
  66394. * Agent radius. [Limit: >= 0]
  66395. */
  66396. radius: number;
  66397. /**
  66398. * Agent height. [Limit: > 0]
  66399. */
  66400. height: number;
  66401. /**
  66402. * Maximum allowed acceleration. [Limit: >= 0]
  66403. */
  66404. maxAcceleration: number;
  66405. /**
  66406. * Maximum allowed speed. [Limit: >= 0]
  66407. */
  66408. maxSpeed: number;
  66409. /**
  66410. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66411. */
  66412. collisionQueryRange: number;
  66413. /**
  66414. * The path visibility optimization range. [Limit: > 0]
  66415. */
  66416. pathOptimizationRange: number;
  66417. /**
  66418. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66419. */
  66420. separationWeight: number;
  66421. }
  66422. /**
  66423. * Configures the navigation mesh creation
  66424. */
  66425. export interface INavMeshParameters {
  66426. /**
  66427. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66428. */
  66429. cs: number;
  66430. /**
  66431. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66432. */
  66433. ch: number;
  66434. /**
  66435. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66436. */
  66437. walkableSlopeAngle: number;
  66438. /**
  66439. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66440. * be considered walkable. [Limit: >= 3] [Units: vx]
  66441. */
  66442. walkableHeight: number;
  66443. /**
  66444. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66445. */
  66446. walkableClimb: number;
  66447. /**
  66448. * The distance to erode/shrink the walkable area of the heightfield away from
  66449. * obstructions. [Limit: >=0] [Units: vx]
  66450. */
  66451. walkableRadius: number;
  66452. /**
  66453. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66454. */
  66455. maxEdgeLen: number;
  66456. /**
  66457. * The maximum distance a simplfied contour's border edges should deviate
  66458. * the original raw contour. [Limit: >=0] [Units: vx]
  66459. */
  66460. maxSimplificationError: number;
  66461. /**
  66462. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66463. */
  66464. minRegionArea: number;
  66465. /**
  66466. * Any regions with a span count smaller than this value will, if possible,
  66467. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66468. */
  66469. mergeRegionArea: number;
  66470. /**
  66471. * The maximum number of vertices allowed for polygons generated during the
  66472. * contour to polygon conversion process. [Limit: >= 3]
  66473. */
  66474. maxVertsPerPoly: number;
  66475. /**
  66476. * Sets the sampling distance to use when generating the detail mesh.
  66477. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66478. */
  66479. detailSampleDist: number;
  66480. /**
  66481. * The maximum distance the detail mesh surface should deviate from heightfield
  66482. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66483. */
  66484. detailSampleMaxError: number;
  66485. }
  66486. }
  66487. declare module BABYLON {
  66488. /**
  66489. * RecastJS navigation plugin
  66490. */
  66491. export class RecastJSPlugin implements INavigationEnginePlugin {
  66492. /**
  66493. * Reference to the Recast library
  66494. */
  66495. bjsRECAST: any;
  66496. /**
  66497. * plugin name
  66498. */
  66499. name: string;
  66500. /**
  66501. * the first navmesh created. We might extend this to support multiple navmeshes
  66502. */
  66503. navMesh: any;
  66504. /**
  66505. * Initializes the recastJS plugin
  66506. * @param recastInjection can be used to inject your own recast reference
  66507. */
  66508. constructor(recastInjection?: any);
  66509. /**
  66510. * Creates a navigation mesh
  66511. * @param meshes array of all the geometry used to compute the navigatio mesh
  66512. * @param parameters bunch of parameters used to filter geometry
  66513. */
  66514. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66515. /**
  66516. * Create a navigation mesh debug mesh
  66517. * @param scene is where the mesh will be added
  66518. * @returns debug display mesh
  66519. */
  66520. createDebugNavMesh(scene: Scene): Mesh;
  66521. /**
  66522. * Get a navigation mesh constrained position, closest to the parameter position
  66523. * @param position world position
  66524. * @returns the closest point to position constrained by the navigation mesh
  66525. */
  66526. getClosestPoint(position: Vector3): Vector3;
  66527. /**
  66528. * Get a navigation mesh constrained position, closest to the parameter position
  66529. * @param position world position
  66530. * @param result output the closest point to position constrained by the navigation mesh
  66531. */
  66532. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66533. /**
  66534. * Get a navigation mesh constrained position, within a particular radius
  66535. * @param position world position
  66536. * @param maxRadius the maximum distance to the constrained world position
  66537. * @returns the closest point to position constrained by the navigation mesh
  66538. */
  66539. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66540. /**
  66541. * Get a navigation mesh constrained position, within a particular radius
  66542. * @param position world position
  66543. * @param maxRadius the maximum distance to the constrained world position
  66544. * @param result output the closest point to position constrained by the navigation mesh
  66545. */
  66546. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66547. /**
  66548. * Compute the final position from a segment made of destination-position
  66549. * @param position world position
  66550. * @param destination world position
  66551. * @returns the resulting point along the navmesh
  66552. */
  66553. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66554. /**
  66555. * Compute the final position from a segment made of destination-position
  66556. * @param position world position
  66557. * @param destination world position
  66558. * @param result output the resulting point along the navmesh
  66559. */
  66560. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66561. /**
  66562. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66563. * @param start world position
  66564. * @param end world position
  66565. * @returns array containing world position composing the path
  66566. */
  66567. computePath(start: Vector3, end: Vector3): Vector3[];
  66568. /**
  66569. * Create a new Crowd so you can add agents
  66570. * @param maxAgents the maximum agent count in the crowd
  66571. * @param maxAgentRadius the maximum radius an agent can have
  66572. * @param scene to attach the crowd to
  66573. * @returns the crowd you can add agents to
  66574. */
  66575. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66576. /**
  66577. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66578. * The queries will try to find a solution within those bounds
  66579. * default is (1,1,1)
  66580. * @param extent x,y,z value that define the extent around the queries point of reference
  66581. */
  66582. setDefaultQueryExtent(extent: Vector3): void;
  66583. /**
  66584. * Get the Bounding box extent specified by setDefaultQueryExtent
  66585. * @returns the box extent values
  66586. */
  66587. getDefaultQueryExtent(): Vector3;
  66588. /**
  66589. * build the navmesh from a previously saved state using getNavmeshData
  66590. * @param data the Uint8Array returned by getNavmeshData
  66591. */
  66592. buildFromNavmeshData(data: Uint8Array): void;
  66593. /**
  66594. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66595. * @returns data the Uint8Array that can be saved and reused
  66596. */
  66597. getNavmeshData(): Uint8Array;
  66598. /**
  66599. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66600. * @param result output the box extent values
  66601. */
  66602. getDefaultQueryExtentToRef(result: Vector3): void;
  66603. /**
  66604. * Disposes
  66605. */
  66606. dispose(): void;
  66607. /**
  66608. * If this plugin is supported
  66609. * @returns true if plugin is supported
  66610. */
  66611. isSupported(): boolean;
  66612. }
  66613. /**
  66614. * Recast detour crowd implementation
  66615. */
  66616. export class RecastJSCrowd implements ICrowd {
  66617. /**
  66618. * Recast/detour plugin
  66619. */
  66620. bjsRECASTPlugin: RecastJSPlugin;
  66621. /**
  66622. * Link to the detour crowd
  66623. */
  66624. recastCrowd: any;
  66625. /**
  66626. * One transform per agent
  66627. */
  66628. transforms: TransformNode[];
  66629. /**
  66630. * All agents created
  66631. */
  66632. agents: number[];
  66633. /**
  66634. * Link to the scene is kept to unregister the crowd from the scene
  66635. */
  66636. private _scene;
  66637. /**
  66638. * Observer for crowd updates
  66639. */
  66640. private _onBeforeAnimationsObserver;
  66641. /**
  66642. * Constructor
  66643. * @param plugin recastJS plugin
  66644. * @param maxAgents the maximum agent count in the crowd
  66645. * @param maxAgentRadius the maximum radius an agent can have
  66646. * @param scene to attach the crowd to
  66647. * @returns the crowd you can add agents to
  66648. */
  66649. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66650. /**
  66651. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66652. * You can attach anything to that node. The node position is updated in the scene update tick.
  66653. * @param pos world position that will be constrained by the navigation mesh
  66654. * @param parameters agent parameters
  66655. * @param transform hooked to the agent that will be update by the scene
  66656. * @returns agent index
  66657. */
  66658. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66659. /**
  66660. * Returns the agent position in world space
  66661. * @param index agent index returned by addAgent
  66662. * @returns world space position
  66663. */
  66664. getAgentPosition(index: number): Vector3;
  66665. /**
  66666. * Returns the agent position result in world space
  66667. * @param index agent index returned by addAgent
  66668. * @param result output world space position
  66669. */
  66670. getAgentPositionToRef(index: number, result: Vector3): void;
  66671. /**
  66672. * Returns the agent velocity in world space
  66673. * @param index agent index returned by addAgent
  66674. * @returns world space velocity
  66675. */
  66676. getAgentVelocity(index: number): Vector3;
  66677. /**
  66678. * Returns the agent velocity result in world space
  66679. * @param index agent index returned by addAgent
  66680. * @param result output world space velocity
  66681. */
  66682. getAgentVelocityToRef(index: number, result: Vector3): void;
  66683. /**
  66684. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66685. * @param index agent index returned by addAgent
  66686. * @param destination targeted world position
  66687. */
  66688. agentGoto(index: number, destination: Vector3): void;
  66689. /**
  66690. * Teleport the agent to a new position
  66691. * @param index agent index returned by addAgent
  66692. * @param destination targeted world position
  66693. */
  66694. agentTeleport(index: number, destination: Vector3): void;
  66695. /**
  66696. * Update agent parameters
  66697. * @param index agent index returned by addAgent
  66698. * @param parameters agent parameters
  66699. */
  66700. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66701. /**
  66702. * remove a particular agent previously created
  66703. * @param index agent index returned by addAgent
  66704. */
  66705. removeAgent(index: number): void;
  66706. /**
  66707. * get the list of all agents attached to this crowd
  66708. * @returns list of agent indices
  66709. */
  66710. getAgents(): number[];
  66711. /**
  66712. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66713. * @param deltaTime in seconds
  66714. */
  66715. update(deltaTime: number): void;
  66716. /**
  66717. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66718. * The queries will try to find a solution within those bounds
  66719. * default is (1,1,1)
  66720. * @param extent x,y,z value that define the extent around the queries point of reference
  66721. */
  66722. setDefaultQueryExtent(extent: Vector3): void;
  66723. /**
  66724. * Get the Bounding box extent specified by setDefaultQueryExtent
  66725. * @returns the box extent values
  66726. */
  66727. getDefaultQueryExtent(): Vector3;
  66728. /**
  66729. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66730. * @param result output the box extent values
  66731. */
  66732. getDefaultQueryExtentToRef(result: Vector3): void;
  66733. /**
  66734. * Release all resources
  66735. */
  66736. dispose(): void;
  66737. }
  66738. }
  66739. declare module BABYLON {
  66740. /**
  66741. * Class used to enable access to IndexedDB
  66742. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66743. */
  66744. export class Database implements IOfflineProvider {
  66745. private _callbackManifestChecked;
  66746. private _currentSceneUrl;
  66747. private _db;
  66748. private _enableSceneOffline;
  66749. private _enableTexturesOffline;
  66750. private _manifestVersionFound;
  66751. private _mustUpdateRessources;
  66752. private _hasReachedQuota;
  66753. private _isSupported;
  66754. private _idbFactory;
  66755. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66756. private static IsUASupportingBlobStorage;
  66757. /**
  66758. * Gets a boolean indicating if Database storate is enabled (off by default)
  66759. */
  66760. static IDBStorageEnabled: boolean;
  66761. /**
  66762. * Gets a boolean indicating if scene must be saved in the database
  66763. */
  66764. get enableSceneOffline(): boolean;
  66765. /**
  66766. * Gets a boolean indicating if textures must be saved in the database
  66767. */
  66768. get enableTexturesOffline(): boolean;
  66769. /**
  66770. * Creates a new Database
  66771. * @param urlToScene defines the url to load the scene
  66772. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66773. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66774. */
  66775. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66776. private static _ParseURL;
  66777. private static _ReturnFullUrlLocation;
  66778. private _checkManifestFile;
  66779. /**
  66780. * Open the database and make it available
  66781. * @param successCallback defines the callback to call on success
  66782. * @param errorCallback defines the callback to call on error
  66783. */
  66784. open(successCallback: () => void, errorCallback: () => void): void;
  66785. /**
  66786. * Loads an image from the database
  66787. * @param url defines the url to load from
  66788. * @param image defines the target DOM image
  66789. */
  66790. loadImage(url: string, image: HTMLImageElement): void;
  66791. private _loadImageFromDBAsync;
  66792. private _saveImageIntoDBAsync;
  66793. private _checkVersionFromDB;
  66794. private _loadVersionFromDBAsync;
  66795. private _saveVersionIntoDBAsync;
  66796. /**
  66797. * Loads a file from database
  66798. * @param url defines the URL to load from
  66799. * @param sceneLoaded defines a callback to call on success
  66800. * @param progressCallBack defines a callback to call when progress changed
  66801. * @param errorCallback defines a callback to call on error
  66802. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66803. */
  66804. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66805. private _loadFileAsync;
  66806. private _saveFileAsync;
  66807. /**
  66808. * Validates if xhr data is correct
  66809. * @param xhr defines the request to validate
  66810. * @param dataType defines the expected data type
  66811. * @returns true if data is correct
  66812. */
  66813. private static _ValidateXHRData;
  66814. }
  66815. }
  66816. declare module BABYLON {
  66817. /** @hidden */
  66818. export var gpuUpdateParticlesPixelShader: {
  66819. name: string;
  66820. shader: string;
  66821. };
  66822. }
  66823. declare module BABYLON {
  66824. /** @hidden */
  66825. export var gpuUpdateParticlesVertexShader: {
  66826. name: string;
  66827. shader: string;
  66828. };
  66829. }
  66830. declare module BABYLON {
  66831. /** @hidden */
  66832. export var clipPlaneFragmentDeclaration2: {
  66833. name: string;
  66834. shader: string;
  66835. };
  66836. }
  66837. declare module BABYLON {
  66838. /** @hidden */
  66839. export var gpuRenderParticlesPixelShader: {
  66840. name: string;
  66841. shader: string;
  66842. };
  66843. }
  66844. declare module BABYLON {
  66845. /** @hidden */
  66846. export var clipPlaneVertexDeclaration2: {
  66847. name: string;
  66848. shader: string;
  66849. };
  66850. }
  66851. declare module BABYLON {
  66852. /** @hidden */
  66853. export var gpuRenderParticlesVertexShader: {
  66854. name: string;
  66855. shader: string;
  66856. };
  66857. }
  66858. declare module BABYLON {
  66859. /**
  66860. * This represents a GPU particle system in Babylon
  66861. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66862. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66863. */
  66864. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66865. /**
  66866. * The layer mask we are rendering the particles through.
  66867. */
  66868. layerMask: number;
  66869. private _capacity;
  66870. private _activeCount;
  66871. private _currentActiveCount;
  66872. private _accumulatedCount;
  66873. private _renderEffect;
  66874. private _updateEffect;
  66875. private _buffer0;
  66876. private _buffer1;
  66877. private _spriteBuffer;
  66878. private _updateVAO;
  66879. private _renderVAO;
  66880. private _targetIndex;
  66881. private _sourceBuffer;
  66882. private _targetBuffer;
  66883. private _engine;
  66884. private _currentRenderId;
  66885. private _started;
  66886. private _stopped;
  66887. private _timeDelta;
  66888. private _randomTexture;
  66889. private _randomTexture2;
  66890. private _attributesStrideSize;
  66891. private _updateEffectOptions;
  66892. private _randomTextureSize;
  66893. private _actualFrame;
  66894. private _customEffect;
  66895. private readonly _rawTextureWidth;
  66896. /**
  66897. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66898. */
  66899. static get IsSupported(): boolean;
  66900. /**
  66901. * An event triggered when the system is disposed.
  66902. */
  66903. onDisposeObservable: Observable<IParticleSystem>;
  66904. /**
  66905. * Gets the maximum number of particles active at the same time.
  66906. * @returns The max number of active particles.
  66907. */
  66908. getCapacity(): number;
  66909. /**
  66910. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66911. * to override the particles.
  66912. */
  66913. forceDepthWrite: boolean;
  66914. /**
  66915. * Gets or set the number of active particles
  66916. */
  66917. get activeParticleCount(): number;
  66918. set activeParticleCount(value: number);
  66919. private _preWarmDone;
  66920. /**
  66921. * Specifies if the particles are updated in emitter local space or world space.
  66922. */
  66923. isLocal: boolean;
  66924. /**
  66925. * Is this system ready to be used/rendered
  66926. * @return true if the system is ready
  66927. */
  66928. isReady(): boolean;
  66929. /**
  66930. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66931. * @returns True if it has been started, otherwise false.
  66932. */
  66933. isStarted(): boolean;
  66934. /**
  66935. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66936. * @returns True if it has been stopped, otherwise false.
  66937. */
  66938. isStopped(): boolean;
  66939. /**
  66940. * Gets a boolean indicating that the system is stopping
  66941. * @returns true if the system is currently stopping
  66942. */
  66943. isStopping(): boolean;
  66944. /**
  66945. * Gets the number of particles active at the same time.
  66946. * @returns The number of active particles.
  66947. */
  66948. getActiveCount(): number;
  66949. /**
  66950. * Starts the particle system and begins to emit
  66951. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66952. */
  66953. start(delay?: number): void;
  66954. /**
  66955. * Stops the particle system.
  66956. */
  66957. stop(): void;
  66958. /**
  66959. * Remove all active particles
  66960. */
  66961. reset(): void;
  66962. /**
  66963. * Returns the string "GPUParticleSystem"
  66964. * @returns a string containing the class name
  66965. */
  66966. getClassName(): string;
  66967. /**
  66968. * Gets the custom effect used to render the particles
  66969. * @param blendMode Blend mode for which the effect should be retrieved
  66970. * @returns The effect
  66971. */
  66972. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66973. /**
  66974. * Sets the custom effect used to render the particles
  66975. * @param effect The effect to set
  66976. * @param blendMode Blend mode for which the effect should be set
  66977. */
  66978. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66979. /** @hidden */
  66980. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66981. /**
  66982. * Observable that will be called just before the particles are drawn
  66983. */
  66984. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66985. /**
  66986. * Gets the name of the particle vertex shader
  66987. */
  66988. get vertexShaderName(): string;
  66989. private _colorGradientsTexture;
  66990. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66991. /**
  66992. * Adds a new color gradient
  66993. * @param gradient defines the gradient to use (between 0 and 1)
  66994. * @param color1 defines the color to affect to the specified gradient
  66995. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66996. * @returns the current particle system
  66997. */
  66998. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66999. private _refreshColorGradient;
  67000. /** Force the system to rebuild all gradients that need to be resync */
  67001. forceRefreshGradients(): void;
  67002. /**
  67003. * Remove a specific color gradient
  67004. * @param gradient defines the gradient to remove
  67005. * @returns the current particle system
  67006. */
  67007. removeColorGradient(gradient: number): GPUParticleSystem;
  67008. private _angularSpeedGradientsTexture;
  67009. private _sizeGradientsTexture;
  67010. private _velocityGradientsTexture;
  67011. private _limitVelocityGradientsTexture;
  67012. private _dragGradientsTexture;
  67013. private _addFactorGradient;
  67014. /**
  67015. * Adds a new size gradient
  67016. * @param gradient defines the gradient to use (between 0 and 1)
  67017. * @param factor defines the size factor to affect to the specified gradient
  67018. * @returns the current particle system
  67019. */
  67020. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67021. /**
  67022. * Remove a specific size gradient
  67023. * @param gradient defines the gradient to remove
  67024. * @returns the current particle system
  67025. */
  67026. removeSizeGradient(gradient: number): GPUParticleSystem;
  67027. private _refreshFactorGradient;
  67028. /**
  67029. * Adds a new angular speed gradient
  67030. * @param gradient defines the gradient to use (between 0 and 1)
  67031. * @param factor defines the angular speed to affect to the specified gradient
  67032. * @returns the current particle system
  67033. */
  67034. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67035. /**
  67036. * Remove a specific angular speed gradient
  67037. * @param gradient defines the gradient to remove
  67038. * @returns the current particle system
  67039. */
  67040. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67041. /**
  67042. * Adds a new velocity gradient
  67043. * @param gradient defines the gradient to use (between 0 and 1)
  67044. * @param factor defines the velocity to affect to the specified gradient
  67045. * @returns the current particle system
  67046. */
  67047. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67048. /**
  67049. * Remove a specific velocity gradient
  67050. * @param gradient defines the gradient to remove
  67051. * @returns the current particle system
  67052. */
  67053. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67054. /**
  67055. * Adds a new limit velocity gradient
  67056. * @param gradient defines the gradient to use (between 0 and 1)
  67057. * @param factor defines the limit velocity value to affect to the specified gradient
  67058. * @returns the current particle system
  67059. */
  67060. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67061. /**
  67062. * Remove a specific limit velocity gradient
  67063. * @param gradient defines the gradient to remove
  67064. * @returns the current particle system
  67065. */
  67066. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67067. /**
  67068. * Adds a new drag gradient
  67069. * @param gradient defines the gradient to use (between 0 and 1)
  67070. * @param factor defines the drag value to affect to the specified gradient
  67071. * @returns the current particle system
  67072. */
  67073. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67074. /**
  67075. * Remove a specific drag gradient
  67076. * @param gradient defines the gradient to remove
  67077. * @returns the current particle system
  67078. */
  67079. removeDragGradient(gradient: number): GPUParticleSystem;
  67080. /**
  67081. * Not supported by GPUParticleSystem
  67082. * @param gradient defines the gradient to use (between 0 and 1)
  67083. * @param factor defines the emit rate value to affect to the specified gradient
  67084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67085. * @returns the current particle system
  67086. */
  67087. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67088. /**
  67089. * Not supported by GPUParticleSystem
  67090. * @param gradient defines the gradient to remove
  67091. * @returns the current particle system
  67092. */
  67093. removeEmitRateGradient(gradient: number): IParticleSystem;
  67094. /**
  67095. * Not supported by GPUParticleSystem
  67096. * @param gradient defines the gradient to use (between 0 and 1)
  67097. * @param factor defines the start size value to affect to the specified gradient
  67098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67099. * @returns the current particle system
  67100. */
  67101. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67102. /**
  67103. * Not supported by GPUParticleSystem
  67104. * @param gradient defines the gradient to remove
  67105. * @returns the current particle system
  67106. */
  67107. removeStartSizeGradient(gradient: number): IParticleSystem;
  67108. /**
  67109. * Not supported by GPUParticleSystem
  67110. * @param gradient defines the gradient to use (between 0 and 1)
  67111. * @param min defines the color remap minimal range
  67112. * @param max defines the color remap maximal range
  67113. * @returns the current particle system
  67114. */
  67115. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67116. /**
  67117. * Not supported by GPUParticleSystem
  67118. * @param gradient defines the gradient to remove
  67119. * @returns the current particle system
  67120. */
  67121. removeColorRemapGradient(): IParticleSystem;
  67122. /**
  67123. * Not supported by GPUParticleSystem
  67124. * @param gradient defines the gradient to use (between 0 and 1)
  67125. * @param min defines the alpha remap minimal range
  67126. * @param max defines the alpha remap maximal range
  67127. * @returns the current particle system
  67128. */
  67129. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67130. /**
  67131. * Not supported by GPUParticleSystem
  67132. * @param gradient defines the gradient to remove
  67133. * @returns the current particle system
  67134. */
  67135. removeAlphaRemapGradient(): IParticleSystem;
  67136. /**
  67137. * Not supported by GPUParticleSystem
  67138. * @param gradient defines the gradient to use (between 0 and 1)
  67139. * @param color defines the color to affect to the specified gradient
  67140. * @returns the current particle system
  67141. */
  67142. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67143. /**
  67144. * Not supported by GPUParticleSystem
  67145. * @param gradient defines the gradient to remove
  67146. * @returns the current particle system
  67147. */
  67148. removeRampGradient(): IParticleSystem;
  67149. /**
  67150. * Not supported by GPUParticleSystem
  67151. * @returns the list of ramp gradients
  67152. */
  67153. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67154. /**
  67155. * Not supported by GPUParticleSystem
  67156. * Gets or sets a boolean indicating that ramp gradients must be used
  67157. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67158. */
  67159. get useRampGradients(): boolean;
  67160. set useRampGradients(value: boolean);
  67161. /**
  67162. * Not supported by GPUParticleSystem
  67163. * @param gradient defines the gradient to use (between 0 and 1)
  67164. * @param factor defines the life time factor to affect to the specified gradient
  67165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67166. * @returns the current particle system
  67167. */
  67168. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67169. /**
  67170. * Not supported by GPUParticleSystem
  67171. * @param gradient defines the gradient to remove
  67172. * @returns the current particle system
  67173. */
  67174. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67175. /**
  67176. * Instantiates a GPU particle system.
  67177. * 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.
  67178. * @param name The name of the particle system
  67179. * @param options The options used to create the system
  67180. * @param scene The scene the particle system belongs to
  67181. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67182. * @param customEffect a custom effect used to change the way particles are rendered by default
  67183. */
  67184. constructor(name: string, options: Partial<{
  67185. capacity: number;
  67186. randomTextureSize: number;
  67187. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67188. protected _reset(): void;
  67189. private _createUpdateVAO;
  67190. private _createRenderVAO;
  67191. private _initialize;
  67192. /** @hidden */
  67193. _recreateUpdateEffect(): void;
  67194. private _getEffect;
  67195. /**
  67196. * Fill the defines array according to the current settings of the particle system
  67197. * @param defines Array to be updated
  67198. * @param blendMode blend mode to take into account when updating the array
  67199. */
  67200. fillDefines(defines: Array<string>, blendMode?: number): void;
  67201. /**
  67202. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67203. * @param uniforms Uniforms array to fill
  67204. * @param attributes Attributes array to fill
  67205. * @param samplers Samplers array to fill
  67206. */
  67207. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67208. /** @hidden */
  67209. _recreateRenderEffect(): Effect;
  67210. /**
  67211. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67212. * @param preWarm defines if we are in the pre-warmimg phase
  67213. */
  67214. animate(preWarm?: boolean): void;
  67215. private _createFactorGradientTexture;
  67216. private _createSizeGradientTexture;
  67217. private _createAngularSpeedGradientTexture;
  67218. private _createVelocityGradientTexture;
  67219. private _createLimitVelocityGradientTexture;
  67220. private _createDragGradientTexture;
  67221. private _createColorGradientTexture;
  67222. /**
  67223. * Renders the particle system in its current state
  67224. * @param preWarm defines if the system should only update the particles but not render them
  67225. * @returns the current number of particles
  67226. */
  67227. render(preWarm?: boolean): number;
  67228. /**
  67229. * Rebuilds the particle system
  67230. */
  67231. rebuild(): void;
  67232. private _releaseBuffers;
  67233. private _releaseVAOs;
  67234. /**
  67235. * Disposes the particle system and free the associated resources
  67236. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67237. */
  67238. dispose(disposeTexture?: boolean): void;
  67239. /**
  67240. * Clones the particle system.
  67241. * @param name The name of the cloned object
  67242. * @param newEmitter The new emitter to use
  67243. * @returns the cloned particle system
  67244. */
  67245. clone(name: string, newEmitter: any): GPUParticleSystem;
  67246. /**
  67247. * Serializes the particle system to a JSON object
  67248. * @param serializeTexture defines if the texture must be serialized as well
  67249. * @returns the JSON object
  67250. */
  67251. serialize(serializeTexture?: boolean): any;
  67252. /**
  67253. * Parses a JSON object to create a GPU particle system.
  67254. * @param parsedParticleSystem The JSON object to parse
  67255. * @param scene The scene to create the particle system in
  67256. * @param rootUrl The root url to use to load external dependencies like texture
  67257. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67258. * @returns the parsed GPU particle system
  67259. */
  67260. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67261. }
  67262. }
  67263. declare module BABYLON {
  67264. /**
  67265. * Represents a set of particle systems working together to create a specific effect
  67266. */
  67267. export class ParticleSystemSet implements IDisposable {
  67268. /**
  67269. * Gets or sets base Assets URL
  67270. */
  67271. static BaseAssetsUrl: string;
  67272. private _emitterCreationOptions;
  67273. private _emitterNode;
  67274. /**
  67275. * Gets the particle system list
  67276. */
  67277. systems: IParticleSystem[];
  67278. /**
  67279. * Gets the emitter node used with this set
  67280. */
  67281. get emitterNode(): Nullable<TransformNode>;
  67282. /**
  67283. * Creates a new emitter mesh as a sphere
  67284. * @param options defines the options used to create the sphere
  67285. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67286. * @param scene defines the hosting scene
  67287. */
  67288. setEmitterAsSphere(options: {
  67289. diameter: number;
  67290. segments: number;
  67291. color: Color3;
  67292. }, renderingGroupId: number, scene: Scene): void;
  67293. /**
  67294. * Starts all particle systems of the set
  67295. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67296. */
  67297. start(emitter?: AbstractMesh): void;
  67298. /**
  67299. * Release all associated resources
  67300. */
  67301. dispose(): void;
  67302. /**
  67303. * Serialize the set into a JSON compatible object
  67304. * @param serializeTexture defines if the texture must be serialized as well
  67305. * @returns a JSON compatible representation of the set
  67306. */
  67307. serialize(serializeTexture?: boolean): any;
  67308. /**
  67309. * Parse a new ParticleSystemSet from a serialized source
  67310. * @param data defines a JSON compatible representation of the set
  67311. * @param scene defines the hosting scene
  67312. * @param gpu defines if we want GPU particles or CPU particles
  67313. * @returns a new ParticleSystemSet
  67314. */
  67315. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67316. }
  67317. }
  67318. declare module BABYLON {
  67319. /**
  67320. * This class is made for on one-liner static method to help creating particle system set.
  67321. */
  67322. export class ParticleHelper {
  67323. /**
  67324. * Gets or sets base Assets URL
  67325. */
  67326. static BaseAssetsUrl: string;
  67327. /** Define the Url to load snippets */
  67328. static SnippetUrl: string;
  67329. /**
  67330. * Create a default particle system that you can tweak
  67331. * @param emitter defines the emitter to use
  67332. * @param capacity defines the system capacity (default is 500 particles)
  67333. * @param scene defines the hosting scene
  67334. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67335. * @returns the new Particle system
  67336. */
  67337. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67338. /**
  67339. * This is the main static method (one-liner) of this helper to create different particle systems
  67340. * @param type This string represents the type to the particle system to create
  67341. * @param scene The scene where the particle system should live
  67342. * @param gpu If the system will use gpu
  67343. * @returns the ParticleSystemSet created
  67344. */
  67345. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67346. /**
  67347. * Static function used to export a particle system to a ParticleSystemSet variable.
  67348. * Please note that the emitter shape is not exported
  67349. * @param systems defines the particle systems to export
  67350. * @returns the created particle system set
  67351. */
  67352. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67353. /**
  67354. * Creates a particle system from a snippet saved in a remote file
  67355. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67356. * @param url defines the url to load from
  67357. * @param scene defines the hosting scene
  67358. * @param gpu If the system will use gpu
  67359. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67360. * @returns a promise that will resolve to the new particle system
  67361. */
  67362. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67363. /**
  67364. * Creates a particle system from a snippet saved by the particle system editor
  67365. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67366. * @param scene defines the hosting scene
  67367. * @param gpu If the system will use gpu
  67368. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67369. * @returns a promise that will resolve to the new particle system
  67370. */
  67371. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67372. }
  67373. }
  67374. declare module BABYLON {
  67375. interface Engine {
  67376. /**
  67377. * Create an effect to use with particle systems.
  67378. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67379. * the particle system for which you want to create a custom effect in the last parameter
  67380. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67381. * @param uniformsNames defines a list of attribute names
  67382. * @param samplers defines an array of string used to represent textures
  67383. * @param defines defines the string containing the defines to use to compile the shaders
  67384. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67385. * @param onCompiled defines a function to call when the effect creation is successful
  67386. * @param onError defines a function to call when the effect creation has failed
  67387. * @param particleSystem the particle system you want to create the effect for
  67388. * @returns the new Effect
  67389. */
  67390. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67391. }
  67392. interface Mesh {
  67393. /**
  67394. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67395. * @returns an array of IParticleSystem
  67396. */
  67397. getEmittedParticleSystems(): IParticleSystem[];
  67398. /**
  67399. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67400. * @returns an array of IParticleSystem
  67401. */
  67402. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67403. }
  67404. }
  67405. declare module BABYLON {
  67406. /** Defines the 4 color options */
  67407. export enum PointColor {
  67408. /** color value */
  67409. Color = 2,
  67410. /** uv value */
  67411. UV = 1,
  67412. /** random value */
  67413. Random = 0,
  67414. /** stated value */
  67415. Stated = 3
  67416. }
  67417. /**
  67418. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67419. * 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.
  67420. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67421. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67422. *
  67423. * Full documentation here : TO BE ENTERED
  67424. */
  67425. export class PointsCloudSystem implements IDisposable {
  67426. /**
  67427. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67428. * Example : var p = SPS.particles[i];
  67429. */
  67430. particles: CloudPoint[];
  67431. /**
  67432. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67433. */
  67434. nbParticles: number;
  67435. /**
  67436. * This a counter for your own usage. It's not set by any SPS functions.
  67437. */
  67438. counter: number;
  67439. /**
  67440. * The PCS name. This name is also given to the underlying mesh.
  67441. */
  67442. name: string;
  67443. /**
  67444. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67445. */
  67446. mesh: Mesh;
  67447. /**
  67448. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67449. * Please read :
  67450. */
  67451. vars: any;
  67452. /**
  67453. * @hidden
  67454. */
  67455. _size: number;
  67456. private _scene;
  67457. private _promises;
  67458. private _positions;
  67459. private _indices;
  67460. private _normals;
  67461. private _colors;
  67462. private _uvs;
  67463. private _indices32;
  67464. private _positions32;
  67465. private _colors32;
  67466. private _uvs32;
  67467. private _updatable;
  67468. private _isVisibilityBoxLocked;
  67469. private _alwaysVisible;
  67470. private _groups;
  67471. private _groupCounter;
  67472. private _computeParticleColor;
  67473. private _computeParticleTexture;
  67474. private _computeParticleRotation;
  67475. private _computeBoundingBox;
  67476. private _isReady;
  67477. /**
  67478. * Creates a PCS (Points Cloud System) object
  67479. * @param name (String) is the PCS name, this will be the underlying mesh name
  67480. * @param pointSize (number) is the size for each point
  67481. * @param scene (Scene) is the scene in which the PCS is added
  67482. * @param options defines the options of the PCS e.g.
  67483. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67484. */
  67485. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67486. updatable?: boolean;
  67487. });
  67488. /**
  67489. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67490. * If no points were added to the PCS, the returned mesh is just a single point.
  67491. * @returns a promise for the created mesh
  67492. */
  67493. buildMeshAsync(): Promise<Mesh>;
  67494. /**
  67495. * @hidden
  67496. */
  67497. private _buildMesh;
  67498. private _addParticle;
  67499. private _randomUnitVector;
  67500. private _getColorIndicesForCoord;
  67501. private _setPointsColorOrUV;
  67502. private _colorFromTexture;
  67503. private _calculateDensity;
  67504. /**
  67505. * Adds points to the PCS in random positions within a unit sphere
  67506. * @param nb (positive integer) the number of particles to be created from this model
  67507. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67508. * @returns the number of groups in the system
  67509. */
  67510. addPoints(nb: number, pointFunction?: any): number;
  67511. /**
  67512. * Adds points to the PCS from the surface of the model shape
  67513. * @param mesh is any Mesh object that will be used as a surface model for the points
  67514. * @param nb (positive integer) the number of particles to be created from this model
  67515. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67516. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67517. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67518. * @returns the number of groups in the system
  67519. */
  67520. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67521. /**
  67522. * Adds points to the PCS inside the model shape
  67523. * @param mesh is any Mesh object that will be used as a surface model for the points
  67524. * @param nb (positive integer) the number of particles to be created from this model
  67525. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67526. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67527. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67528. * @returns the number of groups in the system
  67529. */
  67530. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67531. /**
  67532. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67533. * This method calls `updateParticle()` for each particle of the SPS.
  67534. * For an animated SPS, it is usually called within the render loop.
  67535. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67536. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67537. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67538. * @returns the PCS.
  67539. */
  67540. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67541. /**
  67542. * Disposes the PCS.
  67543. */
  67544. dispose(): void;
  67545. /**
  67546. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67547. * doc :
  67548. * @returns the PCS.
  67549. */
  67550. refreshVisibleSize(): PointsCloudSystem;
  67551. /**
  67552. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67553. * @param size the size (float) of the visibility box
  67554. * note : this doesn't lock the PCS mesh bounding box.
  67555. * doc :
  67556. */
  67557. setVisibilityBox(size: number): void;
  67558. /**
  67559. * Gets whether the PCS is always visible or not
  67560. * doc :
  67561. */
  67562. get isAlwaysVisible(): boolean;
  67563. /**
  67564. * Sets the PCS as always visible or not
  67565. * doc :
  67566. */
  67567. set isAlwaysVisible(val: boolean);
  67568. /**
  67569. * Tells to `setParticles()` to compute the particle rotations or not
  67570. * Default value : false. The PCS is faster when it's set to false
  67571. * Note : particle rotations are only applied to parent particles
  67572. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67573. */
  67574. set computeParticleRotation(val: boolean);
  67575. /**
  67576. * Tells to `setParticles()` to compute the particle colors or not.
  67577. * Default value : true. The PCS is faster when it's set to false.
  67578. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67579. */
  67580. set computeParticleColor(val: boolean);
  67581. set computeParticleTexture(val: boolean);
  67582. /**
  67583. * Gets if `setParticles()` computes the particle colors or not.
  67584. * Default value : false. The PCS is faster when it's set to false.
  67585. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67586. */
  67587. get computeParticleColor(): boolean;
  67588. /**
  67589. * Gets if `setParticles()` computes the particle textures or not.
  67590. * Default value : false. The PCS is faster when it's set to false.
  67591. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67592. */
  67593. get computeParticleTexture(): boolean;
  67594. /**
  67595. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67596. */
  67597. set computeBoundingBox(val: boolean);
  67598. /**
  67599. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67600. */
  67601. get computeBoundingBox(): boolean;
  67602. /**
  67603. * This function does nothing. It may be overwritten to set all the particle first values.
  67604. * The PCS doesn't call this function, you may have to call it by your own.
  67605. * doc :
  67606. */
  67607. initParticles(): void;
  67608. /**
  67609. * This function does nothing. It may be overwritten to recycle a particle
  67610. * The PCS doesn't call this function, you can to call it
  67611. * doc :
  67612. * @param particle The particle to recycle
  67613. * @returns the recycled particle
  67614. */
  67615. recycleParticle(particle: CloudPoint): CloudPoint;
  67616. /**
  67617. * Updates a particle : this function should be overwritten by the user.
  67618. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67619. * doc :
  67620. * @example : just set a particle position or velocity and recycle conditions
  67621. * @param particle The particle to update
  67622. * @returns the updated particle
  67623. */
  67624. updateParticle(particle: CloudPoint): CloudPoint;
  67625. /**
  67626. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67627. * This does nothing and may be overwritten by the user.
  67628. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67629. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67630. * @param update the boolean update value actually passed to setParticles()
  67631. */
  67632. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67633. /**
  67634. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67635. * This will be passed three parameters.
  67636. * This does nothing and may be overwritten by the user.
  67637. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67638. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67639. * @param update the boolean update value actually passed to setParticles()
  67640. */
  67641. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67642. }
  67643. }
  67644. declare module BABYLON {
  67645. /**
  67646. * Represents one particle of a points cloud system.
  67647. */
  67648. export class CloudPoint {
  67649. /**
  67650. * particle global index
  67651. */
  67652. idx: number;
  67653. /**
  67654. * The color of the particle
  67655. */
  67656. color: Nullable<Color4>;
  67657. /**
  67658. * The world space position of the particle.
  67659. */
  67660. position: Vector3;
  67661. /**
  67662. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67663. */
  67664. rotation: Vector3;
  67665. /**
  67666. * The world space rotation quaternion of the particle.
  67667. */
  67668. rotationQuaternion: Nullable<Quaternion>;
  67669. /**
  67670. * The uv of the particle.
  67671. */
  67672. uv: Nullable<Vector2>;
  67673. /**
  67674. * The current speed of the particle.
  67675. */
  67676. velocity: Vector3;
  67677. /**
  67678. * The pivot point in the particle local space.
  67679. */
  67680. pivot: Vector3;
  67681. /**
  67682. * Must the particle be translated from its pivot point in its local space ?
  67683. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67684. * Default : false
  67685. */
  67686. translateFromPivot: boolean;
  67687. /**
  67688. * Index of this particle in the global "positions" array (Internal use)
  67689. * @hidden
  67690. */
  67691. _pos: number;
  67692. /**
  67693. * @hidden Index of this particle in the global "indices" array (Internal use)
  67694. */
  67695. _ind: number;
  67696. /**
  67697. * Group this particle belongs to
  67698. */
  67699. _group: PointsGroup;
  67700. /**
  67701. * Group id of this particle
  67702. */
  67703. groupId: number;
  67704. /**
  67705. * Index of the particle in its group id (Internal use)
  67706. */
  67707. idxInGroup: number;
  67708. /**
  67709. * @hidden Particle BoundingInfo object (Internal use)
  67710. */
  67711. _boundingInfo: BoundingInfo;
  67712. /**
  67713. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67714. */
  67715. _pcs: PointsCloudSystem;
  67716. /**
  67717. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67718. */
  67719. _stillInvisible: boolean;
  67720. /**
  67721. * @hidden Last computed particle rotation matrix
  67722. */
  67723. _rotationMatrix: number[];
  67724. /**
  67725. * Parent particle Id, if any.
  67726. * Default null.
  67727. */
  67728. parentId: Nullable<number>;
  67729. /**
  67730. * @hidden Internal global position in the PCS.
  67731. */
  67732. _globalPosition: Vector3;
  67733. /**
  67734. * Creates a Point Cloud object.
  67735. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67736. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67737. * @param group (PointsGroup) is the group the particle belongs to
  67738. * @param groupId (integer) is the group identifier in the PCS.
  67739. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67740. * @param pcs defines the PCS it is associated to
  67741. */
  67742. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67743. /**
  67744. * get point size
  67745. */
  67746. get size(): Vector3;
  67747. /**
  67748. * Set point size
  67749. */
  67750. set size(scale: Vector3);
  67751. /**
  67752. * Legacy support, changed quaternion to rotationQuaternion
  67753. */
  67754. get quaternion(): Nullable<Quaternion>;
  67755. /**
  67756. * Legacy support, changed quaternion to rotationQuaternion
  67757. */
  67758. set quaternion(q: Nullable<Quaternion>);
  67759. /**
  67760. * Returns a boolean. True if the particle intersects a mesh, else false
  67761. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67762. * @param target is the object (point or mesh) what the intersection is computed against
  67763. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67764. * @returns true if it intersects
  67765. */
  67766. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67767. /**
  67768. * get the rotation matrix of the particle
  67769. * @hidden
  67770. */
  67771. getRotationMatrix(m: Matrix): void;
  67772. }
  67773. /**
  67774. * Represents a group of points in a points cloud system
  67775. * * PCS internal tool, don't use it manually.
  67776. */
  67777. export class PointsGroup {
  67778. /**
  67779. * The group id
  67780. * @hidden
  67781. */
  67782. groupID: number;
  67783. /**
  67784. * image data for group (internal use)
  67785. * @hidden
  67786. */
  67787. _groupImageData: Nullable<ArrayBufferView>;
  67788. /**
  67789. * Image Width (internal use)
  67790. * @hidden
  67791. */
  67792. _groupImgWidth: number;
  67793. /**
  67794. * Image Height (internal use)
  67795. * @hidden
  67796. */
  67797. _groupImgHeight: number;
  67798. /**
  67799. * Custom position function (internal use)
  67800. * @hidden
  67801. */
  67802. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67803. /**
  67804. * density per facet for surface points
  67805. * @hidden
  67806. */
  67807. _groupDensity: number[];
  67808. /**
  67809. * Only when points are colored by texture carries pointer to texture list array
  67810. * @hidden
  67811. */
  67812. _textureNb: number;
  67813. /**
  67814. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67815. * PCS internal tool, don't use it manually.
  67816. * @hidden
  67817. */
  67818. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67819. }
  67820. }
  67821. declare module BABYLON {
  67822. interface Scene {
  67823. /** @hidden (Backing field) */
  67824. _physicsEngine: Nullable<IPhysicsEngine>;
  67825. /** @hidden */
  67826. _physicsTimeAccumulator: number;
  67827. /**
  67828. * Gets the current physics engine
  67829. * @returns a IPhysicsEngine or null if none attached
  67830. */
  67831. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67832. /**
  67833. * Enables physics to the current scene
  67834. * @param gravity defines the scene's gravity for the physics engine
  67835. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67836. * @return a boolean indicating if the physics engine was initialized
  67837. */
  67838. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67839. /**
  67840. * Disables and disposes the physics engine associated with the scene
  67841. */
  67842. disablePhysicsEngine(): void;
  67843. /**
  67844. * Gets a boolean indicating if there is an active physics engine
  67845. * @returns a boolean indicating if there is an active physics engine
  67846. */
  67847. isPhysicsEnabled(): boolean;
  67848. /**
  67849. * Deletes a physics compound impostor
  67850. * @param compound defines the compound to delete
  67851. */
  67852. deleteCompoundImpostor(compound: any): void;
  67853. /**
  67854. * An event triggered when physic simulation is about to be run
  67855. */
  67856. onBeforePhysicsObservable: Observable<Scene>;
  67857. /**
  67858. * An event triggered when physic simulation has been done
  67859. */
  67860. onAfterPhysicsObservable: Observable<Scene>;
  67861. }
  67862. interface AbstractMesh {
  67863. /** @hidden */
  67864. _physicsImpostor: Nullable<PhysicsImpostor>;
  67865. /**
  67866. * Gets or sets impostor used for physic simulation
  67867. * @see https://doc.babylonjs.com/features/physics_engine
  67868. */
  67869. physicsImpostor: Nullable<PhysicsImpostor>;
  67870. /**
  67871. * Gets the current physics impostor
  67872. * @see https://doc.babylonjs.com/features/physics_engine
  67873. * @returns a physics impostor or null
  67874. */
  67875. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67876. /** Apply a physic impulse to the mesh
  67877. * @param force defines the force to apply
  67878. * @param contactPoint defines where to apply the force
  67879. * @returns the current mesh
  67880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67881. */
  67882. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67883. /**
  67884. * Creates a physic joint between two meshes
  67885. * @param otherMesh defines the other mesh to use
  67886. * @param pivot1 defines the pivot to use on this mesh
  67887. * @param pivot2 defines the pivot to use on the other mesh
  67888. * @param options defines additional options (can be plugin dependent)
  67889. * @returns the current mesh
  67890. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67891. */
  67892. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67893. /** @hidden */
  67894. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67895. }
  67896. /**
  67897. * Defines the physics engine scene component responsible to manage a physics engine
  67898. */
  67899. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67900. /**
  67901. * The component name helpful to identify the component in the list of scene components.
  67902. */
  67903. readonly name: string;
  67904. /**
  67905. * The scene the component belongs to.
  67906. */
  67907. scene: Scene;
  67908. /**
  67909. * Creates a new instance of the component for the given scene
  67910. * @param scene Defines the scene to register the component in
  67911. */
  67912. constructor(scene: Scene);
  67913. /**
  67914. * Registers the component in a given scene
  67915. */
  67916. register(): void;
  67917. /**
  67918. * Rebuilds the elements related to this component in case of
  67919. * context lost for instance.
  67920. */
  67921. rebuild(): void;
  67922. /**
  67923. * Disposes the component and the associated ressources
  67924. */
  67925. dispose(): void;
  67926. }
  67927. }
  67928. declare module BABYLON {
  67929. /**
  67930. * A helper for physics simulations
  67931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67932. */
  67933. export class PhysicsHelper {
  67934. private _scene;
  67935. private _physicsEngine;
  67936. /**
  67937. * Initializes the Physics helper
  67938. * @param scene Babylon.js scene
  67939. */
  67940. constructor(scene: Scene);
  67941. /**
  67942. * Applies a radial explosion impulse
  67943. * @param origin the origin of the explosion
  67944. * @param radiusOrEventOptions the radius or the options of radial explosion
  67945. * @param strength the explosion strength
  67946. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67947. * @returns A physics radial explosion event, or null
  67948. */
  67949. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67950. /**
  67951. * Applies a radial explosion force
  67952. * @param origin the origin of the explosion
  67953. * @param radiusOrEventOptions the radius or the options of radial explosion
  67954. * @param strength the explosion strength
  67955. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67956. * @returns A physics radial explosion event, or null
  67957. */
  67958. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67959. /**
  67960. * Creates a gravitational field
  67961. * @param origin the origin of the explosion
  67962. * @param radiusOrEventOptions the radius or the options of radial explosion
  67963. * @param strength the explosion strength
  67964. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67965. * @returns A physics gravitational field event, or null
  67966. */
  67967. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67968. /**
  67969. * Creates a physics updraft event
  67970. * @param origin the origin of the updraft
  67971. * @param radiusOrEventOptions the radius or the options of the updraft
  67972. * @param strength the strength of the updraft
  67973. * @param height the height of the updraft
  67974. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67975. * @returns A physics updraft event, or null
  67976. */
  67977. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67978. /**
  67979. * Creates a physics vortex event
  67980. * @param origin the of the vortex
  67981. * @param radiusOrEventOptions the radius or the options of the vortex
  67982. * @param strength the strength of the vortex
  67983. * @param height the height of the vortex
  67984. * @returns a Physics vortex event, or null
  67985. * A physics vortex event or null
  67986. */
  67987. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67988. }
  67989. /**
  67990. * Represents a physics radial explosion event
  67991. */
  67992. class PhysicsRadialExplosionEvent {
  67993. private _scene;
  67994. private _options;
  67995. private _sphere;
  67996. private _dataFetched;
  67997. /**
  67998. * Initializes a radial explosioin event
  67999. * @param _scene BabylonJS scene
  68000. * @param _options The options for the vortex event
  68001. */
  68002. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68003. /**
  68004. * Returns the data related to the radial explosion event (sphere).
  68005. * @returns The radial explosion event data
  68006. */
  68007. getData(): PhysicsRadialExplosionEventData;
  68008. /**
  68009. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68010. * @param impostor A physics imposter
  68011. * @param origin the origin of the explosion
  68012. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68013. */
  68014. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68015. /**
  68016. * Triggers affecterd impostors callbacks
  68017. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68018. */
  68019. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68020. /**
  68021. * Disposes the sphere.
  68022. * @param force Specifies if the sphere should be disposed by force
  68023. */
  68024. dispose(force?: boolean): void;
  68025. /*** Helpers ***/
  68026. private _prepareSphere;
  68027. private _intersectsWithSphere;
  68028. }
  68029. /**
  68030. * Represents a gravitational field event
  68031. */
  68032. class PhysicsGravitationalFieldEvent {
  68033. private _physicsHelper;
  68034. private _scene;
  68035. private _origin;
  68036. private _options;
  68037. private _tickCallback;
  68038. private _sphere;
  68039. private _dataFetched;
  68040. /**
  68041. * Initializes the physics gravitational field event
  68042. * @param _physicsHelper A physics helper
  68043. * @param _scene BabylonJS scene
  68044. * @param _origin The origin position of the gravitational field event
  68045. * @param _options The options for the vortex event
  68046. */
  68047. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68048. /**
  68049. * Returns the data related to the gravitational field event (sphere).
  68050. * @returns A gravitational field event
  68051. */
  68052. getData(): PhysicsGravitationalFieldEventData;
  68053. /**
  68054. * Enables the gravitational field.
  68055. */
  68056. enable(): void;
  68057. /**
  68058. * Disables the gravitational field.
  68059. */
  68060. disable(): void;
  68061. /**
  68062. * Disposes the sphere.
  68063. * @param force The force to dispose from the gravitational field event
  68064. */
  68065. dispose(force?: boolean): void;
  68066. private _tick;
  68067. }
  68068. /**
  68069. * Represents a physics updraft event
  68070. */
  68071. class PhysicsUpdraftEvent {
  68072. private _scene;
  68073. private _origin;
  68074. private _options;
  68075. private _physicsEngine;
  68076. private _originTop;
  68077. private _originDirection;
  68078. private _tickCallback;
  68079. private _cylinder;
  68080. private _cylinderPosition;
  68081. private _dataFetched;
  68082. /**
  68083. * Initializes the physics updraft event
  68084. * @param _scene BabylonJS scene
  68085. * @param _origin The origin position of the updraft
  68086. * @param _options The options for the updraft event
  68087. */
  68088. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68089. /**
  68090. * Returns the data related to the updraft event (cylinder).
  68091. * @returns A physics updraft event
  68092. */
  68093. getData(): PhysicsUpdraftEventData;
  68094. /**
  68095. * Enables the updraft.
  68096. */
  68097. enable(): void;
  68098. /**
  68099. * Disables the updraft.
  68100. */
  68101. disable(): void;
  68102. /**
  68103. * Disposes the cylinder.
  68104. * @param force Specifies if the updraft should be disposed by force
  68105. */
  68106. dispose(force?: boolean): void;
  68107. private getImpostorHitData;
  68108. private _tick;
  68109. /*** Helpers ***/
  68110. private _prepareCylinder;
  68111. private _intersectsWithCylinder;
  68112. }
  68113. /**
  68114. * Represents a physics vortex event
  68115. */
  68116. class PhysicsVortexEvent {
  68117. private _scene;
  68118. private _origin;
  68119. private _options;
  68120. private _physicsEngine;
  68121. private _originTop;
  68122. private _tickCallback;
  68123. private _cylinder;
  68124. private _cylinderPosition;
  68125. private _dataFetched;
  68126. /**
  68127. * Initializes the physics vortex event
  68128. * @param _scene The BabylonJS scene
  68129. * @param _origin The origin position of the vortex
  68130. * @param _options The options for the vortex event
  68131. */
  68132. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68133. /**
  68134. * Returns the data related to the vortex event (cylinder).
  68135. * @returns The physics vortex event data
  68136. */
  68137. getData(): PhysicsVortexEventData;
  68138. /**
  68139. * Enables the vortex.
  68140. */
  68141. enable(): void;
  68142. /**
  68143. * Disables the cortex.
  68144. */
  68145. disable(): void;
  68146. /**
  68147. * Disposes the sphere.
  68148. * @param force
  68149. */
  68150. dispose(force?: boolean): void;
  68151. private getImpostorHitData;
  68152. private _tick;
  68153. /*** Helpers ***/
  68154. private _prepareCylinder;
  68155. private _intersectsWithCylinder;
  68156. }
  68157. /**
  68158. * Options fot the radial explosion event
  68159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68160. */
  68161. export class PhysicsRadialExplosionEventOptions {
  68162. /**
  68163. * The radius of the sphere for the radial explosion.
  68164. */
  68165. radius: number;
  68166. /**
  68167. * The strenth of the explosion.
  68168. */
  68169. strength: number;
  68170. /**
  68171. * The strenght of the force in correspondence to the distance of the affected object
  68172. */
  68173. falloff: PhysicsRadialImpulseFalloff;
  68174. /**
  68175. * Sphere options for the radial explosion.
  68176. */
  68177. sphere: {
  68178. segments: number;
  68179. diameter: number;
  68180. };
  68181. /**
  68182. * Sphere options for the radial explosion.
  68183. */
  68184. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68185. }
  68186. /**
  68187. * Options fot the updraft event
  68188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68189. */
  68190. export class PhysicsUpdraftEventOptions {
  68191. /**
  68192. * The radius of the cylinder for the vortex
  68193. */
  68194. radius: number;
  68195. /**
  68196. * The strenth of the updraft.
  68197. */
  68198. strength: number;
  68199. /**
  68200. * The height of the cylinder for the updraft.
  68201. */
  68202. height: number;
  68203. /**
  68204. * The mode for the the updraft.
  68205. */
  68206. updraftMode: PhysicsUpdraftMode;
  68207. }
  68208. /**
  68209. * Options fot the vortex event
  68210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68211. */
  68212. export class PhysicsVortexEventOptions {
  68213. /**
  68214. * The radius of the cylinder for the vortex
  68215. */
  68216. radius: number;
  68217. /**
  68218. * The strenth of the vortex.
  68219. */
  68220. strength: number;
  68221. /**
  68222. * The height of the cylinder for the vortex.
  68223. */
  68224. height: number;
  68225. /**
  68226. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68227. */
  68228. centripetalForceThreshold: number;
  68229. /**
  68230. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68231. */
  68232. centripetalForceMultiplier: number;
  68233. /**
  68234. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68235. */
  68236. centrifugalForceMultiplier: number;
  68237. /**
  68238. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68239. */
  68240. updraftForceMultiplier: number;
  68241. }
  68242. /**
  68243. * The strenght of the force in correspondence to the distance of the affected object
  68244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68245. */
  68246. export enum PhysicsRadialImpulseFalloff {
  68247. /** Defines that impulse is constant in strength across it's whole radius */
  68248. Constant = 0,
  68249. /** Defines that impulse gets weaker if it's further from the origin */
  68250. Linear = 1
  68251. }
  68252. /**
  68253. * The strength of the force in correspondence to the distance of the affected object
  68254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68255. */
  68256. export enum PhysicsUpdraftMode {
  68257. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68258. Center = 0,
  68259. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68260. Perpendicular = 1
  68261. }
  68262. /**
  68263. * Interface for a physics hit data
  68264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68265. */
  68266. export interface PhysicsHitData {
  68267. /**
  68268. * The force applied at the contact point
  68269. */
  68270. force: Vector3;
  68271. /**
  68272. * The contact point
  68273. */
  68274. contactPoint: Vector3;
  68275. /**
  68276. * The distance from the origin to the contact point
  68277. */
  68278. distanceFromOrigin: number;
  68279. }
  68280. /**
  68281. * Interface for radial explosion event data
  68282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68283. */
  68284. export interface PhysicsRadialExplosionEventData {
  68285. /**
  68286. * A sphere used for the radial explosion event
  68287. */
  68288. sphere: Mesh;
  68289. }
  68290. /**
  68291. * Interface for gravitational field event data
  68292. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68293. */
  68294. export interface PhysicsGravitationalFieldEventData {
  68295. /**
  68296. * A sphere mesh used for the gravitational field event
  68297. */
  68298. sphere: Mesh;
  68299. }
  68300. /**
  68301. * Interface for updraft event data
  68302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68303. */
  68304. export interface PhysicsUpdraftEventData {
  68305. /**
  68306. * A cylinder used for the updraft event
  68307. */
  68308. cylinder: Mesh;
  68309. }
  68310. /**
  68311. * Interface for vortex event data
  68312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68313. */
  68314. export interface PhysicsVortexEventData {
  68315. /**
  68316. * A cylinder used for the vortex event
  68317. */
  68318. cylinder: Mesh;
  68319. }
  68320. /**
  68321. * Interface for an affected physics impostor
  68322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68323. */
  68324. export interface PhysicsAffectedImpostorWithData {
  68325. /**
  68326. * The impostor affected by the effect
  68327. */
  68328. impostor: PhysicsImpostor;
  68329. /**
  68330. * The data about the hit/horce from the explosion
  68331. */
  68332. hitData: PhysicsHitData;
  68333. }
  68334. }
  68335. declare module BABYLON {
  68336. /** @hidden */
  68337. export var blackAndWhitePixelShader: {
  68338. name: string;
  68339. shader: string;
  68340. };
  68341. }
  68342. declare module BABYLON {
  68343. /**
  68344. * Post process used to render in black and white
  68345. */
  68346. export class BlackAndWhitePostProcess extends PostProcess {
  68347. /**
  68348. * Linear about to convert he result to black and white (default: 1)
  68349. */
  68350. degree: number;
  68351. /**
  68352. * Creates a black and white post process
  68353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68354. * @param name The name of the effect.
  68355. * @param options The required width/height ratio to downsize to before computing the render pass.
  68356. * @param camera The camera to apply the render pass to.
  68357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68358. * @param engine The engine which the post process will be applied. (default: current engine)
  68359. * @param reusable If the post process can be reused on the same frame. (default: false)
  68360. */
  68361. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68362. }
  68363. }
  68364. declare module BABYLON {
  68365. /**
  68366. * This represents a set of one or more post processes in Babylon.
  68367. * A post process can be used to apply a shader to a texture after it is rendered.
  68368. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68369. */
  68370. export class PostProcessRenderEffect {
  68371. private _postProcesses;
  68372. private _getPostProcesses;
  68373. private _singleInstance;
  68374. private _cameras;
  68375. private _indicesForCamera;
  68376. /**
  68377. * Name of the effect
  68378. * @hidden
  68379. */
  68380. _name: string;
  68381. /**
  68382. * Instantiates a post process render effect.
  68383. * A post process can be used to apply a shader to a texture after it is rendered.
  68384. * @param engine The engine the effect is tied to
  68385. * @param name The name of the effect
  68386. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68387. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68388. */
  68389. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68390. /**
  68391. * Checks if all the post processes in the effect are supported.
  68392. */
  68393. get isSupported(): boolean;
  68394. /**
  68395. * Updates the current state of the effect
  68396. * @hidden
  68397. */
  68398. _update(): void;
  68399. /**
  68400. * Attaches the effect on cameras
  68401. * @param cameras The camera to attach to.
  68402. * @hidden
  68403. */
  68404. _attachCameras(cameras: Camera): void;
  68405. /**
  68406. * Attaches the effect on cameras
  68407. * @param cameras The camera to attach to.
  68408. * @hidden
  68409. */
  68410. _attachCameras(cameras: Camera[]): void;
  68411. /**
  68412. * Detaches the effect on cameras
  68413. * @param cameras The camera to detatch from.
  68414. * @hidden
  68415. */
  68416. _detachCameras(cameras: Camera): void;
  68417. /**
  68418. * Detatches the effect on cameras
  68419. * @param cameras The camera to detatch from.
  68420. * @hidden
  68421. */
  68422. _detachCameras(cameras: Camera[]): void;
  68423. /**
  68424. * Enables the effect on given cameras
  68425. * @param cameras The camera to enable.
  68426. * @hidden
  68427. */
  68428. _enable(cameras: Camera): void;
  68429. /**
  68430. * Enables the effect on given cameras
  68431. * @param cameras The camera to enable.
  68432. * @hidden
  68433. */
  68434. _enable(cameras: Nullable<Camera[]>): void;
  68435. /**
  68436. * Disables the effect on the given cameras
  68437. * @param cameras The camera to disable.
  68438. * @hidden
  68439. */
  68440. _disable(cameras: Camera): void;
  68441. /**
  68442. * Disables the effect on the given cameras
  68443. * @param cameras The camera to disable.
  68444. * @hidden
  68445. */
  68446. _disable(cameras: Nullable<Camera[]>): void;
  68447. /**
  68448. * Gets a list of the post processes contained in the effect.
  68449. * @param camera The camera to get the post processes on.
  68450. * @returns The list of the post processes in the effect.
  68451. */
  68452. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68453. }
  68454. }
  68455. declare module BABYLON {
  68456. /** @hidden */
  68457. export var extractHighlightsPixelShader: {
  68458. name: string;
  68459. shader: string;
  68460. };
  68461. }
  68462. declare module BABYLON {
  68463. /**
  68464. * 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.
  68465. */
  68466. export class ExtractHighlightsPostProcess extends PostProcess {
  68467. /**
  68468. * The luminance threshold, pixels below this value will be set to black.
  68469. */
  68470. threshold: number;
  68471. /** @hidden */
  68472. _exposure: number;
  68473. /**
  68474. * Post process which has the input texture to be used when performing highlight extraction
  68475. * @hidden
  68476. */
  68477. _inputPostProcess: Nullable<PostProcess>;
  68478. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68479. }
  68480. }
  68481. declare module BABYLON {
  68482. /** @hidden */
  68483. export var bloomMergePixelShader: {
  68484. name: string;
  68485. shader: string;
  68486. };
  68487. }
  68488. declare module BABYLON {
  68489. /**
  68490. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68491. */
  68492. export class BloomMergePostProcess extends PostProcess {
  68493. /** Weight of the bloom to be added to the original input. */
  68494. weight: number;
  68495. /**
  68496. * Creates a new instance of @see BloomMergePostProcess
  68497. * @param name The name of the effect.
  68498. * @param originalFromInput Post process which's input will be used for the merge.
  68499. * @param blurred Blurred highlights post process which's output will be used.
  68500. * @param weight Weight of the bloom to be added to the original input.
  68501. * @param options The required width/height ratio to downsize to before computing the render pass.
  68502. * @param camera The camera to apply the render pass to.
  68503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68504. * @param engine The engine which the post process will be applied. (default: current engine)
  68505. * @param reusable If the post process can be reused on the same frame. (default: false)
  68506. * @param textureType Type of textures used when performing the post process. (default: 0)
  68507. * @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)
  68508. */
  68509. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68510. /** Weight of the bloom to be added to the original input. */
  68511. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68512. }
  68513. }
  68514. declare module BABYLON {
  68515. /**
  68516. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68517. */
  68518. export class BloomEffect extends PostProcessRenderEffect {
  68519. private bloomScale;
  68520. /**
  68521. * @hidden Internal
  68522. */
  68523. _effects: Array<PostProcess>;
  68524. /**
  68525. * @hidden Internal
  68526. */
  68527. _downscale: ExtractHighlightsPostProcess;
  68528. private _blurX;
  68529. private _blurY;
  68530. private _merge;
  68531. /**
  68532. * The luminance threshold to find bright areas of the image to bloom.
  68533. */
  68534. get threshold(): number;
  68535. set threshold(value: number);
  68536. /**
  68537. * The strength of the bloom.
  68538. */
  68539. get weight(): number;
  68540. set weight(value: number);
  68541. /**
  68542. * Specifies the size of the bloom blur kernel, relative to the final output size
  68543. */
  68544. get kernel(): number;
  68545. set kernel(value: number);
  68546. /**
  68547. * Creates a new instance of @see BloomEffect
  68548. * @param scene The scene the effect belongs to.
  68549. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68550. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68551. * @param bloomWeight The the strength of bloom.
  68552. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68553. * @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)
  68554. */
  68555. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68556. /**
  68557. * Disposes each of the internal effects for a given camera.
  68558. * @param camera The camera to dispose the effect on.
  68559. */
  68560. disposeEffects(camera: Camera): void;
  68561. /**
  68562. * @hidden Internal
  68563. */
  68564. _updateEffects(): void;
  68565. /**
  68566. * Internal
  68567. * @returns if all the contained post processes are ready.
  68568. * @hidden
  68569. */
  68570. _isReady(): boolean;
  68571. }
  68572. }
  68573. declare module BABYLON {
  68574. /** @hidden */
  68575. export var chromaticAberrationPixelShader: {
  68576. name: string;
  68577. shader: string;
  68578. };
  68579. }
  68580. declare module BABYLON {
  68581. /**
  68582. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68583. */
  68584. export class ChromaticAberrationPostProcess extends PostProcess {
  68585. /**
  68586. * The amount of seperation of rgb channels (default: 30)
  68587. */
  68588. aberrationAmount: number;
  68589. /**
  68590. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68591. */
  68592. radialIntensity: number;
  68593. /**
  68594. * 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))
  68595. */
  68596. direction: Vector2;
  68597. /**
  68598. * 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))
  68599. */
  68600. centerPosition: Vector2;
  68601. /**
  68602. * Creates a new instance ChromaticAberrationPostProcess
  68603. * @param name The name of the effect.
  68604. * @param screenWidth The width of the screen to apply the effect on.
  68605. * @param screenHeight The height of the screen to apply the effect on.
  68606. * @param options The required width/height ratio to downsize to before computing the render pass.
  68607. * @param camera The camera to apply the render pass to.
  68608. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68609. * @param engine The engine which the post process will be applied. (default: current engine)
  68610. * @param reusable If the post process can be reused on the same frame. (default: false)
  68611. * @param textureType Type of textures used when performing the post process. (default: 0)
  68612. * @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)
  68613. */
  68614. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68615. }
  68616. }
  68617. declare module BABYLON {
  68618. /** @hidden */
  68619. export var circleOfConfusionPixelShader: {
  68620. name: string;
  68621. shader: string;
  68622. };
  68623. }
  68624. declare module BABYLON {
  68625. /**
  68626. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68627. */
  68628. export class CircleOfConfusionPostProcess extends PostProcess {
  68629. /**
  68630. * 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.
  68631. */
  68632. lensSize: number;
  68633. /**
  68634. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68635. */
  68636. fStop: number;
  68637. /**
  68638. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68639. */
  68640. focusDistance: number;
  68641. /**
  68642. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68643. */
  68644. focalLength: number;
  68645. private _depthTexture;
  68646. /**
  68647. * Creates a new instance CircleOfConfusionPostProcess
  68648. * @param name The name of the effect.
  68649. * @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.
  68650. * @param options The required width/height ratio to downsize to before computing the render pass.
  68651. * @param camera The camera to apply the render pass to.
  68652. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68653. * @param engine The engine which the post process will be applied. (default: current engine)
  68654. * @param reusable If the post process can be reused on the same frame. (default: false)
  68655. * @param textureType Type of textures used when performing the post process. (default: 0)
  68656. * @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)
  68657. */
  68658. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68659. /**
  68660. * 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.
  68661. */
  68662. set depthTexture(value: RenderTargetTexture);
  68663. }
  68664. }
  68665. declare module BABYLON {
  68666. /** @hidden */
  68667. export var colorCorrectionPixelShader: {
  68668. name: string;
  68669. shader: string;
  68670. };
  68671. }
  68672. declare module BABYLON {
  68673. /**
  68674. *
  68675. * This post-process allows the modification of rendered colors by using
  68676. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68677. *
  68678. * The object needs to be provided an url to a texture containing the color
  68679. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68680. * Use an image editing software to tweak the LUT to match your needs.
  68681. *
  68682. * For an example of a color LUT, see here:
  68683. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68684. * For explanations on color grading, see here:
  68685. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68686. *
  68687. */
  68688. export class ColorCorrectionPostProcess extends PostProcess {
  68689. private _colorTableTexture;
  68690. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68691. }
  68692. }
  68693. declare module BABYLON {
  68694. /** @hidden */
  68695. export var convolutionPixelShader: {
  68696. name: string;
  68697. shader: string;
  68698. };
  68699. }
  68700. declare module BABYLON {
  68701. /**
  68702. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68703. * input texture to perform effects such as edge detection or sharpening
  68704. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68705. */
  68706. export class ConvolutionPostProcess extends PostProcess {
  68707. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68708. kernel: number[];
  68709. /**
  68710. * Creates a new instance ConvolutionPostProcess
  68711. * @param name The name of the effect.
  68712. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68713. * @param options The required width/height ratio to downsize to before computing the render pass.
  68714. * @param camera The camera to apply the render pass to.
  68715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68716. * @param engine The engine which the post process will be applied. (default: current engine)
  68717. * @param reusable If the post process can be reused on the same frame. (default: false)
  68718. * @param textureType Type of textures used when performing the post process. (default: 0)
  68719. */
  68720. constructor(name: string,
  68721. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68722. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68723. /**
  68724. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68725. */
  68726. static EdgeDetect0Kernel: number[];
  68727. /**
  68728. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68729. */
  68730. static EdgeDetect1Kernel: number[];
  68731. /**
  68732. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68733. */
  68734. static EdgeDetect2Kernel: number[];
  68735. /**
  68736. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68737. */
  68738. static SharpenKernel: number[];
  68739. /**
  68740. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68741. */
  68742. static EmbossKernel: number[];
  68743. /**
  68744. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68745. */
  68746. static GaussianKernel: number[];
  68747. }
  68748. }
  68749. declare module BABYLON {
  68750. /**
  68751. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68752. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68753. * based on samples that have a large difference in distance than the center pixel.
  68754. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68755. */
  68756. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68757. direction: Vector2;
  68758. /**
  68759. * Creates a new instance CircleOfConfusionPostProcess
  68760. * @param name The name of the effect.
  68761. * @param scene The scene the effect belongs to.
  68762. * @param direction The direction the blur should be applied.
  68763. * @param kernel The size of the kernel used to blur.
  68764. * @param options The required width/height ratio to downsize to before computing the render pass.
  68765. * @param camera The camera to apply the render pass to.
  68766. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68767. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68769. * @param engine The engine which the post process will be applied. (default: current engine)
  68770. * @param reusable If the post process can be reused on the same frame. (default: false)
  68771. * @param textureType Type of textures used when performing the post process. (default: 0)
  68772. * @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)
  68773. */
  68774. 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);
  68775. }
  68776. }
  68777. declare module BABYLON {
  68778. /** @hidden */
  68779. export var depthOfFieldMergePixelShader: {
  68780. name: string;
  68781. shader: string;
  68782. };
  68783. }
  68784. declare module BABYLON {
  68785. /**
  68786. * Options to be set when merging outputs from the default pipeline.
  68787. */
  68788. export class DepthOfFieldMergePostProcessOptions {
  68789. /**
  68790. * The original image to merge on top of
  68791. */
  68792. originalFromInput: PostProcess;
  68793. /**
  68794. * Parameters to perform the merge of the depth of field effect
  68795. */
  68796. depthOfField?: {
  68797. circleOfConfusion: PostProcess;
  68798. blurSteps: Array<PostProcess>;
  68799. };
  68800. /**
  68801. * Parameters to perform the merge of bloom effect
  68802. */
  68803. bloom?: {
  68804. blurred: PostProcess;
  68805. weight: number;
  68806. };
  68807. }
  68808. /**
  68809. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68810. */
  68811. export class DepthOfFieldMergePostProcess extends PostProcess {
  68812. private blurSteps;
  68813. /**
  68814. * Creates a new instance of DepthOfFieldMergePostProcess
  68815. * @param name The name of the effect.
  68816. * @param originalFromInput Post process which's input will be used for the merge.
  68817. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68818. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68819. * @param options The required width/height ratio to downsize to before computing the render pass.
  68820. * @param camera The camera to apply the render pass to.
  68821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68822. * @param engine The engine which the post process will be applied. (default: current engine)
  68823. * @param reusable If the post process can be reused on the same frame. (default: false)
  68824. * @param textureType Type of textures used when performing the post process. (default: 0)
  68825. * @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)
  68826. */
  68827. 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);
  68828. /**
  68829. * Updates the effect with the current post process compile time values and recompiles the shader.
  68830. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68831. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68832. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68833. * @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
  68834. * @param onCompiled Called when the shader has been compiled.
  68835. * @param onError Called if there is an error when compiling a shader.
  68836. */
  68837. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68838. }
  68839. }
  68840. declare module BABYLON {
  68841. /**
  68842. * Specifies the level of max blur that should be applied when using the depth of field effect
  68843. */
  68844. export enum DepthOfFieldEffectBlurLevel {
  68845. /**
  68846. * Subtle blur
  68847. */
  68848. Low = 0,
  68849. /**
  68850. * Medium blur
  68851. */
  68852. Medium = 1,
  68853. /**
  68854. * Large blur
  68855. */
  68856. High = 2
  68857. }
  68858. /**
  68859. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68860. */
  68861. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68862. private _circleOfConfusion;
  68863. /**
  68864. * @hidden Internal, blurs from high to low
  68865. */
  68866. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68867. private _depthOfFieldBlurY;
  68868. private _dofMerge;
  68869. /**
  68870. * @hidden Internal post processes in depth of field effect
  68871. */
  68872. _effects: Array<PostProcess>;
  68873. /**
  68874. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68875. */
  68876. set focalLength(value: number);
  68877. get focalLength(): number;
  68878. /**
  68879. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68880. */
  68881. set fStop(value: number);
  68882. get fStop(): number;
  68883. /**
  68884. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68885. */
  68886. set focusDistance(value: number);
  68887. get focusDistance(): number;
  68888. /**
  68889. * 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.
  68890. */
  68891. set lensSize(value: number);
  68892. get lensSize(): number;
  68893. /**
  68894. * Creates a new instance DepthOfFieldEffect
  68895. * @param scene The scene the effect belongs to.
  68896. * @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.
  68897. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68898. * @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)
  68899. */
  68900. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68901. /**
  68902. * Get the current class name of the current effet
  68903. * @returns "DepthOfFieldEffect"
  68904. */
  68905. getClassName(): string;
  68906. /**
  68907. * 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.
  68908. */
  68909. set depthTexture(value: RenderTargetTexture);
  68910. /**
  68911. * Disposes each of the internal effects for a given camera.
  68912. * @param camera The camera to dispose the effect on.
  68913. */
  68914. disposeEffects(camera: Camera): void;
  68915. /**
  68916. * @hidden Internal
  68917. */
  68918. _updateEffects(): void;
  68919. /**
  68920. * Internal
  68921. * @returns if all the contained post processes are ready.
  68922. * @hidden
  68923. */
  68924. _isReady(): boolean;
  68925. }
  68926. }
  68927. declare module BABYLON {
  68928. /** @hidden */
  68929. export var displayPassPixelShader: {
  68930. name: string;
  68931. shader: string;
  68932. };
  68933. }
  68934. declare module BABYLON {
  68935. /**
  68936. * DisplayPassPostProcess which produces an output the same as it's input
  68937. */
  68938. export class DisplayPassPostProcess extends PostProcess {
  68939. /**
  68940. * Creates the DisplayPassPostProcess
  68941. * @param name The name of the effect.
  68942. * @param options The required width/height ratio to downsize to before computing the render pass.
  68943. * @param camera The camera to apply the render pass to.
  68944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68945. * @param engine The engine which the post process will be applied. (default: current engine)
  68946. * @param reusable If the post process can be reused on the same frame. (default: false)
  68947. */
  68948. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68949. }
  68950. }
  68951. declare module BABYLON {
  68952. /** @hidden */
  68953. export var filterPixelShader: {
  68954. name: string;
  68955. shader: string;
  68956. };
  68957. }
  68958. declare module BABYLON {
  68959. /**
  68960. * Applies a kernel filter to the image
  68961. */
  68962. export class FilterPostProcess extends PostProcess {
  68963. /** The matrix to be applied to the image */
  68964. kernelMatrix: Matrix;
  68965. /**
  68966. *
  68967. * @param name The name of the effect.
  68968. * @param kernelMatrix The matrix to be applied to the image
  68969. * @param options The required width/height ratio to downsize to before computing the render pass.
  68970. * @param camera The camera to apply the render pass to.
  68971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68972. * @param engine The engine which the post process will be applied. (default: current engine)
  68973. * @param reusable If the post process can be reused on the same frame. (default: false)
  68974. */
  68975. constructor(name: string,
  68976. /** The matrix to be applied to the image */
  68977. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68978. }
  68979. }
  68980. declare module BABYLON {
  68981. /** @hidden */
  68982. export var fxaaPixelShader: {
  68983. name: string;
  68984. shader: string;
  68985. };
  68986. }
  68987. declare module BABYLON {
  68988. /** @hidden */
  68989. export var fxaaVertexShader: {
  68990. name: string;
  68991. shader: string;
  68992. };
  68993. }
  68994. declare module BABYLON {
  68995. /**
  68996. * Fxaa post process
  68997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68998. */
  68999. export class FxaaPostProcess extends PostProcess {
  69000. /** @hidden */
  69001. texelWidth: number;
  69002. /** @hidden */
  69003. texelHeight: number;
  69004. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69005. private _getDefines;
  69006. }
  69007. }
  69008. declare module BABYLON {
  69009. /** @hidden */
  69010. export var grainPixelShader: {
  69011. name: string;
  69012. shader: string;
  69013. };
  69014. }
  69015. declare module BABYLON {
  69016. /**
  69017. * The GrainPostProcess adds noise to the image at mid luminance levels
  69018. */
  69019. export class GrainPostProcess extends PostProcess {
  69020. /**
  69021. * The intensity of the grain added (default: 30)
  69022. */
  69023. intensity: number;
  69024. /**
  69025. * If the grain should be randomized on every frame
  69026. */
  69027. animated: boolean;
  69028. /**
  69029. * Creates a new instance of @see GrainPostProcess
  69030. * @param name The name of the effect.
  69031. * @param options The required width/height ratio to downsize to before computing the render pass.
  69032. * @param camera The camera to apply the render pass to.
  69033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69034. * @param engine The engine which the post process will be applied. (default: current engine)
  69035. * @param reusable If the post process can be reused on the same frame. (default: false)
  69036. * @param textureType Type of textures used when performing the post process. (default: 0)
  69037. * @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)
  69038. */
  69039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69040. }
  69041. }
  69042. declare module BABYLON {
  69043. /** @hidden */
  69044. export var highlightsPixelShader: {
  69045. name: string;
  69046. shader: string;
  69047. };
  69048. }
  69049. declare module BABYLON {
  69050. /**
  69051. * Extracts highlights from the image
  69052. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69053. */
  69054. export class HighlightsPostProcess extends PostProcess {
  69055. /**
  69056. * Extracts highlights from the image
  69057. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69058. * @param name The name of the effect.
  69059. * @param options The required width/height ratio to downsize to before computing the render pass.
  69060. * @param camera The camera to apply the render pass to.
  69061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69062. * @param engine The engine which the post process will be applied. (default: current engine)
  69063. * @param reusable If the post process can be reused on the same frame. (default: false)
  69064. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69065. */
  69066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69067. }
  69068. }
  69069. declare module BABYLON {
  69070. /** @hidden */
  69071. export var mrtFragmentDeclaration: {
  69072. name: string;
  69073. shader: string;
  69074. };
  69075. }
  69076. declare module BABYLON {
  69077. /** @hidden */
  69078. export var geometryPixelShader: {
  69079. name: string;
  69080. shader: string;
  69081. };
  69082. }
  69083. declare module BABYLON {
  69084. /** @hidden */
  69085. export var geometryVertexShader: {
  69086. name: string;
  69087. shader: string;
  69088. };
  69089. }
  69090. declare module BABYLON {
  69091. /** @hidden */
  69092. interface ISavedTransformationMatrix {
  69093. world: Matrix;
  69094. viewProjection: Matrix;
  69095. }
  69096. /**
  69097. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69098. */
  69099. export class GeometryBufferRenderer {
  69100. /**
  69101. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69102. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69103. */
  69104. static readonly POSITION_TEXTURE_TYPE: number;
  69105. /**
  69106. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69107. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69108. */
  69109. static readonly VELOCITY_TEXTURE_TYPE: number;
  69110. /**
  69111. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69112. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69113. */
  69114. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69115. /**
  69116. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69117. * in order to compute objects velocities when enableVelocity is set to "true"
  69118. * @hidden
  69119. */
  69120. _previousTransformationMatrices: {
  69121. [index: number]: ISavedTransformationMatrix;
  69122. };
  69123. /**
  69124. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69125. * in order to compute objects velocities when enableVelocity is set to "true"
  69126. * @hidden
  69127. */
  69128. _previousBonesTransformationMatrices: {
  69129. [index: number]: Float32Array;
  69130. };
  69131. /**
  69132. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69133. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69134. */
  69135. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69136. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69137. renderTransparentMeshes: boolean;
  69138. private _scene;
  69139. private _resizeObserver;
  69140. private _multiRenderTarget;
  69141. private _ratio;
  69142. private _enablePosition;
  69143. private _enableVelocity;
  69144. private _enableReflectivity;
  69145. private _positionIndex;
  69146. private _velocityIndex;
  69147. private _reflectivityIndex;
  69148. protected _effect: Effect;
  69149. protected _cachedDefines: string;
  69150. /**
  69151. * Set the render list (meshes to be rendered) used in the G buffer.
  69152. */
  69153. set renderList(meshes: Mesh[]);
  69154. /**
  69155. * Gets wether or not G buffer are supported by the running hardware.
  69156. * This requires draw buffer supports
  69157. */
  69158. get isSupported(): boolean;
  69159. /**
  69160. * Returns the index of the given texture type in the G-Buffer textures array
  69161. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69162. * @returns the index of the given texture type in the G-Buffer textures array
  69163. */
  69164. getTextureIndex(textureType: number): number;
  69165. /**
  69166. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69167. */
  69168. get enablePosition(): boolean;
  69169. /**
  69170. * Sets whether or not objects positions are enabled for the G buffer.
  69171. */
  69172. set enablePosition(enable: boolean);
  69173. /**
  69174. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69175. */
  69176. get enableVelocity(): boolean;
  69177. /**
  69178. * Sets wether or not objects velocities are enabled for the G buffer.
  69179. */
  69180. set enableVelocity(enable: boolean);
  69181. /**
  69182. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69183. */
  69184. get enableReflectivity(): boolean;
  69185. /**
  69186. * Sets wether or not objects roughness are enabled for the G buffer.
  69187. */
  69188. set enableReflectivity(enable: boolean);
  69189. /**
  69190. * Gets the scene associated with the buffer.
  69191. */
  69192. get scene(): Scene;
  69193. /**
  69194. * Gets the ratio used by the buffer during its creation.
  69195. * How big is the buffer related to the main canvas.
  69196. */
  69197. get ratio(): number;
  69198. /** @hidden */
  69199. static _SceneComponentInitialization: (scene: Scene) => void;
  69200. /**
  69201. * Creates a new G Buffer for the scene
  69202. * @param scene The scene the buffer belongs to
  69203. * @param ratio How big is the buffer related to the main canvas.
  69204. */
  69205. constructor(scene: Scene, ratio?: number);
  69206. /**
  69207. * Checks wether everything is ready to render a submesh to the G buffer.
  69208. * @param subMesh the submesh to check readiness for
  69209. * @param useInstances is the mesh drawn using instance or not
  69210. * @returns true if ready otherwise false
  69211. */
  69212. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69213. /**
  69214. * Gets the current underlying G Buffer.
  69215. * @returns the buffer
  69216. */
  69217. getGBuffer(): MultiRenderTarget;
  69218. /**
  69219. * Gets the number of samples used to render the buffer (anti aliasing).
  69220. */
  69221. get samples(): number;
  69222. /**
  69223. * Sets the number of samples used to render the buffer (anti aliasing).
  69224. */
  69225. set samples(value: number);
  69226. /**
  69227. * Disposes the renderer and frees up associated resources.
  69228. */
  69229. dispose(): void;
  69230. protected _createRenderTargets(): void;
  69231. private _copyBonesTransformationMatrices;
  69232. }
  69233. }
  69234. declare module BABYLON {
  69235. interface Scene {
  69236. /** @hidden (Backing field) */
  69237. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69238. /**
  69239. * Gets or Sets the current geometry buffer associated to the scene.
  69240. */
  69241. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69242. /**
  69243. * Enables a GeometryBufferRender and associates it with the scene
  69244. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69245. * @returns the GeometryBufferRenderer
  69246. */
  69247. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69248. /**
  69249. * Disables the GeometryBufferRender associated with the scene
  69250. */
  69251. disableGeometryBufferRenderer(): void;
  69252. }
  69253. /**
  69254. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69255. * in several rendering techniques.
  69256. */
  69257. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69258. /**
  69259. * The component name helpful to identify the component in the list of scene components.
  69260. */
  69261. readonly name: string;
  69262. /**
  69263. * The scene the component belongs to.
  69264. */
  69265. scene: Scene;
  69266. /**
  69267. * Creates a new instance of the component for the given scene
  69268. * @param scene Defines the scene to register the component in
  69269. */
  69270. constructor(scene: Scene);
  69271. /**
  69272. * Registers the component in a given scene
  69273. */
  69274. register(): void;
  69275. /**
  69276. * Rebuilds the elements related to this component in case of
  69277. * context lost for instance.
  69278. */
  69279. rebuild(): void;
  69280. /**
  69281. * Disposes the component and the associated ressources
  69282. */
  69283. dispose(): void;
  69284. private _gatherRenderTargets;
  69285. }
  69286. }
  69287. declare module BABYLON {
  69288. /** @hidden */
  69289. export var motionBlurPixelShader: {
  69290. name: string;
  69291. shader: string;
  69292. };
  69293. }
  69294. declare module BABYLON {
  69295. /**
  69296. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69297. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69298. * As an example, all you have to do is to create the post-process:
  69299. * var mb = new BABYLON.MotionBlurPostProcess(
  69300. * 'mb', // The name of the effect.
  69301. * scene, // The scene containing the objects to blur according to their velocity.
  69302. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69303. * camera // The camera to apply the render pass to.
  69304. * );
  69305. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69306. */
  69307. export class MotionBlurPostProcess extends PostProcess {
  69308. /**
  69309. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69310. */
  69311. motionStrength: number;
  69312. /**
  69313. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69314. */
  69315. get motionBlurSamples(): number;
  69316. /**
  69317. * Sets the number of iterations to be used for motion blur quality
  69318. */
  69319. set motionBlurSamples(samples: number);
  69320. private _motionBlurSamples;
  69321. private _geometryBufferRenderer;
  69322. /**
  69323. * Creates a new instance MotionBlurPostProcess
  69324. * @param name The name of the effect.
  69325. * @param scene The scene containing the objects to blur according to their velocity.
  69326. * @param options The required width/height ratio to downsize to before computing the render pass.
  69327. * @param camera The camera to apply the render pass to.
  69328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69329. * @param engine The engine which the post process will be applied. (default: current engine)
  69330. * @param reusable If the post process can be reused on the same frame. (default: false)
  69331. * @param textureType Type of textures used when performing the post process. (default: 0)
  69332. * @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)
  69333. */
  69334. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69335. /**
  69336. * Excludes the given skinned mesh from computing bones velocities.
  69337. * 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.
  69338. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69339. */
  69340. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69341. /**
  69342. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69343. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69344. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69345. */
  69346. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69347. /**
  69348. * Disposes the post process.
  69349. * @param camera The camera to dispose the post process on.
  69350. */
  69351. dispose(camera?: Camera): void;
  69352. }
  69353. }
  69354. declare module BABYLON {
  69355. /** @hidden */
  69356. export var refractionPixelShader: {
  69357. name: string;
  69358. shader: string;
  69359. };
  69360. }
  69361. declare module BABYLON {
  69362. /**
  69363. * Post process which applies a refractin texture
  69364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69365. */
  69366. export class RefractionPostProcess extends PostProcess {
  69367. /** the base color of the refraction (used to taint the rendering) */
  69368. color: Color3;
  69369. /** simulated refraction depth */
  69370. depth: number;
  69371. /** the coefficient of the base color (0 to remove base color tainting) */
  69372. colorLevel: number;
  69373. private _refTexture;
  69374. private _ownRefractionTexture;
  69375. /**
  69376. * Gets or sets the refraction texture
  69377. * Please note that you are responsible for disposing the texture if you set it manually
  69378. */
  69379. get refractionTexture(): Texture;
  69380. set refractionTexture(value: Texture);
  69381. /**
  69382. * Initializes the RefractionPostProcess
  69383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69384. * @param name The name of the effect.
  69385. * @param refractionTextureUrl Url of the refraction texture to use
  69386. * @param color the base color of the refraction (used to taint the rendering)
  69387. * @param depth simulated refraction depth
  69388. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69389. * @param camera The camera to apply the render pass to.
  69390. * @param options The required width/height ratio to downsize to before computing the render pass.
  69391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69392. * @param engine The engine which the post process will be applied. (default: current engine)
  69393. * @param reusable If the post process can be reused on the same frame. (default: false)
  69394. */
  69395. constructor(name: string, refractionTextureUrl: string,
  69396. /** the base color of the refraction (used to taint the rendering) */
  69397. color: Color3,
  69398. /** simulated refraction depth */
  69399. depth: number,
  69400. /** the coefficient of the base color (0 to remove base color tainting) */
  69401. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69402. /**
  69403. * Disposes of the post process
  69404. * @param camera Camera to dispose post process on
  69405. */
  69406. dispose(camera: Camera): void;
  69407. }
  69408. }
  69409. declare module BABYLON {
  69410. /** @hidden */
  69411. export var sharpenPixelShader: {
  69412. name: string;
  69413. shader: string;
  69414. };
  69415. }
  69416. declare module BABYLON {
  69417. /**
  69418. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69419. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69420. */
  69421. export class SharpenPostProcess extends PostProcess {
  69422. /**
  69423. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69424. */
  69425. colorAmount: number;
  69426. /**
  69427. * How much sharpness should be applied (default: 0.3)
  69428. */
  69429. edgeAmount: number;
  69430. /**
  69431. * Creates a new instance ConvolutionPostProcess
  69432. * @param name The name of the effect.
  69433. * @param options The required width/height ratio to downsize to before computing the render pass.
  69434. * @param camera The camera to apply the render pass to.
  69435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69436. * @param engine The engine which the post process will be applied. (default: current engine)
  69437. * @param reusable If the post process can be reused on the same frame. (default: false)
  69438. * @param textureType Type of textures used when performing the post process. (default: 0)
  69439. * @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)
  69440. */
  69441. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69442. }
  69443. }
  69444. declare module BABYLON {
  69445. /**
  69446. * PostProcessRenderPipeline
  69447. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69448. */
  69449. export class PostProcessRenderPipeline {
  69450. private engine;
  69451. private _renderEffects;
  69452. private _renderEffectsForIsolatedPass;
  69453. /**
  69454. * List of inspectable custom properties (used by the Inspector)
  69455. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69456. */
  69457. inspectableCustomProperties: IInspectable[];
  69458. /**
  69459. * @hidden
  69460. */
  69461. protected _cameras: Camera[];
  69462. /** @hidden */
  69463. _name: string;
  69464. /**
  69465. * Gets pipeline name
  69466. */
  69467. get name(): string;
  69468. /** Gets the list of attached cameras */
  69469. get cameras(): Camera[];
  69470. /**
  69471. * Initializes a PostProcessRenderPipeline
  69472. * @param engine engine to add the pipeline to
  69473. * @param name name of the pipeline
  69474. */
  69475. constructor(engine: Engine, name: string);
  69476. /**
  69477. * Gets the class name
  69478. * @returns "PostProcessRenderPipeline"
  69479. */
  69480. getClassName(): string;
  69481. /**
  69482. * If all the render effects in the pipeline are supported
  69483. */
  69484. get isSupported(): boolean;
  69485. /**
  69486. * Adds an effect to the pipeline
  69487. * @param renderEffect the effect to add
  69488. */
  69489. addEffect(renderEffect: PostProcessRenderEffect): void;
  69490. /** @hidden */
  69491. _rebuild(): void;
  69492. /** @hidden */
  69493. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69494. /** @hidden */
  69495. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69496. /** @hidden */
  69497. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69498. /** @hidden */
  69499. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69500. /** @hidden */
  69501. _attachCameras(cameras: Camera, unique: boolean): void;
  69502. /** @hidden */
  69503. _attachCameras(cameras: Camera[], unique: boolean): void;
  69504. /** @hidden */
  69505. _detachCameras(cameras: Camera): void;
  69506. /** @hidden */
  69507. _detachCameras(cameras: Nullable<Camera[]>): void;
  69508. /** @hidden */
  69509. _update(): void;
  69510. /** @hidden */
  69511. _reset(): void;
  69512. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69513. /**
  69514. * Sets the required values to the prepass renderer.
  69515. * @param prePassRenderer defines the prepass renderer to setup.
  69516. * @returns true if the pre pass is needed.
  69517. */
  69518. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69519. /**
  69520. * Disposes of the pipeline
  69521. */
  69522. dispose(): void;
  69523. }
  69524. }
  69525. declare module BABYLON {
  69526. /**
  69527. * PostProcessRenderPipelineManager class
  69528. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69529. */
  69530. export class PostProcessRenderPipelineManager {
  69531. private _renderPipelines;
  69532. /**
  69533. * Initializes a PostProcessRenderPipelineManager
  69534. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69535. */
  69536. constructor();
  69537. /**
  69538. * Gets the list of supported render pipelines
  69539. */
  69540. get supportedPipelines(): PostProcessRenderPipeline[];
  69541. /**
  69542. * Adds a pipeline to the manager
  69543. * @param renderPipeline The pipeline to add
  69544. */
  69545. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69546. /**
  69547. * Attaches a camera to the pipeline
  69548. * @param renderPipelineName The name of the pipeline to attach to
  69549. * @param cameras the camera to attach
  69550. * @param unique if the camera can be attached multiple times to the pipeline
  69551. */
  69552. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69553. /**
  69554. * Detaches a camera from the pipeline
  69555. * @param renderPipelineName The name of the pipeline to detach from
  69556. * @param cameras the camera to detach
  69557. */
  69558. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69559. /**
  69560. * Enables an effect by name on a pipeline
  69561. * @param renderPipelineName the name of the pipeline to enable the effect in
  69562. * @param renderEffectName the name of the effect to enable
  69563. * @param cameras the cameras that the effect should be enabled on
  69564. */
  69565. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69566. /**
  69567. * Disables an effect by name on a pipeline
  69568. * @param renderPipelineName the name of the pipeline to disable the effect in
  69569. * @param renderEffectName the name of the effect to disable
  69570. * @param cameras the cameras that the effect should be disabled on
  69571. */
  69572. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69573. /**
  69574. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69575. */
  69576. update(): void;
  69577. /** @hidden */
  69578. _rebuild(): void;
  69579. /**
  69580. * Disposes of the manager and pipelines
  69581. */
  69582. dispose(): void;
  69583. }
  69584. }
  69585. declare module BABYLON {
  69586. interface Scene {
  69587. /** @hidden (Backing field) */
  69588. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69589. /**
  69590. * Gets the postprocess render pipeline manager
  69591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69592. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69593. */
  69594. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69595. }
  69596. /**
  69597. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69598. */
  69599. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69600. /**
  69601. * The component name helpfull to identify the component in the list of scene components.
  69602. */
  69603. readonly name: string;
  69604. /**
  69605. * The scene the component belongs to.
  69606. */
  69607. scene: Scene;
  69608. /**
  69609. * Creates a new instance of the component for the given scene
  69610. * @param scene Defines the scene to register the component in
  69611. */
  69612. constructor(scene: Scene);
  69613. /**
  69614. * Registers the component in a given scene
  69615. */
  69616. register(): void;
  69617. /**
  69618. * Rebuilds the elements related to this component in case of
  69619. * context lost for instance.
  69620. */
  69621. rebuild(): void;
  69622. /**
  69623. * Disposes the component and the associated ressources
  69624. */
  69625. dispose(): void;
  69626. private _gatherRenderTargets;
  69627. }
  69628. }
  69629. declare module BABYLON {
  69630. /**
  69631. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69632. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69633. */
  69634. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69635. private _scene;
  69636. private _camerasToBeAttached;
  69637. /**
  69638. * ID of the sharpen post process,
  69639. */
  69640. private readonly SharpenPostProcessId;
  69641. /**
  69642. * @ignore
  69643. * ID of the image processing post process;
  69644. */
  69645. readonly ImageProcessingPostProcessId: string;
  69646. /**
  69647. * @ignore
  69648. * ID of the Fast Approximate Anti-Aliasing post process;
  69649. */
  69650. readonly FxaaPostProcessId: string;
  69651. /**
  69652. * ID of the chromatic aberration post process,
  69653. */
  69654. private readonly ChromaticAberrationPostProcessId;
  69655. /**
  69656. * ID of the grain post process
  69657. */
  69658. private readonly GrainPostProcessId;
  69659. /**
  69660. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69661. */
  69662. sharpen: SharpenPostProcess;
  69663. private _sharpenEffect;
  69664. private bloom;
  69665. /**
  69666. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69667. */
  69668. depthOfField: DepthOfFieldEffect;
  69669. /**
  69670. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69671. */
  69672. fxaa: FxaaPostProcess;
  69673. /**
  69674. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69675. */
  69676. imageProcessing: ImageProcessingPostProcess;
  69677. /**
  69678. * Chromatic aberration post process which will shift rgb colors in the image
  69679. */
  69680. chromaticAberration: ChromaticAberrationPostProcess;
  69681. private _chromaticAberrationEffect;
  69682. /**
  69683. * Grain post process which add noise to the image
  69684. */
  69685. grain: GrainPostProcess;
  69686. private _grainEffect;
  69687. /**
  69688. * Glow post process which adds a glow to emissive areas of the image
  69689. */
  69690. private _glowLayer;
  69691. /**
  69692. * Animations which can be used to tweak settings over a period of time
  69693. */
  69694. animations: Animation[];
  69695. private _imageProcessingConfigurationObserver;
  69696. private _sharpenEnabled;
  69697. private _bloomEnabled;
  69698. private _depthOfFieldEnabled;
  69699. private _depthOfFieldBlurLevel;
  69700. private _fxaaEnabled;
  69701. private _imageProcessingEnabled;
  69702. private _defaultPipelineTextureType;
  69703. private _bloomScale;
  69704. private _chromaticAberrationEnabled;
  69705. private _grainEnabled;
  69706. private _buildAllowed;
  69707. /**
  69708. * Gets active scene
  69709. */
  69710. get scene(): Scene;
  69711. /**
  69712. * Enable or disable the sharpen process from the pipeline
  69713. */
  69714. set sharpenEnabled(enabled: boolean);
  69715. get sharpenEnabled(): boolean;
  69716. private _resizeObserver;
  69717. private _hardwareScaleLevel;
  69718. private _bloomKernel;
  69719. /**
  69720. * Specifies the size of the bloom blur kernel, relative to the final output size
  69721. */
  69722. get bloomKernel(): number;
  69723. set bloomKernel(value: number);
  69724. /**
  69725. * Specifies the weight of the bloom in the final rendering
  69726. */
  69727. private _bloomWeight;
  69728. /**
  69729. * Specifies the luma threshold for the area that will be blurred by the bloom
  69730. */
  69731. private _bloomThreshold;
  69732. private _hdr;
  69733. /**
  69734. * The strength of the bloom.
  69735. */
  69736. set bloomWeight(value: number);
  69737. get bloomWeight(): number;
  69738. /**
  69739. * The strength of the bloom.
  69740. */
  69741. set bloomThreshold(value: number);
  69742. get bloomThreshold(): number;
  69743. /**
  69744. * The scale of the bloom, lower value will provide better performance.
  69745. */
  69746. set bloomScale(value: number);
  69747. get bloomScale(): number;
  69748. /**
  69749. * Enable or disable the bloom from the pipeline
  69750. */
  69751. set bloomEnabled(enabled: boolean);
  69752. get bloomEnabled(): boolean;
  69753. private _rebuildBloom;
  69754. /**
  69755. * If the depth of field is enabled.
  69756. */
  69757. get depthOfFieldEnabled(): boolean;
  69758. set depthOfFieldEnabled(enabled: boolean);
  69759. /**
  69760. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69761. */
  69762. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69763. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69764. /**
  69765. * If the anti aliasing is enabled.
  69766. */
  69767. set fxaaEnabled(enabled: boolean);
  69768. get fxaaEnabled(): boolean;
  69769. private _samples;
  69770. /**
  69771. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69772. */
  69773. set samples(sampleCount: number);
  69774. get samples(): number;
  69775. /**
  69776. * If image processing is enabled.
  69777. */
  69778. set imageProcessingEnabled(enabled: boolean);
  69779. get imageProcessingEnabled(): boolean;
  69780. /**
  69781. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69782. */
  69783. set glowLayerEnabled(enabled: boolean);
  69784. get glowLayerEnabled(): boolean;
  69785. /**
  69786. * Gets the glow layer (or null if not defined)
  69787. */
  69788. get glowLayer(): Nullable<GlowLayer>;
  69789. /**
  69790. * Enable or disable the chromaticAberration process from the pipeline
  69791. */
  69792. set chromaticAberrationEnabled(enabled: boolean);
  69793. get chromaticAberrationEnabled(): boolean;
  69794. /**
  69795. * Enable or disable the grain process from the pipeline
  69796. */
  69797. set grainEnabled(enabled: boolean);
  69798. get grainEnabled(): boolean;
  69799. /**
  69800. * @constructor
  69801. * @param name - The rendering pipeline name (default: "")
  69802. * @param hdr - If high dynamic range textures should be used (default: true)
  69803. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69804. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69805. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69806. */
  69807. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69808. /**
  69809. * Get the class name
  69810. * @returns "DefaultRenderingPipeline"
  69811. */
  69812. getClassName(): string;
  69813. /**
  69814. * Force the compilation of the entire pipeline.
  69815. */
  69816. prepare(): void;
  69817. private _hasCleared;
  69818. private _prevPostProcess;
  69819. private _prevPrevPostProcess;
  69820. private _setAutoClearAndTextureSharing;
  69821. private _depthOfFieldSceneObserver;
  69822. private _buildPipeline;
  69823. private _disposePostProcesses;
  69824. /**
  69825. * Adds a camera to the pipeline
  69826. * @param camera the camera to be added
  69827. */
  69828. addCamera(camera: Camera): void;
  69829. /**
  69830. * Removes a camera from the pipeline
  69831. * @param camera the camera to remove
  69832. */
  69833. removeCamera(camera: Camera): void;
  69834. /**
  69835. * Dispose of the pipeline and stop all post processes
  69836. */
  69837. dispose(): void;
  69838. /**
  69839. * Serialize the rendering pipeline (Used when exporting)
  69840. * @returns the serialized object
  69841. */
  69842. serialize(): any;
  69843. /**
  69844. * Parse the serialized pipeline
  69845. * @param source Source pipeline.
  69846. * @param scene The scene to load the pipeline to.
  69847. * @param rootUrl The URL of the serialized pipeline.
  69848. * @returns An instantiated pipeline from the serialized object.
  69849. */
  69850. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69851. }
  69852. }
  69853. declare module BABYLON {
  69854. /** @hidden */
  69855. export var lensHighlightsPixelShader: {
  69856. name: string;
  69857. shader: string;
  69858. };
  69859. }
  69860. declare module BABYLON {
  69861. /** @hidden */
  69862. export var depthOfFieldPixelShader: {
  69863. name: string;
  69864. shader: string;
  69865. };
  69866. }
  69867. declare module BABYLON {
  69868. /**
  69869. * BABYLON.JS Chromatic Aberration GLSL Shader
  69870. * Author: Olivier Guyot
  69871. * Separates very slightly R, G and B colors on the edges of the screen
  69872. * Inspired by Francois Tarlier & Martins Upitis
  69873. */
  69874. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69875. /**
  69876. * @ignore
  69877. * The chromatic aberration PostProcess id in the pipeline
  69878. */
  69879. LensChromaticAberrationEffect: string;
  69880. /**
  69881. * @ignore
  69882. * The highlights enhancing PostProcess id in the pipeline
  69883. */
  69884. HighlightsEnhancingEffect: string;
  69885. /**
  69886. * @ignore
  69887. * The depth-of-field PostProcess id in the pipeline
  69888. */
  69889. LensDepthOfFieldEffect: string;
  69890. private _scene;
  69891. private _depthTexture;
  69892. private _grainTexture;
  69893. private _chromaticAberrationPostProcess;
  69894. private _highlightsPostProcess;
  69895. private _depthOfFieldPostProcess;
  69896. private _edgeBlur;
  69897. private _grainAmount;
  69898. private _chromaticAberration;
  69899. private _distortion;
  69900. private _highlightsGain;
  69901. private _highlightsThreshold;
  69902. private _dofDistance;
  69903. private _dofAperture;
  69904. private _dofDarken;
  69905. private _dofPentagon;
  69906. private _blurNoise;
  69907. /**
  69908. * @constructor
  69909. *
  69910. * Effect parameters are as follow:
  69911. * {
  69912. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69913. * edge_blur: number; // from 0 to x (1 for realism)
  69914. * distortion: number; // from 0 to x (1 for realism)
  69915. * grain_amount: number; // from 0 to 1
  69916. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69917. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69918. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69919. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69920. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69921. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69922. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69923. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69924. * }
  69925. * Note: if an effect parameter is unset, effect is disabled
  69926. *
  69927. * @param name The rendering pipeline name
  69928. * @param parameters - An object containing all parameters (see above)
  69929. * @param scene The scene linked to this pipeline
  69930. * @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)
  69931. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69932. */
  69933. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69934. /**
  69935. * Get the class name
  69936. * @returns "LensRenderingPipeline"
  69937. */
  69938. getClassName(): string;
  69939. /**
  69940. * Gets associated scene
  69941. */
  69942. get scene(): Scene;
  69943. /**
  69944. * Gets or sets the edge blur
  69945. */
  69946. get edgeBlur(): number;
  69947. set edgeBlur(value: number);
  69948. /**
  69949. * Gets or sets the grain amount
  69950. */
  69951. get grainAmount(): number;
  69952. set grainAmount(value: number);
  69953. /**
  69954. * Gets or sets the chromatic aberration amount
  69955. */
  69956. get chromaticAberration(): number;
  69957. set chromaticAberration(value: number);
  69958. /**
  69959. * Gets or sets the depth of field aperture
  69960. */
  69961. get dofAperture(): number;
  69962. set dofAperture(value: number);
  69963. /**
  69964. * Gets or sets the edge distortion
  69965. */
  69966. get edgeDistortion(): number;
  69967. set edgeDistortion(value: number);
  69968. /**
  69969. * Gets or sets the depth of field distortion
  69970. */
  69971. get dofDistortion(): number;
  69972. set dofDistortion(value: number);
  69973. /**
  69974. * Gets or sets the darken out of focus amount
  69975. */
  69976. get darkenOutOfFocus(): number;
  69977. set darkenOutOfFocus(value: number);
  69978. /**
  69979. * Gets or sets a boolean indicating if blur noise is enabled
  69980. */
  69981. get blurNoise(): boolean;
  69982. set blurNoise(value: boolean);
  69983. /**
  69984. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69985. */
  69986. get pentagonBokeh(): boolean;
  69987. set pentagonBokeh(value: boolean);
  69988. /**
  69989. * Gets or sets the highlight grain amount
  69990. */
  69991. get highlightsGain(): number;
  69992. set highlightsGain(value: number);
  69993. /**
  69994. * Gets or sets the highlight threshold
  69995. */
  69996. get highlightsThreshold(): number;
  69997. set highlightsThreshold(value: number);
  69998. /**
  69999. * Sets the amount of blur at the edges
  70000. * @param amount blur amount
  70001. */
  70002. setEdgeBlur(amount: number): void;
  70003. /**
  70004. * Sets edge blur to 0
  70005. */
  70006. disableEdgeBlur(): void;
  70007. /**
  70008. * Sets the amout of grain
  70009. * @param amount Amount of grain
  70010. */
  70011. setGrainAmount(amount: number): void;
  70012. /**
  70013. * Set grain amount to 0
  70014. */
  70015. disableGrain(): void;
  70016. /**
  70017. * Sets the chromatic aberration amount
  70018. * @param amount amount of chromatic aberration
  70019. */
  70020. setChromaticAberration(amount: number): void;
  70021. /**
  70022. * Sets chromatic aberration amount to 0
  70023. */
  70024. disableChromaticAberration(): void;
  70025. /**
  70026. * Sets the EdgeDistortion amount
  70027. * @param amount amount of EdgeDistortion
  70028. */
  70029. setEdgeDistortion(amount: number): void;
  70030. /**
  70031. * Sets edge distortion to 0
  70032. */
  70033. disableEdgeDistortion(): void;
  70034. /**
  70035. * Sets the FocusDistance amount
  70036. * @param amount amount of FocusDistance
  70037. */
  70038. setFocusDistance(amount: number): void;
  70039. /**
  70040. * Disables depth of field
  70041. */
  70042. disableDepthOfField(): void;
  70043. /**
  70044. * Sets the Aperture amount
  70045. * @param amount amount of Aperture
  70046. */
  70047. setAperture(amount: number): void;
  70048. /**
  70049. * Sets the DarkenOutOfFocus amount
  70050. * @param amount amount of DarkenOutOfFocus
  70051. */
  70052. setDarkenOutOfFocus(amount: number): void;
  70053. private _pentagonBokehIsEnabled;
  70054. /**
  70055. * Creates a pentagon bokeh effect
  70056. */
  70057. enablePentagonBokeh(): void;
  70058. /**
  70059. * Disables the pentagon bokeh effect
  70060. */
  70061. disablePentagonBokeh(): void;
  70062. /**
  70063. * Enables noise blur
  70064. */
  70065. enableNoiseBlur(): void;
  70066. /**
  70067. * Disables noise blur
  70068. */
  70069. disableNoiseBlur(): void;
  70070. /**
  70071. * Sets the HighlightsGain amount
  70072. * @param amount amount of HighlightsGain
  70073. */
  70074. setHighlightsGain(amount: number): void;
  70075. /**
  70076. * Sets the HighlightsThreshold amount
  70077. * @param amount amount of HighlightsThreshold
  70078. */
  70079. setHighlightsThreshold(amount: number): void;
  70080. /**
  70081. * Disables highlights
  70082. */
  70083. disableHighlights(): void;
  70084. /**
  70085. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70086. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70087. */
  70088. dispose(disableDepthRender?: boolean): void;
  70089. private _createChromaticAberrationPostProcess;
  70090. private _createHighlightsPostProcess;
  70091. private _createDepthOfFieldPostProcess;
  70092. private _createGrainTexture;
  70093. }
  70094. }
  70095. declare module BABYLON {
  70096. /** @hidden */
  70097. export var ssao2PixelShader: {
  70098. name: string;
  70099. shader: string;
  70100. };
  70101. }
  70102. declare module BABYLON {
  70103. /** @hidden */
  70104. export var ssaoCombinePixelShader: {
  70105. name: string;
  70106. shader: string;
  70107. };
  70108. }
  70109. declare module BABYLON {
  70110. /**
  70111. * Render pipeline to produce ssao effect
  70112. */
  70113. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70114. /**
  70115. * @ignore
  70116. * The PassPostProcess id in the pipeline that contains the original scene color
  70117. */
  70118. SSAOOriginalSceneColorEffect: string;
  70119. /**
  70120. * @ignore
  70121. * The SSAO PostProcess id in the pipeline
  70122. */
  70123. SSAORenderEffect: string;
  70124. /**
  70125. * @ignore
  70126. * The horizontal blur PostProcess id in the pipeline
  70127. */
  70128. SSAOBlurHRenderEffect: string;
  70129. /**
  70130. * @ignore
  70131. * The vertical blur PostProcess id in the pipeline
  70132. */
  70133. SSAOBlurVRenderEffect: string;
  70134. /**
  70135. * @ignore
  70136. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70137. */
  70138. SSAOCombineRenderEffect: string;
  70139. /**
  70140. * The output strength of the SSAO post-process. Default value is 1.0.
  70141. */
  70142. totalStrength: number;
  70143. /**
  70144. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70145. */
  70146. maxZ: number;
  70147. /**
  70148. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70149. */
  70150. minZAspect: number;
  70151. private _samples;
  70152. /**
  70153. * Number of samples used for the SSAO calculations. Default value is 8
  70154. */
  70155. set samples(n: number);
  70156. get samples(): number;
  70157. private _textureSamples;
  70158. /**
  70159. * Number of samples to use for antialiasing
  70160. */
  70161. set textureSamples(n: number);
  70162. get textureSamples(): number;
  70163. /**
  70164. * Force rendering the geometry through geometry buffer
  70165. */
  70166. private _forceGeometryBuffer;
  70167. /**
  70168. * Ratio object used for SSAO ratio and blur ratio
  70169. */
  70170. private _ratio;
  70171. /**
  70172. * Dynamically generated sphere sampler.
  70173. */
  70174. private _sampleSphere;
  70175. /**
  70176. * Blur filter offsets
  70177. */
  70178. private _samplerOffsets;
  70179. private _expensiveBlur;
  70180. /**
  70181. * If bilateral blur should be used
  70182. */
  70183. set expensiveBlur(b: boolean);
  70184. get expensiveBlur(): boolean;
  70185. /**
  70186. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70187. */
  70188. radius: number;
  70189. /**
  70190. * The base color of the SSAO post-process
  70191. * The final result is "base + ssao" between [0, 1]
  70192. */
  70193. base: number;
  70194. /**
  70195. * Support test.
  70196. */
  70197. static get IsSupported(): boolean;
  70198. private _scene;
  70199. private _randomTexture;
  70200. private _originalColorPostProcess;
  70201. private _ssaoPostProcess;
  70202. private _blurHPostProcess;
  70203. private _blurVPostProcess;
  70204. private _ssaoCombinePostProcess;
  70205. private _prePassRenderer;
  70206. /**
  70207. * Gets active scene
  70208. */
  70209. get scene(): Scene;
  70210. /**
  70211. * @constructor
  70212. * @param name The rendering pipeline name
  70213. * @param scene The scene linked to this pipeline
  70214. * @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 }
  70215. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70216. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70217. */
  70218. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70219. /**
  70220. * Get the class name
  70221. * @returns "SSAO2RenderingPipeline"
  70222. */
  70223. getClassName(): string;
  70224. /**
  70225. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70226. */
  70227. dispose(disableGeometryBufferRenderer?: boolean): void;
  70228. private _createBlurPostProcess;
  70229. /** @hidden */
  70230. _rebuild(): void;
  70231. private _bits;
  70232. private _radicalInverse_VdC;
  70233. private _hammersley;
  70234. private _hemisphereSample_uniform;
  70235. private _generateHemisphere;
  70236. private _getDefinesForSSAO;
  70237. private _createSSAOPostProcess;
  70238. private _createSSAOCombinePostProcess;
  70239. private _createRandomTexture;
  70240. /**
  70241. * Serialize the rendering pipeline (Used when exporting)
  70242. * @returns the serialized object
  70243. */
  70244. serialize(): any;
  70245. /**
  70246. * Parse the serialized pipeline
  70247. * @param source Source pipeline.
  70248. * @param scene The scene to load the pipeline to.
  70249. * @param rootUrl The URL of the serialized pipeline.
  70250. * @returns An instantiated pipeline from the serialized object.
  70251. */
  70252. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70253. /**
  70254. * Sets the required values to the prepass renderer.
  70255. * @param prePassRenderer defines the prepass renderer to setup
  70256. * @returns true if the pre pass is needed.
  70257. */
  70258. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70259. }
  70260. }
  70261. declare module BABYLON {
  70262. /** @hidden */
  70263. export var ssaoPixelShader: {
  70264. name: string;
  70265. shader: string;
  70266. };
  70267. }
  70268. declare module BABYLON {
  70269. /**
  70270. * Render pipeline to produce ssao effect
  70271. */
  70272. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70273. /**
  70274. * @ignore
  70275. * The PassPostProcess id in the pipeline that contains the original scene color
  70276. */
  70277. SSAOOriginalSceneColorEffect: string;
  70278. /**
  70279. * @ignore
  70280. * The SSAO PostProcess id in the pipeline
  70281. */
  70282. SSAORenderEffect: string;
  70283. /**
  70284. * @ignore
  70285. * The horizontal blur PostProcess id in the pipeline
  70286. */
  70287. SSAOBlurHRenderEffect: string;
  70288. /**
  70289. * @ignore
  70290. * The vertical blur PostProcess id in the pipeline
  70291. */
  70292. SSAOBlurVRenderEffect: string;
  70293. /**
  70294. * @ignore
  70295. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70296. */
  70297. SSAOCombineRenderEffect: string;
  70298. /**
  70299. * The output strength of the SSAO post-process. Default value is 1.0.
  70300. */
  70301. totalStrength: number;
  70302. /**
  70303. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70304. */
  70305. radius: number;
  70306. /**
  70307. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70308. * Must not be equal to fallOff and superior to fallOff.
  70309. * Default value is 0.0075
  70310. */
  70311. area: number;
  70312. /**
  70313. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70314. * Must not be equal to area and inferior to area.
  70315. * Default value is 0.000001
  70316. */
  70317. fallOff: number;
  70318. /**
  70319. * The base color of the SSAO post-process
  70320. * The final result is "base + ssao" between [0, 1]
  70321. */
  70322. base: number;
  70323. private _scene;
  70324. private _depthTexture;
  70325. private _randomTexture;
  70326. private _originalColorPostProcess;
  70327. private _ssaoPostProcess;
  70328. private _blurHPostProcess;
  70329. private _blurVPostProcess;
  70330. private _ssaoCombinePostProcess;
  70331. private _firstUpdate;
  70332. /**
  70333. * Gets active scene
  70334. */
  70335. get scene(): Scene;
  70336. /**
  70337. * @constructor
  70338. * @param name - The rendering pipeline name
  70339. * @param scene - The scene linked to this pipeline
  70340. * @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 }
  70341. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70342. */
  70343. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70344. /**
  70345. * Get the class name
  70346. * @returns "SSAORenderingPipeline"
  70347. */
  70348. getClassName(): string;
  70349. /**
  70350. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70351. */
  70352. dispose(disableDepthRender?: boolean): void;
  70353. private _createBlurPostProcess;
  70354. /** @hidden */
  70355. _rebuild(): void;
  70356. private _createSSAOPostProcess;
  70357. private _createSSAOCombinePostProcess;
  70358. private _createRandomTexture;
  70359. }
  70360. }
  70361. declare module BABYLON {
  70362. /** @hidden */
  70363. export var screenSpaceReflectionPixelShader: {
  70364. name: string;
  70365. shader: string;
  70366. };
  70367. }
  70368. declare module BABYLON {
  70369. /**
  70370. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70371. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70372. */
  70373. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70374. /**
  70375. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70376. */
  70377. threshold: number;
  70378. /**
  70379. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70380. */
  70381. strength: number;
  70382. /**
  70383. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70384. */
  70385. reflectionSpecularFalloffExponent: number;
  70386. /**
  70387. * 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]
  70388. */
  70389. step: number;
  70390. /**
  70391. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70392. */
  70393. roughnessFactor: number;
  70394. private _geometryBufferRenderer;
  70395. private _enableSmoothReflections;
  70396. private _reflectionSamples;
  70397. private _smoothSteps;
  70398. /**
  70399. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70400. * @param name The name of the effect.
  70401. * @param scene The scene containing the objects to calculate reflections.
  70402. * @param options The required width/height ratio to downsize to before computing the render pass.
  70403. * @param camera The camera to apply the render pass to.
  70404. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70405. * @param engine The engine which the post process will be applied. (default: current engine)
  70406. * @param reusable If the post process can be reused on the same frame. (default: false)
  70407. * @param textureType Type of textures used when performing the post process. (default: 0)
  70408. * @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)
  70409. */
  70410. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70411. /**
  70412. * Gets wether or not smoothing reflections is enabled.
  70413. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70414. */
  70415. get enableSmoothReflections(): boolean;
  70416. /**
  70417. * Sets wether or not smoothing reflections is enabled.
  70418. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70419. */
  70420. set enableSmoothReflections(enabled: boolean);
  70421. /**
  70422. * Gets the number of samples taken while computing reflections. More samples count is high,
  70423. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70424. */
  70425. get reflectionSamples(): number;
  70426. /**
  70427. * Sets the number of samples taken while computing reflections. More samples count is high,
  70428. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70429. */
  70430. set reflectionSamples(samples: number);
  70431. /**
  70432. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70433. * more the post-process will require GPU power and can generate a drop in FPS.
  70434. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70435. */
  70436. get smoothSteps(): number;
  70437. set smoothSteps(steps: number);
  70438. private _updateEffectDefines;
  70439. }
  70440. }
  70441. declare module BABYLON {
  70442. /** @hidden */
  70443. export var standardPixelShader: {
  70444. name: string;
  70445. shader: string;
  70446. };
  70447. }
  70448. declare module BABYLON {
  70449. /**
  70450. * Standard rendering pipeline
  70451. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70452. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70453. */
  70454. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70455. /**
  70456. * Public members
  70457. */
  70458. /**
  70459. * Post-process which contains the original scene color before the pipeline applies all the effects
  70460. */
  70461. originalPostProcess: Nullable<PostProcess>;
  70462. /**
  70463. * Post-process used to down scale an image x4
  70464. */
  70465. downSampleX4PostProcess: Nullable<PostProcess>;
  70466. /**
  70467. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70468. */
  70469. brightPassPostProcess: Nullable<PostProcess>;
  70470. /**
  70471. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70472. */
  70473. blurHPostProcesses: PostProcess[];
  70474. /**
  70475. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70476. */
  70477. blurVPostProcesses: PostProcess[];
  70478. /**
  70479. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70480. */
  70481. textureAdderPostProcess: Nullable<PostProcess>;
  70482. /**
  70483. * Post-process used to create volumetric lighting effect
  70484. */
  70485. volumetricLightPostProcess: Nullable<PostProcess>;
  70486. /**
  70487. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70488. */
  70489. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70490. /**
  70491. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70492. */
  70493. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70494. /**
  70495. * Post-process used to merge the volumetric light effect and the real scene color
  70496. */
  70497. volumetricLightMergePostProces: Nullable<PostProcess>;
  70498. /**
  70499. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70500. */
  70501. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70502. /**
  70503. * Base post-process used to calculate the average luminance of the final image for HDR
  70504. */
  70505. luminancePostProcess: Nullable<PostProcess>;
  70506. /**
  70507. * Post-processes used to create down sample post-processes in order to get
  70508. * the average luminance of the final image for HDR
  70509. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70510. */
  70511. luminanceDownSamplePostProcesses: PostProcess[];
  70512. /**
  70513. * Post-process used to create a HDR effect (light adaptation)
  70514. */
  70515. hdrPostProcess: Nullable<PostProcess>;
  70516. /**
  70517. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70518. */
  70519. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70520. /**
  70521. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70522. */
  70523. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70524. /**
  70525. * Post-process used to merge the final HDR post-process and the real scene color
  70526. */
  70527. hdrFinalPostProcess: Nullable<PostProcess>;
  70528. /**
  70529. * Post-process used to create a lens flare effect
  70530. */
  70531. lensFlarePostProcess: Nullable<PostProcess>;
  70532. /**
  70533. * Post-process that merges the result of the lens flare post-process and the real scene color
  70534. */
  70535. lensFlareComposePostProcess: Nullable<PostProcess>;
  70536. /**
  70537. * Post-process used to create a motion blur effect
  70538. */
  70539. motionBlurPostProcess: Nullable<PostProcess>;
  70540. /**
  70541. * Post-process used to create a depth of field effect
  70542. */
  70543. depthOfFieldPostProcess: Nullable<PostProcess>;
  70544. /**
  70545. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70546. */
  70547. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70548. /**
  70549. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70550. */
  70551. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70552. /**
  70553. * Represents the brightness threshold in order to configure the illuminated surfaces
  70554. */
  70555. brightThreshold: number;
  70556. /**
  70557. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70558. */
  70559. blurWidth: number;
  70560. /**
  70561. * Sets if the blur for highlighted surfaces must be only horizontal
  70562. */
  70563. horizontalBlur: boolean;
  70564. /**
  70565. * Gets the overall exposure used by the pipeline
  70566. */
  70567. get exposure(): number;
  70568. /**
  70569. * Sets the overall exposure used by the pipeline
  70570. */
  70571. set exposure(value: number);
  70572. /**
  70573. * Texture used typically to simulate "dirty" on camera lens
  70574. */
  70575. lensTexture: Nullable<Texture>;
  70576. /**
  70577. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70578. */
  70579. volumetricLightCoefficient: number;
  70580. /**
  70581. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70582. */
  70583. volumetricLightPower: number;
  70584. /**
  70585. * Used the set the blur intensity to smooth the volumetric lights
  70586. */
  70587. volumetricLightBlurScale: number;
  70588. /**
  70589. * Light (spot or directional) used to generate the volumetric lights rays
  70590. * The source light must have a shadow generate so the pipeline can get its
  70591. * depth map
  70592. */
  70593. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70594. /**
  70595. * For eye adaptation, represents the minimum luminance the eye can see
  70596. */
  70597. hdrMinimumLuminance: number;
  70598. /**
  70599. * For eye adaptation, represents the decrease luminance speed
  70600. */
  70601. hdrDecreaseRate: number;
  70602. /**
  70603. * For eye adaptation, represents the increase luminance speed
  70604. */
  70605. hdrIncreaseRate: number;
  70606. /**
  70607. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70608. */
  70609. get hdrAutoExposure(): boolean;
  70610. /**
  70611. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70612. */
  70613. set hdrAutoExposure(value: boolean);
  70614. /**
  70615. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70616. */
  70617. lensColorTexture: Nullable<Texture>;
  70618. /**
  70619. * The overall strengh for the lens flare effect
  70620. */
  70621. lensFlareStrength: number;
  70622. /**
  70623. * Dispersion coefficient for lens flare ghosts
  70624. */
  70625. lensFlareGhostDispersal: number;
  70626. /**
  70627. * Main lens flare halo width
  70628. */
  70629. lensFlareHaloWidth: number;
  70630. /**
  70631. * Based on the lens distortion effect, defines how much the lens flare result
  70632. * is distorted
  70633. */
  70634. lensFlareDistortionStrength: number;
  70635. /**
  70636. * Configures the blur intensity used for for lens flare (halo)
  70637. */
  70638. lensFlareBlurWidth: number;
  70639. /**
  70640. * Lens star texture must be used to simulate rays on the flares and is available
  70641. * in the documentation
  70642. */
  70643. lensStarTexture: Nullable<Texture>;
  70644. /**
  70645. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70646. * flare effect by taking account of the dirt texture
  70647. */
  70648. lensFlareDirtTexture: Nullable<Texture>;
  70649. /**
  70650. * Represents the focal length for the depth of field effect
  70651. */
  70652. depthOfFieldDistance: number;
  70653. /**
  70654. * Represents the blur intensity for the blurred part of the depth of field effect
  70655. */
  70656. depthOfFieldBlurWidth: number;
  70657. /**
  70658. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70659. */
  70660. get motionStrength(): number;
  70661. /**
  70662. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70663. */
  70664. set motionStrength(strength: number);
  70665. /**
  70666. * Gets wether or not the motion blur post-process is object based or screen based.
  70667. */
  70668. get objectBasedMotionBlur(): boolean;
  70669. /**
  70670. * Sets wether or not the motion blur post-process should be object based or screen based
  70671. */
  70672. set objectBasedMotionBlur(value: boolean);
  70673. /**
  70674. * List of animations for the pipeline (IAnimatable implementation)
  70675. */
  70676. animations: Animation[];
  70677. /**
  70678. * Private members
  70679. */
  70680. private _scene;
  70681. private _currentDepthOfFieldSource;
  70682. private _basePostProcess;
  70683. private _fixedExposure;
  70684. private _currentExposure;
  70685. private _hdrAutoExposure;
  70686. private _hdrCurrentLuminance;
  70687. private _motionStrength;
  70688. private _isObjectBasedMotionBlur;
  70689. private _floatTextureType;
  70690. private _camerasToBeAttached;
  70691. private _ratio;
  70692. private _bloomEnabled;
  70693. private _depthOfFieldEnabled;
  70694. private _vlsEnabled;
  70695. private _lensFlareEnabled;
  70696. private _hdrEnabled;
  70697. private _motionBlurEnabled;
  70698. private _fxaaEnabled;
  70699. private _screenSpaceReflectionsEnabled;
  70700. private _motionBlurSamples;
  70701. private _volumetricLightStepsCount;
  70702. private _samples;
  70703. /**
  70704. * @ignore
  70705. * Specifies if the bloom pipeline is enabled
  70706. */
  70707. get BloomEnabled(): boolean;
  70708. set BloomEnabled(enabled: boolean);
  70709. /**
  70710. * @ignore
  70711. * Specifies if the depth of field pipeline is enabed
  70712. */
  70713. get DepthOfFieldEnabled(): boolean;
  70714. set DepthOfFieldEnabled(enabled: boolean);
  70715. /**
  70716. * @ignore
  70717. * Specifies if the lens flare pipeline is enabed
  70718. */
  70719. get LensFlareEnabled(): boolean;
  70720. set LensFlareEnabled(enabled: boolean);
  70721. /**
  70722. * @ignore
  70723. * Specifies if the HDR pipeline is enabled
  70724. */
  70725. get HDREnabled(): boolean;
  70726. set HDREnabled(enabled: boolean);
  70727. /**
  70728. * @ignore
  70729. * Specifies if the volumetric lights scattering effect is enabled
  70730. */
  70731. get VLSEnabled(): boolean;
  70732. set VLSEnabled(enabled: boolean);
  70733. /**
  70734. * @ignore
  70735. * Specifies if the motion blur effect is enabled
  70736. */
  70737. get MotionBlurEnabled(): boolean;
  70738. set MotionBlurEnabled(enabled: boolean);
  70739. /**
  70740. * Specifies if anti-aliasing is enabled
  70741. */
  70742. get fxaaEnabled(): boolean;
  70743. set fxaaEnabled(enabled: boolean);
  70744. /**
  70745. * Specifies if screen space reflections are enabled.
  70746. */
  70747. get screenSpaceReflectionsEnabled(): boolean;
  70748. set screenSpaceReflectionsEnabled(enabled: boolean);
  70749. /**
  70750. * Specifies the number of steps used to calculate the volumetric lights
  70751. * Typically in interval [50, 200]
  70752. */
  70753. get volumetricLightStepsCount(): number;
  70754. set volumetricLightStepsCount(count: number);
  70755. /**
  70756. * Specifies the number of samples used for the motion blur effect
  70757. * Typically in interval [16, 64]
  70758. */
  70759. get motionBlurSamples(): number;
  70760. set motionBlurSamples(samples: number);
  70761. /**
  70762. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70763. */
  70764. get samples(): number;
  70765. set samples(sampleCount: number);
  70766. /**
  70767. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70768. * @constructor
  70769. * @param name The rendering pipeline name
  70770. * @param scene The scene linked to this pipeline
  70771. * @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)
  70772. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70773. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70774. */
  70775. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70776. private _buildPipeline;
  70777. private _createDownSampleX4PostProcess;
  70778. private _createBrightPassPostProcess;
  70779. private _createBlurPostProcesses;
  70780. private _createTextureAdderPostProcess;
  70781. private _createVolumetricLightPostProcess;
  70782. private _createLuminancePostProcesses;
  70783. private _createHdrPostProcess;
  70784. private _createLensFlarePostProcess;
  70785. private _createDepthOfFieldPostProcess;
  70786. private _createMotionBlurPostProcess;
  70787. private _getDepthTexture;
  70788. private _disposePostProcesses;
  70789. /**
  70790. * Dispose of the pipeline and stop all post processes
  70791. */
  70792. dispose(): void;
  70793. /**
  70794. * Serialize the rendering pipeline (Used when exporting)
  70795. * @returns the serialized object
  70796. */
  70797. serialize(): any;
  70798. /**
  70799. * Parse the serialized pipeline
  70800. * @param source Source pipeline.
  70801. * @param scene The scene to load the pipeline to.
  70802. * @param rootUrl The URL of the serialized pipeline.
  70803. * @returns An instantiated pipeline from the serialized object.
  70804. */
  70805. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70806. /**
  70807. * Luminance steps
  70808. */
  70809. static LuminanceSteps: number;
  70810. }
  70811. }
  70812. declare module BABYLON {
  70813. /** @hidden */
  70814. export var stereoscopicInterlacePixelShader: {
  70815. name: string;
  70816. shader: string;
  70817. };
  70818. }
  70819. declare module BABYLON {
  70820. /**
  70821. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70822. */
  70823. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70824. private _stepSize;
  70825. private _passedProcess;
  70826. /**
  70827. * Initializes a StereoscopicInterlacePostProcessI
  70828. * @param name The name of the effect.
  70829. * @param rigCameras The rig cameras to be appled to the post process
  70830. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70831. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70833. * @param engine The engine which the post process will be applied. (default: current engine)
  70834. * @param reusable If the post process can be reused on the same frame. (default: false)
  70835. */
  70836. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70837. }
  70838. /**
  70839. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70840. */
  70841. export class StereoscopicInterlacePostProcess extends PostProcess {
  70842. private _stepSize;
  70843. private _passedProcess;
  70844. /**
  70845. * Initializes a StereoscopicInterlacePostProcess
  70846. * @param name The name of the effect.
  70847. * @param rigCameras The rig cameras to be appled to the post process
  70848. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70850. * @param engine The engine which the post process will be applied. (default: current engine)
  70851. * @param reusable If the post process can be reused on the same frame. (default: false)
  70852. */
  70853. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70854. }
  70855. }
  70856. declare module BABYLON {
  70857. /** @hidden */
  70858. export var tonemapPixelShader: {
  70859. name: string;
  70860. shader: string;
  70861. };
  70862. }
  70863. declare module BABYLON {
  70864. /** Defines operator used for tonemapping */
  70865. export enum TonemappingOperator {
  70866. /** Hable */
  70867. Hable = 0,
  70868. /** Reinhard */
  70869. Reinhard = 1,
  70870. /** HejiDawson */
  70871. HejiDawson = 2,
  70872. /** Photographic */
  70873. Photographic = 3
  70874. }
  70875. /**
  70876. * Defines a post process to apply tone mapping
  70877. */
  70878. export class TonemapPostProcess extends PostProcess {
  70879. private _operator;
  70880. /** Defines the required exposure adjustement */
  70881. exposureAdjustment: number;
  70882. /**
  70883. * Creates a new TonemapPostProcess
  70884. * @param name defines the name of the postprocess
  70885. * @param _operator defines the operator to use
  70886. * @param exposureAdjustment defines the required exposure adjustement
  70887. * @param camera defines the camera to use (can be null)
  70888. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70889. * @param engine defines the hosting engine (can be ignore if camera is set)
  70890. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70891. */
  70892. constructor(name: string, _operator: TonemappingOperator,
  70893. /** Defines the required exposure adjustement */
  70894. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70895. }
  70896. }
  70897. declare module BABYLON {
  70898. /** @hidden */
  70899. export var volumetricLightScatteringPixelShader: {
  70900. name: string;
  70901. shader: string;
  70902. };
  70903. }
  70904. declare module BABYLON {
  70905. /** @hidden */
  70906. export var volumetricLightScatteringPassVertexShader: {
  70907. name: string;
  70908. shader: string;
  70909. };
  70910. }
  70911. declare module BABYLON {
  70912. /** @hidden */
  70913. export var volumetricLightScatteringPassPixelShader: {
  70914. name: string;
  70915. shader: string;
  70916. };
  70917. }
  70918. declare module BABYLON {
  70919. /**
  70920. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70921. */
  70922. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70923. private _volumetricLightScatteringPass;
  70924. private _volumetricLightScatteringRTT;
  70925. private _viewPort;
  70926. private _screenCoordinates;
  70927. private _cachedDefines;
  70928. /**
  70929. * If not undefined, the mesh position is computed from the attached node position
  70930. */
  70931. attachedNode: {
  70932. position: Vector3;
  70933. };
  70934. /**
  70935. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70936. */
  70937. customMeshPosition: Vector3;
  70938. /**
  70939. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70940. */
  70941. useCustomMeshPosition: boolean;
  70942. /**
  70943. * If the post-process should inverse the light scattering direction
  70944. */
  70945. invert: boolean;
  70946. /**
  70947. * The internal mesh used by the post-process
  70948. */
  70949. mesh: Mesh;
  70950. /**
  70951. * @hidden
  70952. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70953. */
  70954. get useDiffuseColor(): boolean;
  70955. set useDiffuseColor(useDiffuseColor: boolean);
  70956. /**
  70957. * Array containing the excluded meshes not rendered in the internal pass
  70958. */
  70959. excludedMeshes: AbstractMesh[];
  70960. /**
  70961. * Controls the overall intensity of the post-process
  70962. */
  70963. exposure: number;
  70964. /**
  70965. * Dissipates each sample's contribution in range [0, 1]
  70966. */
  70967. decay: number;
  70968. /**
  70969. * Controls the overall intensity of each sample
  70970. */
  70971. weight: number;
  70972. /**
  70973. * Controls the density of each sample
  70974. */
  70975. density: number;
  70976. /**
  70977. * @constructor
  70978. * @param name The post-process name
  70979. * @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)
  70980. * @param camera The camera that the post-process will be attached to
  70981. * @param mesh The mesh used to create the light scattering
  70982. * @param samples The post-process quality, default 100
  70983. * @param samplingModeThe post-process filtering mode
  70984. * @param engine The babylon engine
  70985. * @param reusable If the post-process is reusable
  70986. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70987. */
  70988. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70989. /**
  70990. * Returns the string "VolumetricLightScatteringPostProcess"
  70991. * @returns "VolumetricLightScatteringPostProcess"
  70992. */
  70993. getClassName(): string;
  70994. private _isReady;
  70995. /**
  70996. * Sets the new light position for light scattering effect
  70997. * @param position The new custom light position
  70998. */
  70999. setCustomMeshPosition(position: Vector3): void;
  71000. /**
  71001. * Returns the light position for light scattering effect
  71002. * @return Vector3 The custom light position
  71003. */
  71004. getCustomMeshPosition(): Vector3;
  71005. /**
  71006. * Disposes the internal assets and detaches the post-process from the camera
  71007. */
  71008. dispose(camera: Camera): void;
  71009. /**
  71010. * Returns the render target texture used by the post-process
  71011. * @return the render target texture used by the post-process
  71012. */
  71013. getPass(): RenderTargetTexture;
  71014. private _meshExcluded;
  71015. private _createPass;
  71016. private _updateMeshScreenCoordinates;
  71017. /**
  71018. * Creates a default mesh for the Volumeric Light Scattering post-process
  71019. * @param name The mesh name
  71020. * @param scene The scene where to create the mesh
  71021. * @return the default mesh
  71022. */
  71023. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71024. }
  71025. }
  71026. declare module BABYLON {
  71027. /** @hidden */
  71028. export var screenSpaceCurvaturePixelShader: {
  71029. name: string;
  71030. shader: string;
  71031. };
  71032. }
  71033. declare module BABYLON {
  71034. /**
  71035. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71036. */
  71037. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71038. /**
  71039. * Defines how much ridge the curvature effect displays.
  71040. */
  71041. ridge: number;
  71042. /**
  71043. * Defines how much valley the curvature effect displays.
  71044. */
  71045. valley: number;
  71046. private _geometryBufferRenderer;
  71047. /**
  71048. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71049. * @param name The name of the effect.
  71050. * @param scene The scene containing the objects to blur according to their velocity.
  71051. * @param options The required width/height ratio to downsize to before computing the render pass.
  71052. * @param camera The camera to apply the render pass to.
  71053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71054. * @param engine The engine which the post process will be applied. (default: current engine)
  71055. * @param reusable If the post process can be reused on the same frame. (default: false)
  71056. * @param textureType Type of textures used when performing the post process. (default: 0)
  71057. * @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)
  71058. */
  71059. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71060. /**
  71061. * Support test.
  71062. */
  71063. static get IsSupported(): boolean;
  71064. }
  71065. }
  71066. declare module BABYLON {
  71067. interface Scene {
  71068. /** @hidden (Backing field) */
  71069. _boundingBoxRenderer: BoundingBoxRenderer;
  71070. /** @hidden (Backing field) */
  71071. _forceShowBoundingBoxes: boolean;
  71072. /**
  71073. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71074. */
  71075. forceShowBoundingBoxes: boolean;
  71076. /**
  71077. * Gets the bounding box renderer associated with the scene
  71078. * @returns a BoundingBoxRenderer
  71079. */
  71080. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71081. }
  71082. interface AbstractMesh {
  71083. /** @hidden (Backing field) */
  71084. _showBoundingBox: boolean;
  71085. /**
  71086. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71087. */
  71088. showBoundingBox: boolean;
  71089. }
  71090. /**
  71091. * Component responsible of rendering the bounding box of the meshes in a scene.
  71092. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71093. */
  71094. export class BoundingBoxRenderer implements ISceneComponent {
  71095. /**
  71096. * The component name helpfull to identify the component in the list of scene components.
  71097. */
  71098. readonly name: string;
  71099. /**
  71100. * The scene the component belongs to.
  71101. */
  71102. scene: Scene;
  71103. /**
  71104. * Color of the bounding box lines placed in front of an object
  71105. */
  71106. frontColor: Color3;
  71107. /**
  71108. * Color of the bounding box lines placed behind an object
  71109. */
  71110. backColor: Color3;
  71111. /**
  71112. * Defines if the renderer should show the back lines or not
  71113. */
  71114. showBackLines: boolean;
  71115. /**
  71116. * Observable raised before rendering a bounding box
  71117. */
  71118. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71119. /**
  71120. * Observable raised after rendering a bounding box
  71121. */
  71122. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71123. /**
  71124. * @hidden
  71125. */
  71126. renderList: SmartArray<BoundingBox>;
  71127. private _colorShader;
  71128. private _vertexBuffers;
  71129. private _indexBuffer;
  71130. private _fillIndexBuffer;
  71131. private _fillIndexData;
  71132. /**
  71133. * Instantiates a new bounding box renderer in a scene.
  71134. * @param scene the scene the renderer renders in
  71135. */
  71136. constructor(scene: Scene);
  71137. /**
  71138. * Registers the component in a given scene
  71139. */
  71140. register(): void;
  71141. private _evaluateSubMesh;
  71142. private _activeMesh;
  71143. private _prepareRessources;
  71144. private _createIndexBuffer;
  71145. /**
  71146. * Rebuilds the elements related to this component in case of
  71147. * context lost for instance.
  71148. */
  71149. rebuild(): void;
  71150. /**
  71151. * @hidden
  71152. */
  71153. reset(): void;
  71154. /**
  71155. * Render the bounding boxes of a specific rendering group
  71156. * @param renderingGroupId defines the rendering group to render
  71157. */
  71158. render(renderingGroupId: number): void;
  71159. /**
  71160. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71161. * @param mesh Define the mesh to render the occlusion bounding box for
  71162. */
  71163. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71164. /**
  71165. * Dispose and release the resources attached to this renderer.
  71166. */
  71167. dispose(): void;
  71168. }
  71169. }
  71170. declare module BABYLON {
  71171. interface Scene {
  71172. /** @hidden (Backing field) */
  71173. _depthRenderer: {
  71174. [id: string]: DepthRenderer;
  71175. };
  71176. /**
  71177. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71178. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71179. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71180. * @returns the created depth renderer
  71181. */
  71182. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71183. /**
  71184. * Disables a depth renderer for a given camera
  71185. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71186. */
  71187. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71188. }
  71189. /**
  71190. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71191. * in several rendering techniques.
  71192. */
  71193. export class DepthRendererSceneComponent implements ISceneComponent {
  71194. /**
  71195. * The component name helpfull to identify the component in the list of scene components.
  71196. */
  71197. readonly name: string;
  71198. /**
  71199. * The scene the component belongs to.
  71200. */
  71201. scene: Scene;
  71202. /**
  71203. * Creates a new instance of the component for the given scene
  71204. * @param scene Defines the scene to register the component in
  71205. */
  71206. constructor(scene: Scene);
  71207. /**
  71208. * Registers the component in a given scene
  71209. */
  71210. register(): void;
  71211. /**
  71212. * Rebuilds the elements related to this component in case of
  71213. * context lost for instance.
  71214. */
  71215. rebuild(): void;
  71216. /**
  71217. * Disposes the component and the associated ressources
  71218. */
  71219. dispose(): void;
  71220. private _gatherRenderTargets;
  71221. private _gatherActiveCameraRenderTargets;
  71222. }
  71223. }
  71224. declare module BABYLON {
  71225. interface AbstractScene {
  71226. /** @hidden (Backing field) */
  71227. _prePassRenderer: Nullable<PrePassRenderer>;
  71228. /**
  71229. * Gets or Sets the current prepass renderer associated to the scene.
  71230. */
  71231. prePassRenderer: Nullable<PrePassRenderer>;
  71232. /**
  71233. * Enables the prepass and associates it with the scene
  71234. * @returns the PrePassRenderer
  71235. */
  71236. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71237. /**
  71238. * Disables the prepass associated with the scene
  71239. */
  71240. disablePrePassRenderer(): void;
  71241. }
  71242. /**
  71243. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71244. * in several rendering techniques.
  71245. */
  71246. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71247. /**
  71248. * The component name helpful to identify the component in the list of scene components.
  71249. */
  71250. readonly name: string;
  71251. /**
  71252. * The scene the component belongs to.
  71253. */
  71254. scene: Scene;
  71255. /**
  71256. * Creates a new instance of the component for the given scene
  71257. * @param scene Defines the scene to register the component in
  71258. */
  71259. constructor(scene: Scene);
  71260. /**
  71261. * Registers the component in a given scene
  71262. */
  71263. register(): void;
  71264. private _beforeCameraDraw;
  71265. private _afterCameraDraw;
  71266. private _beforeClearStage;
  71267. /**
  71268. * Serializes the component data to the specified json object
  71269. * @param serializationObject The object to serialize to
  71270. */
  71271. serialize(serializationObject: any): void;
  71272. /**
  71273. * Adds all the elements from the container to the scene
  71274. * @param container the container holding the elements
  71275. */
  71276. addFromContainer(container: AbstractScene): void;
  71277. /**
  71278. * Removes all the elements in the container from the scene
  71279. * @param container contains the elements to remove
  71280. * @param dispose if the removed element should be disposed (default: false)
  71281. */
  71282. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71283. /**
  71284. * Rebuilds the elements related to this component in case of
  71285. * context lost for instance.
  71286. */
  71287. rebuild(): void;
  71288. /**
  71289. * Disposes the component and the associated ressources
  71290. */
  71291. dispose(): void;
  71292. }
  71293. }
  71294. declare module BABYLON {
  71295. /** @hidden */
  71296. export var outlinePixelShader: {
  71297. name: string;
  71298. shader: string;
  71299. };
  71300. }
  71301. declare module BABYLON {
  71302. /** @hidden */
  71303. export var outlineVertexShader: {
  71304. name: string;
  71305. shader: string;
  71306. };
  71307. }
  71308. declare module BABYLON {
  71309. interface Scene {
  71310. /** @hidden */
  71311. _outlineRenderer: OutlineRenderer;
  71312. /**
  71313. * Gets the outline renderer associated with the scene
  71314. * @returns a OutlineRenderer
  71315. */
  71316. getOutlineRenderer(): OutlineRenderer;
  71317. }
  71318. interface AbstractMesh {
  71319. /** @hidden (Backing field) */
  71320. _renderOutline: boolean;
  71321. /**
  71322. * Gets or sets a boolean indicating if the outline must be rendered as well
  71323. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71324. */
  71325. renderOutline: boolean;
  71326. /** @hidden (Backing field) */
  71327. _renderOverlay: boolean;
  71328. /**
  71329. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71330. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71331. */
  71332. renderOverlay: boolean;
  71333. }
  71334. /**
  71335. * This class is responsible to draw bothe outline/overlay of meshes.
  71336. * It should not be used directly but through the available method on mesh.
  71337. */
  71338. export class OutlineRenderer implements ISceneComponent {
  71339. /**
  71340. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71341. */
  71342. private static _StencilReference;
  71343. /**
  71344. * The name of the component. Each component must have a unique name.
  71345. */
  71346. name: string;
  71347. /**
  71348. * The scene the component belongs to.
  71349. */
  71350. scene: Scene;
  71351. /**
  71352. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71353. */
  71354. zOffset: number;
  71355. private _engine;
  71356. private _effect;
  71357. private _cachedDefines;
  71358. private _savedDepthWrite;
  71359. /**
  71360. * Instantiates a new outline renderer. (There could be only one per scene).
  71361. * @param scene Defines the scene it belongs to
  71362. */
  71363. constructor(scene: Scene);
  71364. /**
  71365. * Register the component to one instance of a scene.
  71366. */
  71367. register(): void;
  71368. /**
  71369. * Rebuilds the elements related to this component in case of
  71370. * context lost for instance.
  71371. */
  71372. rebuild(): void;
  71373. /**
  71374. * Disposes the component and the associated ressources.
  71375. */
  71376. dispose(): void;
  71377. /**
  71378. * Renders the outline in the canvas.
  71379. * @param subMesh Defines the sumesh to render
  71380. * @param batch Defines the batch of meshes in case of instances
  71381. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71382. */
  71383. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71384. /**
  71385. * Returns whether or not the outline renderer is ready for a given submesh.
  71386. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71387. * @param subMesh Defines the submesh to check readyness for
  71388. * @param useInstances Defines wheter wee are trying to render instances or not
  71389. * @returns true if ready otherwise false
  71390. */
  71391. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71392. private _beforeRenderingMesh;
  71393. private _afterRenderingMesh;
  71394. }
  71395. }
  71396. declare module BABYLON {
  71397. /**
  71398. * Defines the basic options interface of a Sprite Frame Source Size.
  71399. */
  71400. export interface ISpriteJSONSpriteSourceSize {
  71401. /**
  71402. * number of the original width of the Frame
  71403. */
  71404. w: number;
  71405. /**
  71406. * number of the original height of the Frame
  71407. */
  71408. h: number;
  71409. }
  71410. /**
  71411. * Defines the basic options interface of a Sprite Frame Data.
  71412. */
  71413. export interface ISpriteJSONSpriteFrameData {
  71414. /**
  71415. * number of the x offset of the Frame
  71416. */
  71417. x: number;
  71418. /**
  71419. * number of the y offset of the Frame
  71420. */
  71421. y: number;
  71422. /**
  71423. * number of the width of the Frame
  71424. */
  71425. w: number;
  71426. /**
  71427. * number of the height of the Frame
  71428. */
  71429. h: number;
  71430. }
  71431. /**
  71432. * Defines the basic options interface of a JSON Sprite.
  71433. */
  71434. export interface ISpriteJSONSprite {
  71435. /**
  71436. * string name of the Frame
  71437. */
  71438. filename: string;
  71439. /**
  71440. * ISpriteJSONSpriteFrame basic object of the frame data
  71441. */
  71442. frame: ISpriteJSONSpriteFrameData;
  71443. /**
  71444. * boolean to flag is the frame was rotated.
  71445. */
  71446. rotated: boolean;
  71447. /**
  71448. * boolean to flag is the frame was trimmed.
  71449. */
  71450. trimmed: boolean;
  71451. /**
  71452. * ISpriteJSONSpriteFrame basic object of the source data
  71453. */
  71454. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71455. /**
  71456. * ISpriteJSONSpriteFrame basic object of the source data
  71457. */
  71458. sourceSize: ISpriteJSONSpriteSourceSize;
  71459. }
  71460. /**
  71461. * Defines the basic options interface of a JSON atlas.
  71462. */
  71463. export interface ISpriteJSONAtlas {
  71464. /**
  71465. * Array of objects that contain the frame data.
  71466. */
  71467. frames: Array<ISpriteJSONSprite>;
  71468. /**
  71469. * object basic object containing the sprite meta data.
  71470. */
  71471. meta?: object;
  71472. }
  71473. }
  71474. declare module BABYLON {
  71475. /** @hidden */
  71476. export var spriteMapPixelShader: {
  71477. name: string;
  71478. shader: string;
  71479. };
  71480. }
  71481. declare module BABYLON {
  71482. /** @hidden */
  71483. export var spriteMapVertexShader: {
  71484. name: string;
  71485. shader: string;
  71486. };
  71487. }
  71488. declare module BABYLON {
  71489. /**
  71490. * Defines the basic options interface of a SpriteMap
  71491. */
  71492. export interface ISpriteMapOptions {
  71493. /**
  71494. * Vector2 of the number of cells in the grid.
  71495. */
  71496. stageSize?: Vector2;
  71497. /**
  71498. * Vector2 of the size of the output plane in World Units.
  71499. */
  71500. outputSize?: Vector2;
  71501. /**
  71502. * Vector3 of the position of the output plane in World Units.
  71503. */
  71504. outputPosition?: Vector3;
  71505. /**
  71506. * Vector3 of the rotation of the output plane.
  71507. */
  71508. outputRotation?: Vector3;
  71509. /**
  71510. * number of layers that the system will reserve in resources.
  71511. */
  71512. layerCount?: number;
  71513. /**
  71514. * number of max animation frames a single cell will reserve in resources.
  71515. */
  71516. maxAnimationFrames?: number;
  71517. /**
  71518. * number cell index of the base tile when the system compiles.
  71519. */
  71520. baseTile?: number;
  71521. /**
  71522. * boolean flip the sprite after its been repositioned by the framing data.
  71523. */
  71524. flipU?: boolean;
  71525. /**
  71526. * Vector3 scalar of the global RGB values of the SpriteMap.
  71527. */
  71528. colorMultiply?: Vector3;
  71529. }
  71530. /**
  71531. * Defines the IDisposable interface in order to be cleanable from resources.
  71532. */
  71533. export interface ISpriteMap extends IDisposable {
  71534. /**
  71535. * String name of the SpriteMap.
  71536. */
  71537. name: string;
  71538. /**
  71539. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71540. */
  71541. atlasJSON: ISpriteJSONAtlas;
  71542. /**
  71543. * Texture of the SpriteMap.
  71544. */
  71545. spriteSheet: Texture;
  71546. /**
  71547. * The parameters to initialize the SpriteMap with.
  71548. */
  71549. options: ISpriteMapOptions;
  71550. }
  71551. /**
  71552. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71553. */
  71554. export class SpriteMap implements ISpriteMap {
  71555. /** The Name of the spriteMap */
  71556. name: string;
  71557. /** The JSON file with the frame and meta data */
  71558. atlasJSON: ISpriteJSONAtlas;
  71559. /** The systems Sprite Sheet Texture */
  71560. spriteSheet: Texture;
  71561. /** Arguments passed with the Constructor */
  71562. options: ISpriteMapOptions;
  71563. /** Public Sprite Storage array, parsed from atlasJSON */
  71564. sprites: Array<ISpriteJSONSprite>;
  71565. /** Returns the Number of Sprites in the System */
  71566. get spriteCount(): number;
  71567. /** Returns the Position of Output Plane*/
  71568. get position(): Vector3;
  71569. /** Returns the Position of Output Plane*/
  71570. set position(v: Vector3);
  71571. /** Returns the Rotation of Output Plane*/
  71572. get rotation(): Vector3;
  71573. /** Returns the Rotation of Output Plane*/
  71574. set rotation(v: Vector3);
  71575. /** Sets the AnimationMap*/
  71576. get animationMap(): RawTexture;
  71577. /** Sets the AnimationMap*/
  71578. set animationMap(v: RawTexture);
  71579. /** Scene that the SpriteMap was created in */
  71580. private _scene;
  71581. /** Texture Buffer of Float32 that holds tile frame data*/
  71582. private _frameMap;
  71583. /** Texture Buffers of Float32 that holds tileMap data*/
  71584. private _tileMaps;
  71585. /** Texture Buffer of Float32 that holds Animation Data*/
  71586. private _animationMap;
  71587. /** Custom ShaderMaterial Central to the System*/
  71588. private _material;
  71589. /** Custom ShaderMaterial Central to the System*/
  71590. private _output;
  71591. /** Systems Time Ticker*/
  71592. private _time;
  71593. /**
  71594. * Creates a new SpriteMap
  71595. * @param name defines the SpriteMaps Name
  71596. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71597. * @param spriteSheet is the Texture that the Sprites are on.
  71598. * @param options a basic deployment configuration
  71599. * @param scene The Scene that the map is deployed on
  71600. */
  71601. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71602. /**
  71603. * Returns tileID location
  71604. * @returns Vector2 the cell position ID
  71605. */
  71606. getTileID(): Vector2;
  71607. /**
  71608. * Gets the UV location of the mouse over the SpriteMap.
  71609. * @returns Vector2 the UV position of the mouse interaction
  71610. */
  71611. getMousePosition(): Vector2;
  71612. /**
  71613. * Creates the "frame" texture Buffer
  71614. * -------------------------------------
  71615. * Structure of frames
  71616. * "filename": "Falling-Water-2.png",
  71617. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71618. * "rotated": true,
  71619. * "trimmed": true,
  71620. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71621. * "sourceSize": {"w":32,"h":32}
  71622. * @returns RawTexture of the frameMap
  71623. */
  71624. private _createFrameBuffer;
  71625. /**
  71626. * Creates the tileMap texture Buffer
  71627. * @param buffer normally and array of numbers, or a false to generate from scratch
  71628. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71629. * @returns RawTexture of the tileMap
  71630. */
  71631. private _createTileBuffer;
  71632. /**
  71633. * Modifies the data of the tileMaps
  71634. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71635. * @param pos is the iVector2 Coordinates of the Tile
  71636. * @param tile The SpriteIndex of the new Tile
  71637. */
  71638. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71639. /**
  71640. * Creates the animationMap texture Buffer
  71641. * @param buffer normally and array of numbers, or a false to generate from scratch
  71642. * @returns RawTexture of the animationMap
  71643. */
  71644. private _createTileAnimationBuffer;
  71645. /**
  71646. * Modifies the data of the animationMap
  71647. * @param cellID is the Index of the Sprite
  71648. * @param _frame is the target Animation frame
  71649. * @param toCell is the Target Index of the next frame of the animation
  71650. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71651. * @param speed is a global scalar of the time variable on the map.
  71652. */
  71653. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71654. /**
  71655. * Exports the .tilemaps file
  71656. */
  71657. saveTileMaps(): void;
  71658. /**
  71659. * Imports the .tilemaps file
  71660. * @param url of the .tilemaps file
  71661. */
  71662. loadTileMaps(url: string): void;
  71663. /**
  71664. * Release associated resources
  71665. */
  71666. dispose(): void;
  71667. }
  71668. }
  71669. declare module BABYLON {
  71670. /**
  71671. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71672. * @see https://doc.babylonjs.com/babylon101/sprites
  71673. */
  71674. export class SpritePackedManager extends SpriteManager {
  71675. /** defines the packed manager's name */
  71676. name: string;
  71677. /**
  71678. * Creates a new sprite manager from a packed sprite sheet
  71679. * @param name defines the manager's name
  71680. * @param imgUrl defines the sprite sheet url
  71681. * @param capacity defines the maximum allowed number of sprites
  71682. * @param scene defines the hosting scene
  71683. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71684. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71685. * @param samplingMode defines the smapling mode to use with spritesheet
  71686. * @param fromPacked set to true; do not alter
  71687. */
  71688. constructor(
  71689. /** defines the packed manager's name */
  71690. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71691. }
  71692. }
  71693. declare module BABYLON {
  71694. /**
  71695. * Defines the list of states available for a task inside a AssetsManager
  71696. */
  71697. export enum AssetTaskState {
  71698. /**
  71699. * Initialization
  71700. */
  71701. INIT = 0,
  71702. /**
  71703. * Running
  71704. */
  71705. RUNNING = 1,
  71706. /**
  71707. * Done
  71708. */
  71709. DONE = 2,
  71710. /**
  71711. * Error
  71712. */
  71713. ERROR = 3
  71714. }
  71715. /**
  71716. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71717. */
  71718. export abstract class AbstractAssetTask {
  71719. /**
  71720. * Task name
  71721. */ name: string;
  71722. /**
  71723. * Callback called when the task is successful
  71724. */
  71725. onSuccess: (task: any) => void;
  71726. /**
  71727. * Callback called when the task is not successful
  71728. */
  71729. onError: (task: any, message?: string, exception?: any) => void;
  71730. /**
  71731. * Creates a new AssetsManager
  71732. * @param name defines the name of the task
  71733. */
  71734. constructor(
  71735. /**
  71736. * Task name
  71737. */ name: string);
  71738. private _isCompleted;
  71739. private _taskState;
  71740. private _errorObject;
  71741. /**
  71742. * Get if the task is completed
  71743. */
  71744. get isCompleted(): boolean;
  71745. /**
  71746. * Gets the current state of the task
  71747. */
  71748. get taskState(): AssetTaskState;
  71749. /**
  71750. * Gets the current error object (if task is in error)
  71751. */
  71752. get errorObject(): {
  71753. message?: string;
  71754. exception?: any;
  71755. };
  71756. /**
  71757. * Internal only
  71758. * @hidden
  71759. */
  71760. _setErrorObject(message?: string, exception?: any): void;
  71761. /**
  71762. * Execute the current task
  71763. * @param scene defines the scene where you want your assets to be loaded
  71764. * @param onSuccess is a callback called when the task is successfully executed
  71765. * @param onError is a callback called if an error occurs
  71766. */
  71767. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71768. /**
  71769. * Execute the current task
  71770. * @param scene defines the scene where you want your assets to be loaded
  71771. * @param onSuccess is a callback called when the task is successfully executed
  71772. * @param onError is a callback called if an error occurs
  71773. */
  71774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71775. /**
  71776. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71777. * This can be used with failed tasks that have the reason for failure fixed.
  71778. */
  71779. reset(): void;
  71780. private onErrorCallback;
  71781. private onDoneCallback;
  71782. }
  71783. /**
  71784. * Define the interface used by progress events raised during assets loading
  71785. */
  71786. export interface IAssetsProgressEvent {
  71787. /**
  71788. * Defines the number of remaining tasks to process
  71789. */
  71790. remainingCount: number;
  71791. /**
  71792. * Defines the total number of tasks
  71793. */
  71794. totalCount: number;
  71795. /**
  71796. * Defines the task that was just processed
  71797. */
  71798. task: AbstractAssetTask;
  71799. }
  71800. /**
  71801. * Class used to share progress information about assets loading
  71802. */
  71803. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71804. /**
  71805. * Defines the number of remaining tasks to process
  71806. */
  71807. remainingCount: number;
  71808. /**
  71809. * Defines the total number of tasks
  71810. */
  71811. totalCount: number;
  71812. /**
  71813. * Defines the task that was just processed
  71814. */
  71815. task: AbstractAssetTask;
  71816. /**
  71817. * Creates a AssetsProgressEvent
  71818. * @param remainingCount defines the number of remaining tasks to process
  71819. * @param totalCount defines the total number of tasks
  71820. * @param task defines the task that was just processed
  71821. */
  71822. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71823. }
  71824. /**
  71825. * Define a task used by AssetsManager to load meshes
  71826. */
  71827. export class MeshAssetTask extends AbstractAssetTask {
  71828. /**
  71829. * Defines the name of the task
  71830. */
  71831. name: string;
  71832. /**
  71833. * Defines the list of mesh's names you want to load
  71834. */
  71835. meshesNames: any;
  71836. /**
  71837. * Defines the root url to use as a base to load your meshes and associated resources
  71838. */
  71839. rootUrl: string;
  71840. /**
  71841. * Defines the filename or File of the scene to load from
  71842. */
  71843. sceneFilename: string | File;
  71844. /**
  71845. * Gets the list of loaded meshes
  71846. */
  71847. loadedMeshes: Array<AbstractMesh>;
  71848. /**
  71849. * Gets the list of loaded particle systems
  71850. */
  71851. loadedParticleSystems: Array<IParticleSystem>;
  71852. /**
  71853. * Gets the list of loaded skeletons
  71854. */
  71855. loadedSkeletons: Array<Skeleton>;
  71856. /**
  71857. * Gets the list of loaded animation groups
  71858. */
  71859. loadedAnimationGroups: Array<AnimationGroup>;
  71860. /**
  71861. * Callback called when the task is successful
  71862. */
  71863. onSuccess: (task: MeshAssetTask) => void;
  71864. /**
  71865. * Callback called when the task is successful
  71866. */
  71867. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71868. /**
  71869. * Creates a new MeshAssetTask
  71870. * @param name defines the name of the task
  71871. * @param meshesNames defines the list of mesh's names you want to load
  71872. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71873. * @param sceneFilename defines the filename or File of the scene to load from
  71874. */
  71875. constructor(
  71876. /**
  71877. * Defines the name of the task
  71878. */
  71879. name: string,
  71880. /**
  71881. * Defines the list of mesh's names you want to load
  71882. */
  71883. meshesNames: any,
  71884. /**
  71885. * Defines the root url to use as a base to load your meshes and associated resources
  71886. */
  71887. rootUrl: string,
  71888. /**
  71889. * Defines the filename or File of the scene to load from
  71890. */
  71891. sceneFilename: string | File);
  71892. /**
  71893. * Execute the current task
  71894. * @param scene defines the scene where you want your assets to be loaded
  71895. * @param onSuccess is a callback called when the task is successfully executed
  71896. * @param onError is a callback called if an error occurs
  71897. */
  71898. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71899. }
  71900. /**
  71901. * Define a task used by AssetsManager to load text content
  71902. */
  71903. export class TextFileAssetTask extends AbstractAssetTask {
  71904. /**
  71905. * Defines the name of the task
  71906. */
  71907. name: string;
  71908. /**
  71909. * Defines the location of the file to load
  71910. */
  71911. url: string;
  71912. /**
  71913. * Gets the loaded text string
  71914. */
  71915. text: string;
  71916. /**
  71917. * Callback called when the task is successful
  71918. */
  71919. onSuccess: (task: TextFileAssetTask) => void;
  71920. /**
  71921. * Callback called when the task is successful
  71922. */
  71923. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71924. /**
  71925. * Creates a new TextFileAssetTask object
  71926. * @param name defines the name of the task
  71927. * @param url defines the location of the file to load
  71928. */
  71929. constructor(
  71930. /**
  71931. * Defines the name of the task
  71932. */
  71933. name: string,
  71934. /**
  71935. * Defines the location of the file to load
  71936. */
  71937. url: string);
  71938. /**
  71939. * Execute the current task
  71940. * @param scene defines the scene where you want your assets to be loaded
  71941. * @param onSuccess is a callback called when the task is successfully executed
  71942. * @param onError is a callback called if an error occurs
  71943. */
  71944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71945. }
  71946. /**
  71947. * Define a task used by AssetsManager to load binary data
  71948. */
  71949. export class BinaryFileAssetTask extends AbstractAssetTask {
  71950. /**
  71951. * Defines the name of the task
  71952. */
  71953. name: string;
  71954. /**
  71955. * Defines the location of the file to load
  71956. */
  71957. url: string;
  71958. /**
  71959. * Gets the lodaded data (as an array buffer)
  71960. */
  71961. data: ArrayBuffer;
  71962. /**
  71963. * Callback called when the task is successful
  71964. */
  71965. onSuccess: (task: BinaryFileAssetTask) => void;
  71966. /**
  71967. * Callback called when the task is successful
  71968. */
  71969. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71970. /**
  71971. * Creates a new BinaryFileAssetTask object
  71972. * @param name defines the name of the new task
  71973. * @param url defines the location of the file to load
  71974. */
  71975. constructor(
  71976. /**
  71977. * Defines the name of the task
  71978. */
  71979. name: string,
  71980. /**
  71981. * Defines the location of the file to load
  71982. */
  71983. url: string);
  71984. /**
  71985. * Execute the current task
  71986. * @param scene defines the scene where you want your assets to be loaded
  71987. * @param onSuccess is a callback called when the task is successfully executed
  71988. * @param onError is a callback called if an error occurs
  71989. */
  71990. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71991. }
  71992. /**
  71993. * Define a task used by AssetsManager to load images
  71994. */
  71995. export class ImageAssetTask extends AbstractAssetTask {
  71996. /**
  71997. * Defines the name of the task
  71998. */
  71999. name: string;
  72000. /**
  72001. * Defines the location of the image to load
  72002. */
  72003. url: string;
  72004. /**
  72005. * Gets the loaded images
  72006. */
  72007. image: HTMLImageElement;
  72008. /**
  72009. * Callback called when the task is successful
  72010. */
  72011. onSuccess: (task: ImageAssetTask) => void;
  72012. /**
  72013. * Callback called when the task is successful
  72014. */
  72015. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72016. /**
  72017. * Creates a new ImageAssetTask
  72018. * @param name defines the name of the task
  72019. * @param url defines the location of the image to load
  72020. */
  72021. constructor(
  72022. /**
  72023. * Defines the name of the task
  72024. */
  72025. name: string,
  72026. /**
  72027. * Defines the location of the image to load
  72028. */
  72029. url: string);
  72030. /**
  72031. * Execute the current task
  72032. * @param scene defines the scene where you want your assets to be loaded
  72033. * @param onSuccess is a callback called when the task is successfully executed
  72034. * @param onError is a callback called if an error occurs
  72035. */
  72036. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72037. }
  72038. /**
  72039. * Defines the interface used by texture loading tasks
  72040. */
  72041. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72042. /**
  72043. * Gets the loaded texture
  72044. */
  72045. texture: TEX;
  72046. }
  72047. /**
  72048. * Define a task used by AssetsManager to load 2D textures
  72049. */
  72050. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72051. /**
  72052. * Defines the name of the task
  72053. */
  72054. name: string;
  72055. /**
  72056. * Defines the location of the file to load
  72057. */
  72058. url: string;
  72059. /**
  72060. * Defines if mipmap should not be generated (default is false)
  72061. */
  72062. noMipmap?: boolean | undefined;
  72063. /**
  72064. * Defines if texture must be inverted on Y axis (default is true)
  72065. */
  72066. invertY: boolean;
  72067. /**
  72068. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72069. */
  72070. samplingMode: number;
  72071. /**
  72072. * Gets the loaded texture
  72073. */
  72074. texture: Texture;
  72075. /**
  72076. * Callback called when the task is successful
  72077. */
  72078. onSuccess: (task: TextureAssetTask) => void;
  72079. /**
  72080. * Callback called when the task is successful
  72081. */
  72082. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72083. /**
  72084. * Creates a new TextureAssetTask object
  72085. * @param name defines the name of the task
  72086. * @param url defines the location of the file to load
  72087. * @param noMipmap defines if mipmap should not be generated (default is false)
  72088. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72089. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72090. */
  72091. constructor(
  72092. /**
  72093. * Defines the name of the task
  72094. */
  72095. name: string,
  72096. /**
  72097. * Defines the location of the file to load
  72098. */
  72099. url: string,
  72100. /**
  72101. * Defines if mipmap should not be generated (default is false)
  72102. */
  72103. noMipmap?: boolean | undefined,
  72104. /**
  72105. * Defines if texture must be inverted on Y axis (default is true)
  72106. */
  72107. invertY?: boolean,
  72108. /**
  72109. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72110. */
  72111. samplingMode?: number);
  72112. /**
  72113. * Execute the current task
  72114. * @param scene defines the scene where you want your assets to be loaded
  72115. * @param onSuccess is a callback called when the task is successfully executed
  72116. * @param onError is a callback called if an error occurs
  72117. */
  72118. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72119. }
  72120. /**
  72121. * Define a task used by AssetsManager to load cube textures
  72122. */
  72123. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72124. /**
  72125. * Defines the name of the task
  72126. */
  72127. name: string;
  72128. /**
  72129. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72130. */
  72131. url: string;
  72132. /**
  72133. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72134. */
  72135. extensions?: string[] | undefined;
  72136. /**
  72137. * Defines if mipmaps should not be generated (default is false)
  72138. */
  72139. noMipmap?: boolean | undefined;
  72140. /**
  72141. * Defines the explicit list of files (undefined by default)
  72142. */
  72143. files?: string[] | undefined;
  72144. /**
  72145. * Gets the loaded texture
  72146. */
  72147. texture: CubeTexture;
  72148. /**
  72149. * Callback called when the task is successful
  72150. */
  72151. onSuccess: (task: CubeTextureAssetTask) => void;
  72152. /**
  72153. * Callback called when the task is successful
  72154. */
  72155. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72156. /**
  72157. * Creates a new CubeTextureAssetTask
  72158. * @param name defines the name of the task
  72159. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72160. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72161. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72162. * @param files defines the explicit list of files (undefined by default)
  72163. */
  72164. constructor(
  72165. /**
  72166. * Defines the name of the task
  72167. */
  72168. name: string,
  72169. /**
  72170. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72171. */
  72172. url: string,
  72173. /**
  72174. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72175. */
  72176. extensions?: string[] | undefined,
  72177. /**
  72178. * Defines if mipmaps should not be generated (default is false)
  72179. */
  72180. noMipmap?: boolean | undefined,
  72181. /**
  72182. * Defines the explicit list of files (undefined by default)
  72183. */
  72184. files?: string[] | undefined);
  72185. /**
  72186. * Execute the current task
  72187. * @param scene defines the scene where you want your assets to be loaded
  72188. * @param onSuccess is a callback called when the task is successfully executed
  72189. * @param onError is a callback called if an error occurs
  72190. */
  72191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72192. }
  72193. /**
  72194. * Define a task used by AssetsManager to load HDR cube textures
  72195. */
  72196. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72197. /**
  72198. * Defines the name of the task
  72199. */
  72200. name: string;
  72201. /**
  72202. * Defines the location of the file to load
  72203. */
  72204. url: string;
  72205. /**
  72206. * Defines the desired size (the more it increases the longer the generation will be)
  72207. */
  72208. size: number;
  72209. /**
  72210. * Defines if mipmaps should not be generated (default is false)
  72211. */
  72212. noMipmap: boolean;
  72213. /**
  72214. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72215. */
  72216. generateHarmonics: boolean;
  72217. /**
  72218. * 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)
  72219. */
  72220. gammaSpace: boolean;
  72221. /**
  72222. * Internal Use Only
  72223. */
  72224. reserved: boolean;
  72225. /**
  72226. * Gets the loaded texture
  72227. */
  72228. texture: HDRCubeTexture;
  72229. /**
  72230. * Callback called when the task is successful
  72231. */
  72232. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72233. /**
  72234. * Callback called when the task is successful
  72235. */
  72236. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72237. /**
  72238. * Creates a new HDRCubeTextureAssetTask object
  72239. * @param name defines the name of the task
  72240. * @param url defines the location of the file to load
  72241. * @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.
  72242. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72243. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72244. * @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)
  72245. * @param reserved Internal use only
  72246. */
  72247. constructor(
  72248. /**
  72249. * Defines the name of the task
  72250. */
  72251. name: string,
  72252. /**
  72253. * Defines the location of the file to load
  72254. */
  72255. url: string,
  72256. /**
  72257. * Defines the desired size (the more it increases the longer the generation will be)
  72258. */
  72259. size: number,
  72260. /**
  72261. * Defines if mipmaps should not be generated (default is false)
  72262. */
  72263. noMipmap?: boolean,
  72264. /**
  72265. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72266. */
  72267. generateHarmonics?: boolean,
  72268. /**
  72269. * 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)
  72270. */
  72271. gammaSpace?: boolean,
  72272. /**
  72273. * Internal Use Only
  72274. */
  72275. reserved?: boolean);
  72276. /**
  72277. * Execute the current task
  72278. * @param scene defines the scene where you want your assets to be loaded
  72279. * @param onSuccess is a callback called when the task is successfully executed
  72280. * @param onError is a callback called if an error occurs
  72281. */
  72282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72283. }
  72284. /**
  72285. * Define a task used by AssetsManager to load Equirectangular cube textures
  72286. */
  72287. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72288. /**
  72289. * Defines the name of the task
  72290. */
  72291. name: string;
  72292. /**
  72293. * Defines the location of the file to load
  72294. */
  72295. url: string;
  72296. /**
  72297. * Defines the desired size (the more it increases the longer the generation will be)
  72298. */
  72299. size: number;
  72300. /**
  72301. * Defines if mipmaps should not be generated (default is false)
  72302. */
  72303. noMipmap: boolean;
  72304. /**
  72305. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72306. * but the standard material would require them in Gamma space) (default is true)
  72307. */
  72308. gammaSpace: boolean;
  72309. /**
  72310. * Gets the loaded texture
  72311. */
  72312. texture: EquiRectangularCubeTexture;
  72313. /**
  72314. * Callback called when the task is successful
  72315. */
  72316. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72317. /**
  72318. * Callback called when the task is successful
  72319. */
  72320. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72321. /**
  72322. * Creates a new EquiRectangularCubeTextureAssetTask object
  72323. * @param name defines the name of the task
  72324. * @param url defines the location of the file to load
  72325. * @param size defines the desired size (the more it increases the longer the generation will be)
  72326. * If the size is omitted this implies you are using a preprocessed cubemap.
  72327. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72328. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72329. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72330. * (default is true)
  72331. */
  72332. constructor(
  72333. /**
  72334. * Defines the name of the task
  72335. */
  72336. name: string,
  72337. /**
  72338. * Defines the location of the file to load
  72339. */
  72340. url: string,
  72341. /**
  72342. * Defines the desired size (the more it increases the longer the generation will be)
  72343. */
  72344. size: number,
  72345. /**
  72346. * Defines if mipmaps should not be generated (default is false)
  72347. */
  72348. noMipmap?: boolean,
  72349. /**
  72350. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72351. * but the standard material would require them in Gamma space) (default is true)
  72352. */
  72353. gammaSpace?: boolean);
  72354. /**
  72355. * Execute the current task
  72356. * @param scene defines the scene where you want your assets to be loaded
  72357. * @param onSuccess is a callback called when the task is successfully executed
  72358. * @param onError is a callback called if an error occurs
  72359. */
  72360. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72361. }
  72362. /**
  72363. * This class can be used to easily import assets into a scene
  72364. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72365. */
  72366. export class AssetsManager {
  72367. private _scene;
  72368. private _isLoading;
  72369. protected _tasks: AbstractAssetTask[];
  72370. protected _waitingTasksCount: number;
  72371. protected _totalTasksCount: number;
  72372. /**
  72373. * Callback called when all tasks are processed
  72374. */
  72375. onFinish: (tasks: AbstractAssetTask[]) => void;
  72376. /**
  72377. * Callback called when a task is successful
  72378. */
  72379. onTaskSuccess: (task: AbstractAssetTask) => void;
  72380. /**
  72381. * Callback called when a task had an error
  72382. */
  72383. onTaskError: (task: AbstractAssetTask) => void;
  72384. /**
  72385. * Callback called when a task is done (whatever the result is)
  72386. */
  72387. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72388. /**
  72389. * Observable called when all tasks are processed
  72390. */
  72391. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72392. /**
  72393. * Observable called when a task had an error
  72394. */
  72395. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72396. /**
  72397. * Observable called when all tasks were executed
  72398. */
  72399. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72400. /**
  72401. * Observable called when a task is done (whatever the result is)
  72402. */
  72403. onProgressObservable: Observable<IAssetsProgressEvent>;
  72404. /**
  72405. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72406. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72407. */
  72408. useDefaultLoadingScreen: boolean;
  72409. /**
  72410. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72411. * when all assets have been downloaded.
  72412. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72413. */
  72414. autoHideLoadingUI: boolean;
  72415. /**
  72416. * Creates a new AssetsManager
  72417. * @param scene defines the scene to work on
  72418. */
  72419. constructor(scene: Scene);
  72420. /**
  72421. * Add a MeshAssetTask to the list of active tasks
  72422. * @param taskName defines the name of the new task
  72423. * @param meshesNames defines the name of meshes to load
  72424. * @param rootUrl defines the root url to use to locate files
  72425. * @param sceneFilename defines the filename of the scene file
  72426. * @returns a new MeshAssetTask object
  72427. */
  72428. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72429. /**
  72430. * Add a TextFileAssetTask to the list of active tasks
  72431. * @param taskName defines the name of the new task
  72432. * @param url defines the url of the file to load
  72433. * @returns a new TextFileAssetTask object
  72434. */
  72435. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72436. /**
  72437. * Add a BinaryFileAssetTask to the list of active tasks
  72438. * @param taskName defines the name of the new task
  72439. * @param url defines the url of the file to load
  72440. * @returns a new BinaryFileAssetTask object
  72441. */
  72442. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72443. /**
  72444. * Add a ImageAssetTask to the list of active tasks
  72445. * @param taskName defines the name of the new task
  72446. * @param url defines the url of the file to load
  72447. * @returns a new ImageAssetTask object
  72448. */
  72449. addImageTask(taskName: string, url: string): ImageAssetTask;
  72450. /**
  72451. * Add a TextureAssetTask to the list of active tasks
  72452. * @param taskName defines the name of the new task
  72453. * @param url defines the url of the file to load
  72454. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72455. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72456. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72457. * @returns a new TextureAssetTask object
  72458. */
  72459. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72460. /**
  72461. * Add a CubeTextureAssetTask to the list of active tasks
  72462. * @param taskName defines the name of the new task
  72463. * @param url defines the url of the file to load
  72464. * @param extensions defines the extension to use to load the cube map (can be null)
  72465. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72466. * @param files defines the list of files to load (can be null)
  72467. * @returns a new CubeTextureAssetTask object
  72468. */
  72469. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72470. /**
  72471. *
  72472. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72473. * @param taskName defines the name of the new task
  72474. * @param url defines the url of the file to load
  72475. * @param size defines the size you want for the cubemap (can be null)
  72476. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72477. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72478. * @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)
  72479. * @param reserved Internal use only
  72480. * @returns a new HDRCubeTextureAssetTask object
  72481. */
  72482. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72483. /**
  72484. *
  72485. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72486. * @param taskName defines the name of the new task
  72487. * @param url defines the url of the file to load
  72488. * @param size defines the size you want for the cubemap (can be null)
  72489. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72490. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72491. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72492. * @returns a new EquiRectangularCubeTextureAssetTask object
  72493. */
  72494. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72495. /**
  72496. * Remove a task from the assets manager.
  72497. * @param task the task to remove
  72498. */
  72499. removeTask(task: AbstractAssetTask): void;
  72500. private _decreaseWaitingTasksCount;
  72501. private _runTask;
  72502. /**
  72503. * Reset the AssetsManager and remove all tasks
  72504. * @return the current instance of the AssetsManager
  72505. */
  72506. reset(): AssetsManager;
  72507. /**
  72508. * Start the loading process
  72509. * @return the current instance of the AssetsManager
  72510. */
  72511. load(): AssetsManager;
  72512. /**
  72513. * Start the loading process as an async operation
  72514. * @return a promise returning the list of failed tasks
  72515. */
  72516. loadAsync(): Promise<void>;
  72517. }
  72518. }
  72519. declare module BABYLON {
  72520. /**
  72521. * Wrapper class for promise with external resolve and reject.
  72522. */
  72523. export class Deferred<T> {
  72524. /**
  72525. * The promise associated with this deferred object.
  72526. */
  72527. readonly promise: Promise<T>;
  72528. private _resolve;
  72529. private _reject;
  72530. /**
  72531. * The resolve method of the promise associated with this deferred object.
  72532. */
  72533. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72534. /**
  72535. * The reject method of the promise associated with this deferred object.
  72536. */
  72537. get reject(): (reason?: any) => void;
  72538. /**
  72539. * Constructor for this deferred object.
  72540. */
  72541. constructor();
  72542. }
  72543. }
  72544. declare module BABYLON {
  72545. /**
  72546. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72547. */
  72548. export class MeshExploder {
  72549. private _centerMesh;
  72550. private _meshes;
  72551. private _meshesOrigins;
  72552. private _toCenterVectors;
  72553. private _scaledDirection;
  72554. private _newPosition;
  72555. private _centerPosition;
  72556. /**
  72557. * Explodes meshes from a center mesh.
  72558. * @param meshes The meshes to explode.
  72559. * @param centerMesh The mesh to be center of explosion.
  72560. */
  72561. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72562. private _setCenterMesh;
  72563. /**
  72564. * Get class name
  72565. * @returns "MeshExploder"
  72566. */
  72567. getClassName(): string;
  72568. /**
  72569. * "Exploded meshes"
  72570. * @returns Array of meshes with the centerMesh at index 0.
  72571. */
  72572. getMeshes(): Array<Mesh>;
  72573. /**
  72574. * Explodes meshes giving a specific direction
  72575. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72576. */
  72577. explode(direction?: number): void;
  72578. }
  72579. }
  72580. declare module BABYLON {
  72581. /**
  72582. * Class used to help managing file picking and drag'n'drop
  72583. */
  72584. export class FilesInput {
  72585. /**
  72586. * List of files ready to be loaded
  72587. */
  72588. static get FilesToLoad(): {
  72589. [key: string]: File;
  72590. };
  72591. /**
  72592. * Callback called when a file is processed
  72593. */
  72594. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72595. private _engine;
  72596. private _currentScene;
  72597. private _sceneLoadedCallback;
  72598. private _progressCallback;
  72599. private _additionalRenderLoopLogicCallback;
  72600. private _textureLoadingCallback;
  72601. private _startingProcessingFilesCallback;
  72602. private _onReloadCallback;
  72603. private _errorCallback;
  72604. private _elementToMonitor;
  72605. private _sceneFileToLoad;
  72606. private _filesToLoad;
  72607. /**
  72608. * Creates a new FilesInput
  72609. * @param engine defines the rendering engine
  72610. * @param scene defines the hosting scene
  72611. * @param sceneLoadedCallback callback called when scene is loaded
  72612. * @param progressCallback callback called to track progress
  72613. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72614. * @param textureLoadingCallback callback called when a texture is loading
  72615. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72616. * @param onReloadCallback callback called when a reload is requested
  72617. * @param errorCallback callback call if an error occurs
  72618. */
  72619. 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>);
  72620. private _dragEnterHandler;
  72621. private _dragOverHandler;
  72622. private _dropHandler;
  72623. /**
  72624. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72625. * @param elementToMonitor defines the DOM element to track
  72626. */
  72627. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72628. /** Gets the current list of files to load */
  72629. get filesToLoad(): File[];
  72630. /**
  72631. * Release all associated resources
  72632. */
  72633. dispose(): void;
  72634. private renderFunction;
  72635. private drag;
  72636. private drop;
  72637. private _traverseFolder;
  72638. private _processFiles;
  72639. /**
  72640. * Load files from a drop event
  72641. * @param event defines the drop event to use as source
  72642. */
  72643. loadFiles(event: any): void;
  72644. private _processReload;
  72645. /**
  72646. * Reload the current scene from the loaded files
  72647. */
  72648. reload(): void;
  72649. }
  72650. }
  72651. declare module BABYLON {
  72652. /**
  72653. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72654. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72655. */
  72656. export class SceneOptimization {
  72657. /**
  72658. * Defines the priority of this optimization (0 by default which means first in the list)
  72659. */
  72660. priority: number;
  72661. /**
  72662. * Gets a string describing the action executed by the current optimization
  72663. * @returns description string
  72664. */
  72665. getDescription(): string;
  72666. /**
  72667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72668. * @param scene defines the current scene where to apply this optimization
  72669. * @param optimizer defines the current optimizer
  72670. * @returns true if everything that can be done was applied
  72671. */
  72672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72673. /**
  72674. * Creates the SceneOptimization object
  72675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72676. * @param desc defines the description associated with the optimization
  72677. */
  72678. constructor(
  72679. /**
  72680. * Defines the priority of this optimization (0 by default which means first in the list)
  72681. */
  72682. priority?: number);
  72683. }
  72684. /**
  72685. * Defines an optimization used to reduce the size of render target textures
  72686. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72687. */
  72688. export class TextureOptimization extends SceneOptimization {
  72689. /**
  72690. * Defines the priority of this optimization (0 by default which means first in the list)
  72691. */
  72692. priority: number;
  72693. /**
  72694. * 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
  72695. */
  72696. maximumSize: number;
  72697. /**
  72698. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72699. */
  72700. step: number;
  72701. /**
  72702. * Gets a string describing the action executed by the current optimization
  72703. * @returns description string
  72704. */
  72705. getDescription(): string;
  72706. /**
  72707. * Creates the TextureOptimization object
  72708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72709. * @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
  72710. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72711. */
  72712. constructor(
  72713. /**
  72714. * Defines the priority of this optimization (0 by default which means first in the list)
  72715. */
  72716. priority?: number,
  72717. /**
  72718. * 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
  72719. */
  72720. maximumSize?: number,
  72721. /**
  72722. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72723. */
  72724. step?: number);
  72725. /**
  72726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72727. * @param scene defines the current scene where to apply this optimization
  72728. * @param optimizer defines the current optimizer
  72729. * @returns true if everything that can be done was applied
  72730. */
  72731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72732. }
  72733. /**
  72734. * Defines an optimization used to increase or decrease the rendering resolution
  72735. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72736. */
  72737. export class HardwareScalingOptimization extends SceneOptimization {
  72738. /**
  72739. * Defines the priority of this optimization (0 by default which means first in the list)
  72740. */
  72741. priority: number;
  72742. /**
  72743. * Defines the maximum scale to use (2 by default)
  72744. */
  72745. maximumScale: number;
  72746. /**
  72747. * Defines the step to use between two passes (0.5 by default)
  72748. */
  72749. step: number;
  72750. private _currentScale;
  72751. private _directionOffset;
  72752. /**
  72753. * Gets a string describing the action executed by the current optimization
  72754. * @return description string
  72755. */
  72756. getDescription(): string;
  72757. /**
  72758. * Creates the HardwareScalingOptimization object
  72759. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72760. * @param maximumScale defines the maximum scale to use (2 by default)
  72761. * @param step defines the step to use between two passes (0.5 by default)
  72762. */
  72763. constructor(
  72764. /**
  72765. * Defines the priority of this optimization (0 by default which means first in the list)
  72766. */
  72767. priority?: number,
  72768. /**
  72769. * Defines the maximum scale to use (2 by default)
  72770. */
  72771. maximumScale?: number,
  72772. /**
  72773. * Defines the step to use between two passes (0.5 by default)
  72774. */
  72775. step?: number);
  72776. /**
  72777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72778. * @param scene defines the current scene where to apply this optimization
  72779. * @param optimizer defines the current optimizer
  72780. * @returns true if everything that can be done was applied
  72781. */
  72782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72783. }
  72784. /**
  72785. * Defines an optimization used to remove shadows
  72786. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72787. */
  72788. export class ShadowsOptimization extends SceneOptimization {
  72789. /**
  72790. * Gets a string describing the action executed by the current optimization
  72791. * @return description string
  72792. */
  72793. getDescription(): string;
  72794. /**
  72795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72796. * @param scene defines the current scene where to apply this optimization
  72797. * @param optimizer defines the current optimizer
  72798. * @returns true if everything that can be done was applied
  72799. */
  72800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72801. }
  72802. /**
  72803. * Defines an optimization used to turn post-processes off
  72804. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72805. */
  72806. export class PostProcessesOptimization extends SceneOptimization {
  72807. /**
  72808. * Gets a string describing the action executed by the current optimization
  72809. * @return description string
  72810. */
  72811. getDescription(): string;
  72812. /**
  72813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72814. * @param scene defines the current scene where to apply this optimization
  72815. * @param optimizer defines the current optimizer
  72816. * @returns true if everything that can be done was applied
  72817. */
  72818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72819. }
  72820. /**
  72821. * Defines an optimization used to turn lens flares off
  72822. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72823. */
  72824. export class LensFlaresOptimization extends SceneOptimization {
  72825. /**
  72826. * Gets a string describing the action executed by the current optimization
  72827. * @return description string
  72828. */
  72829. getDescription(): string;
  72830. /**
  72831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72832. * @param scene defines the current scene where to apply this optimization
  72833. * @param optimizer defines the current optimizer
  72834. * @returns true if everything that can be done was applied
  72835. */
  72836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72837. }
  72838. /**
  72839. * Defines an optimization based on user defined callback.
  72840. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72841. */
  72842. export class CustomOptimization extends SceneOptimization {
  72843. /**
  72844. * Callback called to apply the custom optimization.
  72845. */
  72846. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72847. /**
  72848. * Callback called to get custom description
  72849. */
  72850. onGetDescription: () => string;
  72851. /**
  72852. * Gets a string describing the action executed by the current optimization
  72853. * @returns description string
  72854. */
  72855. getDescription(): string;
  72856. /**
  72857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72858. * @param scene defines the current scene where to apply this optimization
  72859. * @param optimizer defines the current optimizer
  72860. * @returns true if everything that can be done was applied
  72861. */
  72862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72863. }
  72864. /**
  72865. * Defines an optimization used to turn particles off
  72866. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72867. */
  72868. export class ParticlesOptimization extends SceneOptimization {
  72869. /**
  72870. * Gets a string describing the action executed by the current optimization
  72871. * @return description string
  72872. */
  72873. getDescription(): string;
  72874. /**
  72875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72876. * @param scene defines the current scene where to apply this optimization
  72877. * @param optimizer defines the current optimizer
  72878. * @returns true if everything that can be done was applied
  72879. */
  72880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72881. }
  72882. /**
  72883. * Defines an optimization used to turn render targets off
  72884. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72885. */
  72886. export class RenderTargetsOptimization extends SceneOptimization {
  72887. /**
  72888. * Gets a string describing the action executed by the current optimization
  72889. * @return description string
  72890. */
  72891. getDescription(): string;
  72892. /**
  72893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72894. * @param scene defines the current scene where to apply this optimization
  72895. * @param optimizer defines the current optimizer
  72896. * @returns true if everything that can be done was applied
  72897. */
  72898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72899. }
  72900. /**
  72901. * Defines an optimization used to merge meshes with compatible materials
  72902. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72903. */
  72904. export class MergeMeshesOptimization extends SceneOptimization {
  72905. private static _UpdateSelectionTree;
  72906. /**
  72907. * Gets or sets a boolean which defines if optimization octree has to be updated
  72908. */
  72909. static get UpdateSelectionTree(): boolean;
  72910. /**
  72911. * Gets or sets a boolean which defines if optimization octree has to be updated
  72912. */
  72913. static set UpdateSelectionTree(value: boolean);
  72914. /**
  72915. * Gets a string describing the action executed by the current optimization
  72916. * @return description string
  72917. */
  72918. getDescription(): string;
  72919. private _canBeMerged;
  72920. /**
  72921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72922. * @param scene defines the current scene where to apply this optimization
  72923. * @param optimizer defines the current optimizer
  72924. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72925. * @returns true if everything that can be done was applied
  72926. */
  72927. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72928. }
  72929. /**
  72930. * Defines a list of options used by SceneOptimizer
  72931. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72932. */
  72933. export class SceneOptimizerOptions {
  72934. /**
  72935. * Defines the target frame rate to reach (60 by default)
  72936. */
  72937. targetFrameRate: number;
  72938. /**
  72939. * Defines the interval between two checkes (2000ms by default)
  72940. */
  72941. trackerDuration: number;
  72942. /**
  72943. * Gets the list of optimizations to apply
  72944. */
  72945. optimizations: SceneOptimization[];
  72946. /**
  72947. * Creates a new list of options used by SceneOptimizer
  72948. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72949. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72950. */
  72951. constructor(
  72952. /**
  72953. * Defines the target frame rate to reach (60 by default)
  72954. */
  72955. targetFrameRate?: number,
  72956. /**
  72957. * Defines the interval between two checkes (2000ms by default)
  72958. */
  72959. trackerDuration?: number);
  72960. /**
  72961. * Add a new optimization
  72962. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72963. * @returns the current SceneOptimizerOptions
  72964. */
  72965. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72966. /**
  72967. * Add a new custom optimization
  72968. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72969. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72970. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72971. * @returns the current SceneOptimizerOptions
  72972. */
  72973. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72974. /**
  72975. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72976. * @param targetFrameRate defines the target frame rate (60 by default)
  72977. * @returns a SceneOptimizerOptions object
  72978. */
  72979. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72980. /**
  72981. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72982. * @param targetFrameRate defines the target frame rate (60 by default)
  72983. * @returns a SceneOptimizerOptions object
  72984. */
  72985. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72986. /**
  72987. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72988. * @param targetFrameRate defines the target frame rate (60 by default)
  72989. * @returns a SceneOptimizerOptions object
  72990. */
  72991. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72992. }
  72993. /**
  72994. * Class used to run optimizations in order to reach a target frame rate
  72995. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72996. */
  72997. export class SceneOptimizer implements IDisposable {
  72998. private _isRunning;
  72999. private _options;
  73000. private _scene;
  73001. private _currentPriorityLevel;
  73002. private _targetFrameRate;
  73003. private _trackerDuration;
  73004. private _currentFrameRate;
  73005. private _sceneDisposeObserver;
  73006. private _improvementMode;
  73007. /**
  73008. * Defines an observable called when the optimizer reaches the target frame rate
  73009. */
  73010. onSuccessObservable: Observable<SceneOptimizer>;
  73011. /**
  73012. * Defines an observable called when the optimizer enables an optimization
  73013. */
  73014. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73015. /**
  73016. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73017. */
  73018. onFailureObservable: Observable<SceneOptimizer>;
  73019. /**
  73020. * Gets a boolean indicating if the optimizer is in improvement mode
  73021. */
  73022. get isInImprovementMode(): boolean;
  73023. /**
  73024. * Gets the current priority level (0 at start)
  73025. */
  73026. get currentPriorityLevel(): number;
  73027. /**
  73028. * Gets the current frame rate checked by the SceneOptimizer
  73029. */
  73030. get currentFrameRate(): number;
  73031. /**
  73032. * Gets or sets the current target frame rate (60 by default)
  73033. */
  73034. get targetFrameRate(): number;
  73035. /**
  73036. * Gets or sets the current target frame rate (60 by default)
  73037. */
  73038. set targetFrameRate(value: number);
  73039. /**
  73040. * Gets or sets the current interval between two checks (every 2000ms by default)
  73041. */
  73042. get trackerDuration(): number;
  73043. /**
  73044. * Gets or sets the current interval between two checks (every 2000ms by default)
  73045. */
  73046. set trackerDuration(value: number);
  73047. /**
  73048. * Gets the list of active optimizations
  73049. */
  73050. get optimizations(): SceneOptimization[];
  73051. /**
  73052. * Creates a new SceneOptimizer
  73053. * @param scene defines the scene to work on
  73054. * @param options defines the options to use with the SceneOptimizer
  73055. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73056. * @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)
  73057. */
  73058. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73059. /**
  73060. * Stops the current optimizer
  73061. */
  73062. stop(): void;
  73063. /**
  73064. * Reset the optimizer to initial step (current priority level = 0)
  73065. */
  73066. reset(): void;
  73067. /**
  73068. * Start the optimizer. By default it will try to reach a specific framerate
  73069. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73070. */
  73071. start(): void;
  73072. private _checkCurrentState;
  73073. /**
  73074. * Release all resources
  73075. */
  73076. dispose(): void;
  73077. /**
  73078. * Helper function to create a SceneOptimizer with one single line of code
  73079. * @param scene defines the scene to work on
  73080. * @param options defines the options to use with the SceneOptimizer
  73081. * @param onSuccess defines a callback to call on success
  73082. * @param onFailure defines a callback to call on failure
  73083. * @returns the new SceneOptimizer object
  73084. */
  73085. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73086. }
  73087. }
  73088. declare module BABYLON {
  73089. /**
  73090. * Class used to serialize a scene into a string
  73091. */
  73092. export class SceneSerializer {
  73093. /**
  73094. * Clear cache used by a previous serialization
  73095. */
  73096. static ClearCache(): void;
  73097. /**
  73098. * Serialize a scene into a JSON compatible object
  73099. * @param scene defines the scene to serialize
  73100. * @returns a JSON compatible object
  73101. */
  73102. static Serialize(scene: Scene): any;
  73103. /**
  73104. * Serialize a mesh into a JSON compatible object
  73105. * @param toSerialize defines the mesh to serialize
  73106. * @param withParents defines if parents must be serialized as well
  73107. * @param withChildren defines if children must be serialized as well
  73108. * @returns a JSON compatible object
  73109. */
  73110. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73111. }
  73112. }
  73113. declare module BABYLON {
  73114. /**
  73115. * Class used to host texture specific utilities
  73116. */
  73117. export class TextureTools {
  73118. /**
  73119. * Uses the GPU to create a copy texture rescaled at a given size
  73120. * @param texture Texture to copy from
  73121. * @param width defines the desired width
  73122. * @param height defines the desired height
  73123. * @param useBilinearMode defines if bilinear mode has to be used
  73124. * @return the generated texture
  73125. */
  73126. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73127. }
  73128. }
  73129. declare module BABYLON {
  73130. /**
  73131. * This represents the different options available for the video capture.
  73132. */
  73133. export interface VideoRecorderOptions {
  73134. /** Defines the mime type of the video. */
  73135. mimeType: string;
  73136. /** Defines the FPS the video should be recorded at. */
  73137. fps: number;
  73138. /** Defines the chunk size for the recording data. */
  73139. recordChunckSize: number;
  73140. /** The audio tracks to attach to the recording. */
  73141. audioTracks?: MediaStreamTrack[];
  73142. }
  73143. /**
  73144. * This can help with recording videos from BabylonJS.
  73145. * This is based on the available WebRTC functionalities of the browser.
  73146. *
  73147. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73148. */
  73149. export class VideoRecorder {
  73150. private static readonly _defaultOptions;
  73151. /**
  73152. * Returns whether or not the VideoRecorder is available in your browser.
  73153. * @param engine Defines the Babylon Engine.
  73154. * @returns true if supported otherwise false.
  73155. */
  73156. static IsSupported(engine: Engine): boolean;
  73157. private readonly _options;
  73158. private _canvas;
  73159. private _mediaRecorder;
  73160. private _recordedChunks;
  73161. private _fileName;
  73162. private _resolve;
  73163. private _reject;
  73164. /**
  73165. * True when a recording is already in progress.
  73166. */
  73167. get isRecording(): boolean;
  73168. /**
  73169. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73170. * @param engine Defines the BabylonJS Engine you wish to record.
  73171. * @param options Defines options that can be used to customize the capture.
  73172. */
  73173. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73174. /**
  73175. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73176. */
  73177. stopRecording(): void;
  73178. /**
  73179. * Starts recording the canvas for a max duration specified in parameters.
  73180. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73181. * If null no automatic download will start and you can rely on the promise to get the data back.
  73182. * @param maxDuration Defines the maximum recording time in seconds.
  73183. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73184. * @return A promise callback at the end of the recording with the video data in Blob.
  73185. */
  73186. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73187. /**
  73188. * Releases internal resources used during the recording.
  73189. */
  73190. dispose(): void;
  73191. private _handleDataAvailable;
  73192. private _handleError;
  73193. private _handleStop;
  73194. }
  73195. }
  73196. declare module BABYLON {
  73197. /**
  73198. * Class containing a set of static utilities functions for screenshots
  73199. */
  73200. export class ScreenshotTools {
  73201. /**
  73202. * Captures a screenshot of the current rendering
  73203. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73204. * @param engine defines the rendering engine
  73205. * @param camera defines the source camera
  73206. * @param size This parameter can be set to a single number or to an object with the
  73207. * following (optional) properties: precision, width, height. If a single number is passed,
  73208. * it will be used for both width and height. If an object is passed, the screenshot size
  73209. * will be derived from the parameters. The precision property is a multiplier allowing
  73210. * rendering at a higher or lower resolution
  73211. * @param successCallback defines the callback receives a single parameter which contains the
  73212. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73213. * src parameter of an <img> to display it
  73214. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73215. * Check your browser for supported MIME types
  73216. */
  73217. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73218. /**
  73219. * Captures a screenshot of the current rendering
  73220. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73221. * @param engine defines the rendering engine
  73222. * @param camera defines the source camera
  73223. * @param size This parameter can be set to a single number or to an object with the
  73224. * following (optional) properties: precision, width, height. If a single number is passed,
  73225. * it will be used for both width and height. If an object is passed, the screenshot size
  73226. * will be derived from the parameters. The precision property is a multiplier allowing
  73227. * rendering at a higher or lower resolution
  73228. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73229. * Check your browser for supported MIME types
  73230. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73231. * to the src parameter of an <img> to display it
  73232. */
  73233. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73234. /**
  73235. * Generates an image screenshot from the specified camera.
  73236. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73237. * @param engine The engine to use for rendering
  73238. * @param camera The camera to use for rendering
  73239. * @param size This parameter can be set to a single number or to an object with the
  73240. * following (optional) properties: precision, width, height. If a single number is passed,
  73241. * it will be used for both width and height. If an object is passed, the screenshot size
  73242. * will be derived from the parameters. The precision property is a multiplier allowing
  73243. * rendering at a higher or lower resolution
  73244. * @param successCallback The callback receives a single parameter which contains the
  73245. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73246. * src parameter of an <img> to display it
  73247. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73248. * Check your browser for supported MIME types
  73249. * @param samples Texture samples (default: 1)
  73250. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73251. * @param fileName A name for for the downloaded file.
  73252. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73253. */
  73254. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73255. /**
  73256. * Generates an image screenshot from the specified camera.
  73257. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73258. * @param engine The engine to use for rendering
  73259. * @param camera The camera to use for rendering
  73260. * @param size This parameter can be set to a single number or to an object with the
  73261. * following (optional) properties: precision, width, height. If a single number is passed,
  73262. * it will be used for both width and height. If an object is passed, the screenshot size
  73263. * will be derived from the parameters. The precision property is a multiplier allowing
  73264. * rendering at a higher or lower resolution
  73265. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73266. * Check your browser for supported MIME types
  73267. * @param samples Texture samples (default: 1)
  73268. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73269. * @param fileName A name for for the downloaded file.
  73270. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73271. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73272. * to the src parameter of an <img> to display it
  73273. */
  73274. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73275. /**
  73276. * Gets height and width for screenshot size
  73277. * @private
  73278. */
  73279. private static _getScreenshotSize;
  73280. }
  73281. }
  73282. declare module BABYLON {
  73283. /**
  73284. * Interface for a data buffer
  73285. */
  73286. export interface IDataBuffer {
  73287. /**
  73288. * Reads bytes from the data buffer.
  73289. * @param byteOffset The byte offset to read
  73290. * @param byteLength The byte length to read
  73291. * @returns A promise that resolves when the bytes are read
  73292. */
  73293. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73294. /**
  73295. * The byte length of the buffer.
  73296. */
  73297. readonly byteLength: number;
  73298. }
  73299. /**
  73300. * Utility class for reading from a data buffer
  73301. */
  73302. export class DataReader {
  73303. /**
  73304. * The data buffer associated with this data reader.
  73305. */
  73306. readonly buffer: IDataBuffer;
  73307. /**
  73308. * The current byte offset from the beginning of the data buffer.
  73309. */
  73310. byteOffset: number;
  73311. private _dataView;
  73312. private _dataByteOffset;
  73313. /**
  73314. * Constructor
  73315. * @param buffer The buffer to read
  73316. */
  73317. constructor(buffer: IDataBuffer);
  73318. /**
  73319. * Loads the given byte length.
  73320. * @param byteLength The byte length to load
  73321. * @returns A promise that resolves when the load is complete
  73322. */
  73323. loadAsync(byteLength: number): Promise<void>;
  73324. /**
  73325. * Read a unsigned 32-bit integer from the currently loaded data range.
  73326. * @returns The 32-bit integer read
  73327. */
  73328. readUint32(): number;
  73329. /**
  73330. * Read a byte array from the currently loaded data range.
  73331. * @param byteLength The byte length to read
  73332. * @returns The byte array read
  73333. */
  73334. readUint8Array(byteLength: number): Uint8Array;
  73335. /**
  73336. * Read a string from the currently loaded data range.
  73337. * @param byteLength The byte length to read
  73338. * @returns The string read
  73339. */
  73340. readString(byteLength: number): string;
  73341. /**
  73342. * Skips the given byte length the currently loaded data range.
  73343. * @param byteLength The byte length to skip
  73344. */
  73345. skipBytes(byteLength: number): void;
  73346. }
  73347. }
  73348. declare module BABYLON {
  73349. /**
  73350. * Class for storing data to local storage if available or in-memory storage otherwise
  73351. */
  73352. export class DataStorage {
  73353. private static _Storage;
  73354. private static _GetStorage;
  73355. /**
  73356. * Reads a string from the data storage
  73357. * @param key The key to read
  73358. * @param defaultValue The value if the key doesn't exist
  73359. * @returns The string value
  73360. */
  73361. static ReadString(key: string, defaultValue: string): string;
  73362. /**
  73363. * Writes a string to the data storage
  73364. * @param key The key to write
  73365. * @param value The value to write
  73366. */
  73367. static WriteString(key: string, value: string): void;
  73368. /**
  73369. * Reads a boolean from the data storage
  73370. * @param key The key to read
  73371. * @param defaultValue The value if the key doesn't exist
  73372. * @returns The boolean value
  73373. */
  73374. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73375. /**
  73376. * Writes a boolean to the data storage
  73377. * @param key The key to write
  73378. * @param value The value to write
  73379. */
  73380. static WriteBoolean(key: string, value: boolean): void;
  73381. /**
  73382. * Reads a number from the data storage
  73383. * @param key The key to read
  73384. * @param defaultValue The value if the key doesn't exist
  73385. * @returns The number value
  73386. */
  73387. static ReadNumber(key: string, defaultValue: number): number;
  73388. /**
  73389. * Writes a number to the data storage
  73390. * @param key The key to write
  73391. * @param value The value to write
  73392. */
  73393. static WriteNumber(key: string, value: number): void;
  73394. }
  73395. }
  73396. declare module BABYLON {
  73397. /**
  73398. * An interface for all Hit test features
  73399. */
  73400. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73401. /**
  73402. * Triggered when new babylon (transformed) hit test results are available
  73403. */
  73404. onHitTestResultObservable: Observable<T[]>;
  73405. }
  73406. /**
  73407. * Options used for hit testing
  73408. */
  73409. export interface IWebXRLegacyHitTestOptions {
  73410. /**
  73411. * Only test when user interacted with the scene. Default - hit test every frame
  73412. */
  73413. testOnPointerDownOnly?: boolean;
  73414. /**
  73415. * The node to use to transform the local results to world coordinates
  73416. */
  73417. worldParentNode?: TransformNode;
  73418. }
  73419. /**
  73420. * Interface defining the babylon result of raycasting/hit-test
  73421. */
  73422. export interface IWebXRLegacyHitResult {
  73423. /**
  73424. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73425. */
  73426. transformationMatrix: Matrix;
  73427. /**
  73428. * The native hit test result
  73429. */
  73430. xrHitResult: XRHitResult | XRHitTestResult;
  73431. }
  73432. /**
  73433. * The currently-working hit-test module.
  73434. * Hit test (or Ray-casting) is used to interact with the real world.
  73435. * For further information read here - https://github.com/immersive-web/hit-test
  73436. */
  73437. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73438. /**
  73439. * options to use when constructing this feature
  73440. */
  73441. readonly options: IWebXRLegacyHitTestOptions;
  73442. private _direction;
  73443. private _mat;
  73444. private _onSelectEnabled;
  73445. private _origin;
  73446. /**
  73447. * The module's name
  73448. */
  73449. static readonly Name: string;
  73450. /**
  73451. * The (Babylon) version of this module.
  73452. * This is an integer representing the implementation version.
  73453. * This number does not correspond to the WebXR specs version
  73454. */
  73455. static readonly Version: number;
  73456. /**
  73457. * Populated with the last native XR Hit Results
  73458. */
  73459. lastNativeXRHitResults: XRHitResult[];
  73460. /**
  73461. * Triggered when new babylon (transformed) hit test results are available
  73462. */
  73463. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73464. /**
  73465. * Creates a new instance of the (legacy version) hit test feature
  73466. * @param _xrSessionManager an instance of WebXRSessionManager
  73467. * @param options options to use when constructing this feature
  73468. */
  73469. constructor(_xrSessionManager: WebXRSessionManager,
  73470. /**
  73471. * options to use when constructing this feature
  73472. */
  73473. options?: IWebXRLegacyHitTestOptions);
  73474. /**
  73475. * execute a hit test with an XR Ray
  73476. *
  73477. * @param xrSession a native xrSession that will execute this hit test
  73478. * @param xrRay the ray (position and direction) to use for ray-casting
  73479. * @param referenceSpace native XR reference space to use for the hit-test
  73480. * @param filter filter function that will filter the results
  73481. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73482. */
  73483. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73484. /**
  73485. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73486. * @param event the (select) event to use to select with
  73487. * @param referenceSpace the reference space to use for this hit test
  73488. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73489. */
  73490. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73491. /**
  73492. * attach this feature
  73493. * Will usually be called by the features manager
  73494. *
  73495. * @returns true if successful.
  73496. */
  73497. attach(): boolean;
  73498. /**
  73499. * detach this feature.
  73500. * Will usually be called by the features manager
  73501. *
  73502. * @returns true if successful.
  73503. */
  73504. detach(): boolean;
  73505. /**
  73506. * Dispose this feature and all of the resources attached
  73507. */
  73508. dispose(): void;
  73509. protected _onXRFrame(frame: XRFrame): void;
  73510. private _onHitTestResults;
  73511. private _onSelect;
  73512. }
  73513. }
  73514. declare module BABYLON {
  73515. /**
  73516. * Options used for hit testing (version 2)
  73517. */
  73518. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73519. /**
  73520. * Do not create a permanent hit test. Will usually be used when only
  73521. * transient inputs are needed.
  73522. */
  73523. disablePermanentHitTest?: boolean;
  73524. /**
  73525. * Enable transient (for example touch-based) hit test inspections
  73526. */
  73527. enableTransientHitTest?: boolean;
  73528. /**
  73529. * Offset ray for the permanent hit test
  73530. */
  73531. offsetRay?: Vector3;
  73532. /**
  73533. * Offset ray for the transient hit test
  73534. */
  73535. transientOffsetRay?: Vector3;
  73536. /**
  73537. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73538. */
  73539. useReferenceSpace?: boolean;
  73540. }
  73541. /**
  73542. * Interface defining the babylon result of hit-test
  73543. */
  73544. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73545. /**
  73546. * The input source that generated this hit test (if transient)
  73547. */
  73548. inputSource?: XRInputSource;
  73549. /**
  73550. * Is this a transient hit test
  73551. */
  73552. isTransient?: boolean;
  73553. /**
  73554. * Position of the hit test result
  73555. */
  73556. position: Vector3;
  73557. /**
  73558. * Rotation of the hit test result
  73559. */
  73560. rotationQuaternion: Quaternion;
  73561. /**
  73562. * The native hit test result
  73563. */
  73564. xrHitResult: XRHitTestResult;
  73565. }
  73566. /**
  73567. * The currently-working hit-test module.
  73568. * Hit test (or Ray-casting) is used to interact with the real world.
  73569. * For further information read here - https://github.com/immersive-web/hit-test
  73570. *
  73571. * Tested on chrome (mobile) 80.
  73572. */
  73573. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73574. /**
  73575. * options to use when constructing this feature
  73576. */
  73577. readonly options: IWebXRHitTestOptions;
  73578. private _tmpMat;
  73579. private _tmpPos;
  73580. private _tmpQuat;
  73581. private _transientXrHitTestSource;
  73582. private _xrHitTestSource;
  73583. private initHitTestSource;
  73584. /**
  73585. * The module's name
  73586. */
  73587. static readonly Name: string;
  73588. /**
  73589. * The (Babylon) version of this module.
  73590. * This is an integer representing the implementation version.
  73591. * This number does not correspond to the WebXR specs version
  73592. */
  73593. static readonly Version: number;
  73594. /**
  73595. * When set to true, each hit test will have its own position/rotation objects
  73596. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73597. * the developers will clone them or copy them as they see fit.
  73598. */
  73599. autoCloneTransformation: boolean;
  73600. /**
  73601. * Triggered when new babylon (transformed) hit test results are available
  73602. */
  73603. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73604. /**
  73605. * Use this to temporarily pause hit test checks.
  73606. */
  73607. paused: boolean;
  73608. /**
  73609. * Creates a new instance of the hit test feature
  73610. * @param _xrSessionManager an instance of WebXRSessionManager
  73611. * @param options options to use when constructing this feature
  73612. */
  73613. constructor(_xrSessionManager: WebXRSessionManager,
  73614. /**
  73615. * options to use when constructing this feature
  73616. */
  73617. options?: IWebXRHitTestOptions);
  73618. /**
  73619. * attach this feature
  73620. * Will usually be called by the features manager
  73621. *
  73622. * @returns true if successful.
  73623. */
  73624. attach(): boolean;
  73625. /**
  73626. * detach this feature.
  73627. * Will usually be called by the features manager
  73628. *
  73629. * @returns true if successful.
  73630. */
  73631. detach(): boolean;
  73632. /**
  73633. * Dispose this feature and all of the resources attached
  73634. */
  73635. dispose(): void;
  73636. protected _onXRFrame(frame: XRFrame): void;
  73637. private _processWebXRHitTestResult;
  73638. }
  73639. }
  73640. declare module BABYLON {
  73641. /**
  73642. * Configuration options of the anchor system
  73643. */
  73644. export interface IWebXRAnchorSystemOptions {
  73645. /**
  73646. * a node that will be used to convert local to world coordinates
  73647. */
  73648. worldParentNode?: TransformNode;
  73649. /**
  73650. * If set to true a reference of the created anchors will be kept until the next session starts
  73651. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73652. */
  73653. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73654. }
  73655. /**
  73656. * A babylon container for an XR Anchor
  73657. */
  73658. export interface IWebXRAnchor {
  73659. /**
  73660. * A babylon-assigned ID for this anchor
  73661. */
  73662. id: number;
  73663. /**
  73664. * Transformation matrix to apply to an object attached to this anchor
  73665. */
  73666. transformationMatrix: Matrix;
  73667. /**
  73668. * The native anchor object
  73669. */
  73670. xrAnchor: XRAnchor;
  73671. /**
  73672. * if defined, this object will be constantly updated by the anchor's position and rotation
  73673. */
  73674. attachedNode?: TransformNode;
  73675. }
  73676. /**
  73677. * An implementation of the anchor system for WebXR.
  73678. * For further information see https://github.com/immersive-web/anchors/
  73679. */
  73680. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73681. private _options;
  73682. private _lastFrameDetected;
  73683. private _trackedAnchors;
  73684. private _referenceSpaceForFrameAnchors;
  73685. private _futureAnchors;
  73686. /**
  73687. * The module's name
  73688. */
  73689. static readonly Name: string;
  73690. /**
  73691. * The (Babylon) version of this module.
  73692. * This is an integer representing the implementation version.
  73693. * This number does not correspond to the WebXR specs version
  73694. */
  73695. static readonly Version: number;
  73696. /**
  73697. * Observers registered here will be executed when a new anchor was added to the session
  73698. */
  73699. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73700. /**
  73701. * Observers registered here will be executed when an anchor was removed from the session
  73702. */
  73703. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73704. /**
  73705. * Observers registered here will be executed when an existing anchor updates
  73706. * This can execute N times every frame
  73707. */
  73708. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73709. /**
  73710. * Set the reference space to use for anchor creation, when not using a hit test.
  73711. * Will default to the session's reference space if not defined
  73712. */
  73713. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73714. /**
  73715. * constructs a new anchor system
  73716. * @param _xrSessionManager an instance of WebXRSessionManager
  73717. * @param _options configuration object for this feature
  73718. */
  73719. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73720. private _tmpVector;
  73721. private _tmpQuaternion;
  73722. private _populateTmpTransformation;
  73723. /**
  73724. * Create a new anchor point using a hit test result at a specific point in the scene
  73725. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73726. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73727. *
  73728. * @param hitTestResult The hit test result to use for this anchor creation
  73729. * @param position an optional position offset for this anchor
  73730. * @param rotationQuaternion an optional rotation offset for this anchor
  73731. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73732. */
  73733. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73734. /**
  73735. * Add a new anchor at a specific position and rotation
  73736. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73737. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73738. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73739. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73740. *
  73741. * @param position the position in which to add an anchor
  73742. * @param rotationQuaternion an optional rotation for the anchor transformation
  73743. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73744. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73745. */
  73746. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73747. /**
  73748. * detach this feature.
  73749. * Will usually be called by the features manager
  73750. *
  73751. * @returns true if successful.
  73752. */
  73753. detach(): boolean;
  73754. /**
  73755. * Dispose this feature and all of the resources attached
  73756. */
  73757. dispose(): void;
  73758. protected _onXRFrame(frame: XRFrame): void;
  73759. /**
  73760. * avoiding using Array.find for global support.
  73761. * @param xrAnchor the plane to find in the array
  73762. */
  73763. private _findIndexInAnchorArray;
  73764. private _updateAnchorWithXRFrame;
  73765. private _createAnchorAtTransformation;
  73766. }
  73767. }
  73768. declare module BABYLON {
  73769. /**
  73770. * Options used in the plane detector module
  73771. */
  73772. export interface IWebXRPlaneDetectorOptions {
  73773. /**
  73774. * The node to use to transform the local results to world coordinates
  73775. */
  73776. worldParentNode?: TransformNode;
  73777. /**
  73778. * If set to true a reference of the created planes will be kept until the next session starts
  73779. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73780. */
  73781. doNotRemovePlanesOnSessionEnded?: boolean;
  73782. }
  73783. /**
  73784. * A babylon interface for a WebXR plane.
  73785. * A Plane is actually a polygon, built from N points in space
  73786. *
  73787. * Supported in chrome 79, not supported in canary 81 ATM
  73788. */
  73789. export interface IWebXRPlane {
  73790. /**
  73791. * a babylon-assigned ID for this polygon
  73792. */
  73793. id: number;
  73794. /**
  73795. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73796. */
  73797. polygonDefinition: Array<Vector3>;
  73798. /**
  73799. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73800. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73801. */
  73802. transformationMatrix: Matrix;
  73803. /**
  73804. * the native xr-plane object
  73805. */
  73806. xrPlane: XRPlane;
  73807. }
  73808. /**
  73809. * The plane detector is used to detect planes in the real world when in AR
  73810. * For more information see https://github.com/immersive-web/real-world-geometry/
  73811. */
  73812. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73813. private _options;
  73814. private _detectedPlanes;
  73815. private _enabled;
  73816. private _lastFrameDetected;
  73817. /**
  73818. * The module's name
  73819. */
  73820. static readonly Name: string;
  73821. /**
  73822. * The (Babylon) version of this module.
  73823. * This is an integer representing the implementation version.
  73824. * This number does not correspond to the WebXR specs version
  73825. */
  73826. static readonly Version: number;
  73827. /**
  73828. * Observers registered here will be executed when a new plane was added to the session
  73829. */
  73830. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73831. /**
  73832. * Observers registered here will be executed when a plane is no longer detected in the session
  73833. */
  73834. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73835. /**
  73836. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73837. * This can execute N times every frame
  73838. */
  73839. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73840. /**
  73841. * construct a new Plane Detector
  73842. * @param _xrSessionManager an instance of xr Session manager
  73843. * @param _options configuration to use when constructing this feature
  73844. */
  73845. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73846. /**
  73847. * detach this feature.
  73848. * Will usually be called by the features manager
  73849. *
  73850. * @returns true if successful.
  73851. */
  73852. detach(): boolean;
  73853. /**
  73854. * Dispose this feature and all of the resources attached
  73855. */
  73856. dispose(): void;
  73857. protected _onXRFrame(frame: XRFrame): void;
  73858. private _init;
  73859. private _updatePlaneWithXRPlane;
  73860. /**
  73861. * avoiding using Array.find for global support.
  73862. * @param xrPlane the plane to find in the array
  73863. */
  73864. private findIndexInPlaneArray;
  73865. }
  73866. }
  73867. declare module BABYLON {
  73868. /**
  73869. * Options interface for the background remover plugin
  73870. */
  73871. export interface IWebXRBackgroundRemoverOptions {
  73872. /**
  73873. * Further background meshes to disable when entering AR
  73874. */
  73875. backgroundMeshes?: AbstractMesh[];
  73876. /**
  73877. * flags to configure the removal of the environment helper.
  73878. * If not set, the entire background will be removed. If set, flags should be set as well.
  73879. */
  73880. environmentHelperRemovalFlags?: {
  73881. /**
  73882. * Should the skybox be removed (default false)
  73883. */
  73884. skyBox?: boolean;
  73885. /**
  73886. * Should the ground be removed (default false)
  73887. */
  73888. ground?: boolean;
  73889. };
  73890. /**
  73891. * don't disable the environment helper
  73892. */
  73893. ignoreEnvironmentHelper?: boolean;
  73894. }
  73895. /**
  73896. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73897. */
  73898. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73899. /**
  73900. * read-only options to be used in this module
  73901. */
  73902. readonly options: IWebXRBackgroundRemoverOptions;
  73903. /**
  73904. * The module's name
  73905. */
  73906. static readonly Name: string;
  73907. /**
  73908. * The (Babylon) version of this module.
  73909. * This is an integer representing the implementation version.
  73910. * This number does not correspond to the WebXR specs version
  73911. */
  73912. static readonly Version: number;
  73913. /**
  73914. * registered observers will be triggered when the background state changes
  73915. */
  73916. onBackgroundStateChangedObservable: Observable<boolean>;
  73917. /**
  73918. * constructs a new background remover module
  73919. * @param _xrSessionManager the session manager for this module
  73920. * @param options read-only options to be used in this module
  73921. */
  73922. constructor(_xrSessionManager: WebXRSessionManager,
  73923. /**
  73924. * read-only options to be used in this module
  73925. */
  73926. options?: IWebXRBackgroundRemoverOptions);
  73927. /**
  73928. * attach this feature
  73929. * Will usually be called by the features manager
  73930. *
  73931. * @returns true if successful.
  73932. */
  73933. attach(): boolean;
  73934. /**
  73935. * detach this feature.
  73936. * Will usually be called by the features manager
  73937. *
  73938. * @returns true if successful.
  73939. */
  73940. detach(): boolean;
  73941. /**
  73942. * Dispose this feature and all of the resources attached
  73943. */
  73944. dispose(): void;
  73945. protected _onXRFrame(_xrFrame: XRFrame): void;
  73946. private _setBackgroundState;
  73947. }
  73948. }
  73949. declare module BABYLON {
  73950. /**
  73951. * Options for the controller physics feature
  73952. */
  73953. export class IWebXRControllerPhysicsOptions {
  73954. /**
  73955. * Should the headset get its own impostor
  73956. */
  73957. enableHeadsetImpostor?: boolean;
  73958. /**
  73959. * Optional parameters for the headset impostor
  73960. */
  73961. headsetImpostorParams?: {
  73962. /**
  73963. * The type of impostor to create. Default is sphere
  73964. */
  73965. impostorType: number;
  73966. /**
  73967. * the size of the impostor. Defaults to 10cm
  73968. */
  73969. impostorSize?: number | {
  73970. width: number;
  73971. height: number;
  73972. depth: number;
  73973. };
  73974. /**
  73975. * Friction definitions
  73976. */
  73977. friction?: number;
  73978. /**
  73979. * Restitution
  73980. */
  73981. restitution?: number;
  73982. };
  73983. /**
  73984. * The physics properties of the future impostors
  73985. */
  73986. physicsProperties?: {
  73987. /**
  73988. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73989. * Note that this requires a physics engine that supports mesh impostors!
  73990. */
  73991. useControllerMesh?: boolean;
  73992. /**
  73993. * The type of impostor to create. Default is sphere
  73994. */
  73995. impostorType?: number;
  73996. /**
  73997. * the size of the impostor. Defaults to 10cm
  73998. */
  73999. impostorSize?: number | {
  74000. width: number;
  74001. height: number;
  74002. depth: number;
  74003. };
  74004. /**
  74005. * Friction definitions
  74006. */
  74007. friction?: number;
  74008. /**
  74009. * Restitution
  74010. */
  74011. restitution?: number;
  74012. };
  74013. /**
  74014. * the xr input to use with this pointer selection
  74015. */
  74016. xrInput: WebXRInput;
  74017. }
  74018. /**
  74019. * Add physics impostor to your webxr controllers,
  74020. * including naive calculation of their linear and angular velocity
  74021. */
  74022. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74023. private readonly _options;
  74024. private _attachController;
  74025. private _controllers;
  74026. private _debugMode;
  74027. private _delta;
  74028. private _headsetImpostor?;
  74029. private _headsetMesh?;
  74030. private _lastTimestamp;
  74031. private _tmpQuaternion;
  74032. private _tmpVector;
  74033. /**
  74034. * The module's name
  74035. */
  74036. static readonly Name: string;
  74037. /**
  74038. * The (Babylon) version of this module.
  74039. * This is an integer representing the implementation version.
  74040. * This number does not correspond to the webxr specs version
  74041. */
  74042. static readonly Version: number;
  74043. /**
  74044. * Construct a new Controller Physics Feature
  74045. * @param _xrSessionManager the corresponding xr session manager
  74046. * @param _options options to create this feature with
  74047. */
  74048. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74049. /**
  74050. * @hidden
  74051. * enable debugging - will show console outputs and the impostor mesh
  74052. */
  74053. _enablePhysicsDebug(): void;
  74054. /**
  74055. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74056. * @param xrController the controller to add
  74057. */
  74058. addController(xrController: WebXRInputSource): void;
  74059. /**
  74060. * attach this feature
  74061. * Will usually be called by the features manager
  74062. *
  74063. * @returns true if successful.
  74064. */
  74065. attach(): boolean;
  74066. /**
  74067. * detach this feature.
  74068. * Will usually be called by the features manager
  74069. *
  74070. * @returns true if successful.
  74071. */
  74072. detach(): boolean;
  74073. /**
  74074. * Get the headset impostor, if enabled
  74075. * @returns the impostor
  74076. */
  74077. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74078. /**
  74079. * Get the physics impostor of a specific controller.
  74080. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74081. * @param controller the controller or the controller id of which to get the impostor
  74082. * @returns the impostor or null
  74083. */
  74084. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74085. /**
  74086. * Update the physics properties provided in the constructor
  74087. * @param newProperties the new properties object
  74088. */
  74089. setPhysicsProperties(newProperties: {
  74090. impostorType?: number;
  74091. impostorSize?: number | {
  74092. width: number;
  74093. height: number;
  74094. depth: number;
  74095. };
  74096. friction?: number;
  74097. restitution?: number;
  74098. }): void;
  74099. protected _onXRFrame(_xrFrame: any): void;
  74100. private _detachController;
  74101. }
  74102. }
  74103. declare module BABYLON {
  74104. /**
  74105. * The motion controller class for all microsoft mixed reality controllers
  74106. */
  74107. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74108. protected readonly _mapping: {
  74109. defaultButton: {
  74110. valueNodeName: string;
  74111. unpressedNodeName: string;
  74112. pressedNodeName: string;
  74113. };
  74114. defaultAxis: {
  74115. valueNodeName: string;
  74116. minNodeName: string;
  74117. maxNodeName: string;
  74118. };
  74119. buttons: {
  74120. "xr-standard-trigger": {
  74121. rootNodeName: string;
  74122. componentProperty: string;
  74123. states: string[];
  74124. };
  74125. "xr-standard-squeeze": {
  74126. rootNodeName: string;
  74127. componentProperty: string;
  74128. states: string[];
  74129. };
  74130. "xr-standard-touchpad": {
  74131. rootNodeName: string;
  74132. labelAnchorNodeName: string;
  74133. touchPointNodeName: string;
  74134. };
  74135. "xr-standard-thumbstick": {
  74136. rootNodeName: string;
  74137. componentProperty: string;
  74138. states: string[];
  74139. };
  74140. };
  74141. axes: {
  74142. "xr-standard-touchpad": {
  74143. "x-axis": {
  74144. rootNodeName: string;
  74145. };
  74146. "y-axis": {
  74147. rootNodeName: string;
  74148. };
  74149. };
  74150. "xr-standard-thumbstick": {
  74151. "x-axis": {
  74152. rootNodeName: string;
  74153. };
  74154. "y-axis": {
  74155. rootNodeName: string;
  74156. };
  74157. };
  74158. };
  74159. };
  74160. /**
  74161. * The base url used to load the left and right controller models
  74162. */
  74163. static MODEL_BASE_URL: string;
  74164. /**
  74165. * The name of the left controller model file
  74166. */
  74167. static MODEL_LEFT_FILENAME: string;
  74168. /**
  74169. * The name of the right controller model file
  74170. */
  74171. static MODEL_RIGHT_FILENAME: string;
  74172. profileId: string;
  74173. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74174. protected _getFilenameAndPath(): {
  74175. filename: string;
  74176. path: string;
  74177. };
  74178. protected _getModelLoadingConstraints(): boolean;
  74179. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74180. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74181. protected _updateModel(): void;
  74182. }
  74183. }
  74184. declare module BABYLON {
  74185. /**
  74186. * The motion controller class for oculus touch (quest, rift).
  74187. * This class supports legacy mapping as well the standard xr mapping
  74188. */
  74189. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74190. private _forceLegacyControllers;
  74191. private _modelRootNode;
  74192. /**
  74193. * The base url used to load the left and right controller models
  74194. */
  74195. static MODEL_BASE_URL: string;
  74196. /**
  74197. * The name of the left controller model file
  74198. */
  74199. static MODEL_LEFT_FILENAME: string;
  74200. /**
  74201. * The name of the right controller model file
  74202. */
  74203. static MODEL_RIGHT_FILENAME: string;
  74204. /**
  74205. * Base Url for the Quest controller model.
  74206. */
  74207. static QUEST_MODEL_BASE_URL: string;
  74208. profileId: string;
  74209. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74210. protected _getFilenameAndPath(): {
  74211. filename: string;
  74212. path: string;
  74213. };
  74214. protected _getModelLoadingConstraints(): boolean;
  74215. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74216. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74217. protected _updateModel(): void;
  74218. /**
  74219. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74220. * between the touch and touch 2.
  74221. */
  74222. private _isQuest;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /**
  74227. * The motion controller class for the standard HTC-Vive controllers
  74228. */
  74229. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74230. private _modelRootNode;
  74231. /**
  74232. * The base url used to load the left and right controller models
  74233. */
  74234. static MODEL_BASE_URL: string;
  74235. /**
  74236. * File name for the controller model.
  74237. */
  74238. static MODEL_FILENAME: string;
  74239. profileId: string;
  74240. /**
  74241. * Create a new Vive motion controller object
  74242. * @param scene the scene to use to create this controller
  74243. * @param gamepadObject the corresponding gamepad object
  74244. * @param handedness the handedness of the controller
  74245. */
  74246. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74247. protected _getFilenameAndPath(): {
  74248. filename: string;
  74249. path: string;
  74250. };
  74251. protected _getModelLoadingConstraints(): boolean;
  74252. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74253. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74254. protected _updateModel(): void;
  74255. }
  74256. }
  74257. declare module BABYLON {
  74258. /**
  74259. * A cursor which tracks a point on a path
  74260. */
  74261. export class PathCursor {
  74262. private path;
  74263. /**
  74264. * Stores path cursor callbacks for when an onchange event is triggered
  74265. */
  74266. private _onchange;
  74267. /**
  74268. * The value of the path cursor
  74269. */
  74270. value: number;
  74271. /**
  74272. * The animation array of the path cursor
  74273. */
  74274. animations: Animation[];
  74275. /**
  74276. * Initializes the path cursor
  74277. * @param path The path to track
  74278. */
  74279. constructor(path: Path2);
  74280. /**
  74281. * Gets the cursor point on the path
  74282. * @returns A point on the path cursor at the cursor location
  74283. */
  74284. getPoint(): Vector3;
  74285. /**
  74286. * Moves the cursor ahead by the step amount
  74287. * @param step The amount to move the cursor forward
  74288. * @returns This path cursor
  74289. */
  74290. moveAhead(step?: number): PathCursor;
  74291. /**
  74292. * Moves the cursor behind by the step amount
  74293. * @param step The amount to move the cursor back
  74294. * @returns This path cursor
  74295. */
  74296. moveBack(step?: number): PathCursor;
  74297. /**
  74298. * Moves the cursor by the step amount
  74299. * If the step amount is greater than one, an exception is thrown
  74300. * @param step The amount to move the cursor
  74301. * @returns This path cursor
  74302. */
  74303. move(step: number): PathCursor;
  74304. /**
  74305. * Ensures that the value is limited between zero and one
  74306. * @returns This path cursor
  74307. */
  74308. private ensureLimits;
  74309. /**
  74310. * Runs onchange callbacks on change (used by the animation engine)
  74311. * @returns This path cursor
  74312. */
  74313. private raiseOnChange;
  74314. /**
  74315. * Executes a function on change
  74316. * @param f A path cursor onchange callback
  74317. * @returns This path cursor
  74318. */
  74319. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74320. }
  74321. }
  74322. declare module BABYLON {
  74323. /** @hidden */
  74324. export var blurPixelShader: {
  74325. name: string;
  74326. shader: string;
  74327. };
  74328. }
  74329. declare module BABYLON {
  74330. /** @hidden */
  74331. export var pointCloudVertexDeclaration: {
  74332. name: string;
  74333. shader: string;
  74334. };
  74335. }
  74336. // Mixins
  74337. interface Window {
  74338. mozIndexedDB: IDBFactory;
  74339. webkitIndexedDB: IDBFactory;
  74340. msIndexedDB: IDBFactory;
  74341. webkitURL: typeof URL;
  74342. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74343. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74344. WebGLRenderingContext: WebGLRenderingContext;
  74345. MSGesture: MSGesture;
  74346. CANNON: any;
  74347. AudioContext: AudioContext;
  74348. webkitAudioContext: AudioContext;
  74349. PointerEvent: any;
  74350. Math: Math;
  74351. Uint8Array: Uint8ArrayConstructor;
  74352. Float32Array: Float32ArrayConstructor;
  74353. mozURL: typeof URL;
  74354. msURL: typeof URL;
  74355. VRFrameData: any; // WebVR, from specs 1.1
  74356. DracoDecoderModule: any;
  74357. setImmediate(handler: (...args: any[]) => void): number;
  74358. }
  74359. interface HTMLCanvasElement {
  74360. requestPointerLock(): void;
  74361. msRequestPointerLock?(): void;
  74362. mozRequestPointerLock?(): void;
  74363. webkitRequestPointerLock?(): void;
  74364. /** Track wether a record is in progress */
  74365. isRecording: boolean;
  74366. /** Capture Stream method defined by some browsers */
  74367. captureStream(fps?: number): MediaStream;
  74368. }
  74369. interface CanvasRenderingContext2D {
  74370. msImageSmoothingEnabled: boolean;
  74371. }
  74372. interface MouseEvent {
  74373. mozMovementX: number;
  74374. mozMovementY: number;
  74375. webkitMovementX: number;
  74376. webkitMovementY: number;
  74377. msMovementX: number;
  74378. msMovementY: number;
  74379. }
  74380. interface Navigator {
  74381. mozGetVRDevices: (any: any) => any;
  74382. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74383. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74384. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74385. webkitGetGamepads(): Gamepad[];
  74386. msGetGamepads(): Gamepad[];
  74387. webkitGamepads(): Gamepad[];
  74388. }
  74389. interface HTMLVideoElement {
  74390. mozSrcObject: any;
  74391. }
  74392. interface Math {
  74393. fround(x: number): number;
  74394. imul(a: number, b: number): number;
  74395. }
  74396. interface WebGLRenderingContext {
  74397. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74398. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74399. vertexAttribDivisor(index: number, divisor: number): void;
  74400. createVertexArray(): any;
  74401. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74402. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74403. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74404. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74405. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74406. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74407. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74408. // Queries
  74409. createQuery(): WebGLQuery;
  74410. deleteQuery(query: WebGLQuery): void;
  74411. beginQuery(target: number, query: WebGLQuery): void;
  74412. endQuery(target: number): void;
  74413. getQueryParameter(query: WebGLQuery, pname: number): any;
  74414. getQuery(target: number, pname: number): any;
  74415. MAX_SAMPLES: number;
  74416. RGBA8: number;
  74417. READ_FRAMEBUFFER: number;
  74418. DRAW_FRAMEBUFFER: number;
  74419. UNIFORM_BUFFER: number;
  74420. HALF_FLOAT_OES: number;
  74421. RGBA16F: number;
  74422. RGBA32F: number;
  74423. R32F: number;
  74424. RG32F: number;
  74425. RGB32F: number;
  74426. R16F: number;
  74427. RG16F: number;
  74428. RGB16F: number;
  74429. RED: number;
  74430. RG: number;
  74431. R8: number;
  74432. RG8: number;
  74433. UNSIGNED_INT_24_8: number;
  74434. DEPTH24_STENCIL8: number;
  74435. MIN: number;
  74436. MAX: number;
  74437. /* Multiple Render Targets */
  74438. drawBuffers(buffers: number[]): void;
  74439. readBuffer(src: number): void;
  74440. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74441. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74442. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74443. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74444. // Occlusion Query
  74445. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74446. ANY_SAMPLES_PASSED: number;
  74447. QUERY_RESULT_AVAILABLE: number;
  74448. QUERY_RESULT: number;
  74449. }
  74450. interface WebGLProgram {
  74451. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74452. }
  74453. interface EXT_disjoint_timer_query {
  74454. QUERY_COUNTER_BITS_EXT: number;
  74455. TIME_ELAPSED_EXT: number;
  74456. TIMESTAMP_EXT: number;
  74457. GPU_DISJOINT_EXT: number;
  74458. QUERY_RESULT_EXT: number;
  74459. QUERY_RESULT_AVAILABLE_EXT: number;
  74460. queryCounterEXT(query: WebGLQuery, target: number): void;
  74461. createQueryEXT(): WebGLQuery;
  74462. beginQueryEXT(target: number, query: WebGLQuery): void;
  74463. endQueryEXT(target: number): void;
  74464. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74465. deleteQueryEXT(query: WebGLQuery): void;
  74466. }
  74467. interface WebGLUniformLocation {
  74468. _currentState: any;
  74469. }
  74470. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74471. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74472. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74473. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74474. interface WebGLRenderingContext {
  74475. readonly RASTERIZER_DISCARD: number;
  74476. readonly DEPTH_COMPONENT24: number;
  74477. readonly TEXTURE_3D: number;
  74478. readonly TEXTURE_2D_ARRAY: number;
  74479. readonly TEXTURE_COMPARE_FUNC: number;
  74480. readonly TEXTURE_COMPARE_MODE: number;
  74481. readonly COMPARE_REF_TO_TEXTURE: number;
  74482. readonly TEXTURE_WRAP_R: number;
  74483. readonly HALF_FLOAT: number;
  74484. readonly RGB8: number;
  74485. readonly RED_INTEGER: number;
  74486. readonly RG_INTEGER: number;
  74487. readonly RGB_INTEGER: number;
  74488. readonly RGBA_INTEGER: number;
  74489. readonly R8_SNORM: number;
  74490. readonly RG8_SNORM: number;
  74491. readonly RGB8_SNORM: number;
  74492. readonly RGBA8_SNORM: number;
  74493. readonly R8I: number;
  74494. readonly RG8I: number;
  74495. readonly RGB8I: number;
  74496. readonly RGBA8I: number;
  74497. readonly R8UI: number;
  74498. readonly RG8UI: number;
  74499. readonly RGB8UI: number;
  74500. readonly RGBA8UI: number;
  74501. readonly R16I: number;
  74502. readonly RG16I: number;
  74503. readonly RGB16I: number;
  74504. readonly RGBA16I: number;
  74505. readonly R16UI: number;
  74506. readonly RG16UI: number;
  74507. readonly RGB16UI: number;
  74508. readonly RGBA16UI: number;
  74509. readonly R32I: number;
  74510. readonly RG32I: number;
  74511. readonly RGB32I: number;
  74512. readonly RGBA32I: number;
  74513. readonly R32UI: number;
  74514. readonly RG32UI: number;
  74515. readonly RGB32UI: number;
  74516. readonly RGBA32UI: number;
  74517. readonly RGB10_A2UI: number;
  74518. readonly R11F_G11F_B10F: number;
  74519. readonly RGB9_E5: number;
  74520. readonly RGB10_A2: number;
  74521. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74522. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74523. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74524. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74525. readonly DEPTH_COMPONENT32F: number;
  74526. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74527. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74528. 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;
  74529. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74530. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74531. readonly TRANSFORM_FEEDBACK: number;
  74532. readonly INTERLEAVED_ATTRIBS: number;
  74533. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74534. createTransformFeedback(): WebGLTransformFeedback;
  74535. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74536. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74537. beginTransformFeedback(primitiveMode: number): void;
  74538. endTransformFeedback(): void;
  74539. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74540. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74541. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74542. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74543. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74544. }
  74545. interface ImageBitmap {
  74546. readonly width: number;
  74547. readonly height: number;
  74548. close(): void;
  74549. }
  74550. interface WebGLQuery extends WebGLObject {
  74551. }
  74552. declare var WebGLQuery: {
  74553. prototype: WebGLQuery;
  74554. new(): WebGLQuery;
  74555. };
  74556. interface WebGLSampler extends WebGLObject {
  74557. }
  74558. declare var WebGLSampler: {
  74559. prototype: WebGLSampler;
  74560. new(): WebGLSampler;
  74561. };
  74562. interface WebGLSync extends WebGLObject {
  74563. }
  74564. declare var WebGLSync: {
  74565. prototype: WebGLSync;
  74566. new(): WebGLSync;
  74567. };
  74568. interface WebGLTransformFeedback extends WebGLObject {
  74569. }
  74570. declare var WebGLTransformFeedback: {
  74571. prototype: WebGLTransformFeedback;
  74572. new(): WebGLTransformFeedback;
  74573. };
  74574. interface WebGLVertexArrayObject extends WebGLObject {
  74575. }
  74576. declare var WebGLVertexArrayObject: {
  74577. prototype: WebGLVertexArrayObject;
  74578. new(): WebGLVertexArrayObject;
  74579. };
  74580. // Type definitions for WebVR API
  74581. // Project: https://w3c.github.io/webvr/
  74582. // Definitions by: six a <https://github.com/lostfictions>
  74583. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74584. interface VRDisplay extends EventTarget {
  74585. /**
  74586. * Dictionary of capabilities describing the VRDisplay.
  74587. */
  74588. readonly capabilities: VRDisplayCapabilities;
  74589. /**
  74590. * z-depth defining the far plane of the eye view frustum
  74591. * enables mapping of values in the render target depth
  74592. * attachment to scene coordinates. Initially set to 10000.0.
  74593. */
  74594. depthFar: number;
  74595. /**
  74596. * z-depth defining the near plane of the eye view frustum
  74597. * enables mapping of values in the render target depth
  74598. * attachment to scene coordinates. Initially set to 0.01.
  74599. */
  74600. depthNear: number;
  74601. /**
  74602. * An identifier for this distinct VRDisplay. Used as an
  74603. * association point in the Gamepad API.
  74604. */
  74605. readonly displayId: number;
  74606. /**
  74607. * A display name, a user-readable name identifying it.
  74608. */
  74609. readonly displayName: string;
  74610. readonly isConnected: boolean;
  74611. readonly isPresenting: boolean;
  74612. /**
  74613. * If this VRDisplay supports room-scale experiences, the optional
  74614. * stage attribute contains details on the room-scale parameters.
  74615. */
  74616. readonly stageParameters: VRStageParameters | null;
  74617. /**
  74618. * Passing the value returned by `requestAnimationFrame` to
  74619. * `cancelAnimationFrame` will unregister the callback.
  74620. * @param handle Define the hanle of the request to cancel
  74621. */
  74622. cancelAnimationFrame(handle: number): void;
  74623. /**
  74624. * Stops presenting to the VRDisplay.
  74625. * @returns a promise to know when it stopped
  74626. */
  74627. exitPresent(): Promise<void>;
  74628. /**
  74629. * Return the current VREyeParameters for the given eye.
  74630. * @param whichEye Define the eye we want the parameter for
  74631. * @returns the eye parameters
  74632. */
  74633. getEyeParameters(whichEye: string): VREyeParameters;
  74634. /**
  74635. * Populates the passed VRFrameData with the information required to render
  74636. * the current frame.
  74637. * @param frameData Define the data structure to populate
  74638. * @returns true if ok otherwise false
  74639. */
  74640. getFrameData(frameData: VRFrameData): boolean;
  74641. /**
  74642. * Get the layers currently being presented.
  74643. * @returns the list of VR layers
  74644. */
  74645. getLayers(): VRLayer[];
  74646. /**
  74647. * Return a VRPose containing the future predicted pose of the VRDisplay
  74648. * when the current frame will be presented. The value returned will not
  74649. * change until JavaScript has returned control to the browser.
  74650. *
  74651. * The VRPose will contain the position, orientation, velocity,
  74652. * and acceleration of each of these properties.
  74653. * @returns the pose object
  74654. */
  74655. getPose(): VRPose;
  74656. /**
  74657. * Return the current instantaneous pose of the VRDisplay, with no
  74658. * prediction applied.
  74659. * @returns the current instantaneous pose
  74660. */
  74661. getImmediatePose(): VRPose;
  74662. /**
  74663. * The callback passed to `requestAnimationFrame` will be called
  74664. * any time a new frame should be rendered. When the VRDisplay is
  74665. * presenting the callback will be called at the native refresh
  74666. * rate of the HMD. When not presenting this function acts
  74667. * identically to how window.requestAnimationFrame acts. Content should
  74668. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74669. * asynchronously from other displays and at differing refresh rates.
  74670. * @param callback Define the eaction to run next frame
  74671. * @returns the request handle it
  74672. */
  74673. requestAnimationFrame(callback: FrameRequestCallback): number;
  74674. /**
  74675. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74676. * Repeat calls while already presenting will update the VRLayers being displayed.
  74677. * @param layers Define the list of layer to present
  74678. * @returns a promise to know when the request has been fulfilled
  74679. */
  74680. requestPresent(layers: VRLayer[]): Promise<void>;
  74681. /**
  74682. * Reset the pose for this display, treating its current position and
  74683. * orientation as the "origin/zero" values. VRPose.position,
  74684. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74685. * updated when calling resetPose(). This should be called in only
  74686. * sitting-space experiences.
  74687. */
  74688. resetPose(): void;
  74689. /**
  74690. * The VRLayer provided to the VRDisplay will be captured and presented
  74691. * in the HMD. Calling this function has the same effect on the source
  74692. * canvas as any other operation that uses its source image, and canvases
  74693. * created without preserveDrawingBuffer set to true will be cleared.
  74694. * @param pose Define the pose to submit
  74695. */
  74696. submitFrame(pose?: VRPose): void;
  74697. }
  74698. declare var VRDisplay: {
  74699. prototype: VRDisplay;
  74700. new(): VRDisplay;
  74701. };
  74702. interface VRLayer {
  74703. leftBounds?: number[] | Float32Array | null;
  74704. rightBounds?: number[] | Float32Array | null;
  74705. source?: HTMLCanvasElement | null;
  74706. }
  74707. interface VRDisplayCapabilities {
  74708. readonly canPresent: boolean;
  74709. readonly hasExternalDisplay: boolean;
  74710. readonly hasOrientation: boolean;
  74711. readonly hasPosition: boolean;
  74712. readonly maxLayers: number;
  74713. }
  74714. interface VREyeParameters {
  74715. /** @deprecated */
  74716. readonly fieldOfView: VRFieldOfView;
  74717. readonly offset: Float32Array;
  74718. readonly renderHeight: number;
  74719. readonly renderWidth: number;
  74720. }
  74721. interface VRFieldOfView {
  74722. readonly downDegrees: number;
  74723. readonly leftDegrees: number;
  74724. readonly rightDegrees: number;
  74725. readonly upDegrees: number;
  74726. }
  74727. interface VRFrameData {
  74728. readonly leftProjectionMatrix: Float32Array;
  74729. readonly leftViewMatrix: Float32Array;
  74730. readonly pose: VRPose;
  74731. readonly rightProjectionMatrix: Float32Array;
  74732. readonly rightViewMatrix: Float32Array;
  74733. readonly timestamp: number;
  74734. }
  74735. interface VRPose {
  74736. readonly angularAcceleration: Float32Array | null;
  74737. readonly angularVelocity: Float32Array | null;
  74738. readonly linearAcceleration: Float32Array | null;
  74739. readonly linearVelocity: Float32Array | null;
  74740. readonly orientation: Float32Array | null;
  74741. readonly position: Float32Array | null;
  74742. readonly timestamp: number;
  74743. }
  74744. interface VRStageParameters {
  74745. sittingToStandingTransform?: Float32Array;
  74746. sizeX?: number;
  74747. sizeY?: number;
  74748. }
  74749. interface Navigator {
  74750. getVRDisplays(): Promise<VRDisplay[]>;
  74751. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74752. }
  74753. interface Window {
  74754. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74755. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74756. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74757. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74758. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74759. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74760. }
  74761. interface Gamepad {
  74762. readonly displayId: number;
  74763. }
  74764. type XRSessionMode =
  74765. | "inline"
  74766. | "immersive-vr"
  74767. | "immersive-ar";
  74768. type XRReferenceSpaceType =
  74769. | "viewer"
  74770. | "local"
  74771. | "local-floor"
  74772. | "bounded-floor"
  74773. | "unbounded";
  74774. type XREnvironmentBlendMode =
  74775. | "opaque"
  74776. | "additive"
  74777. | "alpha-blend";
  74778. type XRVisibilityState =
  74779. | "visible"
  74780. | "visible-blurred"
  74781. | "hidden";
  74782. type XRHandedness =
  74783. | "none"
  74784. | "left"
  74785. | "right";
  74786. type XRTargetRayMode =
  74787. | "gaze"
  74788. | "tracked-pointer"
  74789. | "screen";
  74790. type XREye =
  74791. | "none"
  74792. | "left"
  74793. | "right";
  74794. type XREventType =
  74795. | "devicechange"
  74796. | "visibilitychange"
  74797. | "end"
  74798. | "inputsourceschange"
  74799. | "select"
  74800. | "selectstart"
  74801. | "selectend"
  74802. | "squeeze"
  74803. | "squeezestart"
  74804. | "squeezeend"
  74805. | "reset";
  74806. interface XRSpace extends EventTarget {
  74807. }
  74808. interface XRRenderState {
  74809. depthNear?: number;
  74810. depthFar?: number;
  74811. inlineVerticalFieldOfView?: number;
  74812. baseLayer?: XRWebGLLayer;
  74813. }
  74814. interface XRInputSource {
  74815. handedness: XRHandedness;
  74816. targetRayMode: XRTargetRayMode;
  74817. targetRaySpace: XRSpace;
  74818. gripSpace: XRSpace | undefined;
  74819. gamepad: Gamepad | undefined;
  74820. profiles: Array<string>;
  74821. }
  74822. interface XRSessionInit {
  74823. optionalFeatures?: string[];
  74824. requiredFeatures?: string[];
  74825. }
  74826. interface XRSession {
  74827. addEventListener: Function;
  74828. removeEventListener: Function;
  74829. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74830. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74831. requestAnimationFrame: Function;
  74832. end(): Promise<void>;
  74833. renderState: XRRenderState;
  74834. inputSources: Array<XRInputSource>;
  74835. // hit test
  74836. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74837. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74838. // legacy AR hit test
  74839. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74840. // legacy plane detection
  74841. updateWorldTrackingState(options: {
  74842. planeDetectionState?: { enabled: boolean; }
  74843. }): void;
  74844. }
  74845. interface XRReferenceSpace extends XRSpace {
  74846. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74847. onreset: any;
  74848. }
  74849. type XRPlaneSet = Set<XRPlane>;
  74850. type XRAnchorSet = Set<XRAnchor>;
  74851. interface XRFrame {
  74852. session: XRSession;
  74853. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74854. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74855. // AR
  74856. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74857. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74858. // Anchors
  74859. trackedAnchors?: XRAnchorSet;
  74860. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74861. // Planes
  74862. worldInformation: {
  74863. detectedPlanes?: XRPlaneSet;
  74864. };
  74865. }
  74866. interface XRViewerPose extends XRPose {
  74867. views: Array<XRView>;
  74868. }
  74869. interface XRPose {
  74870. transform: XRRigidTransform;
  74871. emulatedPosition: boolean;
  74872. }
  74873. interface XRWebGLLayerOptions {
  74874. antialias?: boolean;
  74875. depth?: boolean;
  74876. stencil?: boolean;
  74877. alpha?: boolean;
  74878. multiview?: boolean;
  74879. framebufferScaleFactor?: number;
  74880. }
  74881. declare var XRWebGLLayer: {
  74882. prototype: XRWebGLLayer;
  74883. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74884. };
  74885. interface XRWebGLLayer {
  74886. framebuffer: WebGLFramebuffer;
  74887. framebufferWidth: number;
  74888. framebufferHeight: number;
  74889. getViewport: Function;
  74890. }
  74891. declare class XRRigidTransform {
  74892. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74893. position: DOMPointReadOnly;
  74894. orientation: DOMPointReadOnly;
  74895. matrix: Float32Array;
  74896. inverse: XRRigidTransform;
  74897. }
  74898. interface XRView {
  74899. eye: XREye;
  74900. projectionMatrix: Float32Array;
  74901. transform: XRRigidTransform;
  74902. }
  74903. interface XRInputSourceChangeEvent {
  74904. session: XRSession;
  74905. removed: Array<XRInputSource>;
  74906. added: Array<XRInputSource>;
  74907. }
  74908. interface XRInputSourceEvent extends Event {
  74909. readonly frame: XRFrame;
  74910. readonly inputSource: XRInputSource;
  74911. }
  74912. // Experimental(er) features
  74913. declare class XRRay {
  74914. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74915. origin: DOMPointReadOnly;
  74916. direction: DOMPointReadOnly;
  74917. matrix: Float32Array;
  74918. }
  74919. declare enum XRHitTestTrackableType {
  74920. "point",
  74921. "plane"
  74922. }
  74923. interface XRHitResult {
  74924. hitMatrix: Float32Array;
  74925. }
  74926. interface XRTransientInputHitTestResult {
  74927. readonly inputSource: XRInputSource;
  74928. readonly results: Array<XRHitTestResult>;
  74929. }
  74930. interface XRHitTestResult {
  74931. getPose(baseSpace: XRSpace): XRPose | undefined;
  74932. // When anchor system is enabled
  74933. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74934. }
  74935. interface XRHitTestSource {
  74936. cancel(): void;
  74937. }
  74938. interface XRTransientInputHitTestSource {
  74939. cancel(): void;
  74940. }
  74941. interface XRHitTestOptionsInit {
  74942. space: XRSpace;
  74943. entityTypes?: Array<XRHitTestTrackableType>;
  74944. offsetRay?: XRRay;
  74945. }
  74946. interface XRTransientInputHitTestOptionsInit {
  74947. profile: string;
  74948. entityTypes?: Array<XRHitTestTrackableType>;
  74949. offsetRay?: XRRay;
  74950. }
  74951. interface XRAnchor {
  74952. anchorSpace: XRSpace;
  74953. delete(): void;
  74954. }
  74955. interface XRPlane {
  74956. orientation: "Horizontal" | "Vertical";
  74957. planeSpace: XRSpace;
  74958. polygon: Array<DOMPointReadOnly>;
  74959. lastChangedTime: number;
  74960. }
  74961. /**
  74962. * @ignore
  74963. */
  74964. declare module BABYLON.GLTF2.Exporter {
  74965. }
  74966. /**
  74967. * @ignore
  74968. */
  74969. declare module BABYLON.GLTF1 {
  74970. }
  74971. declare module BABYLON.GUI {
  74972. /**
  74973. * Class used to specific a value and its associated unit
  74974. */
  74975. export class ValueAndUnit {
  74976. /** defines the unit to store */
  74977. unit: number;
  74978. /** defines a boolean indicating if the value can be negative */
  74979. negativeValueAllowed: boolean;
  74980. private _value;
  74981. private _originalUnit;
  74982. /**
  74983. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74984. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74985. */
  74986. ignoreAdaptiveScaling: boolean;
  74987. /**
  74988. * Creates a new ValueAndUnit
  74989. * @param value defines the value to store
  74990. * @param unit defines the unit to store
  74991. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74992. */
  74993. constructor(value: number,
  74994. /** defines the unit to store */
  74995. unit?: number,
  74996. /** defines a boolean indicating if the value can be negative */
  74997. negativeValueAllowed?: boolean);
  74998. /** Gets a boolean indicating if the value is a percentage */
  74999. get isPercentage(): boolean;
  75000. /** Gets a boolean indicating if the value is store as pixel */
  75001. get isPixel(): boolean;
  75002. /** Gets direct internal value */
  75003. get internalValue(): number;
  75004. /**
  75005. * Gets value as pixel
  75006. * @param host defines the root host
  75007. * @param refValue defines the reference value for percentages
  75008. * @returns the value as pixel
  75009. */
  75010. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75011. /**
  75012. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75013. * @param value defines the value to store
  75014. * @param unit defines the unit to store
  75015. * @returns the current ValueAndUnit
  75016. */
  75017. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75018. /**
  75019. * Gets the value accordingly to its unit
  75020. * @param host defines the root host
  75021. * @returns the value
  75022. */
  75023. getValue(host: AdvancedDynamicTexture): number;
  75024. /**
  75025. * Gets a string representation of the value
  75026. * @param host defines the root host
  75027. * @param decimals defines an optional number of decimals to display
  75028. * @returns a string
  75029. */
  75030. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75031. /**
  75032. * Store a value parsed from a string
  75033. * @param source defines the source string
  75034. * @returns true if the value was successfully parsed
  75035. */
  75036. fromString(source: string | number): boolean;
  75037. private static _Regex;
  75038. private static _UNITMODE_PERCENTAGE;
  75039. private static _UNITMODE_PIXEL;
  75040. /** UNITMODE_PERCENTAGE */
  75041. static get UNITMODE_PERCENTAGE(): number;
  75042. /** UNITMODE_PIXEL */
  75043. static get UNITMODE_PIXEL(): number;
  75044. }
  75045. }
  75046. declare module BABYLON.GUI {
  75047. /**
  75048. * Define a style used by control to automatically setup properties based on a template.
  75049. * Only support font related properties so far
  75050. */
  75051. export class Style implements BABYLON.IDisposable {
  75052. private _fontFamily;
  75053. private _fontStyle;
  75054. private _fontWeight;
  75055. /** @hidden */
  75056. _host: AdvancedDynamicTexture;
  75057. /** @hidden */
  75058. _fontSize: ValueAndUnit;
  75059. /**
  75060. * BABYLON.Observable raised when the style values are changed
  75061. */
  75062. onChangedObservable: BABYLON.Observable<Style>;
  75063. /**
  75064. * Creates a new style object
  75065. * @param host defines the AdvancedDynamicTexture which hosts this style
  75066. */
  75067. constructor(host: AdvancedDynamicTexture);
  75068. /**
  75069. * Gets or sets the font size
  75070. */
  75071. get fontSize(): string | number;
  75072. set fontSize(value: string | number);
  75073. /**
  75074. * Gets or sets the font family
  75075. */
  75076. get fontFamily(): string;
  75077. set fontFamily(value: string);
  75078. /**
  75079. * Gets or sets the font style
  75080. */
  75081. get fontStyle(): string;
  75082. set fontStyle(value: string);
  75083. /** Gets or sets font weight */
  75084. get fontWeight(): string;
  75085. set fontWeight(value: string);
  75086. /** Dispose all associated resources */
  75087. dispose(): void;
  75088. }
  75089. }
  75090. declare module BABYLON.GUI {
  75091. /**
  75092. * Class used to transport BABYLON.Vector2 information for pointer events
  75093. */
  75094. export class Vector2WithInfo extends BABYLON.Vector2 {
  75095. /** defines the current mouse button index */
  75096. buttonIndex: number;
  75097. /**
  75098. * Creates a new Vector2WithInfo
  75099. * @param source defines the vector2 data to transport
  75100. * @param buttonIndex defines the current mouse button index
  75101. */
  75102. constructor(source: BABYLON.Vector2,
  75103. /** defines the current mouse button index */
  75104. buttonIndex?: number);
  75105. }
  75106. /** Class used to provide 2D matrix features */
  75107. export class Matrix2D {
  75108. /** Gets the internal array of 6 floats used to store matrix data */
  75109. m: Float32Array;
  75110. /**
  75111. * Creates a new matrix
  75112. * @param m00 defines value for (0, 0)
  75113. * @param m01 defines value for (0, 1)
  75114. * @param m10 defines value for (1, 0)
  75115. * @param m11 defines value for (1, 1)
  75116. * @param m20 defines value for (2, 0)
  75117. * @param m21 defines value for (2, 1)
  75118. */
  75119. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75120. /**
  75121. * Fills the matrix from direct values
  75122. * @param m00 defines value for (0, 0)
  75123. * @param m01 defines value for (0, 1)
  75124. * @param m10 defines value for (1, 0)
  75125. * @param m11 defines value for (1, 1)
  75126. * @param m20 defines value for (2, 0)
  75127. * @param m21 defines value for (2, 1)
  75128. * @returns the current modified matrix
  75129. */
  75130. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75131. /**
  75132. * Gets matrix determinant
  75133. * @returns the determinant
  75134. */
  75135. determinant(): number;
  75136. /**
  75137. * Inverses the matrix and stores it in a target matrix
  75138. * @param result defines the target matrix
  75139. * @returns the current matrix
  75140. */
  75141. invertToRef(result: Matrix2D): Matrix2D;
  75142. /**
  75143. * Multiplies the current matrix with another one
  75144. * @param other defines the second operand
  75145. * @param result defines the target matrix
  75146. * @returns the current matrix
  75147. */
  75148. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75149. /**
  75150. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75151. * @param x defines the x coordinate to transform
  75152. * @param y defines the x coordinate to transform
  75153. * @param result defines the target vector2
  75154. * @returns the current matrix
  75155. */
  75156. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75157. /**
  75158. * Creates an identity matrix
  75159. * @returns a new matrix
  75160. */
  75161. static Identity(): Matrix2D;
  75162. /**
  75163. * Creates a translation matrix and stores it in a target matrix
  75164. * @param x defines the x coordinate of the translation
  75165. * @param y defines the y coordinate of the translation
  75166. * @param result defines the target matrix
  75167. */
  75168. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75169. /**
  75170. * Creates a scaling matrix and stores it in a target matrix
  75171. * @param x defines the x coordinate of the scaling
  75172. * @param y defines the y coordinate of the scaling
  75173. * @param result defines the target matrix
  75174. */
  75175. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75176. /**
  75177. * Creates a rotation matrix and stores it in a target matrix
  75178. * @param angle defines the rotation angle
  75179. * @param result defines the target matrix
  75180. */
  75181. static RotationToRef(angle: number, result: Matrix2D): void;
  75182. private static _TempPreTranslationMatrix;
  75183. private static _TempPostTranslationMatrix;
  75184. private static _TempRotationMatrix;
  75185. private static _TempScalingMatrix;
  75186. private static _TempCompose0;
  75187. private static _TempCompose1;
  75188. private static _TempCompose2;
  75189. /**
  75190. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75191. * @param tx defines the x coordinate of the translation
  75192. * @param ty defines the y coordinate of the translation
  75193. * @param angle defines the rotation angle
  75194. * @param scaleX defines the x coordinate of the scaling
  75195. * @param scaleY defines the y coordinate of the scaling
  75196. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75197. * @param result defines the target matrix
  75198. */
  75199. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75200. }
  75201. }
  75202. declare module BABYLON.GUI {
  75203. /**
  75204. * Class used to store 2D control sizes
  75205. */
  75206. export class Measure {
  75207. /** defines left coordinate */
  75208. left: number;
  75209. /** defines top coordinate */
  75210. top: number;
  75211. /** defines width dimension */
  75212. width: number;
  75213. /** defines height dimension */
  75214. height: number;
  75215. /**
  75216. * Creates a new measure
  75217. * @param left defines left coordinate
  75218. * @param top defines top coordinate
  75219. * @param width defines width dimension
  75220. * @param height defines height dimension
  75221. */
  75222. constructor(
  75223. /** defines left coordinate */
  75224. left: number,
  75225. /** defines top coordinate */
  75226. top: number,
  75227. /** defines width dimension */
  75228. width: number,
  75229. /** defines height dimension */
  75230. height: number);
  75231. /**
  75232. * Copy from another measure
  75233. * @param other defines the other measure to copy from
  75234. */
  75235. copyFrom(other: Measure): void;
  75236. /**
  75237. * Copy from a group of 4 floats
  75238. * @param left defines left coordinate
  75239. * @param top defines top coordinate
  75240. * @param width defines width dimension
  75241. * @param height defines height dimension
  75242. */
  75243. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75244. /**
  75245. * Computes the axis aligned bounding box measure for two given measures
  75246. * @param a Input measure
  75247. * @param b Input measure
  75248. * @param result the resulting bounding measure
  75249. */
  75250. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75251. /**
  75252. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75253. * @param transform the matrix to transform the measure before computing the AABB
  75254. * @param result the resulting AABB
  75255. */
  75256. transformToRef(transform: Matrix2D, result: Measure): void;
  75257. /**
  75258. * Check equality between this measure and another one
  75259. * @param other defines the other measures
  75260. * @returns true if both measures are equals
  75261. */
  75262. isEqualsTo(other: Measure): boolean;
  75263. /**
  75264. * Creates an empty measure
  75265. * @returns a new measure
  75266. */
  75267. static Empty(): Measure;
  75268. }
  75269. }
  75270. declare module BABYLON.GUI {
  75271. /**
  75272. * Interface used to define a control that can receive focus
  75273. */
  75274. export interface IFocusableControl {
  75275. /**
  75276. * Function called when the control receives the focus
  75277. */
  75278. onFocus(): void;
  75279. /**
  75280. * Function called when the control loses the focus
  75281. */
  75282. onBlur(): void;
  75283. /**
  75284. * Function called to let the control handle keyboard events
  75285. * @param evt defines the current keyboard event
  75286. */
  75287. processKeyboard(evt: KeyboardEvent): void;
  75288. /**
  75289. * Function called to get the list of controls that should not steal the focus from this control
  75290. * @returns an array of controls
  75291. */
  75292. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75293. }
  75294. /**
  75295. * Class used to create texture to support 2D GUI elements
  75296. * @see https://doc.babylonjs.com/how_to/gui
  75297. */
  75298. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75299. private _isDirty;
  75300. private _renderObserver;
  75301. private _resizeObserver;
  75302. private _preKeyboardObserver;
  75303. private _pointerMoveObserver;
  75304. private _pointerObserver;
  75305. private _canvasPointerOutObserver;
  75306. private _background;
  75307. /** @hidden */
  75308. _rootContainer: Container;
  75309. /** @hidden */
  75310. _lastPickedControl: Control;
  75311. /** @hidden */
  75312. _lastControlOver: {
  75313. [pointerId: number]: Control;
  75314. };
  75315. /** @hidden */
  75316. _lastControlDown: {
  75317. [pointerId: number]: Control;
  75318. };
  75319. /** @hidden */
  75320. _capturingControl: {
  75321. [pointerId: number]: Control;
  75322. };
  75323. /** @hidden */
  75324. _shouldBlockPointer: boolean;
  75325. /** @hidden */
  75326. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75327. /** @hidden */
  75328. _linkedControls: Control[];
  75329. private _isFullscreen;
  75330. private _fullscreenViewport;
  75331. private _idealWidth;
  75332. private _idealHeight;
  75333. private _useSmallestIdeal;
  75334. private _renderAtIdealSize;
  75335. private _focusedControl;
  75336. private _blockNextFocusCheck;
  75337. private _renderScale;
  75338. private _rootElement;
  75339. private _cursorChanged;
  75340. private _defaultMousePointerId;
  75341. /** @hidden */
  75342. _numLayoutCalls: number;
  75343. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75344. get numLayoutCalls(): number;
  75345. /** @hidden */
  75346. _numRenderCalls: number;
  75347. /** Gets the number of render calls made the last time the ADT has been rendered */
  75348. get numRenderCalls(): number;
  75349. /**
  75350. * Define type to string to ensure compatibility across browsers
  75351. * Safari doesn't support DataTransfer constructor
  75352. */
  75353. private _clipboardData;
  75354. /**
  75355. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75356. */
  75357. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75358. /**
  75359. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75360. */
  75361. onControlPickedObservable: BABYLON.Observable<Control>;
  75362. /**
  75363. * BABYLON.Observable event triggered before layout is evaluated
  75364. */
  75365. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75366. /**
  75367. * BABYLON.Observable event triggered after the layout was evaluated
  75368. */
  75369. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75370. /**
  75371. * BABYLON.Observable event triggered before the texture is rendered
  75372. */
  75373. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75374. /**
  75375. * BABYLON.Observable event triggered after the texture was rendered
  75376. */
  75377. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75378. /**
  75379. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75380. */
  75381. premulAlpha: boolean;
  75382. /**
  75383. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75384. * Useful when you want more antialiasing
  75385. */
  75386. get renderScale(): number;
  75387. set renderScale(value: number);
  75388. /** Gets or sets the background color */
  75389. get background(): string;
  75390. set background(value: string);
  75391. /**
  75392. * Gets or sets the ideal width used to design controls.
  75393. * The GUI will then rescale everything accordingly
  75394. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75395. */
  75396. get idealWidth(): number;
  75397. set idealWidth(value: number);
  75398. /**
  75399. * Gets or sets the ideal height used to design controls.
  75400. * The GUI will then rescale everything accordingly
  75401. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75402. */
  75403. get idealHeight(): number;
  75404. set idealHeight(value: number);
  75405. /**
  75406. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75407. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75408. */
  75409. get useSmallestIdeal(): boolean;
  75410. set useSmallestIdeal(value: boolean);
  75411. /**
  75412. * Gets or sets a boolean indicating if adaptive scaling must be used
  75413. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75414. */
  75415. get renderAtIdealSize(): boolean;
  75416. set renderAtIdealSize(value: boolean);
  75417. /**
  75418. * Gets the ratio used when in "ideal mode"
  75419. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75420. * */
  75421. get idealRatio(): number;
  75422. /**
  75423. * Gets the underlying layer used to render the texture when in fullscreen mode
  75424. */
  75425. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75426. /**
  75427. * Gets the root container control
  75428. */
  75429. get rootContainer(): Container;
  75430. /**
  75431. * Returns an array containing the root container.
  75432. * This is mostly used to let the Inspector introspects the ADT
  75433. * @returns an array containing the rootContainer
  75434. */
  75435. getChildren(): Array<Container>;
  75436. /**
  75437. * Will return all controls that are inside this texture
  75438. * @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
  75439. * @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
  75440. * @return all child controls
  75441. */
  75442. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75443. /**
  75444. * Gets or sets the current focused control
  75445. */
  75446. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75447. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75448. /**
  75449. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75450. */
  75451. get isForeground(): boolean;
  75452. set isForeground(value: boolean);
  75453. /**
  75454. * Gets or set information about clipboardData
  75455. */
  75456. get clipboardData(): string;
  75457. set clipboardData(value: string);
  75458. /**
  75459. * Creates a new AdvancedDynamicTexture
  75460. * @param name defines the name of the texture
  75461. * @param width defines the width of the texture
  75462. * @param height defines the height of the texture
  75463. * @param scene defines the hosting scene
  75464. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75465. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75466. */
  75467. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75468. /**
  75469. * Get the current class name of the texture useful for serialization or dynamic coding.
  75470. * @returns "AdvancedDynamicTexture"
  75471. */
  75472. getClassName(): string;
  75473. /**
  75474. * Function used to execute a function on all controls
  75475. * @param func defines the function to execute
  75476. * @param container defines the container where controls belong. If null the root container will be used
  75477. */
  75478. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75479. private _useInvalidateRectOptimization;
  75480. /**
  75481. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75482. */
  75483. get useInvalidateRectOptimization(): boolean;
  75484. set useInvalidateRectOptimization(value: boolean);
  75485. private _invalidatedRectangle;
  75486. /**
  75487. * Invalidates a rectangle area on the gui texture
  75488. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75489. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75490. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75491. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75492. */
  75493. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75494. /**
  75495. * Marks the texture as dirty forcing a complete update
  75496. */
  75497. markAsDirty(): void;
  75498. /**
  75499. * Helper function used to create a new style
  75500. * @returns a new style
  75501. * @see https://doc.babylonjs.com/how_to/gui#styles
  75502. */
  75503. createStyle(): Style;
  75504. /**
  75505. * Adds a new control to the root container
  75506. * @param control defines the control to add
  75507. * @returns the current texture
  75508. */
  75509. addControl(control: Control): AdvancedDynamicTexture;
  75510. /**
  75511. * Removes a control from the root container
  75512. * @param control defines the control to remove
  75513. * @returns the current texture
  75514. */
  75515. removeControl(control: Control): AdvancedDynamicTexture;
  75516. /**
  75517. * Release all resources
  75518. */
  75519. dispose(): void;
  75520. private _onResize;
  75521. /** @hidden */
  75522. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75523. /**
  75524. * Get screen coordinates for a vector3
  75525. * @param position defines the position to project
  75526. * @param worldMatrix defines the world matrix to use
  75527. * @returns the projected position
  75528. */
  75529. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75530. private _checkUpdate;
  75531. private _clearMeasure;
  75532. private _render;
  75533. /** @hidden */
  75534. _changeCursor(cursor: string): void;
  75535. /** @hidden */
  75536. _registerLastControlDown(control: Control, pointerId: number): void;
  75537. private _doPicking;
  75538. /** @hidden */
  75539. _cleanControlAfterRemovalFromList(list: {
  75540. [pointerId: number]: Control;
  75541. }, control: Control): void;
  75542. /** @hidden */
  75543. _cleanControlAfterRemoval(control: Control): void;
  75544. /** Attach to all scene events required to support pointer events */
  75545. attach(): void;
  75546. /** @hidden */
  75547. private onClipboardCopy;
  75548. /** @hidden */
  75549. private onClipboardCut;
  75550. /** @hidden */
  75551. private onClipboardPaste;
  75552. /**
  75553. * Register the clipboard Events onto the canvas
  75554. */
  75555. registerClipboardEvents(): void;
  75556. /**
  75557. * Unregister the clipboard Events from the canvas
  75558. */
  75559. unRegisterClipboardEvents(): void;
  75560. /**
  75561. * Connect the texture to a hosting mesh to enable interactions
  75562. * @param mesh defines the mesh to attach to
  75563. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75564. */
  75565. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75566. /**
  75567. * Move the focus to a specific control
  75568. * @param control defines the control which will receive the focus
  75569. */
  75570. moveFocusToControl(control: IFocusableControl): void;
  75571. private _manageFocus;
  75572. private _attachToOnPointerOut;
  75573. /**
  75574. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75575. * @param mesh defines the mesh which will receive the texture
  75576. * @param width defines the texture width (1024 by default)
  75577. * @param height defines the texture height (1024 by default)
  75578. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75579. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75580. * @returns a new AdvancedDynamicTexture
  75581. */
  75582. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75583. /**
  75584. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75585. * In this mode the texture will rely on a layer for its rendering.
  75586. * This allows it to be treated like any other layer.
  75587. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75588. * LayerMask is set through advancedTexture.layer.layerMask
  75589. * @param name defines name for the texture
  75590. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75591. * @param scene defines the hsoting scene
  75592. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75593. * @returns a new AdvancedDynamicTexture
  75594. */
  75595. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75596. }
  75597. }
  75598. declare module BABYLON.GUI {
  75599. /**
  75600. * Root class used for all 2D controls
  75601. * @see https://doc.babylonjs.com/how_to/gui#controls
  75602. */
  75603. export class Control {
  75604. /** defines the name of the control */
  75605. name?: string | undefined;
  75606. /**
  75607. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75608. */
  75609. static AllowAlphaInheritance: boolean;
  75610. private _alpha;
  75611. private _alphaSet;
  75612. private _zIndex;
  75613. /** @hidden */
  75614. _host: AdvancedDynamicTexture;
  75615. /** Gets or sets the control parent */
  75616. parent: BABYLON.Nullable<Container>;
  75617. /** @hidden */
  75618. _currentMeasure: Measure;
  75619. private _fontFamily;
  75620. private _fontStyle;
  75621. private _fontWeight;
  75622. private _fontSize;
  75623. private _font;
  75624. /** @hidden */
  75625. _width: ValueAndUnit;
  75626. /** @hidden */
  75627. _height: ValueAndUnit;
  75628. /** @hidden */
  75629. protected _fontOffset: {
  75630. ascent: number;
  75631. height: number;
  75632. descent: number;
  75633. };
  75634. private _color;
  75635. private _style;
  75636. private _styleObserver;
  75637. /** @hidden */
  75638. protected _horizontalAlignment: number;
  75639. /** @hidden */
  75640. protected _verticalAlignment: number;
  75641. /** @hidden */
  75642. protected _isDirty: boolean;
  75643. /** @hidden */
  75644. protected _wasDirty: boolean;
  75645. /** @hidden */
  75646. _tempParentMeasure: Measure;
  75647. /** @hidden */
  75648. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75649. /** @hidden */
  75650. protected _cachedParentMeasure: Measure;
  75651. private _paddingLeft;
  75652. private _paddingRight;
  75653. private _paddingTop;
  75654. private _paddingBottom;
  75655. /** @hidden */
  75656. _left: ValueAndUnit;
  75657. /** @hidden */
  75658. _top: ValueAndUnit;
  75659. private _scaleX;
  75660. private _scaleY;
  75661. private _rotation;
  75662. private _transformCenterX;
  75663. private _transformCenterY;
  75664. /** @hidden */
  75665. _transformMatrix: Matrix2D;
  75666. /** @hidden */
  75667. protected _invertTransformMatrix: Matrix2D;
  75668. /** @hidden */
  75669. protected _transformedPosition: BABYLON.Vector2;
  75670. private _isMatrixDirty;
  75671. private _cachedOffsetX;
  75672. private _cachedOffsetY;
  75673. private _isVisible;
  75674. private _isHighlighted;
  75675. /** @hidden */
  75676. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75677. private _fontSet;
  75678. private _dummyVector2;
  75679. private _downCount;
  75680. private _enterCount;
  75681. private _doNotRender;
  75682. private _downPointerIds;
  75683. protected _isEnabled: boolean;
  75684. protected _disabledColor: string;
  75685. protected _disabledColorItem: string;
  75686. /** @hidden */
  75687. protected _rebuildLayout: boolean;
  75688. /** @hidden */
  75689. _customData: any;
  75690. /** @hidden */
  75691. _isClipped: boolean;
  75692. /** @hidden */
  75693. _automaticSize: boolean;
  75694. /** @hidden */
  75695. _tag: any;
  75696. /**
  75697. * 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
  75698. */
  75699. uniqueId: number;
  75700. /**
  75701. * Gets or sets an object used to store user defined information for the node
  75702. */
  75703. metadata: any;
  75704. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75705. isHitTestVisible: boolean;
  75706. /** Gets or sets a boolean indicating if the control can block pointer events */
  75707. isPointerBlocker: boolean;
  75708. /** Gets or sets a boolean indicating if the control can be focusable */
  75709. isFocusInvisible: boolean;
  75710. /**
  75711. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75712. * 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
  75713. */
  75714. clipChildren: boolean;
  75715. /**
  75716. * Gets or sets a boolean indicating that control content must be clipped
  75717. * 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
  75718. */
  75719. clipContent: boolean;
  75720. /**
  75721. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75722. */
  75723. useBitmapCache: boolean;
  75724. private _cacheData;
  75725. private _shadowOffsetX;
  75726. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75727. get shadowOffsetX(): number;
  75728. set shadowOffsetX(value: number);
  75729. private _shadowOffsetY;
  75730. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75731. get shadowOffsetY(): number;
  75732. set shadowOffsetY(value: number);
  75733. private _shadowBlur;
  75734. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75735. get shadowBlur(): number;
  75736. set shadowBlur(value: number);
  75737. private _shadowColor;
  75738. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75739. get shadowColor(): string;
  75740. set shadowColor(value: string);
  75741. /** Gets or sets the cursor to use when the control is hovered */
  75742. hoverCursor: string;
  75743. /** @hidden */
  75744. protected _linkOffsetX: ValueAndUnit;
  75745. /** @hidden */
  75746. protected _linkOffsetY: ValueAndUnit;
  75747. /** Gets the control type name */
  75748. get typeName(): string;
  75749. /**
  75750. * Get the current class name of the control.
  75751. * @returns current class name
  75752. */
  75753. getClassName(): string;
  75754. /**
  75755. * An event triggered when pointer wheel is scrolled
  75756. */
  75757. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75758. /**
  75759. * An event triggered when the pointer move over the control.
  75760. */
  75761. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75762. /**
  75763. * An event triggered when the pointer move out of the control.
  75764. */
  75765. onPointerOutObservable: BABYLON.Observable<Control>;
  75766. /**
  75767. * An event triggered when the pointer taps the control
  75768. */
  75769. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75770. /**
  75771. * An event triggered when pointer up
  75772. */
  75773. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75774. /**
  75775. * An event triggered when a control is clicked on
  75776. */
  75777. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75778. /**
  75779. * An event triggered when pointer enters the control
  75780. */
  75781. onPointerEnterObservable: BABYLON.Observable<Control>;
  75782. /**
  75783. * An event triggered when the control is marked as dirty
  75784. */
  75785. onDirtyObservable: BABYLON.Observable<Control>;
  75786. /**
  75787. * An event triggered before drawing the control
  75788. */
  75789. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75790. /**
  75791. * An event triggered after the control was drawn
  75792. */
  75793. onAfterDrawObservable: BABYLON.Observable<Control>;
  75794. /**
  75795. * An event triggered when the control has been disposed
  75796. */
  75797. onDisposeObservable: BABYLON.Observable<Control>;
  75798. /**
  75799. * Get the hosting AdvancedDynamicTexture
  75800. */
  75801. get host(): AdvancedDynamicTexture;
  75802. /** Gets or set information about font offsets (used to render and align text) */
  75803. get fontOffset(): {
  75804. ascent: number;
  75805. height: number;
  75806. descent: number;
  75807. };
  75808. set fontOffset(offset: {
  75809. ascent: number;
  75810. height: number;
  75811. descent: number;
  75812. });
  75813. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75814. get alpha(): number;
  75815. set alpha(value: number);
  75816. /**
  75817. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75818. */
  75819. get isHighlighted(): boolean;
  75820. set isHighlighted(value: boolean);
  75821. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75822. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75823. */
  75824. get scaleX(): number;
  75825. set scaleX(value: number);
  75826. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75827. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75828. */
  75829. get scaleY(): number;
  75830. set scaleY(value: number);
  75831. /** Gets or sets the rotation angle (0 by default)
  75832. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75833. */
  75834. get rotation(): number;
  75835. set rotation(value: number);
  75836. /** Gets or sets the transformation center on Y axis (0 by default)
  75837. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75838. */
  75839. get transformCenterY(): number;
  75840. set transformCenterY(value: number);
  75841. /** Gets or sets the transformation center on X axis (0 by default)
  75842. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75843. */
  75844. get transformCenterX(): number;
  75845. set transformCenterX(value: number);
  75846. /**
  75847. * Gets or sets the horizontal alignment
  75848. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75849. */
  75850. get horizontalAlignment(): number;
  75851. set horizontalAlignment(value: number);
  75852. /**
  75853. * Gets or sets the vertical alignment
  75854. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75855. */
  75856. get verticalAlignment(): number;
  75857. set verticalAlignment(value: number);
  75858. /**
  75859. * Gets or sets control width
  75860. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75861. */
  75862. get width(): string | number;
  75863. set width(value: string | number);
  75864. /**
  75865. * Gets or sets the control width in pixel
  75866. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75867. */
  75868. get widthInPixels(): number;
  75869. set widthInPixels(value: number);
  75870. /**
  75871. * Gets or sets control height
  75872. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75873. */
  75874. get height(): string | number;
  75875. set height(value: string | number);
  75876. /**
  75877. * Gets or sets control height in pixel
  75878. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75879. */
  75880. get heightInPixels(): number;
  75881. set heightInPixels(value: number);
  75882. /** Gets or set font family */
  75883. get fontFamily(): string;
  75884. set fontFamily(value: string);
  75885. /** Gets or sets font style */
  75886. get fontStyle(): string;
  75887. set fontStyle(value: string);
  75888. /** Gets or sets font weight */
  75889. get fontWeight(): string;
  75890. set fontWeight(value: string);
  75891. /**
  75892. * Gets or sets style
  75893. * @see https://doc.babylonjs.com/how_to/gui#styles
  75894. */
  75895. get style(): BABYLON.Nullable<Style>;
  75896. set style(value: BABYLON.Nullable<Style>);
  75897. /** @hidden */
  75898. get _isFontSizeInPercentage(): boolean;
  75899. /** Gets or sets font size in pixels */
  75900. get fontSizeInPixels(): number;
  75901. set fontSizeInPixels(value: number);
  75902. /** Gets or sets font size */
  75903. get fontSize(): string | number;
  75904. set fontSize(value: string | number);
  75905. /** Gets or sets foreground color */
  75906. get color(): string;
  75907. set color(value: string);
  75908. /** Gets or sets z index which is used to reorder controls on the z axis */
  75909. get zIndex(): number;
  75910. set zIndex(value: number);
  75911. /** Gets or sets a boolean indicating if the control can be rendered */
  75912. get notRenderable(): boolean;
  75913. set notRenderable(value: boolean);
  75914. /** Gets or sets a boolean indicating if the control is visible */
  75915. get isVisible(): boolean;
  75916. set isVisible(value: boolean);
  75917. /** Gets a boolean indicating that the control needs to update its rendering */
  75918. get isDirty(): boolean;
  75919. /**
  75920. * Gets the current linked mesh (or null if none)
  75921. */
  75922. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75923. /**
  75924. * Gets or sets a value indicating the padding to use on the left of the control
  75925. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75926. */
  75927. get paddingLeft(): string | number;
  75928. set paddingLeft(value: string | number);
  75929. /**
  75930. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75931. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75932. */
  75933. get paddingLeftInPixels(): number;
  75934. set paddingLeftInPixels(value: number);
  75935. /**
  75936. * Gets or sets a value indicating the padding to use on the right of the control
  75937. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75938. */
  75939. get paddingRight(): string | number;
  75940. set paddingRight(value: string | number);
  75941. /**
  75942. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75943. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75944. */
  75945. get paddingRightInPixels(): number;
  75946. set paddingRightInPixels(value: number);
  75947. /**
  75948. * Gets or sets a value indicating the padding to use on the top of the control
  75949. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75950. */
  75951. get paddingTop(): string | number;
  75952. set paddingTop(value: string | number);
  75953. /**
  75954. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75955. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75956. */
  75957. get paddingTopInPixels(): number;
  75958. set paddingTopInPixels(value: number);
  75959. /**
  75960. * Gets or sets a value indicating the padding to use on the bottom of the control
  75961. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75962. */
  75963. get paddingBottom(): string | number;
  75964. set paddingBottom(value: string | number);
  75965. /**
  75966. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75967. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75968. */
  75969. get paddingBottomInPixels(): number;
  75970. set paddingBottomInPixels(value: number);
  75971. /**
  75972. * Gets or sets a value indicating the left coordinate of the control
  75973. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75974. */
  75975. get left(): string | number;
  75976. set left(value: string | number);
  75977. /**
  75978. * Gets or sets a value indicating the left coordinate in pixels of the control
  75979. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75980. */
  75981. get leftInPixels(): number;
  75982. set leftInPixels(value: number);
  75983. /**
  75984. * Gets or sets a value indicating the top coordinate of the control
  75985. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75986. */
  75987. get top(): string | number;
  75988. set top(value: string | number);
  75989. /**
  75990. * Gets or sets a value indicating the top coordinate in pixels of the control
  75991. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75992. */
  75993. get topInPixels(): number;
  75994. set topInPixels(value: number);
  75995. /**
  75996. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75997. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75998. */
  75999. get linkOffsetX(): string | number;
  76000. set linkOffsetX(value: string | number);
  76001. /**
  76002. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76003. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76004. */
  76005. get linkOffsetXInPixels(): number;
  76006. set linkOffsetXInPixels(value: number);
  76007. /**
  76008. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76009. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76010. */
  76011. get linkOffsetY(): string | number;
  76012. set linkOffsetY(value: string | number);
  76013. /**
  76014. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76015. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76016. */
  76017. get linkOffsetYInPixels(): number;
  76018. set linkOffsetYInPixels(value: number);
  76019. /** Gets the center coordinate on X axis */
  76020. get centerX(): number;
  76021. /** Gets the center coordinate on Y axis */
  76022. get centerY(): number;
  76023. /** Gets or sets if control is Enabled*/
  76024. get isEnabled(): boolean;
  76025. set isEnabled(value: boolean);
  76026. /** Gets or sets background color of control if it's disabled*/
  76027. get disabledColor(): string;
  76028. set disabledColor(value: string);
  76029. /** Gets or sets front color of control if it's disabled*/
  76030. get disabledColorItem(): string;
  76031. set disabledColorItem(value: string);
  76032. /**
  76033. * Creates a new control
  76034. * @param name defines the name of the control
  76035. */
  76036. constructor(
  76037. /** defines the name of the control */
  76038. name?: string | undefined);
  76039. /** @hidden */
  76040. protected _getTypeName(): string;
  76041. /**
  76042. * Gets the first ascendant in the hierarchy of the given type
  76043. * @param className defines the required type
  76044. * @returns the ascendant or null if not found
  76045. */
  76046. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76047. /** @hidden */
  76048. _resetFontCache(): void;
  76049. /**
  76050. * Determines if a container is an ascendant of the current control
  76051. * @param container defines the container to look for
  76052. * @returns true if the container is one of the ascendant of the control
  76053. */
  76054. isAscendant(container: Control): boolean;
  76055. /**
  76056. * Gets coordinates in local control space
  76057. * @param globalCoordinates defines the coordinates to transform
  76058. * @returns the new coordinates in local space
  76059. */
  76060. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76061. /**
  76062. * Gets coordinates in local control space
  76063. * @param globalCoordinates defines the coordinates to transform
  76064. * @param result defines the target vector2 where to store the result
  76065. * @returns the current control
  76066. */
  76067. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76068. /**
  76069. * Gets coordinates in parent local control space
  76070. * @param globalCoordinates defines the coordinates to transform
  76071. * @returns the new coordinates in parent local space
  76072. */
  76073. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76074. /**
  76075. * Move the current control to a vector3 position projected onto the screen.
  76076. * @param position defines the target position
  76077. * @param scene defines the hosting scene
  76078. */
  76079. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76080. /**
  76081. * Will store all controls that have this control as ascendant in a given array
  76082. * @param results defines the array where to store the descendants
  76083. * @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
  76084. * @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
  76085. */
  76086. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76087. /**
  76088. * Will return all controls that have this control as ascendant
  76089. * @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
  76090. * @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
  76091. * @return all child controls
  76092. */
  76093. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76094. /**
  76095. * Link current control with a target mesh
  76096. * @param mesh defines the mesh to link with
  76097. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76098. */
  76099. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76100. /** @hidden */
  76101. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76102. /** @hidden */
  76103. _offsetLeft(offset: number): void;
  76104. /** @hidden */
  76105. _offsetTop(offset: number): void;
  76106. /** @hidden */
  76107. _markMatrixAsDirty(): void;
  76108. /** @hidden */
  76109. _flagDescendantsAsMatrixDirty(): void;
  76110. /** @hidden */
  76111. _intersectsRect(rect: Measure): boolean;
  76112. /** @hidden */
  76113. protected invalidateRect(): void;
  76114. /** @hidden */
  76115. _markAsDirty(force?: boolean): void;
  76116. /** @hidden */
  76117. _markAllAsDirty(): void;
  76118. /** @hidden */
  76119. _link(host: AdvancedDynamicTexture): void;
  76120. /** @hidden */
  76121. protected _transform(context?: CanvasRenderingContext2D): void;
  76122. /** @hidden */
  76123. _renderHighlight(context: CanvasRenderingContext2D): void;
  76124. /** @hidden */
  76125. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76126. /** @hidden */
  76127. protected _applyStates(context: CanvasRenderingContext2D): void;
  76128. /** @hidden */
  76129. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76130. /** @hidden */
  76131. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76132. protected _evaluateClippingState(parentMeasure: Measure): void;
  76133. /** @hidden */
  76134. _measure(): void;
  76135. /** @hidden */
  76136. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76137. /** @hidden */
  76138. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76139. /** @hidden */
  76140. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76141. /** @hidden */
  76142. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76143. private static _ClipMeasure;
  76144. private _tmpMeasureA;
  76145. private _clip;
  76146. /** @hidden */
  76147. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76148. /** @hidden */
  76149. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76150. /**
  76151. * Tests if a given coordinates belong to the current control
  76152. * @param x defines x coordinate to test
  76153. * @param y defines y coordinate to test
  76154. * @returns true if the coordinates are inside the control
  76155. */
  76156. contains(x: number, y: number): boolean;
  76157. /** @hidden */
  76158. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76159. /** @hidden */
  76160. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76161. /** @hidden */
  76162. _onPointerEnter(target: Control): boolean;
  76163. /** @hidden */
  76164. _onPointerOut(target: Control, force?: boolean): void;
  76165. /** @hidden */
  76166. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76167. /** @hidden */
  76168. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76169. /** @hidden */
  76170. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76171. /** @hidden */
  76172. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76173. /** @hidden */
  76174. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76175. private _prepareFont;
  76176. /** Releases associated resources */
  76177. dispose(): void;
  76178. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76179. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76180. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76181. private static _VERTICAL_ALIGNMENT_TOP;
  76182. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76183. private static _VERTICAL_ALIGNMENT_CENTER;
  76184. /** HORIZONTAL_ALIGNMENT_LEFT */
  76185. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76186. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76187. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76188. /** HORIZONTAL_ALIGNMENT_CENTER */
  76189. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76190. /** VERTICAL_ALIGNMENT_TOP */
  76191. static get VERTICAL_ALIGNMENT_TOP(): number;
  76192. /** VERTICAL_ALIGNMENT_BOTTOM */
  76193. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76194. /** VERTICAL_ALIGNMENT_CENTER */
  76195. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76196. private static _FontHeightSizes;
  76197. /** @hidden */
  76198. static _GetFontOffset(font: string): {
  76199. ascent: number;
  76200. height: number;
  76201. descent: number;
  76202. };
  76203. /**
  76204. * Creates a stack panel that can be used to render headers
  76205. * @param control defines the control to associate with the header
  76206. * @param text defines the text of the header
  76207. * @param size defines the size of the header
  76208. * @param options defines options used to configure the header
  76209. * @returns a new StackPanel
  76210. * @ignore
  76211. * @hidden
  76212. */
  76213. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76214. isHorizontal: boolean;
  76215. controlFirst: boolean;
  76216. }) => any;
  76217. /** @hidden */
  76218. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76219. }
  76220. }
  76221. declare module BABYLON.GUI {
  76222. /**
  76223. * Root class for 2D containers
  76224. * @see https://doc.babylonjs.com/how_to/gui#containers
  76225. */
  76226. export class Container extends Control {
  76227. name?: string | undefined;
  76228. /** @hidden */
  76229. _children: Control[];
  76230. /** @hidden */
  76231. protected _measureForChildren: Measure;
  76232. /** @hidden */
  76233. protected _background: string;
  76234. /** @hidden */
  76235. protected _adaptWidthToChildren: boolean;
  76236. /** @hidden */
  76237. protected _adaptHeightToChildren: boolean;
  76238. /**
  76239. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76240. */
  76241. logLayoutCycleErrors: boolean;
  76242. /**
  76243. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76244. */
  76245. maxLayoutCycle: number;
  76246. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76247. get adaptHeightToChildren(): boolean;
  76248. set adaptHeightToChildren(value: boolean);
  76249. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76250. get adaptWidthToChildren(): boolean;
  76251. set adaptWidthToChildren(value: boolean);
  76252. /** Gets or sets background color */
  76253. get background(): string;
  76254. set background(value: string);
  76255. /** Gets the list of children */
  76256. get children(): Control[];
  76257. /**
  76258. * Creates a new Container
  76259. * @param name defines the name of the container
  76260. */
  76261. constructor(name?: string | undefined);
  76262. protected _getTypeName(): string;
  76263. _flagDescendantsAsMatrixDirty(): void;
  76264. /**
  76265. * Gets a child using its name
  76266. * @param name defines the child name to look for
  76267. * @returns the child control if found
  76268. */
  76269. getChildByName(name: string): BABYLON.Nullable<Control>;
  76270. /**
  76271. * Gets a child using its type and its name
  76272. * @param name defines the child name to look for
  76273. * @param type defines the child type to look for
  76274. * @returns the child control if found
  76275. */
  76276. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76277. /**
  76278. * Search for a specific control in children
  76279. * @param control defines the control to look for
  76280. * @returns true if the control is in child list
  76281. */
  76282. containsControl(control: Control): boolean;
  76283. /**
  76284. * Adds a new control to the current container
  76285. * @param control defines the control to add
  76286. * @returns the current container
  76287. */
  76288. addControl(control: BABYLON.Nullable<Control>): Container;
  76289. /**
  76290. * Removes all controls from the current container
  76291. * @returns the current container
  76292. */
  76293. clearControls(): Container;
  76294. /**
  76295. * Removes a control from the current container
  76296. * @param control defines the control to remove
  76297. * @returns the current container
  76298. */
  76299. removeControl(control: Control): Container;
  76300. /** @hidden */
  76301. _reOrderControl(control: Control): void;
  76302. /** @hidden */
  76303. _offsetLeft(offset: number): void;
  76304. /** @hidden */
  76305. _offsetTop(offset: number): void;
  76306. /** @hidden */
  76307. _markAllAsDirty(): void;
  76308. /** @hidden */
  76309. protected _localDraw(context: CanvasRenderingContext2D): void;
  76310. /** @hidden */
  76311. _link(host: AdvancedDynamicTexture): void;
  76312. /** @hidden */
  76313. protected _beforeLayout(): void;
  76314. /** @hidden */
  76315. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76316. /** @hidden */
  76317. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76318. protected _postMeasure(): void;
  76319. /** @hidden */
  76320. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76321. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76322. /** @hidden */
  76323. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76324. /** @hidden */
  76325. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76326. /** Releases associated resources */
  76327. dispose(): void;
  76328. }
  76329. }
  76330. declare module BABYLON.GUI {
  76331. /** Class used to create rectangle container */
  76332. export class Rectangle extends Container {
  76333. name?: string | undefined;
  76334. private _thickness;
  76335. private _cornerRadius;
  76336. /** Gets or sets border thickness */
  76337. get thickness(): number;
  76338. set thickness(value: number);
  76339. /** Gets or sets the corner radius angle */
  76340. get cornerRadius(): number;
  76341. set cornerRadius(value: number);
  76342. /**
  76343. * Creates a new Rectangle
  76344. * @param name defines the control name
  76345. */
  76346. constructor(name?: string | undefined);
  76347. protected _getTypeName(): string;
  76348. protected _localDraw(context: CanvasRenderingContext2D): void;
  76349. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76350. private _drawRoundedRect;
  76351. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76352. }
  76353. }
  76354. declare module BABYLON.GUI {
  76355. /**
  76356. * Enum that determines the text-wrapping mode to use.
  76357. */
  76358. export enum TextWrapping {
  76359. /**
  76360. * Clip the text when it's larger than Control.width; this is the default mode.
  76361. */
  76362. Clip = 0,
  76363. /**
  76364. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76365. */
  76366. WordWrap = 1,
  76367. /**
  76368. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76369. */
  76370. Ellipsis = 2
  76371. }
  76372. /**
  76373. * Class used to create text block control
  76374. */
  76375. export class TextBlock extends Control {
  76376. /**
  76377. * Defines the name of the control
  76378. */
  76379. name?: string | undefined;
  76380. private _text;
  76381. private _textWrapping;
  76382. private _textHorizontalAlignment;
  76383. private _textVerticalAlignment;
  76384. private _lines;
  76385. private _resizeToFit;
  76386. private _lineSpacing;
  76387. private _outlineWidth;
  76388. private _outlineColor;
  76389. /**
  76390. * An event triggered after the text is changed
  76391. */
  76392. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76393. /**
  76394. * An event triggered after the text was broken up into lines
  76395. */
  76396. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76397. /**
  76398. * Function used to split a string into words. By default, a string is split at each space character found
  76399. */
  76400. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76401. /**
  76402. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76403. */
  76404. get lines(): any[];
  76405. /**
  76406. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76407. */
  76408. get resizeToFit(): boolean;
  76409. /**
  76410. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76411. */
  76412. set resizeToFit(value: boolean);
  76413. /**
  76414. * Gets or sets a boolean indicating if text must be wrapped
  76415. */
  76416. get textWrapping(): TextWrapping | boolean;
  76417. /**
  76418. * Gets or sets a boolean indicating if text must be wrapped
  76419. */
  76420. set textWrapping(value: TextWrapping | boolean);
  76421. /**
  76422. * Gets or sets text to display
  76423. */
  76424. get text(): string;
  76425. /**
  76426. * Gets or sets text to display
  76427. */
  76428. set text(value: string);
  76429. /**
  76430. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76431. */
  76432. get textHorizontalAlignment(): number;
  76433. /**
  76434. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76435. */
  76436. set textHorizontalAlignment(value: number);
  76437. /**
  76438. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76439. */
  76440. get textVerticalAlignment(): number;
  76441. /**
  76442. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76443. */
  76444. set textVerticalAlignment(value: number);
  76445. /**
  76446. * Gets or sets line spacing value
  76447. */
  76448. set lineSpacing(value: string | number);
  76449. /**
  76450. * Gets or sets line spacing value
  76451. */
  76452. get lineSpacing(): string | number;
  76453. /**
  76454. * Gets or sets outlineWidth of the text to display
  76455. */
  76456. get outlineWidth(): number;
  76457. /**
  76458. * Gets or sets outlineWidth of the text to display
  76459. */
  76460. set outlineWidth(value: number);
  76461. /**
  76462. * Gets or sets outlineColor of the text to display
  76463. */
  76464. get outlineColor(): string;
  76465. /**
  76466. * Gets or sets outlineColor of the text to display
  76467. */
  76468. set outlineColor(value: string);
  76469. /**
  76470. * Creates a new TextBlock object
  76471. * @param name defines the name of the control
  76472. * @param text defines the text to display (emptry string by default)
  76473. */
  76474. constructor(
  76475. /**
  76476. * Defines the name of the control
  76477. */
  76478. name?: string | undefined, text?: string);
  76479. protected _getTypeName(): string;
  76480. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76481. private _drawText;
  76482. /** @hidden */
  76483. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76484. protected _applyStates(context: CanvasRenderingContext2D): void;
  76485. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76486. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76487. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76488. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76489. protected _renderLines(context: CanvasRenderingContext2D): void;
  76490. /**
  76491. * Given a width constraint applied on the text block, find the expected height
  76492. * @returns expected height
  76493. */
  76494. computeExpectedHeight(): number;
  76495. dispose(): void;
  76496. }
  76497. }
  76498. declare module BABYLON.GUI {
  76499. /**
  76500. * Class used to create 2D images
  76501. */
  76502. export class Image extends Control {
  76503. name?: string | undefined;
  76504. private _workingCanvas;
  76505. private _domImage;
  76506. private _imageWidth;
  76507. private _imageHeight;
  76508. private _loaded;
  76509. private _stretch;
  76510. private _source;
  76511. private _autoScale;
  76512. private _sourceLeft;
  76513. private _sourceTop;
  76514. private _sourceWidth;
  76515. private _sourceHeight;
  76516. private _svgAttributesComputationCompleted;
  76517. private _isSVG;
  76518. private _cellWidth;
  76519. private _cellHeight;
  76520. private _cellId;
  76521. private _populateNinePatchSlicesFromImage;
  76522. private _sliceLeft;
  76523. private _sliceRight;
  76524. private _sliceTop;
  76525. private _sliceBottom;
  76526. private _detectPointerOnOpaqueOnly;
  76527. /**
  76528. * BABYLON.Observable notified when the content is loaded
  76529. */
  76530. onImageLoadedObservable: BABYLON.Observable<Image>;
  76531. /**
  76532. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76533. */
  76534. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76535. /**
  76536. * Gets a boolean indicating that the content is loaded
  76537. */
  76538. get isLoaded(): boolean;
  76539. /**
  76540. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76541. */
  76542. get populateNinePatchSlicesFromImage(): boolean;
  76543. set populateNinePatchSlicesFromImage(value: boolean);
  76544. /**
  76545. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76546. * Beware using this as this will comsume more memory as the image has to be stored twice
  76547. */
  76548. get detectPointerOnOpaqueOnly(): boolean;
  76549. set detectPointerOnOpaqueOnly(value: boolean);
  76550. /**
  76551. * Gets or sets the left value for slicing (9-patch)
  76552. */
  76553. get sliceLeft(): number;
  76554. set sliceLeft(value: number);
  76555. /**
  76556. * Gets or sets the right value for slicing (9-patch)
  76557. */
  76558. get sliceRight(): number;
  76559. set sliceRight(value: number);
  76560. /**
  76561. * Gets or sets the top value for slicing (9-patch)
  76562. */
  76563. get sliceTop(): number;
  76564. set sliceTop(value: number);
  76565. /**
  76566. * Gets or sets the bottom value for slicing (9-patch)
  76567. */
  76568. get sliceBottom(): number;
  76569. set sliceBottom(value: number);
  76570. /**
  76571. * Gets or sets the left coordinate in the source image
  76572. */
  76573. get sourceLeft(): number;
  76574. set sourceLeft(value: number);
  76575. /**
  76576. * Gets or sets the top coordinate in the source image
  76577. */
  76578. get sourceTop(): number;
  76579. set sourceTop(value: number);
  76580. /**
  76581. * Gets or sets the width to capture in the source image
  76582. */
  76583. get sourceWidth(): number;
  76584. set sourceWidth(value: number);
  76585. /**
  76586. * Gets or sets the height to capture in the source image
  76587. */
  76588. get sourceHeight(): number;
  76589. set sourceHeight(value: number);
  76590. /** Indicates if the format of the image is SVG */
  76591. get isSVG(): boolean;
  76592. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76593. get svgAttributesComputationCompleted(): boolean;
  76594. /**
  76595. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76596. * @see https://doc.babylonjs.com/how_to/gui#image
  76597. */
  76598. get autoScale(): boolean;
  76599. set autoScale(value: boolean);
  76600. /** Gets or sets the streching mode used by the image */
  76601. get stretch(): number;
  76602. set stretch(value: number);
  76603. /** @hidden */
  76604. _rotate90(n: number, preserveProperties?: boolean): Image;
  76605. private _handleRotationForSVGImage;
  76606. private _rotate90SourceProperties;
  76607. /**
  76608. * Gets or sets the internal DOM image used to render the control
  76609. */
  76610. set domImage(value: HTMLImageElement);
  76611. get domImage(): HTMLImageElement;
  76612. private _onImageLoaded;
  76613. private _extractNinePatchSliceDataFromImage;
  76614. /**
  76615. * Gets or sets image source url
  76616. */
  76617. set source(value: BABYLON.Nullable<string>);
  76618. /**
  76619. * Checks for svg document with icon id present
  76620. */
  76621. private _svgCheck;
  76622. /**
  76623. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76624. * given external svg file and icon id
  76625. */
  76626. private _getSVGAttribs;
  76627. /**
  76628. * Gets or sets the cell width to use when animation sheet is enabled
  76629. * @see https://doc.babylonjs.com/how_to/gui#image
  76630. */
  76631. get cellWidth(): number;
  76632. set cellWidth(value: number);
  76633. /**
  76634. * Gets or sets the cell height to use when animation sheet is enabled
  76635. * @see https://doc.babylonjs.com/how_to/gui#image
  76636. */
  76637. get cellHeight(): number;
  76638. set cellHeight(value: number);
  76639. /**
  76640. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76641. * @see https://doc.babylonjs.com/how_to/gui#image
  76642. */
  76643. get cellId(): number;
  76644. set cellId(value: number);
  76645. /**
  76646. * Creates a new Image
  76647. * @param name defines the control name
  76648. * @param url defines the image url
  76649. */
  76650. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76651. /**
  76652. * Tests if a given coordinates belong to the current control
  76653. * @param x defines x coordinate to test
  76654. * @param y defines y coordinate to test
  76655. * @returns true if the coordinates are inside the control
  76656. */
  76657. contains(x: number, y: number): boolean;
  76658. protected _getTypeName(): string;
  76659. /** Force the control to synchronize with its content */
  76660. synchronizeSizeWithContent(): void;
  76661. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76662. private _prepareWorkingCanvasForOpaqueDetection;
  76663. private _drawImage;
  76664. _draw(context: CanvasRenderingContext2D): void;
  76665. private _renderCornerPatch;
  76666. private _renderNinePatch;
  76667. dispose(): void;
  76668. /** STRETCH_NONE */
  76669. static readonly STRETCH_NONE: number;
  76670. /** STRETCH_FILL */
  76671. static readonly STRETCH_FILL: number;
  76672. /** STRETCH_UNIFORM */
  76673. static readonly STRETCH_UNIFORM: number;
  76674. /** STRETCH_EXTEND */
  76675. static readonly STRETCH_EXTEND: number;
  76676. /** NINE_PATCH */
  76677. static readonly STRETCH_NINE_PATCH: number;
  76678. }
  76679. }
  76680. declare module BABYLON.GUI {
  76681. /**
  76682. * Class used to create 2D buttons
  76683. */
  76684. export class Button extends Rectangle {
  76685. name?: string | undefined;
  76686. /**
  76687. * Function called to generate a pointer enter animation
  76688. */
  76689. pointerEnterAnimation: () => void;
  76690. /**
  76691. * Function called to generate a pointer out animation
  76692. */
  76693. pointerOutAnimation: () => void;
  76694. /**
  76695. * Function called to generate a pointer down animation
  76696. */
  76697. pointerDownAnimation: () => void;
  76698. /**
  76699. * Function called to generate a pointer up animation
  76700. */
  76701. pointerUpAnimation: () => void;
  76702. /**
  76703. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76704. */
  76705. delegatePickingToChildren: boolean;
  76706. private _image;
  76707. /**
  76708. * Returns the image part of the button (if any)
  76709. */
  76710. get image(): BABYLON.Nullable<Image>;
  76711. private _textBlock;
  76712. /**
  76713. * Returns the image part of the button (if any)
  76714. */
  76715. get textBlock(): BABYLON.Nullable<TextBlock>;
  76716. /**
  76717. * Creates a new Button
  76718. * @param name defines the name of the button
  76719. */
  76720. constructor(name?: string | undefined);
  76721. protected _getTypeName(): string;
  76722. /** @hidden */
  76723. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76724. /** @hidden */
  76725. _onPointerEnter(target: Control): boolean;
  76726. /** @hidden */
  76727. _onPointerOut(target: Control, force?: boolean): void;
  76728. /** @hidden */
  76729. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76730. /** @hidden */
  76731. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76732. /**
  76733. * Creates a new button made with an image and a text
  76734. * @param name defines the name of the button
  76735. * @param text defines the text of the button
  76736. * @param imageUrl defines the url of the image
  76737. * @returns a new Button
  76738. */
  76739. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76740. /**
  76741. * Creates a new button made with an image
  76742. * @param name defines the name of the button
  76743. * @param imageUrl defines the url of the image
  76744. * @returns a new Button
  76745. */
  76746. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76747. /**
  76748. * Creates a new button made with a text
  76749. * @param name defines the name of the button
  76750. * @param text defines the text of the button
  76751. * @returns a new Button
  76752. */
  76753. static CreateSimpleButton(name: string, text: string): Button;
  76754. /**
  76755. * Creates a new button made with an image and a centered text
  76756. * @param name defines the name of the button
  76757. * @param text defines the text of the button
  76758. * @param imageUrl defines the url of the image
  76759. * @returns a new Button
  76760. */
  76761. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76762. }
  76763. }
  76764. declare module BABYLON.GUI {
  76765. /**
  76766. * Class used to create a 2D stack panel container
  76767. */
  76768. export class StackPanel extends Container {
  76769. name?: string | undefined;
  76770. private _isVertical;
  76771. private _manualWidth;
  76772. private _manualHeight;
  76773. private _doNotTrackManualChanges;
  76774. /**
  76775. * Gets or sets a boolean indicating that layou warnings should be ignored
  76776. */
  76777. ignoreLayoutWarnings: boolean;
  76778. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76779. get isVertical(): boolean;
  76780. set isVertical(value: boolean);
  76781. /**
  76782. * Gets or sets panel width.
  76783. * This value should not be set when in horizontal mode as it will be computed automatically
  76784. */
  76785. set width(value: string | number);
  76786. get width(): string | number;
  76787. /**
  76788. * Gets or sets panel height.
  76789. * This value should not be set when in vertical mode as it will be computed automatically
  76790. */
  76791. set height(value: string | number);
  76792. get height(): string | number;
  76793. /**
  76794. * Creates a new StackPanel
  76795. * @param name defines control name
  76796. */
  76797. constructor(name?: string | undefined);
  76798. protected _getTypeName(): string;
  76799. /** @hidden */
  76800. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76801. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76802. protected _postMeasure(): void;
  76803. }
  76804. }
  76805. declare module BABYLON.GUI {
  76806. /**
  76807. * Class used to represent a 2D checkbox
  76808. */
  76809. export class Checkbox extends Control {
  76810. name?: string | undefined;
  76811. private _isChecked;
  76812. private _background;
  76813. private _checkSizeRatio;
  76814. private _thickness;
  76815. /** Gets or sets border thickness */
  76816. get thickness(): number;
  76817. set thickness(value: number);
  76818. /**
  76819. * BABYLON.Observable raised when isChecked property changes
  76820. */
  76821. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76822. /** Gets or sets a value indicating the ratio between overall size and check size */
  76823. get checkSizeRatio(): number;
  76824. set checkSizeRatio(value: number);
  76825. /** Gets or sets background color */
  76826. get background(): string;
  76827. set background(value: string);
  76828. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76829. get isChecked(): boolean;
  76830. set isChecked(value: boolean);
  76831. /**
  76832. * Creates a new CheckBox
  76833. * @param name defines the control name
  76834. */
  76835. constructor(name?: string | undefined);
  76836. protected _getTypeName(): string;
  76837. /** @hidden */
  76838. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76839. /** @hidden */
  76840. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76841. /**
  76842. * Utility function to easily create a checkbox with a header
  76843. * @param title defines the label to use for the header
  76844. * @param onValueChanged defines the callback to call when value changes
  76845. * @returns a StackPanel containing the checkbox and a textBlock
  76846. */
  76847. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76848. }
  76849. }
  76850. declare module BABYLON.GUI {
  76851. /**
  76852. * Class used to store key control properties
  76853. */
  76854. export class KeyPropertySet {
  76855. /** Width */
  76856. width?: string;
  76857. /** Height */
  76858. height?: string;
  76859. /** Left padding */
  76860. paddingLeft?: string;
  76861. /** Right padding */
  76862. paddingRight?: string;
  76863. /** Top padding */
  76864. paddingTop?: string;
  76865. /** Bottom padding */
  76866. paddingBottom?: string;
  76867. /** Foreground color */
  76868. color?: string;
  76869. /** Background color */
  76870. background?: string;
  76871. }
  76872. /**
  76873. * Class used to create virtual keyboard
  76874. */
  76875. export class VirtualKeyboard extends StackPanel {
  76876. /** BABYLON.Observable raised when a key is pressed */
  76877. onKeyPressObservable: BABYLON.Observable<string>;
  76878. /** Gets or sets default key button width */
  76879. defaultButtonWidth: string;
  76880. /** Gets or sets default key button height */
  76881. defaultButtonHeight: string;
  76882. /** Gets or sets default key button left padding */
  76883. defaultButtonPaddingLeft: string;
  76884. /** Gets or sets default key button right padding */
  76885. defaultButtonPaddingRight: string;
  76886. /** Gets or sets default key button top padding */
  76887. defaultButtonPaddingTop: string;
  76888. /** Gets or sets default key button bottom padding */
  76889. defaultButtonPaddingBottom: string;
  76890. /** Gets or sets default key button foreground color */
  76891. defaultButtonColor: string;
  76892. /** Gets or sets default key button background color */
  76893. defaultButtonBackground: string;
  76894. /** Gets or sets shift button foreground color */
  76895. shiftButtonColor: string;
  76896. /** Gets or sets shift button thickness*/
  76897. selectedShiftThickness: number;
  76898. /** Gets shift key state */
  76899. shiftState: number;
  76900. protected _getTypeName(): string;
  76901. private _createKey;
  76902. /**
  76903. * Adds a new row of keys
  76904. * @param keys defines the list of keys to add
  76905. * @param propertySets defines the associated property sets
  76906. */
  76907. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76908. /**
  76909. * Set the shift key to a specific state
  76910. * @param shiftState defines the new shift state
  76911. */
  76912. applyShiftState(shiftState: number): void;
  76913. private _currentlyConnectedInputText;
  76914. private _connectedInputTexts;
  76915. private _onKeyPressObserver;
  76916. /** Gets the input text control currently attached to the keyboard */
  76917. get connectedInputText(): BABYLON.Nullable<InputText>;
  76918. /**
  76919. * Connects the keyboard with an input text control
  76920. *
  76921. * @param input defines the target control
  76922. */
  76923. connect(input: InputText): void;
  76924. /**
  76925. * Disconnects the keyboard from connected InputText controls
  76926. *
  76927. * @param input optionally defines a target control, otherwise all are disconnected
  76928. */
  76929. disconnect(input?: InputText): void;
  76930. private _removeConnectedInputObservables;
  76931. /**
  76932. * Release all resources
  76933. */
  76934. dispose(): void;
  76935. /**
  76936. * Creates a new keyboard using a default layout
  76937. *
  76938. * @param name defines control name
  76939. * @returns a new VirtualKeyboard
  76940. */
  76941. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76942. }
  76943. }
  76944. declare module BABYLON.GUI {
  76945. /**
  76946. * Class used to create input text control
  76947. */
  76948. export class InputText extends Control implements IFocusableControl {
  76949. name?: string | undefined;
  76950. private _text;
  76951. private _placeholderText;
  76952. private _background;
  76953. private _focusedBackground;
  76954. private _focusedColor;
  76955. private _placeholderColor;
  76956. private _thickness;
  76957. private _margin;
  76958. private _autoStretchWidth;
  76959. private _maxWidth;
  76960. private _isFocused;
  76961. private _blinkTimeout;
  76962. private _blinkIsEven;
  76963. private _cursorOffset;
  76964. private _scrollLeft;
  76965. private _textWidth;
  76966. private _clickedCoordinate;
  76967. private _deadKey;
  76968. private _addKey;
  76969. private _currentKey;
  76970. private _isTextHighlightOn;
  76971. private _textHighlightColor;
  76972. private _highligherOpacity;
  76973. private _highlightedText;
  76974. private _startHighlightIndex;
  76975. private _endHighlightIndex;
  76976. private _cursorIndex;
  76977. private _onFocusSelectAll;
  76978. private _isPointerDown;
  76979. private _onClipboardObserver;
  76980. private _onPointerDblTapObserver;
  76981. /** @hidden */
  76982. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76983. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76984. promptMessage: string;
  76985. /** Force disable prompt on mobile device */
  76986. disableMobilePrompt: boolean;
  76987. /** BABYLON.Observable raised when the text changes */
  76988. onTextChangedObservable: BABYLON.Observable<InputText>;
  76989. /** BABYLON.Observable raised just before an entered character is to be added */
  76990. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76991. /** BABYLON.Observable raised when the control gets the focus */
  76992. onFocusObservable: BABYLON.Observable<InputText>;
  76993. /** BABYLON.Observable raised when the control loses the focus */
  76994. onBlurObservable: BABYLON.Observable<InputText>;
  76995. /**Observable raised when the text is highlighted */
  76996. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76997. /**Observable raised when copy event is triggered */
  76998. onTextCopyObservable: BABYLON.Observable<InputText>;
  76999. /** BABYLON.Observable raised when cut event is triggered */
  77000. onTextCutObservable: BABYLON.Observable<InputText>;
  77001. /** BABYLON.Observable raised when paste event is triggered */
  77002. onTextPasteObservable: BABYLON.Observable<InputText>;
  77003. /** BABYLON.Observable raised when a key event was processed */
  77004. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77005. /** Gets or sets the maximum width allowed by the control */
  77006. get maxWidth(): string | number;
  77007. /** Gets the maximum width allowed by the control in pixels */
  77008. get maxWidthInPixels(): number;
  77009. set maxWidth(value: string | number);
  77010. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77011. get highligherOpacity(): number;
  77012. set highligherOpacity(value: number);
  77013. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77014. get onFocusSelectAll(): boolean;
  77015. set onFocusSelectAll(value: boolean);
  77016. /** Gets or sets the text hightlight color */
  77017. get textHighlightColor(): string;
  77018. set textHighlightColor(value: string);
  77019. /** Gets or sets control margin */
  77020. get margin(): string;
  77021. /** Gets control margin in pixels */
  77022. get marginInPixels(): number;
  77023. set margin(value: string);
  77024. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77025. get autoStretchWidth(): boolean;
  77026. set autoStretchWidth(value: boolean);
  77027. /** Gets or sets border thickness */
  77028. get thickness(): number;
  77029. set thickness(value: number);
  77030. /** Gets or sets the background color when focused */
  77031. get focusedBackground(): string;
  77032. set focusedBackground(value: string);
  77033. /** Gets or sets the background color when focused */
  77034. get focusedColor(): string;
  77035. set focusedColor(value: string);
  77036. /** Gets or sets the background color */
  77037. get background(): string;
  77038. set background(value: string);
  77039. /** Gets or sets the placeholder color */
  77040. get placeholderColor(): string;
  77041. set placeholderColor(value: string);
  77042. /** Gets or sets the text displayed when the control is empty */
  77043. get placeholderText(): string;
  77044. set placeholderText(value: string);
  77045. /** Gets or sets the dead key flag */
  77046. get deadKey(): boolean;
  77047. set deadKey(flag: boolean);
  77048. /** Gets or sets the highlight text */
  77049. get highlightedText(): string;
  77050. set highlightedText(text: string);
  77051. /** Gets or sets if the current key should be added */
  77052. get addKey(): boolean;
  77053. set addKey(flag: boolean);
  77054. /** Gets or sets the value of the current key being entered */
  77055. get currentKey(): string;
  77056. set currentKey(key: string);
  77057. /** Gets or sets the text displayed in the control */
  77058. get text(): string;
  77059. set text(value: string);
  77060. /** Gets or sets control width */
  77061. get width(): string | number;
  77062. set width(value: string | number);
  77063. /**
  77064. * Creates a new InputText
  77065. * @param name defines the control name
  77066. * @param text defines the text of the control
  77067. */
  77068. constructor(name?: string | undefined, text?: string);
  77069. /** @hidden */
  77070. onBlur(): void;
  77071. /** @hidden */
  77072. onFocus(): void;
  77073. protected _getTypeName(): string;
  77074. /**
  77075. * Function called to get the list of controls that should not steal the focus from this control
  77076. * @returns an array of controls
  77077. */
  77078. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77079. /** @hidden */
  77080. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77081. /** @hidden */
  77082. private _updateValueFromCursorIndex;
  77083. /** @hidden */
  77084. private _processDblClick;
  77085. /** @hidden */
  77086. private _selectAllText;
  77087. /**
  77088. * Handles the keyboard event
  77089. * @param evt Defines the KeyboardEvent
  77090. */
  77091. processKeyboard(evt: KeyboardEvent): void;
  77092. /** @hidden */
  77093. private _onCopyText;
  77094. /** @hidden */
  77095. private _onCutText;
  77096. /** @hidden */
  77097. private _onPasteText;
  77098. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77099. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77100. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77101. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77102. protected _beforeRenderText(text: string): string;
  77103. dispose(): void;
  77104. }
  77105. }
  77106. declare module BABYLON.GUI {
  77107. /**
  77108. * Class used to create a 2D grid container
  77109. */
  77110. export class Grid extends Container {
  77111. name?: string | undefined;
  77112. private _rowDefinitions;
  77113. private _columnDefinitions;
  77114. private _cells;
  77115. private _childControls;
  77116. /**
  77117. * Gets the number of columns
  77118. */
  77119. get columnCount(): number;
  77120. /**
  77121. * Gets the number of rows
  77122. */
  77123. get rowCount(): number;
  77124. /** Gets the list of children */
  77125. get children(): Control[];
  77126. /** Gets the list of cells (e.g. the containers) */
  77127. get cells(): {
  77128. [key: string]: Container;
  77129. };
  77130. /**
  77131. * Gets the definition of a specific row
  77132. * @param index defines the index of the row
  77133. * @returns the row definition
  77134. */
  77135. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77136. /**
  77137. * Gets the definition of a specific column
  77138. * @param index defines the index of the column
  77139. * @returns the column definition
  77140. */
  77141. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77142. /**
  77143. * Adds a new row to the grid
  77144. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77145. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77146. * @returns the current grid
  77147. */
  77148. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77149. /**
  77150. * Adds a new column to the grid
  77151. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77152. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77153. * @returns the current grid
  77154. */
  77155. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77156. /**
  77157. * Update a row definition
  77158. * @param index defines the index of the row to update
  77159. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77160. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77161. * @returns the current grid
  77162. */
  77163. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77164. /**
  77165. * Update a column definition
  77166. * @param index defines the index of the column to update
  77167. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77168. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77169. * @returns the current grid
  77170. */
  77171. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77172. /**
  77173. * Gets the list of children stored in a specific cell
  77174. * @param row defines the row to check
  77175. * @param column defines the column to check
  77176. * @returns the list of controls
  77177. */
  77178. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77179. /**
  77180. * Gets a string representing the child cell info (row x column)
  77181. * @param child defines the control to get info from
  77182. * @returns a string containing the child cell info (row x column)
  77183. */
  77184. getChildCellInfo(child: Control): string;
  77185. private _removeCell;
  77186. private _offsetCell;
  77187. /**
  77188. * Remove a column definition at specified index
  77189. * @param index defines the index of the column to remove
  77190. * @returns the current grid
  77191. */
  77192. removeColumnDefinition(index: number): Grid;
  77193. /**
  77194. * Remove a row definition at specified index
  77195. * @param index defines the index of the row to remove
  77196. * @returns the current grid
  77197. */
  77198. removeRowDefinition(index: number): Grid;
  77199. /**
  77200. * Adds a new control to the current grid
  77201. * @param control defines the control to add
  77202. * @param row defines the row where to add the control (0 by default)
  77203. * @param column defines the column where to add the control (0 by default)
  77204. * @returns the current grid
  77205. */
  77206. addControl(control: Control, row?: number, column?: number): Grid;
  77207. /**
  77208. * Removes a control from the current container
  77209. * @param control defines the control to remove
  77210. * @returns the current container
  77211. */
  77212. removeControl(control: Control): Container;
  77213. /**
  77214. * Creates a new Grid
  77215. * @param name defines control name
  77216. */
  77217. constructor(name?: string | undefined);
  77218. protected _getTypeName(): string;
  77219. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77220. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77221. _flagDescendantsAsMatrixDirty(): void;
  77222. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77223. /** Releases associated resources */
  77224. dispose(): void;
  77225. }
  77226. }
  77227. declare module BABYLON.GUI {
  77228. /** Class used to create color pickers */
  77229. export class ColorPicker extends Control {
  77230. name?: string | undefined;
  77231. private static _Epsilon;
  77232. private _colorWheelCanvas;
  77233. private _value;
  77234. private _tmpColor;
  77235. private _pointerStartedOnSquare;
  77236. private _pointerStartedOnWheel;
  77237. private _squareLeft;
  77238. private _squareTop;
  77239. private _squareSize;
  77240. private _h;
  77241. private _s;
  77242. private _v;
  77243. private _lastPointerDownID;
  77244. /**
  77245. * BABYLON.Observable raised when the value changes
  77246. */
  77247. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77248. /** Gets or sets the color of the color picker */
  77249. get value(): BABYLON.Color3;
  77250. set value(value: BABYLON.Color3);
  77251. /**
  77252. * Gets or sets control width
  77253. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77254. */
  77255. get width(): string | number;
  77256. set width(value: string | number);
  77257. /**
  77258. * Gets or sets control height
  77259. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77260. */
  77261. get height(): string | number;
  77262. /** Gets or sets control height */
  77263. set height(value: string | number);
  77264. /** Gets or sets control size */
  77265. get size(): string | number;
  77266. set size(value: string | number);
  77267. /**
  77268. * Creates a new ColorPicker
  77269. * @param name defines the control name
  77270. */
  77271. constructor(name?: string | undefined);
  77272. protected _getTypeName(): string;
  77273. /** @hidden */
  77274. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77275. private _updateSquareProps;
  77276. private _drawGradientSquare;
  77277. private _drawCircle;
  77278. private _createColorWheelCanvas;
  77279. /** @hidden */
  77280. _draw(context: CanvasRenderingContext2D): void;
  77281. private _pointerIsDown;
  77282. private _updateValueFromPointer;
  77283. private _isPointOnSquare;
  77284. private _isPointOnWheel;
  77285. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77286. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77287. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77288. /**
  77289. * This function expands the color picker by creating a color picker dialog with manual
  77290. * color value input and the ability to save colors into an array to be used later in
  77291. * subsequent launches of the dialogue.
  77292. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77293. * @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.
  77294. * @returns picked color as a hex string and the saved colors array as hex strings.
  77295. */
  77296. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77297. pickerWidth?: string;
  77298. pickerHeight?: string;
  77299. headerHeight?: string;
  77300. lastColor?: string;
  77301. swatchLimit?: number;
  77302. numSwatchesPerLine?: number;
  77303. savedColors?: Array<string>;
  77304. }): Promise<{
  77305. savedColors?: string[];
  77306. pickedColor: string;
  77307. }>;
  77308. }
  77309. }
  77310. declare module BABYLON.GUI {
  77311. /** Class used to create 2D ellipse containers */
  77312. export class Ellipse extends Container {
  77313. name?: string | undefined;
  77314. private _thickness;
  77315. /** Gets or sets border thickness */
  77316. get thickness(): number;
  77317. set thickness(value: number);
  77318. /**
  77319. * Creates a new Ellipse
  77320. * @param name defines the control name
  77321. */
  77322. constructor(name?: string | undefined);
  77323. protected _getTypeName(): string;
  77324. protected _localDraw(context: CanvasRenderingContext2D): void;
  77325. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77326. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77327. }
  77328. }
  77329. declare module BABYLON.GUI {
  77330. /**
  77331. * Class used to create a password control
  77332. */
  77333. export class InputPassword extends InputText {
  77334. protected _beforeRenderText(text: string): string;
  77335. }
  77336. }
  77337. declare module BABYLON.GUI {
  77338. /** Class used to render 2D lines */
  77339. export class Line extends Control {
  77340. name?: string | undefined;
  77341. private _lineWidth;
  77342. private _x1;
  77343. private _y1;
  77344. private _x2;
  77345. private _y2;
  77346. private _dash;
  77347. private _connectedControl;
  77348. private _connectedControlDirtyObserver;
  77349. /** Gets or sets the dash pattern */
  77350. get dash(): Array<number>;
  77351. set dash(value: Array<number>);
  77352. /** Gets or sets the control connected with the line end */
  77353. get connectedControl(): Control;
  77354. set connectedControl(value: Control);
  77355. /** Gets or sets start coordinates on X axis */
  77356. get x1(): string | number;
  77357. set x1(value: string | number);
  77358. /** Gets or sets start coordinates on Y axis */
  77359. get y1(): string | number;
  77360. set y1(value: string | number);
  77361. /** Gets or sets end coordinates on X axis */
  77362. get x2(): string | number;
  77363. set x2(value: string | number);
  77364. /** Gets or sets end coordinates on Y axis */
  77365. get y2(): string | number;
  77366. set y2(value: string | number);
  77367. /** Gets or sets line width */
  77368. get lineWidth(): number;
  77369. set lineWidth(value: number);
  77370. /** Gets or sets horizontal alignment */
  77371. set horizontalAlignment(value: number);
  77372. /** Gets or sets vertical alignment */
  77373. set verticalAlignment(value: number);
  77374. private get _effectiveX2();
  77375. private get _effectiveY2();
  77376. /**
  77377. * Creates a new Line
  77378. * @param name defines the control name
  77379. */
  77380. constructor(name?: string | undefined);
  77381. protected _getTypeName(): string;
  77382. _draw(context: CanvasRenderingContext2D): void;
  77383. _measure(): void;
  77384. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77385. /**
  77386. * Move one end of the line given 3D cartesian coordinates.
  77387. * @param position Targeted world position
  77388. * @param scene BABYLON.Scene
  77389. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77390. */
  77391. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77392. /**
  77393. * Move one end of the line to a position in screen absolute space.
  77394. * @param projectedPosition Position in screen absolute space (X, Y)
  77395. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77396. */
  77397. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77398. }
  77399. }
  77400. declare module BABYLON.GUI {
  77401. /**
  77402. * Class used to store a point for a MultiLine object.
  77403. * The point can be pure 2D coordinates, a mesh or a control
  77404. */
  77405. export class MultiLinePoint {
  77406. private _multiLine;
  77407. private _x;
  77408. private _y;
  77409. private _control;
  77410. private _mesh;
  77411. private _controlObserver;
  77412. private _meshObserver;
  77413. /** @hidden */
  77414. _point: BABYLON.Vector2;
  77415. /**
  77416. * Creates a new MultiLinePoint
  77417. * @param multiLine defines the source MultiLine object
  77418. */
  77419. constructor(multiLine: MultiLine);
  77420. /** Gets or sets x coordinate */
  77421. get x(): string | number;
  77422. set x(value: string | number);
  77423. /** Gets or sets y coordinate */
  77424. get y(): string | number;
  77425. set y(value: string | number);
  77426. /** Gets or sets the control associated with this point */
  77427. get control(): BABYLON.Nullable<Control>;
  77428. set control(value: BABYLON.Nullable<Control>);
  77429. /** Gets or sets the mesh associated with this point */
  77430. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77431. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77432. /** Resets links */
  77433. resetLinks(): void;
  77434. /**
  77435. * Gets a translation vector
  77436. * @returns the translation vector
  77437. */
  77438. translate(): BABYLON.Vector2;
  77439. private _translatePoint;
  77440. /** Release associated resources */
  77441. dispose(): void;
  77442. }
  77443. }
  77444. declare module BABYLON.GUI {
  77445. /**
  77446. * Class used to create multi line control
  77447. */
  77448. export class MultiLine extends Control {
  77449. name?: string | undefined;
  77450. private _lineWidth;
  77451. private _dash;
  77452. private _points;
  77453. private _minX;
  77454. private _minY;
  77455. private _maxX;
  77456. private _maxY;
  77457. /**
  77458. * Creates a new MultiLine
  77459. * @param name defines the control name
  77460. */
  77461. constructor(name?: string | undefined);
  77462. /** Gets or sets dash pattern */
  77463. get dash(): Array<number>;
  77464. set dash(value: Array<number>);
  77465. /**
  77466. * Gets point stored at specified index
  77467. * @param index defines the index to look for
  77468. * @returns the requested point if found
  77469. */
  77470. getAt(index: number): MultiLinePoint;
  77471. /** Function called when a point is updated */
  77472. onPointUpdate: () => void;
  77473. /**
  77474. * Adds new points to the point collection
  77475. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77476. * @returns the list of created MultiLinePoint
  77477. */
  77478. add(...items: (AbstractMesh | Control | {
  77479. x: string | number;
  77480. y: string | number;
  77481. })[]): MultiLinePoint[];
  77482. /**
  77483. * Adds a new point to the point collection
  77484. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77485. * @returns the created MultiLinePoint
  77486. */
  77487. push(item?: (AbstractMesh | Control | {
  77488. x: string | number;
  77489. y: string | number;
  77490. })): MultiLinePoint;
  77491. /**
  77492. * Remove a specific value or point from the active point collection
  77493. * @param value defines the value or point to remove
  77494. */
  77495. remove(value: number | MultiLinePoint): void;
  77496. /**
  77497. * Resets this object to initial state (no point)
  77498. */
  77499. reset(): void;
  77500. /**
  77501. * Resets all links
  77502. */
  77503. resetLinks(): void;
  77504. /** Gets or sets line width */
  77505. get lineWidth(): number;
  77506. set lineWidth(value: number);
  77507. set horizontalAlignment(value: number);
  77508. set verticalAlignment(value: number);
  77509. protected _getTypeName(): string;
  77510. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77511. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77512. _measure(): void;
  77513. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77514. dispose(): void;
  77515. }
  77516. }
  77517. declare module BABYLON.GUI {
  77518. /**
  77519. * Class used to create radio button controls
  77520. */
  77521. export class RadioButton extends Control {
  77522. name?: string | undefined;
  77523. private _isChecked;
  77524. private _background;
  77525. private _checkSizeRatio;
  77526. private _thickness;
  77527. /** Gets or sets border thickness */
  77528. get thickness(): number;
  77529. set thickness(value: number);
  77530. /** Gets or sets group name */
  77531. group: string;
  77532. /** BABYLON.Observable raised when isChecked is changed */
  77533. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77534. /** Gets or sets a value indicating the ratio between overall size and check size */
  77535. get checkSizeRatio(): number;
  77536. set checkSizeRatio(value: number);
  77537. /** Gets or sets background color */
  77538. get background(): string;
  77539. set background(value: string);
  77540. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77541. get isChecked(): boolean;
  77542. set isChecked(value: boolean);
  77543. /**
  77544. * Creates a new RadioButton
  77545. * @param name defines the control name
  77546. */
  77547. constructor(name?: string | undefined);
  77548. protected _getTypeName(): string;
  77549. _draw(context: CanvasRenderingContext2D): void;
  77550. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77551. /**
  77552. * Utility function to easily create a radio button with a header
  77553. * @param title defines the label to use for the header
  77554. * @param group defines the group to use for the radio button
  77555. * @param isChecked defines the initial state of the radio button
  77556. * @param onValueChanged defines the callback to call when value changes
  77557. * @returns a StackPanel containing the radio button and a textBlock
  77558. */
  77559. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77560. }
  77561. }
  77562. declare module BABYLON.GUI {
  77563. /**
  77564. * Class used to create slider controls
  77565. */
  77566. export class BaseSlider extends Control {
  77567. name?: string | undefined;
  77568. protected _thumbWidth: ValueAndUnit;
  77569. private _minimum;
  77570. private _maximum;
  77571. private _value;
  77572. private _isVertical;
  77573. protected _barOffset: ValueAndUnit;
  77574. private _isThumbClamped;
  77575. protected _displayThumb: boolean;
  77576. private _step;
  77577. private _lastPointerDownID;
  77578. protected _effectiveBarOffset: number;
  77579. protected _renderLeft: number;
  77580. protected _renderTop: number;
  77581. protected _renderWidth: number;
  77582. protected _renderHeight: number;
  77583. protected _backgroundBoxLength: number;
  77584. protected _backgroundBoxThickness: number;
  77585. protected _effectiveThumbThickness: number;
  77586. /** BABYLON.Observable raised when the sldier value changes */
  77587. onValueChangedObservable: BABYLON.Observable<number>;
  77588. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77589. get displayThumb(): boolean;
  77590. set displayThumb(value: boolean);
  77591. /** Gets or sets a step to apply to values (0 by default) */
  77592. get step(): number;
  77593. set step(value: number);
  77594. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77595. get barOffset(): string | number;
  77596. /** Gets main bar offset in pixels*/
  77597. get barOffsetInPixels(): number;
  77598. set barOffset(value: string | number);
  77599. /** Gets or sets thumb width */
  77600. get thumbWidth(): string | number;
  77601. /** Gets thumb width in pixels */
  77602. get thumbWidthInPixels(): number;
  77603. set thumbWidth(value: string | number);
  77604. /** Gets or sets minimum value */
  77605. get minimum(): number;
  77606. set minimum(value: number);
  77607. /** Gets or sets maximum value */
  77608. get maximum(): number;
  77609. set maximum(value: number);
  77610. /** Gets or sets current value */
  77611. get value(): number;
  77612. set value(value: number);
  77613. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77614. get isVertical(): boolean;
  77615. set isVertical(value: boolean);
  77616. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77617. get isThumbClamped(): boolean;
  77618. set isThumbClamped(value: boolean);
  77619. /**
  77620. * Creates a new BaseSlider
  77621. * @param name defines the control name
  77622. */
  77623. constructor(name?: string | undefined);
  77624. protected _getTypeName(): string;
  77625. protected _getThumbPosition(): number;
  77626. protected _getThumbThickness(type: string): number;
  77627. protected _prepareRenderingData(type: string): void;
  77628. private _pointerIsDown;
  77629. /** @hidden */
  77630. protected _updateValueFromPointer(x: number, y: number): void;
  77631. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77632. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77633. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77634. }
  77635. }
  77636. declare module BABYLON.GUI {
  77637. /**
  77638. * Class used to create slider controls
  77639. */
  77640. export class Slider extends BaseSlider {
  77641. name?: string | undefined;
  77642. private _background;
  77643. private _borderColor;
  77644. private _isThumbCircle;
  77645. protected _displayValueBar: boolean;
  77646. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77647. get displayValueBar(): boolean;
  77648. set displayValueBar(value: boolean);
  77649. /** Gets or sets border color */
  77650. get borderColor(): string;
  77651. set borderColor(value: string);
  77652. /** Gets or sets background color */
  77653. get background(): string;
  77654. set background(value: string);
  77655. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77656. get isThumbCircle(): boolean;
  77657. set isThumbCircle(value: boolean);
  77658. /**
  77659. * Creates a new Slider
  77660. * @param name defines the control name
  77661. */
  77662. constructor(name?: string | undefined);
  77663. protected _getTypeName(): string;
  77664. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77665. }
  77666. }
  77667. declare module BABYLON.GUI {
  77668. /** Class used to create a RadioGroup
  77669. * which contains groups of radio buttons
  77670. */
  77671. export class SelectorGroup {
  77672. /** name of SelectorGroup */
  77673. name: string;
  77674. private _groupPanel;
  77675. private _selectors;
  77676. private _groupHeader;
  77677. /**
  77678. * Creates a new SelectorGroup
  77679. * @param name of group, used as a group heading
  77680. */
  77681. constructor(
  77682. /** name of SelectorGroup */
  77683. name: string);
  77684. /** Gets the groupPanel of the SelectorGroup */
  77685. get groupPanel(): StackPanel;
  77686. /** Gets the selectors array */
  77687. get selectors(): StackPanel[];
  77688. /** Gets and sets the group header */
  77689. get header(): string;
  77690. set header(label: string);
  77691. /** @hidden */
  77692. private _addGroupHeader;
  77693. /** @hidden*/
  77694. _getSelector(selectorNb: number): StackPanel | undefined;
  77695. /** Removes the selector at the given position
  77696. * @param selectorNb the position of the selector within the group
  77697. */
  77698. removeSelector(selectorNb: number): void;
  77699. }
  77700. /** Class used to create a CheckboxGroup
  77701. * which contains groups of checkbox buttons
  77702. */
  77703. export class CheckboxGroup extends SelectorGroup {
  77704. /** Adds a checkbox as a control
  77705. * @param text is the label for the selector
  77706. * @param func is the function called when the Selector is checked
  77707. * @param checked is true when Selector is checked
  77708. */
  77709. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77710. /** @hidden */
  77711. _setSelectorLabel(selectorNb: number, label: string): void;
  77712. /** @hidden */
  77713. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77714. /** @hidden */
  77715. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77716. /** @hidden */
  77717. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77718. }
  77719. /** Class used to create a RadioGroup
  77720. * which contains groups of radio buttons
  77721. */
  77722. export class RadioGroup extends SelectorGroup {
  77723. private _selectNb;
  77724. /** Adds a radio button as a control
  77725. * @param label is the label for the selector
  77726. * @param func is the function called when the Selector is checked
  77727. * @param checked is true when Selector is checked
  77728. */
  77729. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77730. /** @hidden */
  77731. _setSelectorLabel(selectorNb: number, label: string): void;
  77732. /** @hidden */
  77733. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77734. /** @hidden */
  77735. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77736. /** @hidden */
  77737. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77738. }
  77739. /** Class used to create a SliderGroup
  77740. * which contains groups of slider buttons
  77741. */
  77742. export class SliderGroup extends SelectorGroup {
  77743. /**
  77744. * Adds a slider to the SelectorGroup
  77745. * @param label is the label for the SliderBar
  77746. * @param func is the function called when the Slider moves
  77747. * @param unit is a string describing the units used, eg degrees or metres
  77748. * @param min is the minimum value for the Slider
  77749. * @param max is the maximum value for the Slider
  77750. * @param value is the start value for the Slider between min and max
  77751. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77752. */
  77753. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77754. /** @hidden */
  77755. _setSelectorLabel(selectorNb: number, label: string): void;
  77756. /** @hidden */
  77757. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77758. /** @hidden */
  77759. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77760. /** @hidden */
  77761. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77762. }
  77763. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77764. * @see https://doc.babylonjs.com/how_to/selector
  77765. */
  77766. export class SelectionPanel extends Rectangle {
  77767. /** name of SelectionPanel */
  77768. name: string;
  77769. /** an array of SelectionGroups */
  77770. groups: SelectorGroup[];
  77771. private _panel;
  77772. private _buttonColor;
  77773. private _buttonBackground;
  77774. private _headerColor;
  77775. private _barColor;
  77776. private _barHeight;
  77777. private _spacerHeight;
  77778. private _labelColor;
  77779. private _groups;
  77780. private _bars;
  77781. /**
  77782. * Creates a new SelectionPanel
  77783. * @param name of SelectionPanel
  77784. * @param groups is an array of SelectionGroups
  77785. */
  77786. constructor(
  77787. /** name of SelectionPanel */
  77788. name: string,
  77789. /** an array of SelectionGroups */
  77790. groups?: SelectorGroup[]);
  77791. protected _getTypeName(): string;
  77792. /** Gets or sets the headerColor */
  77793. get headerColor(): string;
  77794. set headerColor(color: string);
  77795. private _setHeaderColor;
  77796. /** Gets or sets the button color */
  77797. get buttonColor(): string;
  77798. set buttonColor(color: string);
  77799. private _setbuttonColor;
  77800. /** Gets or sets the label color */
  77801. get labelColor(): string;
  77802. set labelColor(color: string);
  77803. private _setLabelColor;
  77804. /** Gets or sets the button background */
  77805. get buttonBackground(): string;
  77806. set buttonBackground(color: string);
  77807. private _setButtonBackground;
  77808. /** Gets or sets the color of separator bar */
  77809. get barColor(): string;
  77810. set barColor(color: string);
  77811. private _setBarColor;
  77812. /** Gets or sets the height of separator bar */
  77813. get barHeight(): string;
  77814. set barHeight(value: string);
  77815. private _setBarHeight;
  77816. /** Gets or sets the height of spacers*/
  77817. get spacerHeight(): string;
  77818. set spacerHeight(value: string);
  77819. private _setSpacerHeight;
  77820. /** Adds a bar between groups */
  77821. private _addSpacer;
  77822. /** Add a group to the selection panel
  77823. * @param group is the selector group to add
  77824. */
  77825. addGroup(group: SelectorGroup): void;
  77826. /** Remove the group from the given position
  77827. * @param groupNb is the position of the group in the list
  77828. */
  77829. removeGroup(groupNb: number): void;
  77830. /** Change a group header label
  77831. * @param label is the new group header label
  77832. * @param groupNb is the number of the group to relabel
  77833. * */
  77834. setHeaderName(label: string, groupNb: number): void;
  77835. /** Change selector label to the one given
  77836. * @param label is the new selector label
  77837. * @param groupNb is the number of the groupcontaining the selector
  77838. * @param selectorNb is the number of the selector within a group to relabel
  77839. * */
  77840. relabel(label: string, groupNb: number, selectorNb: number): void;
  77841. /** For a given group position remove the selector at the given position
  77842. * @param groupNb is the number of the group to remove the selector from
  77843. * @param selectorNb is the number of the selector within the group
  77844. */
  77845. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77846. /** For a given group position of correct type add a checkbox button
  77847. * @param groupNb is the number of the group to remove the selector from
  77848. * @param label is the label for the selector
  77849. * @param func is the function called when the Selector is checked
  77850. * @param checked is true when Selector is checked
  77851. */
  77852. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77853. /** For a given group position of correct type add a radio button
  77854. * @param groupNb is the number of the group to remove the selector from
  77855. * @param label is the label for the selector
  77856. * @param func is the function called when the Selector is checked
  77857. * @param checked is true when Selector is checked
  77858. */
  77859. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77860. /**
  77861. * For a given slider group add a slider
  77862. * @param groupNb is the number of the group to add the slider to
  77863. * @param label is the label for the Slider
  77864. * @param func is the function called when the Slider moves
  77865. * @param unit is a string describing the units used, eg degrees or metres
  77866. * @param min is the minimum value for the Slider
  77867. * @param max is the maximum value for the Slider
  77868. * @param value is the start value for the Slider between min and max
  77869. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77870. */
  77871. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77872. }
  77873. }
  77874. declare module BABYLON.GUI {
  77875. /**
  77876. * Class used to hold a the container for ScrollViewer
  77877. * @hidden
  77878. */
  77879. export class _ScrollViewerWindow extends Container {
  77880. parentClientWidth: number;
  77881. parentClientHeight: number;
  77882. private _freezeControls;
  77883. private _parentMeasure;
  77884. private _oldLeft;
  77885. private _oldTop;
  77886. get freezeControls(): boolean;
  77887. set freezeControls(value: boolean);
  77888. private _bucketWidth;
  77889. private _bucketHeight;
  77890. private _buckets;
  77891. private _bucketLen;
  77892. get bucketWidth(): number;
  77893. get bucketHeight(): number;
  77894. setBucketSizes(width: number, height: number): void;
  77895. private _useBuckets;
  77896. private _makeBuckets;
  77897. private _dispatchInBuckets;
  77898. private _updateMeasures;
  77899. private _updateChildrenMeasures;
  77900. private _restoreMeasures;
  77901. /**
  77902. * Creates a new ScrollViewerWindow
  77903. * @param name of ScrollViewerWindow
  77904. */
  77905. constructor(name?: string);
  77906. protected _getTypeName(): string;
  77907. /** @hidden */
  77908. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77909. /** @hidden */
  77910. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77911. private _scrollChildren;
  77912. private _scrollChildrenWithBuckets;
  77913. /** @hidden */
  77914. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77915. protected _postMeasure(): void;
  77916. }
  77917. }
  77918. declare module BABYLON.GUI {
  77919. /**
  77920. * Class used to create slider controls
  77921. */
  77922. export class ScrollBar extends BaseSlider {
  77923. name?: string | undefined;
  77924. private _background;
  77925. private _borderColor;
  77926. private _tempMeasure;
  77927. /** Gets or sets border color */
  77928. get borderColor(): string;
  77929. set borderColor(value: string);
  77930. /** Gets or sets background color */
  77931. get background(): string;
  77932. set background(value: string);
  77933. /**
  77934. * Creates a new Slider
  77935. * @param name defines the control name
  77936. */
  77937. constructor(name?: string | undefined);
  77938. protected _getTypeName(): string;
  77939. protected _getThumbThickness(): number;
  77940. _draw(context: CanvasRenderingContext2D): void;
  77941. private _first;
  77942. private _originX;
  77943. private _originY;
  77944. /** @hidden */
  77945. protected _updateValueFromPointer(x: number, y: number): void;
  77946. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77947. }
  77948. }
  77949. declare module BABYLON.GUI {
  77950. /**
  77951. * Class used to create slider controls
  77952. */
  77953. export class ImageScrollBar extends BaseSlider {
  77954. name?: string | undefined;
  77955. private _backgroundBaseImage;
  77956. private _backgroundImage;
  77957. private _thumbImage;
  77958. private _thumbBaseImage;
  77959. private _thumbLength;
  77960. private _thumbHeight;
  77961. private _barImageHeight;
  77962. private _tempMeasure;
  77963. /** Number of 90° rotation to apply on the images when in vertical mode */
  77964. num90RotationInVerticalMode: number;
  77965. /**
  77966. * Gets or sets the image used to render the background for horizontal bar
  77967. */
  77968. get backgroundImage(): Image;
  77969. set backgroundImage(value: Image);
  77970. /**
  77971. * Gets or sets the image used to render the thumb
  77972. */
  77973. get thumbImage(): Image;
  77974. set thumbImage(value: Image);
  77975. /**
  77976. * Gets or sets the length of the thumb
  77977. */
  77978. get thumbLength(): number;
  77979. set thumbLength(value: number);
  77980. /**
  77981. * Gets or sets the height of the thumb
  77982. */
  77983. get thumbHeight(): number;
  77984. set thumbHeight(value: number);
  77985. /**
  77986. * Gets or sets the height of the bar image
  77987. */
  77988. get barImageHeight(): number;
  77989. set barImageHeight(value: number);
  77990. /**
  77991. * Creates a new ImageScrollBar
  77992. * @param name defines the control name
  77993. */
  77994. constructor(name?: string | undefined);
  77995. protected _getTypeName(): string;
  77996. protected _getThumbThickness(): number;
  77997. _draw(context: CanvasRenderingContext2D): void;
  77998. private _first;
  77999. private _originX;
  78000. private _originY;
  78001. /** @hidden */
  78002. protected _updateValueFromPointer(x: number, y: number): void;
  78003. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78004. }
  78005. }
  78006. declare module BABYLON.GUI {
  78007. /**
  78008. * Class used to hold a viewer window and sliders in a grid
  78009. */
  78010. export class ScrollViewer extends Rectangle {
  78011. private _grid;
  78012. private _horizontalBarSpace;
  78013. private _verticalBarSpace;
  78014. private _dragSpace;
  78015. private _horizontalBar;
  78016. private _verticalBar;
  78017. private _barColor;
  78018. private _barBackground;
  78019. private _barImage;
  78020. private _horizontalBarImage;
  78021. private _verticalBarImage;
  78022. private _barBackgroundImage;
  78023. private _horizontalBarBackgroundImage;
  78024. private _verticalBarBackgroundImage;
  78025. private _barSize;
  78026. private _window;
  78027. private _pointerIsOver;
  78028. private _wheelPrecision;
  78029. private _onWheelObserver;
  78030. private _clientWidth;
  78031. private _clientHeight;
  78032. private _useImageBar;
  78033. private _thumbLength;
  78034. private _thumbHeight;
  78035. private _barImageHeight;
  78036. private _horizontalBarImageHeight;
  78037. private _verticalBarImageHeight;
  78038. private _oldWindowContentsWidth;
  78039. private _oldWindowContentsHeight;
  78040. /**
  78041. * Gets the horizontal scrollbar
  78042. */
  78043. get horizontalBar(): ScrollBar | ImageScrollBar;
  78044. /**
  78045. * Gets the vertical scrollbar
  78046. */
  78047. get verticalBar(): ScrollBar | ImageScrollBar;
  78048. /**
  78049. * Adds a new control to the current container
  78050. * @param control defines the control to add
  78051. * @returns the current container
  78052. */
  78053. addControl(control: BABYLON.Nullable<Control>): Container;
  78054. /**
  78055. * Removes a control from the current container
  78056. * @param control defines the control to remove
  78057. * @returns the current container
  78058. */
  78059. removeControl(control: Control): Container;
  78060. /** Gets the list of children */
  78061. get children(): Control[];
  78062. _flagDescendantsAsMatrixDirty(): void;
  78063. /**
  78064. * Freezes or unfreezes the controls in the window.
  78065. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78066. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78067. */
  78068. get freezeControls(): boolean;
  78069. set freezeControls(value: boolean);
  78070. /** Gets the bucket width */
  78071. get bucketWidth(): number;
  78072. /** Gets the bucket height */
  78073. get bucketHeight(): number;
  78074. /**
  78075. * Sets the bucket sizes.
  78076. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78077. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78078. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78079. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78080. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78081. * used), that's why it is not enabled by default.
  78082. * @param width width of the bucket
  78083. * @param height height of the bucket
  78084. */
  78085. setBucketSizes(width: number, height: number): void;
  78086. private _forceHorizontalBar;
  78087. private _forceVerticalBar;
  78088. /**
  78089. * Forces the horizontal scroll bar to be displayed
  78090. */
  78091. get forceHorizontalBar(): boolean;
  78092. set forceHorizontalBar(value: boolean);
  78093. /**
  78094. * Forces the vertical scroll bar to be displayed
  78095. */
  78096. get forceVerticalBar(): boolean;
  78097. set forceVerticalBar(value: boolean);
  78098. /**
  78099. * Creates a new ScrollViewer
  78100. * @param name of ScrollViewer
  78101. */
  78102. constructor(name?: string, isImageBased?: boolean);
  78103. /** Reset the scroll viewer window to initial size */
  78104. resetWindow(): void;
  78105. protected _getTypeName(): string;
  78106. private _buildClientSizes;
  78107. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78108. protected _postMeasure(): void;
  78109. /**
  78110. * Gets or sets the mouse wheel precision
  78111. * from 0 to 1 with a default value of 0.05
  78112. * */
  78113. get wheelPrecision(): number;
  78114. set wheelPrecision(value: number);
  78115. /** Gets or sets the scroll bar container background color */
  78116. get scrollBackground(): string;
  78117. set scrollBackground(color: string);
  78118. /** Gets or sets the bar color */
  78119. get barColor(): string;
  78120. set barColor(color: string);
  78121. /** Gets or sets the bar image */
  78122. get thumbImage(): Image;
  78123. set thumbImage(value: Image);
  78124. /** Gets or sets the horizontal bar image */
  78125. get horizontalThumbImage(): Image;
  78126. set horizontalThumbImage(value: Image);
  78127. /** Gets or sets the vertical bar image */
  78128. get verticalThumbImage(): Image;
  78129. set verticalThumbImage(value: Image);
  78130. /** Gets or sets the size of the bar */
  78131. get barSize(): number;
  78132. set barSize(value: number);
  78133. /** Gets or sets the length of the thumb */
  78134. get thumbLength(): number;
  78135. set thumbLength(value: number);
  78136. /** Gets or sets the height of the thumb */
  78137. get thumbHeight(): number;
  78138. set thumbHeight(value: number);
  78139. /** Gets or sets the height of the bar image */
  78140. get barImageHeight(): number;
  78141. set barImageHeight(value: number);
  78142. /** Gets or sets the height of the horizontal bar image */
  78143. get horizontalBarImageHeight(): number;
  78144. set horizontalBarImageHeight(value: number);
  78145. /** Gets or sets the height of the vertical bar image */
  78146. get verticalBarImageHeight(): number;
  78147. set verticalBarImageHeight(value: number);
  78148. /** Gets or sets the bar background */
  78149. get barBackground(): string;
  78150. set barBackground(color: string);
  78151. /** Gets or sets the bar background image */
  78152. get barImage(): Image;
  78153. set barImage(value: Image);
  78154. /** Gets or sets the horizontal bar background image */
  78155. get horizontalBarImage(): Image;
  78156. set horizontalBarImage(value: Image);
  78157. /** Gets or sets the vertical bar background image */
  78158. get verticalBarImage(): Image;
  78159. set verticalBarImage(value: Image);
  78160. private _setWindowPosition;
  78161. /** @hidden */
  78162. private _updateScroller;
  78163. _link(host: AdvancedDynamicTexture): void;
  78164. /** @hidden */
  78165. private _addBar;
  78166. /** @hidden */
  78167. private _attachWheel;
  78168. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78169. /** Releases associated resources */
  78170. dispose(): void;
  78171. }
  78172. }
  78173. declare module BABYLON.GUI {
  78174. /** Class used to render a grid */
  78175. export class DisplayGrid extends Control {
  78176. name?: string | undefined;
  78177. private _cellWidth;
  78178. private _cellHeight;
  78179. private _minorLineTickness;
  78180. private _minorLineColor;
  78181. private _majorLineTickness;
  78182. private _majorLineColor;
  78183. private _majorLineFrequency;
  78184. private _background;
  78185. private _displayMajorLines;
  78186. private _displayMinorLines;
  78187. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78188. get displayMinorLines(): boolean;
  78189. set displayMinorLines(value: boolean);
  78190. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78191. get displayMajorLines(): boolean;
  78192. set displayMajorLines(value: boolean);
  78193. /** Gets or sets background color (Black by default) */
  78194. get background(): string;
  78195. set background(value: string);
  78196. /** Gets or sets the width of each cell (20 by default) */
  78197. get cellWidth(): number;
  78198. set cellWidth(value: number);
  78199. /** Gets or sets the height of each cell (20 by default) */
  78200. get cellHeight(): number;
  78201. set cellHeight(value: number);
  78202. /** Gets or sets the tickness of minor lines (1 by default) */
  78203. get minorLineTickness(): number;
  78204. set minorLineTickness(value: number);
  78205. /** Gets or sets the color of minor lines (DarkGray by default) */
  78206. get minorLineColor(): string;
  78207. set minorLineColor(value: string);
  78208. /** Gets or sets the tickness of major lines (2 by default) */
  78209. get majorLineTickness(): number;
  78210. set majorLineTickness(value: number);
  78211. /** Gets or sets the color of major lines (White by default) */
  78212. get majorLineColor(): string;
  78213. set majorLineColor(value: string);
  78214. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78215. get majorLineFrequency(): number;
  78216. set majorLineFrequency(value: number);
  78217. /**
  78218. * Creates a new GridDisplayRectangle
  78219. * @param name defines the control name
  78220. */
  78221. constructor(name?: string | undefined);
  78222. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78223. protected _getTypeName(): string;
  78224. }
  78225. }
  78226. declare module BABYLON.GUI {
  78227. /**
  78228. * Class used to create slider controls based on images
  78229. */
  78230. export class ImageBasedSlider extends BaseSlider {
  78231. name?: string | undefined;
  78232. private _backgroundImage;
  78233. private _thumbImage;
  78234. private _valueBarImage;
  78235. private _tempMeasure;
  78236. get displayThumb(): boolean;
  78237. set displayThumb(value: boolean);
  78238. /**
  78239. * Gets or sets the image used to render the background
  78240. */
  78241. get backgroundImage(): Image;
  78242. set backgroundImage(value: Image);
  78243. /**
  78244. * Gets or sets the image used to render the value bar
  78245. */
  78246. get valueBarImage(): Image;
  78247. set valueBarImage(value: Image);
  78248. /**
  78249. * Gets or sets the image used to render the thumb
  78250. */
  78251. get thumbImage(): Image;
  78252. set thumbImage(value: Image);
  78253. /**
  78254. * Creates a new ImageBasedSlider
  78255. * @param name defines the control name
  78256. */
  78257. constructor(name?: string | undefined);
  78258. protected _getTypeName(): string;
  78259. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78260. }
  78261. }
  78262. declare module BABYLON.GUI {
  78263. /**
  78264. * Forcing an export so that this code will execute
  78265. * @hidden
  78266. */
  78267. const name = "Statics";
  78268. }
  78269. declare module BABYLON.GUI {
  78270. /**
  78271. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78272. */
  78273. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78274. /**
  78275. * Define the instrumented AdvancedDynamicTexture.
  78276. */
  78277. texture: AdvancedDynamicTexture;
  78278. private _captureRenderTime;
  78279. private _renderTime;
  78280. private _captureLayoutTime;
  78281. private _layoutTime;
  78282. private _onBeginRenderObserver;
  78283. private _onEndRenderObserver;
  78284. private _onBeginLayoutObserver;
  78285. private _onEndLayoutObserver;
  78286. /**
  78287. * Gets the perf counter used to capture render time
  78288. */
  78289. get renderTimeCounter(): BABYLON.PerfCounter;
  78290. /**
  78291. * Gets the perf counter used to capture layout time
  78292. */
  78293. get layoutTimeCounter(): BABYLON.PerfCounter;
  78294. /**
  78295. * Enable or disable the render time capture
  78296. */
  78297. get captureRenderTime(): boolean;
  78298. set captureRenderTime(value: boolean);
  78299. /**
  78300. * Enable or disable the layout time capture
  78301. */
  78302. get captureLayoutTime(): boolean;
  78303. set captureLayoutTime(value: boolean);
  78304. /**
  78305. * Instantiates a new advanced dynamic texture instrumentation.
  78306. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78307. * @param texture Defines the AdvancedDynamicTexture to instrument
  78308. */
  78309. constructor(
  78310. /**
  78311. * Define the instrumented AdvancedDynamicTexture.
  78312. */
  78313. texture: AdvancedDynamicTexture);
  78314. /**
  78315. * Dispose and release associated resources.
  78316. */
  78317. dispose(): void;
  78318. }
  78319. }
  78320. declare module BABYLON.GUI {
  78321. /**
  78322. * Class used to load GUI via XML.
  78323. */
  78324. export class XmlLoader {
  78325. private _nodes;
  78326. private _nodeTypes;
  78327. private _isLoaded;
  78328. private _objectAttributes;
  78329. private _parentClass;
  78330. /**
  78331. * Create a new xml loader
  78332. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78333. */
  78334. constructor(parentClass?: null);
  78335. private _getChainElement;
  78336. private _getClassAttribute;
  78337. private _createGuiElement;
  78338. private _parseGrid;
  78339. private _parseElement;
  78340. private _prepareSourceElement;
  78341. private _parseElementsFromSource;
  78342. private _parseXml;
  78343. /**
  78344. * Gets if the loading has finished.
  78345. * @returns whether the loading has finished or not
  78346. */
  78347. isLoaded(): boolean;
  78348. /**
  78349. * Gets a loaded node / control by id.
  78350. * @param id the Controls id set in the xml
  78351. * @returns element of type Control
  78352. */
  78353. getNodeById(id: string): any;
  78354. /**
  78355. * Gets all loaded nodes / controls
  78356. * @returns Array of controls
  78357. */
  78358. getNodes(): any;
  78359. /**
  78360. * Initiates the xml layout loading
  78361. * @param xmlFile defines the xml layout to load
  78362. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78363. * @param callback defines the callback called on layout load.
  78364. */
  78365. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78366. }
  78367. }
  78368. declare module BABYLON.GUI {
  78369. /**
  78370. * Class used to create containers for controls
  78371. */
  78372. export class Container3D extends Control3D {
  78373. private _blockLayout;
  78374. /**
  78375. * Gets the list of child controls
  78376. */
  78377. protected _children: Control3D[];
  78378. /**
  78379. * Gets the list of child controls
  78380. */
  78381. get children(): Array<Control3D>;
  78382. /**
  78383. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78384. * This is helpful to optimize layout operation when adding multiple children in a row
  78385. */
  78386. get blockLayout(): boolean;
  78387. set blockLayout(value: boolean);
  78388. /**
  78389. * Creates a new container
  78390. * @param name defines the container name
  78391. */
  78392. constructor(name?: string);
  78393. /**
  78394. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78395. * @returns the current container
  78396. */
  78397. updateLayout(): Container3D;
  78398. /**
  78399. * Gets a boolean indicating if the given control is in the children of this control
  78400. * @param control defines the control to check
  78401. * @returns true if the control is in the child list
  78402. */
  78403. containsControl(control: Control3D): boolean;
  78404. /**
  78405. * Adds a control to the children of this control
  78406. * @param control defines the control to add
  78407. * @returns the current container
  78408. */
  78409. addControl(control: Control3D): Container3D;
  78410. /**
  78411. * This function will be called everytime a new control is added
  78412. */
  78413. protected _arrangeChildren(): void;
  78414. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78415. /**
  78416. * Removes a control from the children of this control
  78417. * @param control defines the control to remove
  78418. * @returns the current container
  78419. */
  78420. removeControl(control: Control3D): Container3D;
  78421. protected _getTypeName(): string;
  78422. /**
  78423. * Releases all associated resources
  78424. */
  78425. dispose(): void;
  78426. /** Control rotation will remain unchanged */
  78427. static readonly UNSET_ORIENTATION: number;
  78428. /** Control will rotate to make it look at sphere central axis */
  78429. static readonly FACEORIGIN_ORIENTATION: number;
  78430. /** Control will rotate to make it look back at sphere central axis */
  78431. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78432. /** Control will rotate to look at z axis (0, 0, 1) */
  78433. static readonly FACEFORWARD_ORIENTATION: number;
  78434. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78435. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78436. }
  78437. }
  78438. declare module BABYLON.GUI {
  78439. /**
  78440. * Class used to manage 3D user interface
  78441. * @see https://doc.babylonjs.com/how_to/gui3d
  78442. */
  78443. export class GUI3DManager implements BABYLON.IDisposable {
  78444. private _scene;
  78445. private _sceneDisposeObserver;
  78446. private _utilityLayer;
  78447. private _rootContainer;
  78448. private _pointerObserver;
  78449. private _pointerOutObserver;
  78450. /** @hidden */
  78451. _lastPickedControl: Control3D;
  78452. /** @hidden */
  78453. _lastControlOver: {
  78454. [pointerId: number]: Control3D;
  78455. };
  78456. /** @hidden */
  78457. _lastControlDown: {
  78458. [pointerId: number]: Control3D;
  78459. };
  78460. /**
  78461. * BABYLON.Observable raised when the point picked by the pointer events changed
  78462. */
  78463. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78464. /** @hidden */
  78465. _sharedMaterials: {
  78466. [key: string]: BABYLON.Material;
  78467. };
  78468. /** Gets the hosting scene */
  78469. get scene(): BABYLON.Scene;
  78470. /** Gets associated utility layer */
  78471. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78472. /**
  78473. * Creates a new GUI3DManager
  78474. * @param scene
  78475. */
  78476. constructor(scene?: BABYLON.Scene);
  78477. private _handlePointerOut;
  78478. private _doPicking;
  78479. /**
  78480. * Gets the root container
  78481. */
  78482. get rootContainer(): Container3D;
  78483. /**
  78484. * Gets a boolean indicating if the given control is in the root child list
  78485. * @param control defines the control to check
  78486. * @returns true if the control is in the root child list
  78487. */
  78488. containsControl(control: Control3D): boolean;
  78489. /**
  78490. * Adds a control to the root child list
  78491. * @param control defines the control to add
  78492. * @returns the current manager
  78493. */
  78494. addControl(control: Control3D): GUI3DManager;
  78495. /**
  78496. * Removes a control from the root child list
  78497. * @param control defines the control to remove
  78498. * @returns the current container
  78499. */
  78500. removeControl(control: Control3D): GUI3DManager;
  78501. /**
  78502. * Releases all associated resources
  78503. */
  78504. dispose(): void;
  78505. }
  78506. }
  78507. declare module BABYLON.GUI {
  78508. /**
  78509. * Class used to transport BABYLON.Vector3 information for pointer events
  78510. */
  78511. export class Vector3WithInfo extends BABYLON.Vector3 {
  78512. /** defines the current mouse button index */
  78513. buttonIndex: number;
  78514. /**
  78515. * Creates a new Vector3WithInfo
  78516. * @param source defines the vector3 data to transport
  78517. * @param buttonIndex defines the current mouse button index
  78518. */
  78519. constructor(source: BABYLON.Vector3,
  78520. /** defines the current mouse button index */
  78521. buttonIndex?: number);
  78522. }
  78523. }
  78524. declare module BABYLON.GUI {
  78525. /**
  78526. * Class used as base class for controls
  78527. */
  78528. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78529. /** Defines the control name */
  78530. name?: string | undefined;
  78531. /** @hidden */
  78532. _host: GUI3DManager;
  78533. private _node;
  78534. private _downCount;
  78535. private _enterCount;
  78536. private _downPointerIds;
  78537. private _isVisible;
  78538. /** Gets or sets the control position in world space */
  78539. get position(): BABYLON.Vector3;
  78540. set position(value: BABYLON.Vector3);
  78541. /** Gets or sets the control scaling in world space */
  78542. get scaling(): BABYLON.Vector3;
  78543. set scaling(value: BABYLON.Vector3);
  78544. /** Callback used to start pointer enter animation */
  78545. pointerEnterAnimation: () => void;
  78546. /** Callback used to start pointer out animation */
  78547. pointerOutAnimation: () => void;
  78548. /** Callback used to start pointer down animation */
  78549. pointerDownAnimation: () => void;
  78550. /** Callback used to start pointer up animation */
  78551. pointerUpAnimation: () => void;
  78552. /**
  78553. * An event triggered when the pointer move over the control
  78554. */
  78555. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78556. /**
  78557. * An event triggered when the pointer move out of the control
  78558. */
  78559. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78560. /**
  78561. * An event triggered when the pointer taps the control
  78562. */
  78563. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78564. /**
  78565. * An event triggered when pointer is up
  78566. */
  78567. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78568. /**
  78569. * An event triggered when a control is clicked on (with a mouse)
  78570. */
  78571. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78572. /**
  78573. * An event triggered when pointer enters the control
  78574. */
  78575. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78576. /**
  78577. * Gets or sets the parent container
  78578. */
  78579. parent: BABYLON.Nullable<Container3D>;
  78580. private _behaviors;
  78581. /**
  78582. * Gets the list of attached behaviors
  78583. * @see https://doc.babylonjs.com/features/behaviour
  78584. */
  78585. get behaviors(): BABYLON.Behavior<Control3D>[];
  78586. /**
  78587. * Attach a behavior to the control
  78588. * @see https://doc.babylonjs.com/features/behaviour
  78589. * @param behavior defines the behavior to attach
  78590. * @returns the current control
  78591. */
  78592. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78593. /**
  78594. * Remove an attached behavior
  78595. * @see https://doc.babylonjs.com/features/behaviour
  78596. * @param behavior defines the behavior to attach
  78597. * @returns the current control
  78598. */
  78599. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78600. /**
  78601. * Gets an attached behavior by name
  78602. * @param name defines the name of the behavior to look for
  78603. * @see https://doc.babylonjs.com/features/behaviour
  78604. * @returns null if behavior was not found else the requested behavior
  78605. */
  78606. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78607. /** Gets or sets a boolean indicating if the control is visible */
  78608. get isVisible(): boolean;
  78609. set isVisible(value: boolean);
  78610. /**
  78611. * Creates a new control
  78612. * @param name defines the control name
  78613. */
  78614. constructor(
  78615. /** Defines the control name */
  78616. name?: string | undefined);
  78617. /**
  78618. * Gets a string representing the class name
  78619. */
  78620. get typeName(): string;
  78621. /**
  78622. * Get the current class name of the control.
  78623. * @returns current class name
  78624. */
  78625. getClassName(): string;
  78626. protected _getTypeName(): string;
  78627. /**
  78628. * Gets the transform node used by this control
  78629. */
  78630. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78631. /**
  78632. * Gets the mesh used to render this control
  78633. */
  78634. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78635. /**
  78636. * Link the control as child of the given node
  78637. * @param node defines the node to link to. Use null to unlink the control
  78638. * @returns the current control
  78639. */
  78640. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78641. /** @hidden **/
  78642. _prepareNode(scene: BABYLON.Scene): void;
  78643. /**
  78644. * Node creation.
  78645. * Can be overriden by children
  78646. * @param scene defines the scene where the node must be attached
  78647. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78648. */
  78649. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78650. /**
  78651. * Affect a material to the given mesh
  78652. * @param mesh defines the mesh which will represent the control
  78653. */
  78654. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78655. /** @hidden */
  78656. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78657. /** @hidden */
  78658. _onPointerEnter(target: Control3D): boolean;
  78659. /** @hidden */
  78660. _onPointerOut(target: Control3D): void;
  78661. /** @hidden */
  78662. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78663. /** @hidden */
  78664. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78665. /** @hidden */
  78666. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78667. /** @hidden */
  78668. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78669. /** @hidden */
  78670. _disposeNode(): void;
  78671. /**
  78672. * Releases all associated resources
  78673. */
  78674. dispose(): void;
  78675. }
  78676. }
  78677. declare module BABYLON.GUI {
  78678. /**
  78679. * Class used as a root to all buttons
  78680. */
  78681. export class AbstractButton3D extends Control3D {
  78682. /**
  78683. * Creates a new button
  78684. * @param name defines the control name
  78685. */
  78686. constructor(name?: string);
  78687. protected _getTypeName(): string;
  78688. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78689. }
  78690. }
  78691. declare module BABYLON.GUI {
  78692. /**
  78693. * Class used to create a button in 3D
  78694. */
  78695. export class Button3D extends AbstractButton3D {
  78696. /** @hidden */
  78697. protected _currentMaterial: BABYLON.Material;
  78698. private _facadeTexture;
  78699. private _content;
  78700. private _contentResolution;
  78701. private _contentScaleRatio;
  78702. /**
  78703. * Gets or sets the texture resolution used to render content (512 by default)
  78704. */
  78705. get contentResolution(): BABYLON.int;
  78706. set contentResolution(value: BABYLON.int);
  78707. /**
  78708. * Gets or sets the texture scale ratio used to render content (2 by default)
  78709. */
  78710. get contentScaleRatio(): number;
  78711. set contentScaleRatio(value: number);
  78712. protected _disposeFacadeTexture(): void;
  78713. protected _resetContent(): void;
  78714. /**
  78715. * Creates a new button
  78716. * @param name defines the control name
  78717. */
  78718. constructor(name?: string);
  78719. /**
  78720. * Gets or sets the GUI 2D content used to display the button's facade
  78721. */
  78722. get content(): Control;
  78723. set content(value: Control);
  78724. /**
  78725. * Apply the facade texture (created from the content property).
  78726. * This function can be overloaded by child classes
  78727. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78728. */
  78729. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78730. protected _getTypeName(): string;
  78731. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78732. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78733. /**
  78734. * Releases all associated resources
  78735. */
  78736. dispose(): void;
  78737. }
  78738. }
  78739. declare module BABYLON.GUI {
  78740. /**
  78741. * Abstract class used to create a container panel deployed on the surface of a volume
  78742. */
  78743. export abstract class VolumeBasedPanel extends Container3D {
  78744. private _columns;
  78745. private _rows;
  78746. private _rowThenColum;
  78747. private _orientation;
  78748. protected _cellWidth: number;
  78749. protected _cellHeight: number;
  78750. /**
  78751. * Gets or sets the distance between elements
  78752. */
  78753. margin: number;
  78754. /**
  78755. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78756. * | Value | Type | Description |
  78757. * | ----- | ----------------------------------- | ----------- |
  78758. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78759. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78760. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78761. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78762. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78763. */
  78764. get orientation(): number;
  78765. set orientation(value: number);
  78766. /**
  78767. * Gets or sets the number of columns requested (10 by default).
  78768. * The panel will automatically compute the number of rows based on number of child controls.
  78769. */
  78770. get columns(): BABYLON.int;
  78771. set columns(value: BABYLON.int);
  78772. /**
  78773. * Gets or sets a the number of rows requested.
  78774. * The panel will automatically compute the number of columns based on number of child controls.
  78775. */
  78776. get rows(): BABYLON.int;
  78777. set rows(value: BABYLON.int);
  78778. /**
  78779. * Creates new VolumeBasedPanel
  78780. */
  78781. constructor();
  78782. protected _arrangeChildren(): void;
  78783. /** Child classes must implement this function to provide correct control positioning */
  78784. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78785. /** Child classes can implement this function to provide additional processing */
  78786. protected _finalProcessing(): void;
  78787. }
  78788. }
  78789. declare module BABYLON.GUI {
  78790. /**
  78791. * Class used to create a container panel deployed on the surface of a cylinder
  78792. */
  78793. export class CylinderPanel extends VolumeBasedPanel {
  78794. private _radius;
  78795. /**
  78796. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78797. */
  78798. get radius(): BABYLON.float;
  78799. set radius(value: BABYLON.float);
  78800. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78801. private _cylindricalMapping;
  78802. }
  78803. }
  78804. declare module BABYLON.GUI {
  78805. /** @hidden */
  78806. export var fluentVertexShader: {
  78807. name: string;
  78808. shader: string;
  78809. };
  78810. }
  78811. declare module BABYLON.GUI {
  78812. /** @hidden */
  78813. export var fluentPixelShader: {
  78814. name: string;
  78815. shader: string;
  78816. };
  78817. }
  78818. declare module BABYLON.GUI {
  78819. /** @hidden */
  78820. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78821. INNERGLOW: boolean;
  78822. BORDER: boolean;
  78823. HOVERLIGHT: boolean;
  78824. TEXTURE: boolean;
  78825. constructor();
  78826. }
  78827. /**
  78828. * Class used to render controls with fluent desgin
  78829. */
  78830. export class FluentMaterial extends BABYLON.PushMaterial {
  78831. /**
  78832. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78833. */
  78834. innerGlowColorIntensity: number;
  78835. /**
  78836. * Gets or sets the inner glow color (white by default)
  78837. */
  78838. innerGlowColor: BABYLON.Color3;
  78839. /**
  78840. * Gets or sets alpha value (default is 1.0)
  78841. */
  78842. alpha: number;
  78843. /**
  78844. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78845. */
  78846. albedoColor: BABYLON.Color3;
  78847. /**
  78848. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78849. */
  78850. renderBorders: boolean;
  78851. /**
  78852. * Gets or sets border width (default is 0.5)
  78853. */
  78854. borderWidth: number;
  78855. /**
  78856. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78857. */
  78858. edgeSmoothingValue: number;
  78859. /**
  78860. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78861. */
  78862. borderMinValue: number;
  78863. /**
  78864. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78865. */
  78866. renderHoverLight: boolean;
  78867. /**
  78868. * Gets or sets the radius used to render the hover light (default is 1.0)
  78869. */
  78870. hoverRadius: number;
  78871. /**
  78872. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78873. */
  78874. hoverColor: BABYLON.Color4;
  78875. /**
  78876. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78877. */
  78878. hoverPosition: BABYLON.Vector3;
  78879. private _albedoTexture;
  78880. /** Gets or sets the texture to use for albedo color */
  78881. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78882. /**
  78883. * Creates a new Fluent material
  78884. * @param name defines the name of the material
  78885. * @param scene defines the hosting scene
  78886. */
  78887. constructor(name: string, scene: BABYLON.Scene);
  78888. needAlphaBlending(): boolean;
  78889. needAlphaTesting(): boolean;
  78890. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78893. getActiveTextures(): BABYLON.BaseTexture[];
  78894. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78895. dispose(forceDisposeEffect?: boolean): void;
  78896. clone(name: string): FluentMaterial;
  78897. serialize(): any;
  78898. getClassName(): string;
  78899. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78900. }
  78901. }
  78902. declare module BABYLON.GUI {
  78903. /**
  78904. * Class used to create a holographic button in 3D
  78905. */
  78906. export class HolographicButton extends Button3D {
  78907. private _backPlate;
  78908. private _textPlate;
  78909. private _frontPlate;
  78910. private _text;
  78911. private _imageUrl;
  78912. private _shareMaterials;
  78913. private _frontMaterial;
  78914. private _backMaterial;
  78915. private _plateMaterial;
  78916. private _pickedPointObserver;
  78917. private _tooltipFade;
  78918. private _tooltipTextBlock;
  78919. private _tooltipTexture;
  78920. private _tooltipMesh;
  78921. private _tooltipHoverObserver;
  78922. private _tooltipOutObserver;
  78923. private _disposeTooltip;
  78924. /**
  78925. * Rendering ground id of all the mesh in the button
  78926. */
  78927. set renderingGroupId(id: number);
  78928. get renderingGroupId(): number;
  78929. /**
  78930. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78931. */
  78932. set tooltipText(text: BABYLON.Nullable<string>);
  78933. get tooltipText(): BABYLON.Nullable<string>;
  78934. /**
  78935. * Gets or sets text for the button
  78936. */
  78937. get text(): string;
  78938. set text(value: string);
  78939. /**
  78940. * Gets or sets the image url for the button
  78941. */
  78942. get imageUrl(): string;
  78943. set imageUrl(value: string);
  78944. /**
  78945. * Gets the back material used by this button
  78946. */
  78947. get backMaterial(): FluentMaterial;
  78948. /**
  78949. * Gets the front material used by this button
  78950. */
  78951. get frontMaterial(): FluentMaterial;
  78952. /**
  78953. * Gets the plate material used by this button
  78954. */
  78955. get plateMaterial(): BABYLON.StandardMaterial;
  78956. /**
  78957. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78958. */
  78959. get shareMaterials(): boolean;
  78960. /**
  78961. * Creates a new button
  78962. * @param name defines the control name
  78963. */
  78964. constructor(name?: string, shareMaterials?: boolean);
  78965. protected _getTypeName(): string;
  78966. private _rebuildContent;
  78967. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78968. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78969. private _createBackMaterial;
  78970. private _createFrontMaterial;
  78971. private _createPlateMaterial;
  78972. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78973. /**
  78974. * Releases all associated resources
  78975. */
  78976. dispose(): void;
  78977. }
  78978. }
  78979. declare module BABYLON.GUI {
  78980. /**
  78981. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78982. */
  78983. export class MeshButton3D extends Button3D {
  78984. /** @hidden */
  78985. protected _currentMesh: BABYLON.Mesh;
  78986. /**
  78987. * Creates a new 3D button based on a mesh
  78988. * @param mesh mesh to become a 3D button
  78989. * @param name defines the control name
  78990. */
  78991. constructor(mesh: BABYLON.Mesh, name?: string);
  78992. protected _getTypeName(): string;
  78993. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78994. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78995. }
  78996. }
  78997. declare module BABYLON.GUI {
  78998. /**
  78999. * Class used to create a container panel deployed on the surface of a plane
  79000. */
  79001. export class PlanePanel extends VolumeBasedPanel {
  79002. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79003. }
  79004. }
  79005. declare module BABYLON.GUI {
  79006. /**
  79007. * Class used to create a container panel where items get randomized planar mapping
  79008. */
  79009. export class ScatterPanel extends VolumeBasedPanel {
  79010. private _iteration;
  79011. /**
  79012. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79013. */
  79014. get iteration(): BABYLON.float;
  79015. set iteration(value: BABYLON.float);
  79016. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79017. private _scatterMapping;
  79018. protected _finalProcessing(): void;
  79019. }
  79020. }
  79021. declare module BABYLON.GUI {
  79022. /**
  79023. * Class used to create a container panel deployed on the surface of a sphere
  79024. */
  79025. export class SpherePanel extends VolumeBasedPanel {
  79026. private _radius;
  79027. /**
  79028. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79029. */
  79030. get radius(): BABYLON.float;
  79031. set radius(value: BABYLON.float);
  79032. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79033. private _sphericalMapping;
  79034. }
  79035. }
  79036. declare module BABYLON.GUI {
  79037. /**
  79038. * Class used to create a stack panel in 3D on XY plane
  79039. */
  79040. export class StackPanel3D extends Container3D {
  79041. private _isVertical;
  79042. /**
  79043. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79044. */
  79045. get isVertical(): boolean;
  79046. set isVertical(value: boolean);
  79047. /**
  79048. * Gets or sets the distance between elements
  79049. */
  79050. margin: number;
  79051. /**
  79052. * Creates new StackPanel
  79053. * @param isVertical
  79054. */
  79055. constructor(isVertical?: boolean);
  79056. protected _arrangeChildren(): void;
  79057. }
  79058. }
  79059. declare module BABYLON {
  79060. /**
  79061. * Configuration for glTF validation
  79062. */
  79063. export interface IGLTFValidationConfiguration {
  79064. /**
  79065. * The url of the glTF validator.
  79066. */
  79067. url: string;
  79068. }
  79069. /**
  79070. * glTF validation
  79071. */
  79072. export class GLTFValidation {
  79073. /**
  79074. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79075. */
  79076. static Configuration: IGLTFValidationConfiguration;
  79077. private static _LoadScriptPromise;
  79078. /**
  79079. * Validate a glTF asset using the glTF-Validator.
  79080. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79081. * @param rootUrl The root url for the glTF
  79082. * @param fileName The file name for the glTF
  79083. * @param getExternalResource The callback to get external resources for the glTF validator
  79084. * @returns A promise that resolves with the glTF validation results once complete
  79085. */
  79086. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79087. }
  79088. }
  79089. declare module BABYLON {
  79090. /**
  79091. * Mode that determines the coordinate system to use.
  79092. */
  79093. export enum GLTFLoaderCoordinateSystemMode {
  79094. /**
  79095. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79096. */
  79097. AUTO = 0,
  79098. /**
  79099. * Sets the useRightHandedSystem flag on the scene.
  79100. */
  79101. FORCE_RIGHT_HANDED = 1
  79102. }
  79103. /**
  79104. * Mode that determines what animations will start.
  79105. */
  79106. export enum GLTFLoaderAnimationStartMode {
  79107. /**
  79108. * No animation will start.
  79109. */
  79110. NONE = 0,
  79111. /**
  79112. * The first animation will start.
  79113. */
  79114. FIRST = 1,
  79115. /**
  79116. * All animations will start.
  79117. */
  79118. ALL = 2
  79119. }
  79120. /**
  79121. * Interface that contains the data for the glTF asset.
  79122. */
  79123. export interface IGLTFLoaderData {
  79124. /**
  79125. * The object that represents the glTF JSON.
  79126. */
  79127. json: Object;
  79128. /**
  79129. * The BIN chunk of a binary glTF.
  79130. */
  79131. bin: Nullable<IDataBuffer>;
  79132. }
  79133. /**
  79134. * Interface for extending the loader.
  79135. */
  79136. export interface IGLTFLoaderExtension {
  79137. /**
  79138. * The name of this extension.
  79139. */
  79140. readonly name: string;
  79141. /**
  79142. * Defines whether this extension is enabled.
  79143. */
  79144. enabled: boolean;
  79145. /**
  79146. * Defines the order of this extension.
  79147. * The loader sorts the extensions using these values when loading.
  79148. */
  79149. order?: number;
  79150. }
  79151. /**
  79152. * Loader state.
  79153. */
  79154. export enum GLTFLoaderState {
  79155. /**
  79156. * The asset is loading.
  79157. */
  79158. LOADING = 0,
  79159. /**
  79160. * The asset is ready for rendering.
  79161. */
  79162. READY = 1,
  79163. /**
  79164. * The asset is completely loaded.
  79165. */
  79166. COMPLETE = 2
  79167. }
  79168. /** @hidden */
  79169. export interface IImportMeshAsyncOutput {
  79170. meshes: AbstractMesh[];
  79171. particleSystems: IParticleSystem[];
  79172. skeletons: Skeleton[];
  79173. animationGroups: AnimationGroup[];
  79174. lights: Light[];
  79175. transformNodes: TransformNode[];
  79176. }
  79177. /** @hidden */
  79178. export interface IGLTFLoader extends IDisposable {
  79179. readonly state: Nullable<GLTFLoaderState>;
  79180. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79181. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79182. }
  79183. /**
  79184. * File loader for loading glTF files into a scene.
  79185. */
  79186. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79187. /** @hidden */
  79188. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79189. /** @hidden */
  79190. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79191. /**
  79192. * Raised when the asset has been parsed
  79193. */
  79194. onParsedObservable: Observable<IGLTFLoaderData>;
  79195. private _onParsedObserver;
  79196. /**
  79197. * Raised when the asset has been parsed
  79198. */
  79199. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79200. /**
  79201. * 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.
  79202. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79203. * Defaults to true.
  79204. * @hidden
  79205. */
  79206. static IncrementalLoading: boolean;
  79207. /**
  79208. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79209. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79210. * @hidden
  79211. */
  79212. static HomogeneousCoordinates: boolean;
  79213. /**
  79214. * The coordinate system mode. Defaults to AUTO.
  79215. */
  79216. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79217. /**
  79218. * The animation start mode. Defaults to FIRST.
  79219. */
  79220. animationStartMode: GLTFLoaderAnimationStartMode;
  79221. /**
  79222. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79223. */
  79224. compileMaterials: boolean;
  79225. /**
  79226. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79227. */
  79228. useClipPlane: boolean;
  79229. /**
  79230. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79231. */
  79232. compileShadowGenerators: boolean;
  79233. /**
  79234. * Defines if the Alpha blended materials are only applied as coverage.
  79235. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79236. * If true, no extra effects are applied to transparent pixels.
  79237. */
  79238. transparencyAsCoverage: boolean;
  79239. /**
  79240. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79241. * Enabling will disable offline support and glTF validator.
  79242. * Defaults to false.
  79243. */
  79244. useRangeRequests: boolean;
  79245. /**
  79246. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79247. */
  79248. createInstances: boolean;
  79249. /**
  79250. * 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.
  79251. */
  79252. alwaysComputeBoundingBox: boolean;
  79253. /**
  79254. * Function called before loading a url referenced by the asset.
  79255. */
  79256. preprocessUrlAsync: (url: string) => Promise<string>;
  79257. /**
  79258. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79259. */
  79260. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79261. private _onMeshLoadedObserver;
  79262. /**
  79263. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79264. */
  79265. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79266. /**
  79267. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79268. */
  79269. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79270. private _onTextureLoadedObserver;
  79271. /**
  79272. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79273. */
  79274. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79275. /**
  79276. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79277. */
  79278. readonly onMaterialLoadedObservable: Observable<Material>;
  79279. private _onMaterialLoadedObserver;
  79280. /**
  79281. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79282. */
  79283. set onMaterialLoaded(callback: (material: Material) => void);
  79284. /**
  79285. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79286. */
  79287. readonly onCameraLoadedObservable: Observable<Camera>;
  79288. private _onCameraLoadedObserver;
  79289. /**
  79290. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79291. */
  79292. set onCameraLoaded(callback: (camera: Camera) => void);
  79293. /**
  79294. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79295. * For assets with LODs, raised when all of the LODs are complete.
  79296. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79297. */
  79298. readonly onCompleteObservable: Observable<void>;
  79299. private _onCompleteObserver;
  79300. /**
  79301. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79302. * For assets with LODs, raised when all of the LODs are complete.
  79303. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79304. */
  79305. set onComplete(callback: () => void);
  79306. /**
  79307. * Observable raised when an error occurs.
  79308. */
  79309. readonly onErrorObservable: Observable<any>;
  79310. private _onErrorObserver;
  79311. /**
  79312. * Callback raised when an error occurs.
  79313. */
  79314. set onError(callback: (reason: any) => void);
  79315. /**
  79316. * Observable raised after the loader is disposed.
  79317. */
  79318. readonly onDisposeObservable: Observable<void>;
  79319. private _onDisposeObserver;
  79320. /**
  79321. * Callback raised after the loader is disposed.
  79322. */
  79323. set onDispose(callback: () => void);
  79324. /**
  79325. * Observable raised after a loader extension is created.
  79326. * Set additional options for a loader extension in this event.
  79327. */
  79328. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79329. private _onExtensionLoadedObserver;
  79330. /**
  79331. * Callback raised after a loader extension is created.
  79332. */
  79333. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79334. /**
  79335. * Defines if the loader logging is enabled.
  79336. */
  79337. get loggingEnabled(): boolean;
  79338. set loggingEnabled(value: boolean);
  79339. /**
  79340. * Defines if the loader should capture performance counters.
  79341. */
  79342. get capturePerformanceCounters(): boolean;
  79343. set capturePerformanceCounters(value: boolean);
  79344. /**
  79345. * Defines if the loader should validate the asset.
  79346. */
  79347. validate: boolean;
  79348. /**
  79349. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79350. */
  79351. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79352. private _onValidatedObserver;
  79353. /**
  79354. * Callback raised after a loader extension is created.
  79355. */
  79356. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79357. private _loader;
  79358. private _progressCallback?;
  79359. private _requests;
  79360. private static magicBase64Encoded;
  79361. /**
  79362. * Name of the loader ("gltf")
  79363. */
  79364. name: string;
  79365. /** @hidden */
  79366. extensions: ISceneLoaderPluginExtensions;
  79367. /**
  79368. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79369. */
  79370. dispose(): void;
  79371. /** @hidden */
  79372. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79373. /** @hidden */
  79374. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79375. /** @hidden */
  79376. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79377. meshes: AbstractMesh[];
  79378. particleSystems: IParticleSystem[];
  79379. skeletons: Skeleton[];
  79380. animationGroups: AnimationGroup[];
  79381. }>;
  79382. /** @hidden */
  79383. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79384. /** @hidden */
  79385. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79386. /** @hidden */
  79387. canDirectLoad(data: string): boolean;
  79388. /** @hidden */
  79389. directLoad(scene: Scene, data: string): Promise<any>;
  79390. /**
  79391. * The callback that allows custom handling of the root url based on the response url.
  79392. * @param rootUrl the original root url
  79393. * @param responseURL the response url if available
  79394. * @returns the new root url
  79395. */
  79396. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79397. /** @hidden */
  79398. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79399. /**
  79400. * The loader state or null if the loader is not active.
  79401. */
  79402. get loaderState(): Nullable<GLTFLoaderState>;
  79403. /**
  79404. * Returns a promise that resolves when the asset is completely loaded.
  79405. * @returns a promise that resolves when the asset is completely loaded.
  79406. */
  79407. whenCompleteAsync(): Promise<void>;
  79408. /** @hidden */
  79409. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79410. /** @hidden */
  79411. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79412. private _onProgress;
  79413. private _validate;
  79414. private _getLoader;
  79415. private _parseJson;
  79416. private _unpackBinaryAsync;
  79417. private _unpackBinaryV1Async;
  79418. private _unpackBinaryV2Async;
  79419. private static _parseVersion;
  79420. private static _compareVersion;
  79421. private static readonly _logSpaces;
  79422. private _logIndentLevel;
  79423. private _loggingEnabled;
  79424. /** @hidden */
  79425. _log: (message: string) => void;
  79426. /** @hidden */
  79427. _logOpen(message: string): void;
  79428. /** @hidden */
  79429. _logClose(): void;
  79430. private _logEnabled;
  79431. private _logDisabled;
  79432. private _capturePerformanceCounters;
  79433. /** @hidden */
  79434. _startPerformanceCounter: (counterName: string) => void;
  79435. /** @hidden */
  79436. _endPerformanceCounter: (counterName: string) => void;
  79437. private _startPerformanceCounterEnabled;
  79438. private _startPerformanceCounterDisabled;
  79439. private _endPerformanceCounterEnabled;
  79440. private _endPerformanceCounterDisabled;
  79441. }
  79442. }
  79443. declare module BABYLON.GLTF1 {
  79444. /**
  79445. * Enums
  79446. * @hidden
  79447. */
  79448. export enum EComponentType {
  79449. BYTE = 5120,
  79450. UNSIGNED_BYTE = 5121,
  79451. SHORT = 5122,
  79452. UNSIGNED_SHORT = 5123,
  79453. FLOAT = 5126
  79454. }
  79455. /** @hidden */
  79456. export enum EShaderType {
  79457. FRAGMENT = 35632,
  79458. VERTEX = 35633
  79459. }
  79460. /** @hidden */
  79461. export enum EParameterType {
  79462. BYTE = 5120,
  79463. UNSIGNED_BYTE = 5121,
  79464. SHORT = 5122,
  79465. UNSIGNED_SHORT = 5123,
  79466. INT = 5124,
  79467. UNSIGNED_INT = 5125,
  79468. FLOAT = 5126,
  79469. FLOAT_VEC2 = 35664,
  79470. FLOAT_VEC3 = 35665,
  79471. FLOAT_VEC4 = 35666,
  79472. INT_VEC2 = 35667,
  79473. INT_VEC3 = 35668,
  79474. INT_VEC4 = 35669,
  79475. BOOL = 35670,
  79476. BOOL_VEC2 = 35671,
  79477. BOOL_VEC3 = 35672,
  79478. BOOL_VEC4 = 35673,
  79479. FLOAT_MAT2 = 35674,
  79480. FLOAT_MAT3 = 35675,
  79481. FLOAT_MAT4 = 35676,
  79482. SAMPLER_2D = 35678
  79483. }
  79484. /** @hidden */
  79485. export enum ETextureWrapMode {
  79486. CLAMP_TO_EDGE = 33071,
  79487. MIRRORED_REPEAT = 33648,
  79488. REPEAT = 10497
  79489. }
  79490. /** @hidden */
  79491. export enum ETextureFilterType {
  79492. NEAREST = 9728,
  79493. LINEAR = 9728,
  79494. NEAREST_MIPMAP_NEAREST = 9984,
  79495. LINEAR_MIPMAP_NEAREST = 9985,
  79496. NEAREST_MIPMAP_LINEAR = 9986,
  79497. LINEAR_MIPMAP_LINEAR = 9987
  79498. }
  79499. /** @hidden */
  79500. export enum ETextureFormat {
  79501. ALPHA = 6406,
  79502. RGB = 6407,
  79503. RGBA = 6408,
  79504. LUMINANCE = 6409,
  79505. LUMINANCE_ALPHA = 6410
  79506. }
  79507. /** @hidden */
  79508. export enum ECullingType {
  79509. FRONT = 1028,
  79510. BACK = 1029,
  79511. FRONT_AND_BACK = 1032
  79512. }
  79513. /** @hidden */
  79514. export enum EBlendingFunction {
  79515. ZERO = 0,
  79516. ONE = 1,
  79517. SRC_COLOR = 768,
  79518. ONE_MINUS_SRC_COLOR = 769,
  79519. DST_COLOR = 774,
  79520. ONE_MINUS_DST_COLOR = 775,
  79521. SRC_ALPHA = 770,
  79522. ONE_MINUS_SRC_ALPHA = 771,
  79523. DST_ALPHA = 772,
  79524. ONE_MINUS_DST_ALPHA = 773,
  79525. CONSTANT_COLOR = 32769,
  79526. ONE_MINUS_CONSTANT_COLOR = 32770,
  79527. CONSTANT_ALPHA = 32771,
  79528. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79529. SRC_ALPHA_SATURATE = 776
  79530. }
  79531. /** @hidden */
  79532. export interface IGLTFProperty {
  79533. extensions?: {
  79534. [key: string]: any;
  79535. };
  79536. extras?: Object;
  79537. }
  79538. /** @hidden */
  79539. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79540. name?: string;
  79541. }
  79542. /** @hidden */
  79543. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79544. bufferView: string;
  79545. byteOffset: number;
  79546. byteStride: number;
  79547. count: number;
  79548. type: string;
  79549. componentType: EComponentType;
  79550. max?: number[];
  79551. min?: number[];
  79552. name?: string;
  79553. }
  79554. /** @hidden */
  79555. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79556. buffer: string;
  79557. byteOffset: number;
  79558. byteLength: number;
  79559. byteStride: number;
  79560. target?: number;
  79561. }
  79562. /** @hidden */
  79563. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79564. uri: string;
  79565. byteLength?: number;
  79566. type?: string;
  79567. }
  79568. /** @hidden */
  79569. export interface IGLTFShader extends IGLTFChildRootProperty {
  79570. uri: string;
  79571. type: EShaderType;
  79572. }
  79573. /** @hidden */
  79574. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79575. attributes: string[];
  79576. fragmentShader: string;
  79577. vertexShader: string;
  79578. }
  79579. /** @hidden */
  79580. export interface IGLTFTechniqueParameter {
  79581. type: number;
  79582. count?: number;
  79583. semantic?: string;
  79584. node?: string;
  79585. value?: number | boolean | string | Array<any>;
  79586. source?: string;
  79587. babylonValue?: any;
  79588. }
  79589. /** @hidden */
  79590. export interface IGLTFTechniqueCommonProfile {
  79591. lightingModel: string;
  79592. texcoordBindings: Object;
  79593. parameters?: Array<any>;
  79594. }
  79595. /** @hidden */
  79596. export interface IGLTFTechniqueStatesFunctions {
  79597. blendColor?: number[];
  79598. blendEquationSeparate?: number[];
  79599. blendFuncSeparate?: number[];
  79600. colorMask: boolean[];
  79601. cullFace: number[];
  79602. }
  79603. /** @hidden */
  79604. export interface IGLTFTechniqueStates {
  79605. enable: number[];
  79606. functions: IGLTFTechniqueStatesFunctions;
  79607. }
  79608. /** @hidden */
  79609. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79610. parameters: {
  79611. [key: string]: IGLTFTechniqueParameter;
  79612. };
  79613. program: string;
  79614. attributes: {
  79615. [key: string]: string;
  79616. };
  79617. uniforms: {
  79618. [key: string]: string;
  79619. };
  79620. states: IGLTFTechniqueStates;
  79621. }
  79622. /** @hidden */
  79623. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79624. technique?: string;
  79625. values: string[];
  79626. }
  79627. /** @hidden */
  79628. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79629. attributes: {
  79630. [key: string]: string;
  79631. };
  79632. indices: string;
  79633. material: string;
  79634. mode?: number;
  79635. }
  79636. /** @hidden */
  79637. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79638. primitives: IGLTFMeshPrimitive[];
  79639. }
  79640. /** @hidden */
  79641. export interface IGLTFImage extends IGLTFChildRootProperty {
  79642. uri: string;
  79643. }
  79644. /** @hidden */
  79645. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79646. magFilter?: number;
  79647. minFilter?: number;
  79648. wrapS?: number;
  79649. wrapT?: number;
  79650. }
  79651. /** @hidden */
  79652. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79653. sampler: string;
  79654. source: string;
  79655. format?: ETextureFormat;
  79656. internalFormat?: ETextureFormat;
  79657. target?: number;
  79658. type?: number;
  79659. babylonTexture?: Texture;
  79660. }
  79661. /** @hidden */
  79662. export interface IGLTFAmbienLight {
  79663. color?: number[];
  79664. }
  79665. /** @hidden */
  79666. export interface IGLTFDirectionalLight {
  79667. color?: number[];
  79668. }
  79669. /** @hidden */
  79670. export interface IGLTFPointLight {
  79671. color?: number[];
  79672. constantAttenuation?: number;
  79673. linearAttenuation?: number;
  79674. quadraticAttenuation?: number;
  79675. }
  79676. /** @hidden */
  79677. export interface IGLTFSpotLight {
  79678. color?: number[];
  79679. constantAttenuation?: number;
  79680. fallOfAngle?: number;
  79681. fallOffExponent?: number;
  79682. linearAttenuation?: number;
  79683. quadraticAttenuation?: number;
  79684. }
  79685. /** @hidden */
  79686. export interface IGLTFLight extends IGLTFChildRootProperty {
  79687. type: string;
  79688. }
  79689. /** @hidden */
  79690. export interface IGLTFCameraOrthographic {
  79691. xmag: number;
  79692. ymag: number;
  79693. zfar: number;
  79694. znear: number;
  79695. }
  79696. /** @hidden */
  79697. export interface IGLTFCameraPerspective {
  79698. aspectRatio: number;
  79699. yfov: number;
  79700. zfar: number;
  79701. znear: number;
  79702. }
  79703. /** @hidden */
  79704. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79705. type: string;
  79706. }
  79707. /** @hidden */
  79708. export interface IGLTFAnimationChannelTarget {
  79709. id: string;
  79710. path: string;
  79711. }
  79712. /** @hidden */
  79713. export interface IGLTFAnimationChannel {
  79714. sampler: string;
  79715. target: IGLTFAnimationChannelTarget;
  79716. }
  79717. /** @hidden */
  79718. export interface IGLTFAnimationSampler {
  79719. input: string;
  79720. output: string;
  79721. interpolation?: string;
  79722. }
  79723. /** @hidden */
  79724. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79725. channels?: IGLTFAnimationChannel[];
  79726. parameters?: {
  79727. [key: string]: string;
  79728. };
  79729. samplers?: {
  79730. [key: string]: IGLTFAnimationSampler;
  79731. };
  79732. }
  79733. /** @hidden */
  79734. export interface IGLTFNodeInstanceSkin {
  79735. skeletons: string[];
  79736. skin: string;
  79737. meshes: string[];
  79738. }
  79739. /** @hidden */
  79740. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79741. bindShapeMatrix: number[];
  79742. inverseBindMatrices: string;
  79743. jointNames: string[];
  79744. babylonSkeleton?: Skeleton;
  79745. }
  79746. /** @hidden */
  79747. export interface IGLTFNode extends IGLTFChildRootProperty {
  79748. camera?: string;
  79749. children: string[];
  79750. skin?: string;
  79751. jointName?: string;
  79752. light?: string;
  79753. matrix: number[];
  79754. mesh?: string;
  79755. meshes?: string[];
  79756. rotation?: number[];
  79757. scale?: number[];
  79758. translation?: number[];
  79759. babylonNode?: Node;
  79760. }
  79761. /** @hidden */
  79762. export interface IGLTFScene extends IGLTFChildRootProperty {
  79763. nodes: string[];
  79764. }
  79765. /** @hidden */
  79766. export interface IGLTFRuntime {
  79767. extensions: {
  79768. [key: string]: any;
  79769. };
  79770. accessors: {
  79771. [key: string]: IGLTFAccessor;
  79772. };
  79773. buffers: {
  79774. [key: string]: IGLTFBuffer;
  79775. };
  79776. bufferViews: {
  79777. [key: string]: IGLTFBufferView;
  79778. };
  79779. meshes: {
  79780. [key: string]: IGLTFMesh;
  79781. };
  79782. lights: {
  79783. [key: string]: IGLTFLight;
  79784. };
  79785. cameras: {
  79786. [key: string]: IGLTFCamera;
  79787. };
  79788. nodes: {
  79789. [key: string]: IGLTFNode;
  79790. };
  79791. images: {
  79792. [key: string]: IGLTFImage;
  79793. };
  79794. textures: {
  79795. [key: string]: IGLTFTexture;
  79796. };
  79797. shaders: {
  79798. [key: string]: IGLTFShader;
  79799. };
  79800. programs: {
  79801. [key: string]: IGLTFProgram;
  79802. };
  79803. samplers: {
  79804. [key: string]: IGLTFSampler;
  79805. };
  79806. techniques: {
  79807. [key: string]: IGLTFTechnique;
  79808. };
  79809. materials: {
  79810. [key: string]: IGLTFMaterial;
  79811. };
  79812. animations: {
  79813. [key: string]: IGLTFAnimation;
  79814. };
  79815. skins: {
  79816. [key: string]: IGLTFSkins;
  79817. };
  79818. currentScene?: Object;
  79819. scenes: {
  79820. [key: string]: IGLTFScene;
  79821. };
  79822. extensionsUsed: string[];
  79823. extensionsRequired?: string[];
  79824. buffersCount: number;
  79825. shaderscount: number;
  79826. scene: Scene;
  79827. rootUrl: string;
  79828. loadedBufferCount: number;
  79829. loadedBufferViews: {
  79830. [name: string]: ArrayBufferView;
  79831. };
  79832. loadedShaderCount: number;
  79833. importOnlyMeshes: boolean;
  79834. importMeshesNames?: string[];
  79835. dummyNodes: Node[];
  79836. forAssetContainer: boolean;
  79837. }
  79838. /** @hidden */
  79839. export interface INodeToRoot {
  79840. bone: Bone;
  79841. node: IGLTFNode;
  79842. id: string;
  79843. }
  79844. /** @hidden */
  79845. export interface IJointNode {
  79846. node: IGLTFNode;
  79847. id: string;
  79848. }
  79849. }
  79850. declare module BABYLON.GLTF1 {
  79851. /**
  79852. * Utils functions for GLTF
  79853. * @hidden
  79854. */
  79855. export class GLTFUtils {
  79856. /**
  79857. * Sets the given "parameter" matrix
  79858. * @param scene: the Scene object
  79859. * @param source: the source node where to pick the matrix
  79860. * @param parameter: the GLTF technique parameter
  79861. * @param uniformName: the name of the shader's uniform
  79862. * @param shaderMaterial: the shader material
  79863. */
  79864. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79865. /**
  79866. * Sets the given "parameter" matrix
  79867. * @param shaderMaterial: the shader material
  79868. * @param uniform: the name of the shader's uniform
  79869. * @param value: the value of the uniform
  79870. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79871. */
  79872. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79873. /**
  79874. * Returns the wrap mode of the texture
  79875. * @param mode: the mode value
  79876. */
  79877. static GetWrapMode(mode: number): number;
  79878. /**
  79879. * Returns the byte stride giving an accessor
  79880. * @param accessor: the GLTF accessor objet
  79881. */
  79882. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79883. /**
  79884. * Returns the texture filter mode giving a mode value
  79885. * @param mode: the filter mode value
  79886. */
  79887. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79888. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79889. /**
  79890. * Returns a buffer from its accessor
  79891. * @param gltfRuntime: the GLTF runtime
  79892. * @param accessor: the GLTF accessor
  79893. */
  79894. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79895. /**
  79896. * Decodes a buffer view into a string
  79897. * @param view: the buffer view
  79898. */
  79899. static DecodeBufferToText(view: ArrayBufferView): string;
  79900. /**
  79901. * Returns the default material of gltf. Related to
  79902. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79903. * @param scene: the Babylon.js scene
  79904. */
  79905. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79906. private static _DefaultMaterial;
  79907. }
  79908. }
  79909. declare module BABYLON.GLTF1 {
  79910. /**
  79911. * Implementation of the base glTF spec
  79912. * @hidden
  79913. */
  79914. export class GLTFLoaderBase {
  79915. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79916. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79917. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79918. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79919. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79920. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79921. }
  79922. /**
  79923. * glTF V1 Loader
  79924. * @hidden
  79925. */
  79926. export class GLTFLoader implements IGLTFLoader {
  79927. static Extensions: {
  79928. [name: string]: GLTFLoaderExtension;
  79929. };
  79930. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79931. state: Nullable<GLTFLoaderState>;
  79932. dispose(): void;
  79933. private _importMeshAsync;
  79934. /**
  79935. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79936. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79937. * @param scene the scene the meshes should be added to
  79938. * @param forAssetContainer defines if the entities must be stored in the scene
  79939. * @param data gltf data containing information of the meshes in a loaded file
  79940. * @param rootUrl root url to load from
  79941. * @param onProgress event that fires when loading progress has occured
  79942. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79943. */
  79944. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79945. private _loadAsync;
  79946. /**
  79947. * Imports all objects from a loaded gltf file and adds them to the scene
  79948. * @param scene the scene the objects should be added to
  79949. * @param data gltf data containing information of the meshes in a loaded file
  79950. * @param rootUrl root url to load from
  79951. * @param onProgress event that fires when loading progress has occured
  79952. * @returns a promise which completes when objects have been loaded to the scene
  79953. */
  79954. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79955. private _loadShadersAsync;
  79956. private _loadBuffersAsync;
  79957. private _createNodes;
  79958. }
  79959. /** @hidden */
  79960. export abstract class GLTFLoaderExtension {
  79961. private _name;
  79962. constructor(name: string);
  79963. get name(): string;
  79964. /**
  79965. * Defines an override for loading the runtime
  79966. * Return true to stop further extensions from loading the runtime
  79967. */
  79968. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79969. /**
  79970. * Defines an onverride for creating gltf runtime
  79971. * Return true to stop further extensions from creating the runtime
  79972. */
  79973. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79974. /**
  79975. * Defines an override for loading buffers
  79976. * Return true to stop further extensions from loading this buffer
  79977. */
  79978. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79979. /**
  79980. * Defines an override for loading texture buffers
  79981. * Return true to stop further extensions from loading this texture data
  79982. */
  79983. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79984. /**
  79985. * Defines an override for creating textures
  79986. * Return true to stop further extensions from loading this texture
  79987. */
  79988. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79989. /**
  79990. * Defines an override for loading shader strings
  79991. * Return true to stop further extensions from loading this shader data
  79992. */
  79993. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79994. /**
  79995. * Defines an override for loading materials
  79996. * Return true to stop further extensions from loading this material
  79997. */
  79998. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79999. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80000. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80001. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80002. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80003. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80004. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80005. private static LoadTextureBufferAsync;
  80006. private static CreateTextureAsync;
  80007. private static ApplyExtensions;
  80008. }
  80009. }
  80010. declare module BABYLON.GLTF1 {
  80011. /** @hidden */
  80012. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80013. private _bin;
  80014. constructor();
  80015. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80016. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80017. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80018. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80019. }
  80020. }
  80021. declare module BABYLON.GLTF1 {
  80022. /** @hidden */
  80023. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80024. constructor();
  80025. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80026. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80027. private _loadTexture;
  80028. }
  80029. }
  80030. declare module BABYLON.GLTF2.Loader {
  80031. /**
  80032. * Loader interface with an index field.
  80033. */
  80034. export interface IArrayItem {
  80035. /**
  80036. * The index of this item in the array.
  80037. */
  80038. index: number;
  80039. }
  80040. /**
  80041. * Loader interface with additional members.
  80042. */
  80043. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80044. /** @hidden */
  80045. _data?: Promise<ArrayBufferView>;
  80046. /** @hidden */
  80047. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80048. }
  80049. /**
  80050. * Loader interface with additional members.
  80051. */
  80052. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80053. }
  80054. /** @hidden */
  80055. export interface _IAnimationSamplerData {
  80056. input: Float32Array;
  80057. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80058. output: Float32Array;
  80059. }
  80060. /**
  80061. * Loader interface with additional members.
  80062. */
  80063. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80064. /** @hidden */
  80065. _data?: Promise<_IAnimationSamplerData>;
  80066. }
  80067. /**
  80068. * Loader interface with additional members.
  80069. */
  80070. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80071. channels: IAnimationChannel[];
  80072. samplers: IAnimationSampler[];
  80073. /** @hidden */
  80074. _babylonAnimationGroup?: AnimationGroup;
  80075. }
  80076. /**
  80077. * Loader interface with additional members.
  80078. */
  80079. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80080. /** @hidden */
  80081. _data?: Promise<ArrayBufferView>;
  80082. }
  80083. /**
  80084. * Loader interface with additional members.
  80085. */
  80086. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80087. /** @hidden */
  80088. _data?: Promise<ArrayBufferView>;
  80089. /** @hidden */
  80090. _babylonBuffer?: Promise<Buffer>;
  80091. }
  80092. /**
  80093. * Loader interface with additional members.
  80094. */
  80095. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80096. }
  80097. /**
  80098. * Loader interface with additional members.
  80099. */
  80100. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80101. /** @hidden */
  80102. _data?: Promise<ArrayBufferView>;
  80103. }
  80104. /**
  80105. * Loader interface with additional members.
  80106. */
  80107. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80108. }
  80109. /**
  80110. * Loader interface with additional members.
  80111. */
  80112. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80113. }
  80114. /**
  80115. * Loader interface with additional members.
  80116. */
  80117. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80118. baseColorTexture?: ITextureInfo;
  80119. metallicRoughnessTexture?: ITextureInfo;
  80120. }
  80121. /**
  80122. * Loader interface with additional members.
  80123. */
  80124. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80125. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80126. normalTexture?: IMaterialNormalTextureInfo;
  80127. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80128. emissiveTexture?: ITextureInfo;
  80129. /** @hidden */
  80130. _data?: {
  80131. [babylonDrawMode: number]: {
  80132. babylonMaterial: Material;
  80133. babylonMeshes: AbstractMesh[];
  80134. promise: Promise<void>;
  80135. };
  80136. };
  80137. }
  80138. /**
  80139. * Loader interface with additional members.
  80140. */
  80141. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80142. primitives: IMeshPrimitive[];
  80143. }
  80144. /**
  80145. * Loader interface with additional members.
  80146. */
  80147. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80148. /** @hidden */
  80149. _instanceData?: {
  80150. babylonSourceMesh: Mesh;
  80151. promise: Promise<any>;
  80152. };
  80153. }
  80154. /**
  80155. * Loader interface with additional members.
  80156. */
  80157. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80158. /**
  80159. * The parent glTF node.
  80160. */
  80161. parent?: INode;
  80162. /** @hidden */
  80163. _babylonTransformNode?: TransformNode;
  80164. /** @hidden */
  80165. _primitiveBabylonMeshes?: AbstractMesh[];
  80166. /** @hidden */
  80167. _babylonBones?: Bone[];
  80168. /** @hidden */
  80169. _numMorphTargets?: number;
  80170. }
  80171. /** @hidden */
  80172. export interface _ISamplerData {
  80173. noMipMaps: boolean;
  80174. samplingMode: number;
  80175. wrapU: number;
  80176. wrapV: number;
  80177. }
  80178. /**
  80179. * Loader interface with additional members.
  80180. */
  80181. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80182. /** @hidden */
  80183. _data?: _ISamplerData;
  80184. }
  80185. /**
  80186. * Loader interface with additional members.
  80187. */
  80188. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80189. }
  80190. /**
  80191. * Loader interface with additional members.
  80192. */
  80193. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80194. /** @hidden */
  80195. _data?: {
  80196. babylonSkeleton: Skeleton;
  80197. promise: Promise<void>;
  80198. };
  80199. }
  80200. /**
  80201. * Loader interface with additional members.
  80202. */
  80203. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80204. }
  80205. /**
  80206. * Loader interface with additional members.
  80207. */
  80208. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80209. }
  80210. /**
  80211. * Loader interface with additional members.
  80212. */
  80213. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80214. accessors?: IAccessor[];
  80215. animations?: IAnimation[];
  80216. buffers?: IBuffer[];
  80217. bufferViews?: IBufferView[];
  80218. cameras?: ICamera[];
  80219. images?: IImage[];
  80220. materials?: IMaterial[];
  80221. meshes?: IMesh[];
  80222. nodes?: INode[];
  80223. samplers?: ISampler[];
  80224. scenes?: IScene[];
  80225. skins?: ISkin[];
  80226. textures?: ITexture[];
  80227. }
  80228. }
  80229. declare module BABYLON.GLTF2 {
  80230. /**
  80231. * Interface for a glTF loader extension.
  80232. */
  80233. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80234. /**
  80235. * Called after the loader state changes to LOADING.
  80236. */
  80237. onLoading?(): void;
  80238. /**
  80239. * Called after the loader state changes to READY.
  80240. */
  80241. onReady?(): void;
  80242. /**
  80243. * Define this method to modify the default behavior when loading scenes.
  80244. * @param context The context when loading the asset
  80245. * @param scene The glTF scene property
  80246. * @returns A promise that resolves when the load is complete or null if not handled
  80247. */
  80248. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80249. /**
  80250. * Define this method to modify the default behavior when loading nodes.
  80251. * @param context The context when loading the asset
  80252. * @param node The glTF node property
  80253. * @param assign A function called synchronously after parsing the glTF properties
  80254. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80255. */
  80256. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80257. /**
  80258. * Define this method to modify the default behavior when loading cameras.
  80259. * @param context The context when loading the asset
  80260. * @param camera The glTF camera property
  80261. * @param assign A function called synchronously after parsing the glTF properties
  80262. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80263. */
  80264. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80265. /**
  80266. * @hidden
  80267. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80268. * @param context The context when loading the asset
  80269. * @param primitive The glTF mesh primitive property
  80270. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80271. */
  80272. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80273. /**
  80274. * @hidden
  80275. * Define this method to modify the default behavior when loading data for mesh primitives.
  80276. * @param context The context when loading the asset
  80277. * @param name The mesh name when loading the asset
  80278. * @param node The glTF node when loading the asset
  80279. * @param mesh The glTF mesh when loading the asset
  80280. * @param primitive The glTF mesh primitive property
  80281. * @param assign A function called synchronously after parsing the glTF properties
  80282. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80283. */
  80284. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80285. /**
  80286. * @hidden
  80287. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80288. * @param context The context when loading the asset
  80289. * @param material The glTF material property
  80290. * @param assign A function called synchronously after parsing the glTF properties
  80291. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80292. */
  80293. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80294. /**
  80295. * Define this method to modify the default behavior when creating materials.
  80296. * @param context The context when loading the asset
  80297. * @param material The glTF material property
  80298. * @param babylonDrawMode The draw mode for the Babylon material
  80299. * @returns The Babylon material or null if not handled
  80300. */
  80301. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80302. /**
  80303. * Define this method to modify the default behavior when loading material properties.
  80304. * @param context The context when loading the asset
  80305. * @param material The glTF material property
  80306. * @param babylonMaterial The Babylon material
  80307. * @returns A promise that resolves when the load is complete or null if not handled
  80308. */
  80309. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80310. /**
  80311. * Define this method to modify the default behavior when loading texture infos.
  80312. * @param context The context when loading the asset
  80313. * @param textureInfo The glTF texture info property
  80314. * @param assign A function called synchronously after parsing the glTF properties
  80315. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80316. */
  80317. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80318. /**
  80319. * @hidden
  80320. * Define this method to modify the default behavior when loading textures.
  80321. * @param context The context when loading the asset
  80322. * @param texture The glTF texture property
  80323. * @param assign A function called synchronously after parsing the glTF properties
  80324. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80325. */
  80326. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80327. /**
  80328. * Define this method to modify the default behavior when loading animations.
  80329. * @param context The context when loading the asset
  80330. * @param animation The glTF animation property
  80331. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80332. */
  80333. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80334. /**
  80335. * @hidden
  80336. * Define this method to modify the default behavior when loading skins.
  80337. * @param context The context when loading the asset
  80338. * @param node The glTF node property
  80339. * @param skin The glTF skin property
  80340. * @returns A promise that resolves when the load is complete or null if not handled
  80341. */
  80342. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80343. /**
  80344. * @hidden
  80345. * Define this method to modify the default behavior when loading uris.
  80346. * @param context The context when loading the asset
  80347. * @param property The glTF property associated with the uri
  80348. * @param uri The uri to load
  80349. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80350. */
  80351. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80352. /**
  80353. * Define this method to modify the default behavior when loading buffer views.
  80354. * @param context The context when loading the asset
  80355. * @param bufferView The glTF buffer view property
  80356. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80357. */
  80358. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80359. /**
  80360. * Define this method to modify the default behavior when loading buffers.
  80361. * @param context The context when loading the asset
  80362. * @param buffer The glTF buffer property
  80363. * @param byteOffset The byte offset to load
  80364. * @param byteLength The byte length to load
  80365. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80366. */
  80367. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80368. }
  80369. }
  80370. declare module BABYLON.GLTF2 {
  80371. /**
  80372. * Helper class for working with arrays when loading the glTF asset
  80373. */
  80374. export class ArrayItem {
  80375. /**
  80376. * Gets an item from the given array.
  80377. * @param context The context when loading the asset
  80378. * @param array The array to get the item from
  80379. * @param index The index to the array
  80380. * @returns The array item
  80381. */
  80382. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80383. /**
  80384. * Assign an `index` field to each item of the given array.
  80385. * @param array The array of items
  80386. */
  80387. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80388. }
  80389. /**
  80390. * The glTF 2.0 loader
  80391. */
  80392. export class GLTFLoader implements IGLTFLoader {
  80393. /** @hidden */
  80394. _completePromises: Promise<any>[];
  80395. /** @hidden */
  80396. _forAssetContainer: boolean;
  80397. /** Storage */
  80398. _babylonLights: Light[];
  80399. /** @hidden */
  80400. _disableInstancedMesh: number;
  80401. private _disposed;
  80402. private _parent;
  80403. private _state;
  80404. private _extensions;
  80405. private _rootUrl;
  80406. private _fileName;
  80407. private _uniqueRootUrl;
  80408. private _gltf;
  80409. private _bin;
  80410. private _babylonScene;
  80411. private _rootBabylonMesh;
  80412. private _defaultBabylonMaterialData;
  80413. private static _RegisteredExtensions;
  80414. /**
  80415. * The default glTF sampler.
  80416. */
  80417. static readonly DefaultSampler: ISampler;
  80418. /**
  80419. * Registers a loader extension.
  80420. * @param name The name of the loader extension.
  80421. * @param factory The factory function that creates the loader extension.
  80422. */
  80423. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80424. /**
  80425. * Unregisters a loader extension.
  80426. * @param name The name of the loader extension.
  80427. * @returns A boolean indicating whether the extension has been unregistered
  80428. */
  80429. static UnregisterExtension(name: string): boolean;
  80430. /**
  80431. * The loader state.
  80432. */
  80433. get state(): Nullable<GLTFLoaderState>;
  80434. /**
  80435. * The object that represents the glTF JSON.
  80436. */
  80437. get gltf(): IGLTF;
  80438. /**
  80439. * The BIN chunk of a binary glTF.
  80440. */
  80441. get bin(): Nullable<IDataBuffer>;
  80442. /**
  80443. * The parent file loader.
  80444. */
  80445. get parent(): GLTFFileLoader;
  80446. /**
  80447. * The Babylon scene when loading the asset.
  80448. */
  80449. get babylonScene(): Scene;
  80450. /**
  80451. * The root Babylon mesh when loading the asset.
  80452. */
  80453. get rootBabylonMesh(): Mesh;
  80454. /** @hidden */
  80455. constructor(parent: GLTFFileLoader);
  80456. /** @hidden */
  80457. dispose(): void;
  80458. /** @hidden */
  80459. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80460. /** @hidden */
  80461. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80462. private _loadAsync;
  80463. private _loadData;
  80464. private _setupData;
  80465. private _loadExtensions;
  80466. private _checkExtensions;
  80467. private _setState;
  80468. private _createRootNode;
  80469. /**
  80470. * Loads a glTF scene.
  80471. * @param context The context when loading the asset
  80472. * @param scene The glTF scene property
  80473. * @returns A promise that resolves when the load is complete
  80474. */
  80475. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80476. private _forEachPrimitive;
  80477. private _getMeshes;
  80478. private _getTransformNodes;
  80479. private _getSkeletons;
  80480. private _getAnimationGroups;
  80481. private _startAnimations;
  80482. /**
  80483. * Loads a glTF node.
  80484. * @param context The context when loading the asset
  80485. * @param node The glTF node property
  80486. * @param assign A function called synchronously after parsing the glTF properties
  80487. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80488. */
  80489. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80490. private _loadMeshAsync;
  80491. /**
  80492. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80493. * @param context The context when loading the asset
  80494. * @param name The mesh name when loading the asset
  80495. * @param node The glTF node when loading the asset
  80496. * @param mesh The glTF mesh when loading the asset
  80497. * @param primitive The glTF mesh primitive property
  80498. * @param assign A function called synchronously after parsing the glTF properties
  80499. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80500. */
  80501. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80502. private _loadVertexDataAsync;
  80503. private _createMorphTargets;
  80504. private _loadMorphTargetsAsync;
  80505. private _loadMorphTargetVertexDataAsync;
  80506. private static _LoadTransform;
  80507. private _loadSkinAsync;
  80508. private _loadBones;
  80509. private _loadBone;
  80510. private _loadSkinInverseBindMatricesDataAsync;
  80511. private _updateBoneMatrices;
  80512. private _getNodeMatrix;
  80513. /**
  80514. * Loads a glTF camera.
  80515. * @param context The context when loading the asset
  80516. * @param camera The glTF camera property
  80517. * @param assign A function called synchronously after parsing the glTF properties
  80518. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80519. */
  80520. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80521. private _loadAnimationsAsync;
  80522. /**
  80523. * Loads a glTF animation.
  80524. * @param context The context when loading the asset
  80525. * @param animation The glTF animation property
  80526. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80527. */
  80528. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80529. /**
  80530. * @hidden Loads a glTF animation channel.
  80531. * @param context The context when loading the asset
  80532. * @param animationContext The context of the animation when loading the asset
  80533. * @param animation The glTF animation property
  80534. * @param channel The glTF animation channel property
  80535. * @param babylonAnimationGroup The babylon animation group property
  80536. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80537. * @returns A void promise when the channel load is complete
  80538. */
  80539. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80540. private _loadAnimationSamplerAsync;
  80541. private _loadBufferAsync;
  80542. /**
  80543. * Loads a glTF buffer view.
  80544. * @param context The context when loading the asset
  80545. * @param bufferView The glTF buffer view property
  80546. * @returns A promise that resolves with the loaded data when the load is complete
  80547. */
  80548. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80549. private _loadAccessorAsync;
  80550. /** @hidden */
  80551. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80552. private _loadIndicesAccessorAsync;
  80553. private _loadVertexBufferViewAsync;
  80554. private _loadVertexAccessorAsync;
  80555. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80556. /** @hidden */
  80557. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80558. private _createDefaultMaterial;
  80559. /**
  80560. * Creates a Babylon material from a glTF material.
  80561. * @param context The context when loading the asset
  80562. * @param material The glTF material property
  80563. * @param babylonDrawMode The draw mode for the Babylon material
  80564. * @returns The Babylon material
  80565. */
  80566. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80567. /**
  80568. * Loads properties from a glTF material into a Babylon material.
  80569. * @param context The context when loading the asset
  80570. * @param material The glTF material property
  80571. * @param babylonMaterial The Babylon material
  80572. * @returns A promise that resolves when the load is complete
  80573. */
  80574. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80575. /**
  80576. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80577. * @param context The context when loading the asset
  80578. * @param material The glTF material property
  80579. * @param babylonMaterial The Babylon material
  80580. * @returns A promise that resolves when the load is complete
  80581. */
  80582. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80583. /**
  80584. * Loads the alpha properties from a glTF material into a Babylon material.
  80585. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80586. * @param context The context when loading the asset
  80587. * @param material The glTF material property
  80588. * @param babylonMaterial The Babylon material
  80589. */
  80590. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80591. /**
  80592. * Loads a glTF texture info.
  80593. * @param context The context when loading the asset
  80594. * @param textureInfo The glTF texture info property
  80595. * @param assign A function called synchronously after parsing the glTF properties
  80596. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80597. */
  80598. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80599. /** @hidden */
  80600. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80601. /** @hidden */
  80602. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80603. private _loadSampler;
  80604. /**
  80605. * Loads a glTF image.
  80606. * @param context The context when loading the asset
  80607. * @param image The glTF image property
  80608. * @returns A promise that resolves with the loaded data when the load is complete
  80609. */
  80610. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80611. /**
  80612. * Loads a glTF uri.
  80613. * @param context The context when loading the asset
  80614. * @param property The glTF property associated with the uri
  80615. * @param uri The base64 or relative uri
  80616. * @returns A promise that resolves with the loaded data when the load is complete
  80617. */
  80618. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80619. /**
  80620. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80621. * @param babylonObject the Babylon object with metadata
  80622. * @param pointer the JSON pointer
  80623. */
  80624. static AddPointerMetadata(babylonObject: {
  80625. metadata: any;
  80626. }, pointer: string): void;
  80627. private static _GetTextureWrapMode;
  80628. private static _GetTextureSamplingMode;
  80629. private static _GetTypedArrayConstructor;
  80630. private static _GetTypedArray;
  80631. private static _GetNumComponents;
  80632. private static _ValidateUri;
  80633. /** @hidden */
  80634. static _GetDrawMode(context: string, mode: number | undefined): number;
  80635. private _compileMaterialsAsync;
  80636. private _compileShadowGeneratorsAsync;
  80637. private _forEachExtensions;
  80638. private _applyExtensions;
  80639. private _extensionsOnLoading;
  80640. private _extensionsOnReady;
  80641. private _extensionsLoadSceneAsync;
  80642. private _extensionsLoadNodeAsync;
  80643. private _extensionsLoadCameraAsync;
  80644. private _extensionsLoadVertexDataAsync;
  80645. private _extensionsLoadMeshPrimitiveAsync;
  80646. private _extensionsLoadMaterialAsync;
  80647. private _extensionsCreateMaterial;
  80648. private _extensionsLoadMaterialPropertiesAsync;
  80649. private _extensionsLoadTextureInfoAsync;
  80650. private _extensionsLoadTextureAsync;
  80651. private _extensionsLoadAnimationAsync;
  80652. private _extensionsLoadSkinAsync;
  80653. private _extensionsLoadUriAsync;
  80654. private _extensionsLoadBufferViewAsync;
  80655. private _extensionsLoadBufferAsync;
  80656. /**
  80657. * Helper method called by a loader extension to load an glTF extension.
  80658. * @param context The context when loading the asset
  80659. * @param property The glTF property to load the extension from
  80660. * @param extensionName The name of the extension to load
  80661. * @param actionAsync The action to run
  80662. * @returns The promise returned by actionAsync or null if the extension does not exist
  80663. */
  80664. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80665. /**
  80666. * Helper method called by a loader extension to load a glTF extra.
  80667. * @param context The context when loading the asset
  80668. * @param property The glTF property to load the extra from
  80669. * @param extensionName The name of the extension to load
  80670. * @param actionAsync The action to run
  80671. * @returns The promise returned by actionAsync or null if the extra does not exist
  80672. */
  80673. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80674. /**
  80675. * Checks for presence of an extension.
  80676. * @param name The name of the extension to check
  80677. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80678. */
  80679. isExtensionUsed(name: string): boolean;
  80680. /**
  80681. * Increments the indentation level and logs a message.
  80682. * @param message The message to log
  80683. */
  80684. logOpen(message: string): void;
  80685. /**
  80686. * Decrements the indentation level.
  80687. */
  80688. logClose(): void;
  80689. /**
  80690. * Logs a message
  80691. * @param message The message to log
  80692. */
  80693. log(message: string): void;
  80694. /**
  80695. * Starts a performance counter.
  80696. * @param counterName The name of the performance counter
  80697. */
  80698. startPerformanceCounter(counterName: string): void;
  80699. /**
  80700. * Ends a performance counter.
  80701. * @param counterName The name of the performance counter
  80702. */
  80703. endPerformanceCounter(counterName: string): void;
  80704. }
  80705. }
  80706. declare module BABYLON.GLTF2.Loader.Extensions {
  80707. /** @hidden */
  80708. interface IEXTLightsImageBased_LightImageBased {
  80709. _babylonTexture?: BaseTexture;
  80710. _loaded?: Promise<void>;
  80711. }
  80712. /**
  80713. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80714. */
  80715. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80716. /**
  80717. * The name of this extension.
  80718. */
  80719. readonly name: string;
  80720. /**
  80721. * Defines whether this extension is enabled.
  80722. */
  80723. enabled: boolean;
  80724. private _loader;
  80725. private _lights?;
  80726. /** @hidden */
  80727. constructor(loader: GLTFLoader);
  80728. /** @hidden */
  80729. dispose(): void;
  80730. /** @hidden */
  80731. onLoading(): void;
  80732. /** @hidden */
  80733. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80734. private _loadLightAsync;
  80735. }
  80736. }
  80737. declare module BABYLON.GLTF2.Loader.Extensions {
  80738. /**
  80739. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80740. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80741. * !!! Experimental Extension Subject to Changes !!!
  80742. */
  80743. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80744. /**
  80745. * The name of this extension.
  80746. */
  80747. readonly name: string;
  80748. /**
  80749. * Defines whether this extension is enabled.
  80750. */
  80751. enabled: boolean;
  80752. private _loader;
  80753. /** @hidden */
  80754. constructor(loader: GLTFLoader);
  80755. /** @hidden */
  80756. dispose(): void;
  80757. /** @hidden */
  80758. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80759. }
  80760. }
  80761. declare module BABYLON.GLTF2.Loader.Extensions {
  80762. /**
  80763. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80764. */
  80765. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80766. /**
  80767. * The name of this extension.
  80768. */
  80769. readonly name: string;
  80770. /**
  80771. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80772. */
  80773. dracoCompression?: DracoCompression;
  80774. /**
  80775. * Defines whether this extension is enabled.
  80776. */
  80777. enabled: boolean;
  80778. private _loader;
  80779. /** @hidden */
  80780. constructor(loader: GLTFLoader);
  80781. /** @hidden */
  80782. dispose(): void;
  80783. /** @hidden */
  80784. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80785. }
  80786. }
  80787. declare module BABYLON.GLTF2.Loader.Extensions {
  80788. /**
  80789. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80790. */
  80791. export class KHR_lights implements IGLTFLoaderExtension {
  80792. /**
  80793. * The name of this extension.
  80794. */
  80795. readonly name: string;
  80796. /**
  80797. * Defines whether this extension is enabled.
  80798. */
  80799. enabled: boolean;
  80800. private _loader;
  80801. private _lights?;
  80802. /** @hidden */
  80803. constructor(loader: GLTFLoader);
  80804. /** @hidden */
  80805. dispose(): void;
  80806. /** @hidden */
  80807. onLoading(): void;
  80808. /** @hidden */
  80809. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80810. }
  80811. }
  80812. declare module BABYLON.GLTF2.Loader.Extensions {
  80813. /**
  80814. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80815. */
  80816. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80817. /**
  80818. * The name of this extension.
  80819. */
  80820. readonly name: string;
  80821. /**
  80822. * Defines whether this extension is enabled.
  80823. */
  80824. enabled: boolean;
  80825. /**
  80826. * Defines a number that determines the order the extensions are applied.
  80827. */
  80828. order: number;
  80829. private _loader;
  80830. /** @hidden */
  80831. constructor(loader: GLTFLoader);
  80832. /** @hidden */
  80833. dispose(): void;
  80834. /** @hidden */
  80835. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80836. private _loadSpecularGlossinessPropertiesAsync;
  80837. }
  80838. }
  80839. declare module BABYLON.GLTF2.Loader.Extensions {
  80840. /**
  80841. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80842. */
  80843. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80844. /**
  80845. * The name of this extension.
  80846. */
  80847. readonly name: string;
  80848. /**
  80849. * Defines whether this extension is enabled.
  80850. */
  80851. enabled: boolean;
  80852. /**
  80853. * Defines a number that determines the order the extensions are applied.
  80854. */
  80855. order: number;
  80856. private _loader;
  80857. /** @hidden */
  80858. constructor(loader: GLTFLoader);
  80859. /** @hidden */
  80860. dispose(): void;
  80861. /** @hidden */
  80862. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80863. private _loadUnlitPropertiesAsync;
  80864. }
  80865. }
  80866. declare module BABYLON.GLTF2.Loader.Extensions {
  80867. /**
  80868. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80869. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80870. * !!! Experimental Extension Subject to Changes !!!
  80871. */
  80872. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80873. /**
  80874. * The name of this extension.
  80875. */
  80876. readonly name: string;
  80877. /**
  80878. * Defines whether this extension is enabled.
  80879. */
  80880. enabled: boolean;
  80881. /**
  80882. * Defines a number that determines the order the extensions are applied.
  80883. */
  80884. order: number;
  80885. private _loader;
  80886. /** @hidden */
  80887. constructor(loader: GLTFLoader);
  80888. /** @hidden */
  80889. dispose(): void;
  80890. /** @hidden */
  80891. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80892. private _loadClearCoatPropertiesAsync;
  80893. }
  80894. }
  80895. declare module BABYLON.GLTF2.Loader.Extensions {
  80896. /**
  80897. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80898. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80899. * !!! Experimental Extension Subject to Changes !!!
  80900. */
  80901. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80902. /**
  80903. * The name of this extension.
  80904. */
  80905. readonly name: string;
  80906. /**
  80907. * Defines whether this extension is enabled.
  80908. */
  80909. enabled: boolean;
  80910. /**
  80911. * Defines a number that determines the order the extensions are applied.
  80912. */
  80913. order: number;
  80914. private _loader;
  80915. /** @hidden */
  80916. constructor(loader: GLTFLoader);
  80917. /** @hidden */
  80918. dispose(): void;
  80919. /** @hidden */
  80920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80921. private _loadSheenPropertiesAsync;
  80922. }
  80923. }
  80924. declare module BABYLON.GLTF2.Loader.Extensions {
  80925. /**
  80926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80927. * !!! Experimental Extension Subject to Changes !!!
  80928. */
  80929. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80930. /**
  80931. * The name of this extension.
  80932. */
  80933. readonly name: string;
  80934. /**
  80935. * Defines whether this extension is enabled.
  80936. */
  80937. enabled: boolean;
  80938. /**
  80939. * Defines a number that determines the order the extensions are applied.
  80940. */
  80941. order: number;
  80942. private _loader;
  80943. /** @hidden */
  80944. constructor(loader: GLTFLoader);
  80945. /** @hidden */
  80946. dispose(): void;
  80947. /** @hidden */
  80948. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80949. private _loadSpecularPropertiesAsync;
  80950. }
  80951. }
  80952. declare module BABYLON.GLTF2.Loader.Extensions {
  80953. /**
  80954. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80955. * !!! Experimental Extension Subject to Changes !!!
  80956. */
  80957. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80958. /**
  80959. * Default ior Value from the spec.
  80960. */
  80961. private static readonly _DEFAULT_IOR;
  80962. /**
  80963. * The name of this extension.
  80964. */
  80965. readonly name: string;
  80966. /**
  80967. * Defines whether this extension is enabled.
  80968. */
  80969. enabled: boolean;
  80970. /**
  80971. * Defines a number that determines the order the extensions are applied.
  80972. */
  80973. order: number;
  80974. private _loader;
  80975. /** @hidden */
  80976. constructor(loader: GLTFLoader);
  80977. /** @hidden */
  80978. dispose(): void;
  80979. /** @hidden */
  80980. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80981. private _loadIorPropertiesAsync;
  80982. }
  80983. }
  80984. declare module BABYLON.GLTF2.Loader.Extensions {
  80985. /**
  80986. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80987. * !!! Experimental Extension Subject to Changes !!!
  80988. */
  80989. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80990. /**
  80991. * The name of this extension.
  80992. */
  80993. readonly name: string;
  80994. /**
  80995. * Defines whether this extension is enabled.
  80996. */
  80997. enabled: boolean;
  80998. private _loader;
  80999. /** @hidden */
  81000. constructor(loader: GLTFLoader);
  81001. /** @hidden */
  81002. dispose(): void;
  81003. /**
  81004. * Gets the list of available variant tag names for this asset.
  81005. * @param rootMesh The glTF root mesh
  81006. * @returns the list of all the variant names for this model
  81007. */
  81008. static GetAvailableVariants(rootMesh: Mesh): string[];
  81009. /**
  81010. * Gets the list of available variant tag names for this asset.
  81011. * @param rootMesh The glTF root mesh
  81012. * @returns the list of all the variant names for this model
  81013. */
  81014. getAvailableVariants(rootMesh: Mesh): string[];
  81015. /**
  81016. * Select a variant given a variant tag name or a list of variant tag names.
  81017. * @param rootMesh The glTF root mesh
  81018. * @param variantName The variant name(s) to select.
  81019. */
  81020. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81021. /**
  81022. * Select a variant given a variant tag name or a list of variant tag names.
  81023. * @param rootMesh The glTF root mesh
  81024. * @param variantName The variant name(s) to select.
  81025. */
  81026. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81027. /**
  81028. * Reset back to the original before selecting a variant.
  81029. * @param rootMesh The glTF root mesh
  81030. */
  81031. static Reset(rootMesh: Mesh): void;
  81032. /**
  81033. * Reset back to the original before selecting a variant.
  81034. * @param rootMesh The glTF root mesh
  81035. */
  81036. reset(rootMesh: Mesh): void;
  81037. /**
  81038. * Gets the last selected variant tag name(s) or null if original.
  81039. * @param rootMesh The glTF root mesh
  81040. * @returns The selected variant tag name(s).
  81041. */
  81042. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81043. /**
  81044. * Gets the last selected variant tag name(s) or null if original.
  81045. * @param rootMesh The glTF root mesh
  81046. * @returns The selected variant tag name(s).
  81047. */
  81048. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81049. private static _GetExtensionMetadata;
  81050. /** @hidden */
  81051. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81052. }
  81053. }
  81054. declare module BABYLON.GLTF2.Loader.Extensions {
  81055. /**
  81056. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81057. * !!! Experimental Extension Subject to Changes !!!
  81058. */
  81059. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81060. /**
  81061. * The name of this extension.
  81062. */
  81063. readonly name: string;
  81064. /**
  81065. * Defines whether this extension is enabled.
  81066. */
  81067. enabled: boolean;
  81068. /**
  81069. * Defines a number that determines the order the extensions are applied.
  81070. */
  81071. order: number;
  81072. private _loader;
  81073. /** @hidden */
  81074. constructor(loader: GLTFLoader);
  81075. /** @hidden */
  81076. dispose(): void;
  81077. /** @hidden */
  81078. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81079. private _loadTransparentPropertiesAsync;
  81080. }
  81081. }
  81082. declare module BABYLON.GLTF2.Loader.Extensions {
  81083. /**
  81084. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81085. */
  81086. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81087. /**
  81088. * The name of this extension.
  81089. */
  81090. readonly name: string;
  81091. /**
  81092. * Defines whether this extension is enabled.
  81093. */
  81094. enabled: boolean;
  81095. /** @hidden */
  81096. constructor(loader: GLTFLoader);
  81097. /** @hidden */
  81098. dispose(): void;
  81099. }
  81100. }
  81101. declare module BABYLON.GLTF2.Loader.Extensions {
  81102. /**
  81103. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81104. * !!! Experimental Extension Subject to Changes !!!
  81105. */
  81106. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81107. /** The name of this extension. */
  81108. readonly name: string;
  81109. /** Defines whether this extension is enabled. */
  81110. enabled: boolean;
  81111. private _loader;
  81112. /** @hidden */
  81113. constructor(loader: GLTFLoader);
  81114. /** @hidden */
  81115. dispose(): void;
  81116. /** @hidden */
  81117. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81118. }
  81119. }
  81120. declare module BABYLON.GLTF2.Loader.Extensions {
  81121. /**
  81122. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81123. */
  81124. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81125. /**
  81126. * The name of this extension.
  81127. */
  81128. readonly name: string;
  81129. /**
  81130. * Defines whether this extension is enabled.
  81131. */
  81132. enabled: boolean;
  81133. private _loader;
  81134. /** @hidden */
  81135. constructor(loader: GLTFLoader);
  81136. /** @hidden */
  81137. dispose(): void;
  81138. /** @hidden */
  81139. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81140. }
  81141. }
  81142. declare module BABYLON.GLTF2.Loader.Extensions {
  81143. /**
  81144. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81145. * !!! Experimental Extension Subject to Changes !!!
  81146. */
  81147. export class KHR_xmp implements IGLTFLoaderExtension {
  81148. /**
  81149. * The name of this extension.
  81150. */
  81151. readonly name: string;
  81152. /**
  81153. * Defines whether this extension is enabled.
  81154. */
  81155. enabled: boolean;
  81156. /**
  81157. * Defines a number that determines the order the extensions are applied.
  81158. */
  81159. order: number;
  81160. private _loader;
  81161. /** @hidden */
  81162. constructor(loader: GLTFLoader);
  81163. /** @hidden */
  81164. dispose(): void;
  81165. /**
  81166. * Called after the loader state changes to LOADING.
  81167. */
  81168. onLoading(): void;
  81169. }
  81170. }
  81171. declare module BABYLON.GLTF2.Loader.Extensions {
  81172. /**
  81173. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81174. */
  81175. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81176. /**
  81177. * The name of this extension.
  81178. */
  81179. readonly name: string;
  81180. /**
  81181. * Defines whether this extension is enabled.
  81182. */
  81183. enabled: boolean;
  81184. private _loader;
  81185. private _clips;
  81186. private _emitters;
  81187. /** @hidden */
  81188. constructor(loader: GLTFLoader);
  81189. /** @hidden */
  81190. dispose(): void;
  81191. /** @hidden */
  81192. onLoading(): void;
  81193. /** @hidden */
  81194. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81195. /** @hidden */
  81196. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81197. /** @hidden */
  81198. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81199. private _loadClipAsync;
  81200. private _loadEmitterAsync;
  81201. private _getEventAction;
  81202. private _loadAnimationEventAsync;
  81203. }
  81204. }
  81205. declare module BABYLON.GLTF2.Loader.Extensions {
  81206. /**
  81207. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81208. */
  81209. export class MSFT_lod implements IGLTFLoaderExtension {
  81210. /**
  81211. * The name of this extension.
  81212. */
  81213. readonly name: string;
  81214. /**
  81215. * Defines whether this extension is enabled.
  81216. */
  81217. enabled: boolean;
  81218. /**
  81219. * Defines a number that determines the order the extensions are applied.
  81220. */
  81221. order: number;
  81222. /**
  81223. * Maximum number of LODs to load, starting from the lowest LOD.
  81224. */
  81225. maxLODsToLoad: number;
  81226. /**
  81227. * Observable raised when all node LODs of one level are loaded.
  81228. * The event data is the index of the loaded LOD starting from zero.
  81229. * Dispose the loader to cancel the loading of the next level of LODs.
  81230. */
  81231. onNodeLODsLoadedObservable: Observable<number>;
  81232. /**
  81233. * Observable raised when all material LODs of one level are loaded.
  81234. * The event data is the index of the loaded LOD starting from zero.
  81235. * Dispose the loader to cancel the loading of the next level of LODs.
  81236. */
  81237. onMaterialLODsLoadedObservable: Observable<number>;
  81238. private _loader;
  81239. private _bufferLODs;
  81240. private _nodeIndexLOD;
  81241. private _nodeSignalLODs;
  81242. private _nodePromiseLODs;
  81243. private _nodeBufferLODs;
  81244. private _materialIndexLOD;
  81245. private _materialSignalLODs;
  81246. private _materialPromiseLODs;
  81247. private _materialBufferLODs;
  81248. /** @hidden */
  81249. constructor(loader: GLTFLoader);
  81250. /** @hidden */
  81251. dispose(): void;
  81252. /** @hidden */
  81253. onReady(): void;
  81254. /** @hidden */
  81255. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81256. /** @hidden */
  81257. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81258. /** @hidden */
  81259. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81260. /** @hidden */
  81261. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81262. /** @hidden */
  81263. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81264. private _loadBufferLOD;
  81265. /**
  81266. * Gets an array of LOD properties from lowest to highest.
  81267. */
  81268. private _getLODs;
  81269. private _disposeTransformNode;
  81270. private _disposeMaterials;
  81271. }
  81272. }
  81273. declare module BABYLON.GLTF2.Loader.Extensions {
  81274. /** @hidden */
  81275. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81276. readonly name: string;
  81277. enabled: boolean;
  81278. private _loader;
  81279. constructor(loader: GLTFLoader);
  81280. dispose(): void;
  81281. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81282. }
  81283. }
  81284. declare module BABYLON.GLTF2.Loader.Extensions {
  81285. /** @hidden */
  81286. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81287. readonly name: string;
  81288. enabled: boolean;
  81289. private _loader;
  81290. constructor(loader: GLTFLoader);
  81291. dispose(): void;
  81292. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81293. }
  81294. }
  81295. declare module BABYLON.GLTF2.Loader.Extensions {
  81296. /**
  81297. * Store glTF extras (if present) in BJS objects' metadata
  81298. */
  81299. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81300. /**
  81301. * The name of this extension.
  81302. */
  81303. readonly name: string;
  81304. /**
  81305. * Defines whether this extension is enabled.
  81306. */
  81307. enabled: boolean;
  81308. private _loader;
  81309. private _assignExtras;
  81310. /** @hidden */
  81311. constructor(loader: GLTFLoader);
  81312. /** @hidden */
  81313. dispose(): void;
  81314. /** @hidden */
  81315. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81316. /** @hidden */
  81317. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81318. /** @hidden */
  81319. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81320. }
  81321. }
  81322. declare module BABYLON {
  81323. /**
  81324. * Class reading and parsing the MTL file bundled with the obj file.
  81325. */
  81326. export class MTLFileLoader {
  81327. /**
  81328. * Invert Y-Axis of referenced textures on load
  81329. */
  81330. static INVERT_TEXTURE_Y: boolean;
  81331. /**
  81332. * All material loaded from the mtl will be set here
  81333. */
  81334. materials: StandardMaterial[];
  81335. /**
  81336. * This function will read the mtl file and create each material described inside
  81337. * This function could be improve by adding :
  81338. * -some component missing (Ni, Tf...)
  81339. * -including the specific options available
  81340. *
  81341. * @param scene defines the scene the material will be created in
  81342. * @param data defines the mtl data to parse
  81343. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81344. * @param forAssetContainer defines if the material should be registered in the scene
  81345. */
  81346. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81347. /**
  81348. * Gets the texture for the material.
  81349. *
  81350. * If the material is imported from input file,
  81351. * We sanitize the url to ensure it takes the textre from aside the material.
  81352. *
  81353. * @param rootUrl The root url to load from
  81354. * @param value The value stored in the mtl
  81355. * @return The Texture
  81356. */
  81357. private static _getTexture;
  81358. }
  81359. }
  81360. declare module BABYLON {
  81361. /**
  81362. * Options for loading OBJ/MTL files
  81363. */
  81364. type MeshLoadOptions = {
  81365. /**
  81366. * Defines if UVs are optimized by default during load.
  81367. */
  81368. OptimizeWithUV: boolean;
  81369. /**
  81370. * Defines custom scaling of UV coordinates of loaded meshes.
  81371. */
  81372. UVScaling: Vector2;
  81373. /**
  81374. * Invert model on y-axis (does a model scaling inversion)
  81375. */
  81376. InvertY: boolean;
  81377. /**
  81378. * Invert Y-Axis of referenced textures on load
  81379. */
  81380. InvertTextureY: boolean;
  81381. /**
  81382. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81383. */
  81384. ImportVertexColors: boolean;
  81385. /**
  81386. * Compute the normals for the model, even if normals are present in the file.
  81387. */
  81388. ComputeNormals: boolean;
  81389. /**
  81390. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81391. */
  81392. SkipMaterials: boolean;
  81393. /**
  81394. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81395. */
  81396. MaterialLoadingFailsSilently: boolean;
  81397. };
  81398. /**
  81399. * OBJ file type loader.
  81400. * This is a babylon scene loader plugin.
  81401. */
  81402. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81403. /**
  81404. * Defines if UVs are optimized by default during load.
  81405. */
  81406. static OPTIMIZE_WITH_UV: boolean;
  81407. /**
  81408. * Invert model on y-axis (does a model scaling inversion)
  81409. */
  81410. static INVERT_Y: boolean;
  81411. /**
  81412. * Invert Y-Axis of referenced textures on load
  81413. */
  81414. static get INVERT_TEXTURE_Y(): boolean;
  81415. static set INVERT_TEXTURE_Y(value: boolean);
  81416. /**
  81417. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81418. */
  81419. static IMPORT_VERTEX_COLORS: boolean;
  81420. /**
  81421. * Compute the normals for the model, even if normals are present in the file.
  81422. */
  81423. static COMPUTE_NORMALS: boolean;
  81424. /**
  81425. * Defines custom scaling of UV coordinates of loaded meshes.
  81426. */
  81427. static UV_SCALING: Vector2;
  81428. /**
  81429. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81430. */
  81431. static SKIP_MATERIALS: boolean;
  81432. /**
  81433. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81434. *
  81435. * Defaults to true for backwards compatibility.
  81436. */
  81437. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81438. /**
  81439. * Defines the name of the plugin.
  81440. */
  81441. name: string;
  81442. /**
  81443. * Defines the extension the plugin is able to load.
  81444. */
  81445. extensions: string;
  81446. /** @hidden */
  81447. obj: RegExp;
  81448. /** @hidden */
  81449. group: RegExp;
  81450. /** @hidden */
  81451. mtllib: RegExp;
  81452. /** @hidden */
  81453. usemtl: RegExp;
  81454. /** @hidden */
  81455. smooth: RegExp;
  81456. /** @hidden */
  81457. vertexPattern: RegExp;
  81458. /** @hidden */
  81459. normalPattern: RegExp;
  81460. /** @hidden */
  81461. uvPattern: RegExp;
  81462. /** @hidden */
  81463. facePattern1: RegExp;
  81464. /** @hidden */
  81465. facePattern2: RegExp;
  81466. /** @hidden */
  81467. facePattern3: RegExp;
  81468. /** @hidden */
  81469. facePattern4: RegExp;
  81470. /** @hidden */
  81471. facePattern5: RegExp;
  81472. private _forAssetContainer;
  81473. private _meshLoadOptions;
  81474. /**
  81475. * Creates loader for .OBJ files
  81476. *
  81477. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81478. */
  81479. constructor(meshLoadOptions?: MeshLoadOptions);
  81480. private static get currentMeshLoadOptions();
  81481. /**
  81482. * Calls synchronously the MTL file attached to this obj.
  81483. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81484. * Without this function materials are not displayed in the first frame (but displayed after).
  81485. * In consequence it is impossible to get material information in your HTML file
  81486. *
  81487. * @param url The URL of the MTL file
  81488. * @param rootUrl
  81489. * @param onSuccess Callback function to be called when the MTL file is loaded
  81490. * @private
  81491. */
  81492. private _loadMTL;
  81493. /**
  81494. * Instantiates a OBJ file loader plugin.
  81495. * @returns the created plugin
  81496. */
  81497. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81498. /**
  81499. * If the data string can be loaded directly.
  81500. *
  81501. * @param data string containing the file data
  81502. * @returns if the data can be loaded directly
  81503. */
  81504. canDirectLoad(data: string): boolean;
  81505. /**
  81506. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81507. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81508. * @param scene the scene the meshes should be added to
  81509. * @param data the OBJ data to load
  81510. * @param rootUrl root url to load from
  81511. * @param onProgress event that fires when loading progress has occured
  81512. * @param fileName Defines the name of the file to load
  81513. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81514. */
  81515. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81516. meshes: AbstractMesh[];
  81517. particleSystems: IParticleSystem[];
  81518. skeletons: Skeleton[];
  81519. animationGroups: AnimationGroup[];
  81520. }>;
  81521. /**
  81522. * Imports all objects from the loaded OBJ data and adds them to the scene
  81523. * @param scene the scene the objects should be added to
  81524. * @param data the OBJ data to load
  81525. * @param rootUrl root url to load from
  81526. * @param onProgress event that fires when loading progress has occured
  81527. * @param fileName Defines the name of the file to load
  81528. * @returns a promise which completes when objects have been loaded to the scene
  81529. */
  81530. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81531. /**
  81532. * Load into an asset container.
  81533. * @param scene The scene to load into
  81534. * @param data The data to import
  81535. * @param rootUrl The root url for scene and resources
  81536. * @param onProgress The callback when the load progresses
  81537. * @param fileName Defines the name of the file to load
  81538. * @returns The loaded asset container
  81539. */
  81540. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81541. /**
  81542. * Read the OBJ file and create an Array of meshes.
  81543. * Each mesh contains all information given by the OBJ and the MTL file.
  81544. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81545. *
  81546. * @param meshesNames
  81547. * @param scene Scene The scene where are displayed the data
  81548. * @param data String The content of the obj file
  81549. * @param rootUrl String The path to the folder
  81550. * @returns Array<AbstractMesh>
  81551. * @private
  81552. */
  81553. private _parseSolid;
  81554. }
  81555. }
  81556. declare module BABYLON {
  81557. /**
  81558. * STL file type loader.
  81559. * This is a babylon scene loader plugin.
  81560. */
  81561. export class STLFileLoader implements ISceneLoaderPlugin {
  81562. /** @hidden */
  81563. solidPattern: RegExp;
  81564. /** @hidden */
  81565. facetsPattern: RegExp;
  81566. /** @hidden */
  81567. normalPattern: RegExp;
  81568. /** @hidden */
  81569. vertexPattern: RegExp;
  81570. /**
  81571. * Defines the name of the plugin.
  81572. */
  81573. name: string;
  81574. /**
  81575. * Defines the extensions the stl loader is able to load.
  81576. * force data to come in as an ArrayBuffer
  81577. * we'll convert to string if it looks like it's an ASCII .stl
  81578. */
  81579. extensions: ISceneLoaderPluginExtensions;
  81580. /**
  81581. * Import meshes into a scene.
  81582. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81583. * @param scene The scene to import into
  81584. * @param data The data to import
  81585. * @param rootUrl The root url for scene and resources
  81586. * @param meshes The meshes array to import into
  81587. * @param particleSystems The particle systems array to import into
  81588. * @param skeletons The skeletons array to import into
  81589. * @param onError The callback when import fails
  81590. * @returns True if successful or false otherwise
  81591. */
  81592. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81593. /**
  81594. * Load into a scene.
  81595. * @param scene The scene to load into
  81596. * @param data The data to import
  81597. * @param rootUrl The root url for scene and resources
  81598. * @param onError The callback when import fails
  81599. * @returns true if successful or false otherwise
  81600. */
  81601. load(scene: Scene, data: any, rootUrl: string): boolean;
  81602. /**
  81603. * Load into an asset container.
  81604. * @param scene The scene to load into
  81605. * @param data The data to import
  81606. * @param rootUrl The root url for scene and resources
  81607. * @param onError The callback when import fails
  81608. * @returns The loaded asset container
  81609. */
  81610. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81611. private _isBinary;
  81612. private _parseBinary;
  81613. private _parseASCII;
  81614. }
  81615. }
  81616. declare module BABYLON {
  81617. /**
  81618. * Class for generating OBJ data from a Babylon scene.
  81619. */
  81620. export class OBJExport {
  81621. /**
  81622. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81623. * @param mesh defines the list of meshes to serialize
  81624. * @param materials defines if materials should be exported
  81625. * @param matlibname defines the name of the associated mtl file
  81626. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81627. * @returns the OBJ content
  81628. */
  81629. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81630. /**
  81631. * Exports the material(s) of a mesh in .MTL file format (text)
  81632. * @param mesh defines the mesh to extract the material from
  81633. * @returns the mtl content
  81634. */
  81635. static MTL(mesh: Mesh): string;
  81636. }
  81637. }
  81638. declare module BABYLON {
  81639. /** @hidden */
  81640. export var __IGLTFExporterExtension: number;
  81641. /**
  81642. * Interface for extending the exporter
  81643. * @hidden
  81644. */
  81645. export interface IGLTFExporterExtension {
  81646. /**
  81647. * The name of this extension
  81648. */
  81649. readonly name: string;
  81650. /**
  81651. * Defines whether this extension is enabled
  81652. */
  81653. enabled: boolean;
  81654. /**
  81655. * Defines whether this extension is required
  81656. */
  81657. required: boolean;
  81658. }
  81659. }
  81660. declare module BABYLON.GLTF2.Exporter {
  81661. /** @hidden */
  81662. export var __IGLTFExporterExtensionV2: number;
  81663. /**
  81664. * Interface for a glTF exporter extension
  81665. * @hidden
  81666. */
  81667. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81668. /**
  81669. * Define this method to modify the default behavior before exporting a texture
  81670. * @param context The context when loading the asset
  81671. * @param babylonTexture The Babylon.js texture
  81672. * @param mimeType The mime-type of the generated image
  81673. * @returns A promise that resolves with the exported texture
  81674. */
  81675. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81676. /**
  81677. * Define this method to get notified when a texture info is created
  81678. * @param context The context when loading the asset
  81679. * @param textureInfo The glTF texture info
  81680. * @param babylonTexture The Babylon.js texture
  81681. */
  81682. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81683. /**
  81684. * Define this method to modify the default behavior when exporting texture info
  81685. * @param context The context when loading the asset
  81686. * @param meshPrimitive glTF mesh primitive
  81687. * @param babylonSubMesh Babylon submesh
  81688. * @param binaryWriter glTF serializer binary writer instance
  81689. * @returns nullable IMeshPrimitive promise
  81690. */
  81691. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81692. /**
  81693. * Define this method to modify the default behavior when exporting a node
  81694. * @param context The context when exporting the node
  81695. * @param node glTF node
  81696. * @param babylonNode BabylonJS node
  81697. * @returns nullable INode promise
  81698. */
  81699. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81700. [key: number]: number;
  81701. }): Promise<Nullable<INode>>;
  81702. /**
  81703. * Define this method to modify the default behavior when exporting a material
  81704. * @param material glTF material
  81705. * @param babylonMaterial BabylonJS material
  81706. * @returns nullable IMaterial promise
  81707. */
  81708. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81709. /**
  81710. * Define this method to return additional textures to export from a material
  81711. * @param material glTF material
  81712. * @param babylonMaterial BabylonJS material
  81713. * @returns List of textures
  81714. */
  81715. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81716. /** Gets a boolean indicating that this extension was used */
  81717. wasUsed: boolean;
  81718. /** Gets a boolean indicating that this extension is required for the file to work */
  81719. required: boolean;
  81720. /**
  81721. * Called after the exporter state changes to EXPORTING
  81722. */
  81723. onExporting?(): void;
  81724. }
  81725. }
  81726. declare module BABYLON.GLTF2.Exporter {
  81727. /**
  81728. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81729. * @hidden
  81730. */
  81731. export class _GLTFMaterialExporter {
  81732. /**
  81733. * Represents the dielectric specular values for R, G and B
  81734. */
  81735. private static readonly _DielectricSpecular;
  81736. /**
  81737. * Allows the maximum specular power to be defined for material calculations
  81738. */
  81739. private static readonly _MaxSpecularPower;
  81740. /**
  81741. * Mapping to store textures
  81742. */
  81743. private _textureMap;
  81744. /**
  81745. * Numeric tolerance value
  81746. */
  81747. private static readonly _Epsilon;
  81748. /**
  81749. * Reference to the glTF Exporter
  81750. */
  81751. private _exporter;
  81752. constructor(exporter: _Exporter);
  81753. /**
  81754. * Specifies if two colors are approximately equal in value
  81755. * @param color1 first color to compare to
  81756. * @param color2 second color to compare to
  81757. * @param epsilon threshold value
  81758. */
  81759. private static FuzzyEquals;
  81760. /**
  81761. * Gets the materials from a Babylon scene and converts them to glTF materials
  81762. * @param scene babylonjs scene
  81763. * @param mimeType texture mime type
  81764. * @param images array of images
  81765. * @param textures array of textures
  81766. * @param materials array of materials
  81767. * @param imageData mapping of texture names to base64 textures
  81768. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81769. */
  81770. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81771. /**
  81772. * Makes a copy of the glTF material without the texture parameters
  81773. * @param originalMaterial original glTF material
  81774. * @returns glTF material without texture parameters
  81775. */
  81776. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81777. /**
  81778. * Specifies if the material has any texture parameters present
  81779. * @param material glTF Material
  81780. * @returns boolean specifying if texture parameters are present
  81781. */
  81782. _hasTexturesPresent(material: IMaterial): boolean;
  81783. /**
  81784. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81785. * @param babylonStandardMaterial
  81786. * @returns glTF Metallic Roughness Material representation
  81787. */
  81788. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81789. /**
  81790. * Computes the metallic factor
  81791. * @param diffuse diffused value
  81792. * @param specular specular value
  81793. * @param oneMinusSpecularStrength one minus the specular strength
  81794. * @returns metallic value
  81795. */
  81796. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81797. /**
  81798. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81799. * @param glTFMaterial glTF material
  81800. * @param babylonMaterial Babylon material
  81801. */
  81802. private static _SetAlphaMode;
  81803. /**
  81804. * Converts a Babylon Standard Material to a glTF Material
  81805. * @param babylonStandardMaterial BJS Standard Material
  81806. * @param mimeType mime type to use for the textures
  81807. * @param images array of glTF image interfaces
  81808. * @param textures array of glTF texture interfaces
  81809. * @param materials array of glTF material interfaces
  81810. * @param imageData map of image file name to data
  81811. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81812. */
  81813. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81814. private _finishMaterial;
  81815. /**
  81816. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81817. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81818. * @param mimeType mime type to use for the textures
  81819. * @param images array of glTF image interfaces
  81820. * @param textures array of glTF texture interfaces
  81821. * @param materials array of glTF material interfaces
  81822. * @param imageData map of image file name to data
  81823. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81824. */
  81825. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81826. /**
  81827. * Converts an image typed array buffer to a base64 image
  81828. * @param buffer typed array buffer
  81829. * @param width width of the image
  81830. * @param height height of the image
  81831. * @param mimeType mimetype of the image
  81832. * @returns base64 image string
  81833. */
  81834. private _createBase64FromCanvasAsync;
  81835. /**
  81836. * Generates a white texture based on the specified width and height
  81837. * @param width width of the texture in pixels
  81838. * @param height height of the texture in pixels
  81839. * @param scene babylonjs scene
  81840. * @returns white texture
  81841. */
  81842. private _createWhiteTexture;
  81843. /**
  81844. * 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
  81845. * @param texture1 first texture to resize
  81846. * @param texture2 second texture to resize
  81847. * @param scene babylonjs scene
  81848. * @returns resized textures or null
  81849. */
  81850. private _resizeTexturesToSameDimensions;
  81851. /**
  81852. * Converts an array of pixels to a Float32Array
  81853. * Throws an error if the pixel format is not supported
  81854. * @param pixels - array buffer containing pixel values
  81855. * @returns Float32 of pixels
  81856. */
  81857. private _convertPixelArrayToFloat32;
  81858. /**
  81859. * Convert Specular Glossiness Textures to Metallic Roughness
  81860. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81861. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81862. * @param diffuseTexture texture used to store diffuse information
  81863. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81864. * @param factors specular glossiness material factors
  81865. * @param mimeType the mime type to use for the texture
  81866. * @returns pbr metallic roughness interface or null
  81867. */
  81868. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81869. /**
  81870. * Converts specular glossiness material properties to metallic roughness
  81871. * @param specularGlossiness interface with specular glossiness material properties
  81872. * @returns interface with metallic roughness material properties
  81873. */
  81874. private _convertSpecularGlossinessToMetallicRoughness;
  81875. /**
  81876. * Calculates the surface reflectance, independent of lighting conditions
  81877. * @param color Color source to calculate brightness from
  81878. * @returns number representing the perceived brightness, or zero if color is undefined
  81879. */
  81880. private _getPerceivedBrightness;
  81881. /**
  81882. * Returns the maximum color component value
  81883. * @param color
  81884. * @returns maximum color component value, or zero if color is null or undefined
  81885. */
  81886. private _getMaxComponent;
  81887. /**
  81888. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81889. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81890. * @param mimeType mime type to use for the textures
  81891. * @param images array of glTF image interfaces
  81892. * @param textures array of glTF texture interfaces
  81893. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81894. * @param imageData map of image file name to data
  81895. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81896. * @returns glTF PBR Metallic Roughness factors
  81897. */
  81898. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81899. private _getGLTFTextureSampler;
  81900. private _getGLTFTextureWrapMode;
  81901. private _getGLTFTextureWrapModesSampler;
  81902. /**
  81903. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81904. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81905. * @param mimeType mime type to use for the textures
  81906. * @param images array of glTF image interfaces
  81907. * @param textures array of glTF texture interfaces
  81908. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81909. * @param imageData map of image file name to data
  81910. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81911. * @returns glTF PBR Metallic Roughness factors
  81912. */
  81913. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81914. /**
  81915. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81916. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81917. * @param mimeType mime type to use for the textures
  81918. * @param images array of glTF image interfaces
  81919. * @param textures array of glTF texture interfaces
  81920. * @param materials array of glTF material interfaces
  81921. * @param imageData map of image file name to data
  81922. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81923. */
  81924. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81925. private setMetallicRoughnessPbrMaterial;
  81926. private getPixelsFromTexture;
  81927. /**
  81928. * Extracts a texture from a Babylon texture into file data and glTF data
  81929. * @param babylonTexture Babylon texture to extract
  81930. * @param mimeType Mime Type of the babylonTexture
  81931. * @return glTF texture info, or null if the texture format is not supported
  81932. */
  81933. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81934. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81935. /**
  81936. * Builds a texture from base64 string
  81937. * @param base64Texture base64 texture string
  81938. * @param baseTextureName Name to use for the texture
  81939. * @param mimeType image mime type for the texture
  81940. * @param images array of images
  81941. * @param textures array of textures
  81942. * @param imageData map of image data
  81943. * @returns glTF texture info, or null if the texture format is not supported
  81944. */
  81945. private _getTextureInfoFromBase64;
  81946. }
  81947. }
  81948. declare module BABYLON {
  81949. /**
  81950. * Class for holding and downloading glTF file data
  81951. */
  81952. export class GLTFData {
  81953. /**
  81954. * Object which contains the file name as the key and its data as the value
  81955. */
  81956. glTFFiles: {
  81957. [fileName: string]: string | Blob;
  81958. };
  81959. /**
  81960. * Initializes the glTF file object
  81961. */
  81962. constructor();
  81963. /**
  81964. * Downloads the glTF data as files based on their names and data
  81965. */
  81966. downloadFiles(): void;
  81967. }
  81968. }
  81969. declare module BABYLON {
  81970. /**
  81971. * Holds a collection of exporter options and parameters
  81972. */
  81973. export interface IExportOptions {
  81974. /**
  81975. * Function which indicates whether a babylon node should be exported or not
  81976. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81977. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81978. */
  81979. shouldExportNode?(node: Node): boolean;
  81980. /**
  81981. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81982. * @param metadata source metadata to read from
  81983. * @returns the data to store to glTF node extras
  81984. */
  81985. metadataSelector?(metadata: any): any;
  81986. /**
  81987. * The sample rate to bake animation curves
  81988. */
  81989. animationSampleRate?: number;
  81990. /**
  81991. * Begin serialization without waiting for the scene to be ready
  81992. */
  81993. exportWithoutWaitingForScene?: boolean;
  81994. /**
  81995. * Indicates if coordinate system swapping root nodes should be included in export
  81996. */
  81997. includeCoordinateSystemConversionNodes?: boolean;
  81998. }
  81999. /**
  82000. * Class for generating glTF data from a Babylon scene.
  82001. */
  82002. export class GLTF2Export {
  82003. /**
  82004. * Exports the geometry of the scene to .gltf file format asynchronously
  82005. * @param scene Babylon scene with scene hierarchy information
  82006. * @param filePrefix File prefix to use when generating the glTF file
  82007. * @param options Exporter options
  82008. * @returns Returns an object with a .gltf file and associates texture names
  82009. * as keys and their data and paths as values
  82010. */
  82011. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82012. private static _PreExportAsync;
  82013. private static _PostExportAsync;
  82014. /**
  82015. * Exports the geometry of the scene to .glb file format asychronously
  82016. * @param scene Babylon scene with scene hierarchy information
  82017. * @param filePrefix File prefix to use when generating glb file
  82018. * @param options Exporter options
  82019. * @returns Returns an object with a .glb filename as key and data as value
  82020. */
  82021. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82022. }
  82023. }
  82024. declare module BABYLON.GLTF2.Exporter {
  82025. /**
  82026. * @hidden
  82027. */
  82028. export class _GLTFUtilities {
  82029. /**
  82030. * Creates a buffer view based on the supplied arguments
  82031. * @param bufferIndex index value of the specified buffer
  82032. * @param byteOffset byte offset value
  82033. * @param byteLength byte length of the bufferView
  82034. * @param byteStride byte distance between conequential elements
  82035. * @param name name of the buffer view
  82036. * @returns bufferView for glTF
  82037. */
  82038. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82039. /**
  82040. * Creates an accessor based on the supplied arguments
  82041. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82042. * @param name The name of the accessor
  82043. * @param type The type of the accessor
  82044. * @param componentType The datatype of components in the attribute
  82045. * @param count The number of attributes referenced by this accessor
  82046. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82047. * @param min Minimum value of each component in this attribute
  82048. * @param max Maximum value of each component in this attribute
  82049. * @returns accessor for glTF
  82050. */
  82051. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82052. /**
  82053. * Calculates the minimum and maximum values of an array of position floats
  82054. * @param positions Positions array of a mesh
  82055. * @param vertexStart Starting vertex offset to calculate min and max values
  82056. * @param vertexCount Number of vertices to check for min and max values
  82057. * @returns min number array and max number array
  82058. */
  82059. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82060. min: number[];
  82061. max: number[];
  82062. };
  82063. /**
  82064. * Converts a new right-handed Vector3
  82065. * @param vector vector3 array
  82066. * @returns right-handed Vector3
  82067. */
  82068. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82069. /**
  82070. * Converts a Vector3 to right-handed
  82071. * @param vector Vector3 to convert to right-handed
  82072. */
  82073. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82074. /**
  82075. * Converts a three element number array to right-handed
  82076. * @param vector number array to convert to right-handed
  82077. */
  82078. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82079. /**
  82080. * Converts a new right-handed Vector3
  82081. * @param vector vector3 array
  82082. * @returns right-handed Vector3
  82083. */
  82084. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82085. /**
  82086. * Converts a Vector3 to right-handed
  82087. * @param vector Vector3 to convert to right-handed
  82088. */
  82089. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82090. /**
  82091. * Converts a three element number array to right-handed
  82092. * @param vector number array to convert to right-handed
  82093. */
  82094. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82095. /**
  82096. * Converts a Vector4 to right-handed
  82097. * @param vector Vector4 to convert to right-handed
  82098. */
  82099. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82100. /**
  82101. * Converts a Vector4 to right-handed
  82102. * @param vector Vector4 to convert to right-handed
  82103. */
  82104. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82105. /**
  82106. * Converts a Quaternion to right-handed
  82107. * @param quaternion Source quaternion to convert to right-handed
  82108. */
  82109. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82110. /**
  82111. * Converts a Quaternion to right-handed
  82112. * @param quaternion Source quaternion to convert to right-handed
  82113. */
  82114. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82115. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82116. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82117. }
  82118. }
  82119. declare module BABYLON.GLTF2.Exporter {
  82120. /**
  82121. * Converts Babylon Scene into glTF 2.0.
  82122. * @hidden
  82123. */
  82124. export class _Exporter {
  82125. /**
  82126. * Stores the glTF to export
  82127. */
  82128. _glTF: IGLTF;
  82129. /**
  82130. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82131. */
  82132. _bufferViews: IBufferView[];
  82133. /**
  82134. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82135. */
  82136. _accessors: IAccessor[];
  82137. /**
  82138. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82139. */
  82140. _nodes: INode[];
  82141. /**
  82142. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82143. */
  82144. private _scenes;
  82145. /**
  82146. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82147. */
  82148. private _meshes;
  82149. /**
  82150. * Stores all the generated material information, which represents the appearance of each primitive
  82151. */
  82152. _materials: IMaterial[];
  82153. _materialMap: {
  82154. [materialID: number]: number;
  82155. };
  82156. /**
  82157. * Stores all the generated texture information, which is referenced by glTF materials
  82158. */
  82159. _textures: ITexture[];
  82160. /**
  82161. * Stores all the generated image information, which is referenced by glTF textures
  82162. */
  82163. _images: IImage[];
  82164. /**
  82165. * Stores all the texture samplers
  82166. */
  82167. _samplers: ISampler[];
  82168. /**
  82169. * Stores all the generated glTF skins
  82170. */
  82171. _skins: ISkin[];
  82172. /**
  82173. * Stores all the generated animation samplers, which is referenced by glTF animations
  82174. */
  82175. /**
  82176. * Stores the animations for glTF models
  82177. */
  82178. private _animations;
  82179. /**
  82180. * Stores the total amount of bytes stored in the glTF buffer
  82181. */
  82182. private _totalByteLength;
  82183. /**
  82184. * Stores a reference to the Babylon scene containing the source geometry and material information
  82185. */
  82186. _babylonScene: Scene;
  82187. /**
  82188. * Stores a map of the image data, where the key is the file name and the value
  82189. * is the image data
  82190. */
  82191. _imageData: {
  82192. [fileName: string]: {
  82193. data: Uint8Array;
  82194. mimeType: ImageMimeType;
  82195. };
  82196. };
  82197. /**
  82198. * Stores a map of the unique id of a node to its index in the node array
  82199. */
  82200. _nodeMap: {
  82201. [key: number]: number;
  82202. };
  82203. /**
  82204. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82205. */
  82206. _convertToRightHandedSystem: boolean;
  82207. /**
  82208. * Specifies if a Babylon node should be converted to right-handed on export
  82209. */
  82210. _convertToRightHandedSystemMap: {
  82211. [nodeId: number]: boolean;
  82212. };
  82213. _includeCoordinateSystemConversionNodes: boolean;
  82214. /**
  82215. * Baked animation sample rate
  82216. */
  82217. private _animationSampleRate;
  82218. private _options;
  82219. private _localEngine;
  82220. _glTFMaterialExporter: _GLTFMaterialExporter;
  82221. private _extensions;
  82222. private static _ExtensionNames;
  82223. private static _ExtensionFactories;
  82224. private _applyExtension;
  82225. private _applyExtensions;
  82226. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82227. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82228. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82229. [key: number]: number;
  82230. }): Promise<Nullable<INode>>;
  82231. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82232. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82233. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82234. private _forEachExtensions;
  82235. private _extensionsOnExporting;
  82236. /**
  82237. * Load glTF serializer extensions
  82238. */
  82239. private _loadExtensions;
  82240. /**
  82241. * Creates a glTF Exporter instance, which can accept optional exporter options
  82242. * @param babylonScene Babylon scene object
  82243. * @param options Options to modify the behavior of the exporter
  82244. */
  82245. constructor(babylonScene: Scene, options?: IExportOptions);
  82246. dispose(): void;
  82247. /**
  82248. * Registers a glTF exporter extension
  82249. * @param name Name of the extension to export
  82250. * @param factory The factory function that creates the exporter extension
  82251. */
  82252. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82253. /**
  82254. * Un-registers an exporter extension
  82255. * @param name The name fo the exporter extension
  82256. * @returns A boolean indicating whether the extension has been un-registered
  82257. */
  82258. static UnregisterExtension(name: string): boolean;
  82259. /**
  82260. * Lazy load a local engine
  82261. */
  82262. _getLocalEngine(): Engine;
  82263. private reorderIndicesBasedOnPrimitiveMode;
  82264. /**
  82265. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82266. * clock-wise during export to glTF
  82267. * @param submesh BabylonJS submesh
  82268. * @param primitiveMode Primitive mode of the mesh
  82269. * @param sideOrientation the winding order of the submesh
  82270. * @param vertexBufferKind The type of vertex attribute
  82271. * @param meshAttributeArray The vertex attribute data
  82272. * @param byteOffset The offset to the binary data
  82273. * @param binaryWriter The binary data for the glTF file
  82274. * @param convertToRightHandedSystem Converts the values to right-handed
  82275. */
  82276. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82277. /**
  82278. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82279. * clock-wise during export to glTF
  82280. * @param submesh BabylonJS submesh
  82281. * @param primitiveMode Primitive mode of the mesh
  82282. * @param sideOrientation the winding order of the submesh
  82283. * @param vertexBufferKind The type of vertex attribute
  82284. * @param meshAttributeArray The vertex attribute data
  82285. * @param byteOffset The offset to the binary data
  82286. * @param binaryWriter The binary data for the glTF file
  82287. * @param convertToRightHandedSystem Converts the values to right-handed
  82288. */
  82289. private reorderTriangleFillMode;
  82290. /**
  82291. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82292. * clock-wise during export to glTF
  82293. * @param submesh BabylonJS submesh
  82294. * @param primitiveMode Primitive mode of the mesh
  82295. * @param sideOrientation the winding order of the submesh
  82296. * @param vertexBufferKind The type of vertex attribute
  82297. * @param meshAttributeArray The vertex attribute data
  82298. * @param byteOffset The offset to the binary data
  82299. * @param binaryWriter The binary data for the glTF file
  82300. * @param convertToRightHandedSystem Converts the values to right-handed
  82301. */
  82302. private reorderTriangleStripDrawMode;
  82303. /**
  82304. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82305. * clock-wise during export to glTF
  82306. * @param submesh BabylonJS submesh
  82307. * @param primitiveMode Primitive mode of the mesh
  82308. * @param sideOrientation the winding order of the submesh
  82309. * @param vertexBufferKind The type of vertex attribute
  82310. * @param meshAttributeArray The vertex attribute data
  82311. * @param byteOffset The offset to the binary data
  82312. * @param binaryWriter The binary data for the glTF file
  82313. * @param convertToRightHandedSystem Converts the values to right-handed
  82314. */
  82315. private reorderTriangleFanMode;
  82316. /**
  82317. * Writes the vertex attribute data to binary
  82318. * @param vertices The vertices to write to the binary writer
  82319. * @param byteOffset The offset into the binary writer to overwrite binary data
  82320. * @param vertexAttributeKind The vertex attribute type
  82321. * @param meshAttributeArray The vertex attribute data
  82322. * @param binaryWriter The writer containing the binary data
  82323. * @param convertToRightHandedSystem Converts the values to right-handed
  82324. */
  82325. private writeVertexAttributeData;
  82326. /**
  82327. * Writes mesh attribute data to a data buffer
  82328. * Returns the bytelength of the data
  82329. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82330. * @param meshAttributeArray Array containing the attribute data
  82331. * @param byteStride Specifies the space between data
  82332. * @param binaryWriter The buffer to write the binary data to
  82333. * @param convertToRightHandedSystem Converts the values to right-handed
  82334. */
  82335. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82336. /**
  82337. * Generates glTF json data
  82338. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82339. * @param glTFPrefix Text to use when prefixing a glTF file
  82340. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82341. * @returns json data as string
  82342. */
  82343. private generateJSON;
  82344. /**
  82345. * Generates data for .gltf and .bin files based on the glTF prefix string
  82346. * @param glTFPrefix Text to use when prefixing a glTF file
  82347. * @param dispose Dispose the exporter
  82348. * @returns GLTFData with glTF file data
  82349. */
  82350. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82351. /**
  82352. * Creates a binary buffer for glTF
  82353. * @returns array buffer for binary data
  82354. */
  82355. private _generateBinaryAsync;
  82356. /**
  82357. * Pads the number to a multiple of 4
  82358. * @param num number to pad
  82359. * @returns padded number
  82360. */
  82361. private _getPadding;
  82362. /**
  82363. * @hidden
  82364. */
  82365. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82366. /**
  82367. * Sets the TRS for each node
  82368. * @param node glTF Node for storing the transformation data
  82369. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82370. * @param convertToRightHandedSystem Converts the values to right-handed
  82371. */
  82372. private setNodeTransformation;
  82373. private getVertexBufferFromMesh;
  82374. /**
  82375. * Creates a bufferview based on the vertices type for the Babylon mesh
  82376. * @param kind Indicates the type of vertices data
  82377. * @param componentType Indicates the numerical type used to store the data
  82378. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82379. * @param binaryWriter The buffer to write the bufferview data to
  82380. * @param convertToRightHandedSystem Converts the values to right-handed
  82381. */
  82382. private createBufferViewKind;
  82383. /**
  82384. * The primitive mode of the Babylon mesh
  82385. * @param babylonMesh The BabylonJS mesh
  82386. */
  82387. private getMeshPrimitiveMode;
  82388. /**
  82389. * Sets the primitive mode of the glTF mesh primitive
  82390. * @param meshPrimitive glTF mesh primitive
  82391. * @param primitiveMode The primitive mode
  82392. */
  82393. private setPrimitiveMode;
  82394. /**
  82395. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82396. * @param meshPrimitive glTF mesh primitive
  82397. * @param attributeKind vertex attribute
  82398. * @returns boolean specifying if uv coordinates are present
  82399. */
  82400. private setAttributeKind;
  82401. /**
  82402. * Sets data for the primitive attributes of each submesh
  82403. * @param mesh glTF Mesh object to store the primitive attribute information
  82404. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82405. * @param binaryWriter Buffer to write the attribute data to
  82406. * @param convertToRightHandedSystem Converts the values to right-handed
  82407. */
  82408. private setPrimitiveAttributesAsync;
  82409. /**
  82410. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82411. * @param node The node to check
  82412. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82413. */
  82414. private isBabylonCoordinateSystemConvertingNode;
  82415. /**
  82416. * Creates a glTF scene based on the array of meshes
  82417. * Returns the the total byte offset
  82418. * @param babylonScene Babylon scene to get the mesh data from
  82419. * @param binaryWriter Buffer to write binary data to
  82420. */
  82421. private createSceneAsync;
  82422. /**
  82423. * Creates a mapping of Node unique id to node index and handles animations
  82424. * @param babylonScene Babylon Scene
  82425. * @param nodes Babylon transform nodes
  82426. * @param binaryWriter Buffer to write binary data to
  82427. * @returns Node mapping of unique id to index
  82428. */
  82429. private createNodeMapAndAnimationsAsync;
  82430. /**
  82431. * Creates a glTF node from a Babylon mesh
  82432. * @param babylonMesh Source Babylon mesh
  82433. * @param binaryWriter Buffer for storing geometry data
  82434. * @param convertToRightHandedSystem Converts the values to right-handed
  82435. * @param nodeMap Node mapping of unique id to glTF node index
  82436. * @returns glTF node
  82437. */
  82438. private createNodeAsync;
  82439. /**
  82440. * Creates a glTF skin from a Babylon skeleton
  82441. * @param babylonScene Babylon Scene
  82442. * @param nodes Babylon transform nodes
  82443. * @param binaryWriter Buffer to write binary data to
  82444. * @returns Node mapping of unique id to index
  82445. */
  82446. private createSkinsAsync;
  82447. }
  82448. /**
  82449. * @hidden
  82450. *
  82451. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82452. */
  82453. export class _BinaryWriter {
  82454. /**
  82455. * Array buffer which stores all binary data
  82456. */
  82457. private _arrayBuffer;
  82458. /**
  82459. * View of the array buffer
  82460. */
  82461. private _dataView;
  82462. /**
  82463. * byte offset of data in array buffer
  82464. */
  82465. private _byteOffset;
  82466. /**
  82467. * Initialize binary writer with an initial byte length
  82468. * @param byteLength Initial byte length of the array buffer
  82469. */
  82470. constructor(byteLength: number);
  82471. /**
  82472. * Resize the array buffer to the specified byte length
  82473. * @param byteLength
  82474. */
  82475. private resizeBuffer;
  82476. /**
  82477. * Get an array buffer with the length of the byte offset
  82478. * @returns ArrayBuffer resized to the byte offset
  82479. */
  82480. getArrayBuffer(): ArrayBuffer;
  82481. /**
  82482. * Get the byte offset of the array buffer
  82483. * @returns byte offset
  82484. */
  82485. getByteOffset(): number;
  82486. /**
  82487. * Stores an UInt8 in the array buffer
  82488. * @param entry
  82489. * @param byteOffset If defined, specifies where to set the value as an offset.
  82490. */
  82491. setUInt8(entry: number, byteOffset?: number): void;
  82492. /**
  82493. * Stores an UInt16 in the array buffer
  82494. * @param entry
  82495. * @param byteOffset If defined, specifies where to set the value as an offset.
  82496. */
  82497. setUInt16(entry: number, byteOffset?: number): void;
  82498. /**
  82499. * Gets an UInt32 in the array buffer
  82500. * @param entry
  82501. * @param byteOffset If defined, specifies where to set the value as an offset.
  82502. */
  82503. getUInt32(byteOffset: number): number;
  82504. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82505. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82506. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82507. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82508. /**
  82509. * Stores a Float32 in the array buffer
  82510. * @param entry
  82511. */
  82512. setFloat32(entry: number, byteOffset?: number): void;
  82513. /**
  82514. * Stores an UInt32 in the array buffer
  82515. * @param entry
  82516. * @param byteOffset If defined, specifies where to set the value as an offset.
  82517. */
  82518. setUInt32(entry: number, byteOffset?: number): void;
  82519. }
  82520. }
  82521. declare module BABYLON.GLTF2.Exporter {
  82522. /**
  82523. * @hidden
  82524. * Interface to store animation data.
  82525. */
  82526. export interface _IAnimationData {
  82527. /**
  82528. * Keyframe data.
  82529. */
  82530. inputs: number[];
  82531. /**
  82532. * Value data.
  82533. */
  82534. outputs: number[][];
  82535. /**
  82536. * Animation interpolation data.
  82537. */
  82538. samplerInterpolation: AnimationSamplerInterpolation;
  82539. /**
  82540. * Minimum keyframe value.
  82541. */
  82542. inputsMin: number;
  82543. /**
  82544. * Maximum keyframe value.
  82545. */
  82546. inputsMax: number;
  82547. }
  82548. /**
  82549. * @hidden
  82550. */
  82551. export interface _IAnimationInfo {
  82552. /**
  82553. * The target channel for the animation
  82554. */
  82555. animationChannelTargetPath: AnimationChannelTargetPath;
  82556. /**
  82557. * The glTF accessor type for the data.
  82558. */
  82559. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82560. /**
  82561. * Specifies if quaternions should be used.
  82562. */
  82563. useQuaternion: boolean;
  82564. }
  82565. /**
  82566. * @hidden
  82567. * Utility class for generating glTF animation data from BabylonJS.
  82568. */
  82569. export class _GLTFAnimation {
  82570. /**
  82571. * @ignore
  82572. *
  82573. * Creates glTF channel animation from BabylonJS animation.
  82574. * @param babylonTransformNode - BabylonJS mesh.
  82575. * @param animation - animation.
  82576. * @param animationChannelTargetPath - The target animation channel.
  82577. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82578. * @param useQuaternion - Specifies if quaternions are used.
  82579. * @returns nullable IAnimationData
  82580. */
  82581. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82582. private static _DeduceAnimationInfo;
  82583. /**
  82584. * @ignore
  82585. * Create node animations from the transform node animations
  82586. * @param babylonNode
  82587. * @param runtimeGLTFAnimation
  82588. * @param idleGLTFAnimations
  82589. * @param nodeMap
  82590. * @param nodes
  82591. * @param binaryWriter
  82592. * @param bufferViews
  82593. * @param accessors
  82594. * @param convertToRightHandedSystem
  82595. * @param animationSampleRate
  82596. */
  82597. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82598. [key: number]: number;
  82599. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82600. /**
  82601. * @ignore
  82602. * Create node animations from the animation groups
  82603. * @param babylonScene
  82604. * @param glTFAnimations
  82605. * @param nodeMap
  82606. * @param nodes
  82607. * @param binaryWriter
  82608. * @param bufferViews
  82609. * @param accessors
  82610. * @param convertToRightHandedSystemMap
  82611. * @param animationSampleRate
  82612. */
  82613. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82614. [key: number]: number;
  82615. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82616. [nodeId: number]: boolean;
  82617. }, animationSampleRate: number): void;
  82618. private static AddAnimation;
  82619. /**
  82620. * Create a baked animation
  82621. * @param babylonTransformNode BabylonJS mesh
  82622. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82623. * @param animationChannelTargetPath animation target channel
  82624. * @param minFrame minimum animation frame
  82625. * @param maxFrame maximum animation frame
  82626. * @param fps frames per second of the animation
  82627. * @param inputs input key frames of the animation
  82628. * @param outputs output key frame data of the animation
  82629. * @param convertToRightHandedSystem converts the values to right-handed
  82630. * @param useQuaternion specifies if quaternions should be used
  82631. */
  82632. private static _CreateBakedAnimation;
  82633. private static _ConvertFactorToVector3OrQuaternion;
  82634. private static _SetInterpolatedValue;
  82635. /**
  82636. * Creates linear animation from the animation key frames
  82637. * @param babylonTransformNode BabylonJS mesh
  82638. * @param animation BabylonJS animation
  82639. * @param animationChannelTargetPath The target animation channel
  82640. * @param frameDelta The difference between the last and first frame of the animation
  82641. * @param inputs Array to store the key frame times
  82642. * @param outputs Array to store the key frame data
  82643. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82644. * @param useQuaternion Specifies if quaternions are used in the animation
  82645. */
  82646. private static _CreateLinearOrStepAnimation;
  82647. /**
  82648. * Creates cubic spline animation from the animation key frames
  82649. * @param babylonTransformNode BabylonJS mesh
  82650. * @param animation BabylonJS animation
  82651. * @param animationChannelTargetPath The target animation channel
  82652. * @param frameDelta The difference between the last and first frame of the animation
  82653. * @param inputs Array to store the key frame times
  82654. * @param outputs Array to store the key frame data
  82655. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82656. * @param useQuaternion Specifies if quaternions are used in the animation
  82657. */
  82658. private static _CreateCubicSplineAnimation;
  82659. private static _GetBasePositionRotationOrScale;
  82660. /**
  82661. * Adds a key frame value
  82662. * @param keyFrame
  82663. * @param animation
  82664. * @param outputs
  82665. * @param animationChannelTargetPath
  82666. * @param basePositionRotationOrScale
  82667. * @param convertToRightHandedSystem
  82668. * @param useQuaternion
  82669. */
  82670. private static _AddKeyframeValue;
  82671. /**
  82672. * Determine the interpolation based on the key frames
  82673. * @param keyFrames
  82674. * @param animationChannelTargetPath
  82675. * @param useQuaternion
  82676. */
  82677. private static _DeduceInterpolation;
  82678. /**
  82679. * Adds an input tangent or output tangent to the output data
  82680. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82681. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82682. * @param outputs The animation data by keyframe
  82683. * @param animationChannelTargetPath The target animation channel
  82684. * @param interpolation The interpolation type
  82685. * @param keyFrame The key frame with the animation data
  82686. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82687. * @param useQuaternion Specifies if quaternions are used
  82688. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82689. */
  82690. private static AddSplineTangent;
  82691. /**
  82692. * Get the minimum and maximum key frames' frame values
  82693. * @param keyFrames animation key frames
  82694. * @returns the minimum and maximum key frame value
  82695. */
  82696. private static calculateMinMaxKeyFrames;
  82697. }
  82698. }
  82699. declare module BABYLON.GLTF2.Exporter {
  82700. /** @hidden */
  82701. export var textureTransformPixelShader: {
  82702. name: string;
  82703. shader: string;
  82704. };
  82705. }
  82706. declare module BABYLON.GLTF2.Exporter.Extensions {
  82707. /**
  82708. * @hidden
  82709. */
  82710. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82711. private _recordedTextures;
  82712. /** Name of this extension */
  82713. readonly name: string;
  82714. /** Defines whether this extension is enabled */
  82715. enabled: boolean;
  82716. /** Defines whether this extension is required */
  82717. required: boolean;
  82718. /** Reference to the glTF exporter */
  82719. private _wasUsed;
  82720. constructor(exporter: _Exporter);
  82721. dispose(): void;
  82722. /** @hidden */
  82723. get wasUsed(): boolean;
  82724. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82725. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82726. /**
  82727. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82728. * @param babylonTexture
  82729. * @param offset
  82730. * @param rotation
  82731. * @param scale
  82732. * @param scene
  82733. */
  82734. private _textureTransformTextureAsync;
  82735. }
  82736. }
  82737. declare module BABYLON.GLTF2.Exporter.Extensions {
  82738. /**
  82739. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82740. */
  82741. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82742. /** The name of this extension. */
  82743. readonly name: string;
  82744. /** Defines whether this extension is enabled. */
  82745. enabled: boolean;
  82746. /** Defines whether this extension is required */
  82747. required: boolean;
  82748. /** Reference to the glTF exporter */
  82749. private _exporter;
  82750. private _lights;
  82751. /** @hidden */
  82752. constructor(exporter: _Exporter);
  82753. /** @hidden */
  82754. dispose(): void;
  82755. /** @hidden */
  82756. get wasUsed(): boolean;
  82757. /** @hidden */
  82758. onExporting(): void;
  82759. /**
  82760. * Define this method to modify the default behavior when exporting a node
  82761. * @param context The context when exporting the node
  82762. * @param node glTF node
  82763. * @param babylonNode BabylonJS node
  82764. * @param nodeMap Node mapping of unique id to glTF node index
  82765. * @returns nullable INode promise
  82766. */
  82767. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82768. [key: number]: number;
  82769. }): Promise<Nullable<INode>>;
  82770. }
  82771. }
  82772. declare module BABYLON.GLTF2.Exporter.Extensions {
  82773. /**
  82774. * @hidden
  82775. */
  82776. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82777. /** Name of this extension */
  82778. readonly name: string;
  82779. /** Defines whether this extension is enabled */
  82780. enabled: boolean;
  82781. /** Defines whether this extension is required */
  82782. required: boolean;
  82783. /** Reference to the glTF exporter */
  82784. private _textureInfos;
  82785. private _exportedTextures;
  82786. private _wasUsed;
  82787. constructor(exporter: _Exporter);
  82788. dispose(): void;
  82789. /** @hidden */
  82790. get wasUsed(): boolean;
  82791. private _getTextureIndex;
  82792. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82793. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82794. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82795. }
  82796. }
  82797. declare module BABYLON.GLTF2.Exporter.Extensions {
  82798. /**
  82799. * @hidden
  82800. */
  82801. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82802. /** Name of this extension */
  82803. readonly name: string;
  82804. /** Defines whether this extension is enabled */
  82805. enabled: boolean;
  82806. /** Defines whether this extension is required */
  82807. required: boolean;
  82808. private _wasUsed;
  82809. constructor(exporter: _Exporter);
  82810. /** @hidden */
  82811. get wasUsed(): boolean;
  82812. dispose(): void;
  82813. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82814. }
  82815. }
  82816. declare module BABYLON {
  82817. /**
  82818. * Class for generating STL data from a Babylon scene.
  82819. */
  82820. export class STLExport {
  82821. /**
  82822. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82823. * @param meshes list defines the mesh to serialize
  82824. * @param download triggers the automatic download of the file.
  82825. * @param fileName changes the downloads fileName.
  82826. * @param binary changes the STL to a binary type.
  82827. * @param isLittleEndian toggle for binary type exporter.
  82828. * @returns the STL as UTF8 string
  82829. */
  82830. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82831. }
  82832. }
  82833. declare module "babylonjs-gltf2interface" {
  82834. export = BABYLON.GLTF2;
  82835. }
  82836. /**
  82837. * Module for glTF 2.0 Interface
  82838. */
  82839. declare module BABYLON.GLTF2 {
  82840. /**
  82841. * The datatype of the components in the attribute
  82842. */
  82843. const enum AccessorComponentType {
  82844. /**
  82845. * Byte
  82846. */
  82847. BYTE = 5120,
  82848. /**
  82849. * Unsigned Byte
  82850. */
  82851. UNSIGNED_BYTE = 5121,
  82852. /**
  82853. * Short
  82854. */
  82855. SHORT = 5122,
  82856. /**
  82857. * Unsigned Short
  82858. */
  82859. UNSIGNED_SHORT = 5123,
  82860. /**
  82861. * Unsigned Int
  82862. */
  82863. UNSIGNED_INT = 5125,
  82864. /**
  82865. * Float
  82866. */
  82867. FLOAT = 5126,
  82868. }
  82869. /**
  82870. * Specifies if the attirbute is a scalar, vector, or matrix
  82871. */
  82872. const enum AccessorType {
  82873. /**
  82874. * Scalar
  82875. */
  82876. SCALAR = "SCALAR",
  82877. /**
  82878. * Vector2
  82879. */
  82880. VEC2 = "VEC2",
  82881. /**
  82882. * Vector3
  82883. */
  82884. VEC3 = "VEC3",
  82885. /**
  82886. * Vector4
  82887. */
  82888. VEC4 = "VEC4",
  82889. /**
  82890. * Matrix2x2
  82891. */
  82892. MAT2 = "MAT2",
  82893. /**
  82894. * Matrix3x3
  82895. */
  82896. MAT3 = "MAT3",
  82897. /**
  82898. * Matrix4x4
  82899. */
  82900. MAT4 = "MAT4",
  82901. }
  82902. /**
  82903. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82904. */
  82905. const enum AnimationChannelTargetPath {
  82906. /**
  82907. * Translation
  82908. */
  82909. TRANSLATION = "translation",
  82910. /**
  82911. * Rotation
  82912. */
  82913. ROTATION = "rotation",
  82914. /**
  82915. * Scale
  82916. */
  82917. SCALE = "scale",
  82918. /**
  82919. * Weights
  82920. */
  82921. WEIGHTS = "weights",
  82922. }
  82923. /**
  82924. * Interpolation algorithm
  82925. */
  82926. const enum AnimationSamplerInterpolation {
  82927. /**
  82928. * The animated values are linearly interpolated between keyframes
  82929. */
  82930. LINEAR = "LINEAR",
  82931. /**
  82932. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82933. */
  82934. STEP = "STEP",
  82935. /**
  82936. * The animation's interpolation is computed using a cubic spline with specified tangents
  82937. */
  82938. CUBICSPLINE = "CUBICSPLINE",
  82939. }
  82940. /**
  82941. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82942. */
  82943. const enum CameraType {
  82944. /**
  82945. * A perspective camera containing properties to create a perspective projection matrix
  82946. */
  82947. PERSPECTIVE = "perspective",
  82948. /**
  82949. * An orthographic camera containing properties to create an orthographic projection matrix
  82950. */
  82951. ORTHOGRAPHIC = "orthographic",
  82952. }
  82953. /**
  82954. * The mime-type of the image
  82955. */
  82956. const enum ImageMimeType {
  82957. /**
  82958. * JPEG Mime-type
  82959. */
  82960. JPEG = "image/jpeg",
  82961. /**
  82962. * PNG Mime-type
  82963. */
  82964. PNG = "image/png",
  82965. }
  82966. /**
  82967. * The alpha rendering mode of the material
  82968. */
  82969. const enum MaterialAlphaMode {
  82970. /**
  82971. * The alpha value is ignored and the rendered output is fully opaque
  82972. */
  82973. OPAQUE = "OPAQUE",
  82974. /**
  82975. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82976. */
  82977. MASK = "MASK",
  82978. /**
  82979. * 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)
  82980. */
  82981. BLEND = "BLEND",
  82982. }
  82983. /**
  82984. * The type of the primitives to render
  82985. */
  82986. const enum MeshPrimitiveMode {
  82987. /**
  82988. * Points
  82989. */
  82990. POINTS = 0,
  82991. /**
  82992. * Lines
  82993. */
  82994. LINES = 1,
  82995. /**
  82996. * Line Loop
  82997. */
  82998. LINE_LOOP = 2,
  82999. /**
  83000. * Line Strip
  83001. */
  83002. LINE_STRIP = 3,
  83003. /**
  83004. * Triangles
  83005. */
  83006. TRIANGLES = 4,
  83007. /**
  83008. * Triangle Strip
  83009. */
  83010. TRIANGLE_STRIP = 5,
  83011. /**
  83012. * Triangle Fan
  83013. */
  83014. TRIANGLE_FAN = 6,
  83015. }
  83016. /**
  83017. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83018. */
  83019. const enum TextureMagFilter {
  83020. /**
  83021. * Nearest
  83022. */
  83023. NEAREST = 9728,
  83024. /**
  83025. * Linear
  83026. */
  83027. LINEAR = 9729,
  83028. }
  83029. /**
  83030. * Minification filter. All valid values correspond to WebGL enums
  83031. */
  83032. const enum TextureMinFilter {
  83033. /**
  83034. * Nearest
  83035. */
  83036. NEAREST = 9728,
  83037. /**
  83038. * Linear
  83039. */
  83040. LINEAR = 9729,
  83041. /**
  83042. * Nearest Mip-Map Nearest
  83043. */
  83044. NEAREST_MIPMAP_NEAREST = 9984,
  83045. /**
  83046. * Linear Mipmap Nearest
  83047. */
  83048. LINEAR_MIPMAP_NEAREST = 9985,
  83049. /**
  83050. * Nearest Mipmap Linear
  83051. */
  83052. NEAREST_MIPMAP_LINEAR = 9986,
  83053. /**
  83054. * Linear Mipmap Linear
  83055. */
  83056. LINEAR_MIPMAP_LINEAR = 9987,
  83057. }
  83058. /**
  83059. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83060. */
  83061. const enum TextureWrapMode {
  83062. /**
  83063. * Clamp to Edge
  83064. */
  83065. CLAMP_TO_EDGE = 33071,
  83066. /**
  83067. * Mirrored Repeat
  83068. */
  83069. MIRRORED_REPEAT = 33648,
  83070. /**
  83071. * Repeat
  83072. */
  83073. REPEAT = 10497,
  83074. }
  83075. /**
  83076. * glTF Property
  83077. */
  83078. interface IProperty {
  83079. /**
  83080. * Dictionary object with extension-specific objects
  83081. */
  83082. extensions?: {
  83083. [key: string]: any;
  83084. };
  83085. /**
  83086. * Application-Specific data
  83087. */
  83088. extras?: any;
  83089. }
  83090. /**
  83091. * glTF Child of Root Property
  83092. */
  83093. interface IChildRootProperty extends IProperty {
  83094. /**
  83095. * The user-defined name of this object
  83096. */
  83097. name?: string;
  83098. }
  83099. /**
  83100. * Indices of those attributes that deviate from their initialization value
  83101. */
  83102. interface IAccessorSparseIndices extends IProperty {
  83103. /**
  83104. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83105. */
  83106. bufferView: number;
  83107. /**
  83108. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83109. */
  83110. byteOffset?: number;
  83111. /**
  83112. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83113. */
  83114. componentType: AccessorComponentType;
  83115. }
  83116. /**
  83117. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83118. */
  83119. interface IAccessorSparseValues extends IProperty {
  83120. /**
  83121. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83122. */
  83123. bufferView: number;
  83124. /**
  83125. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83126. */
  83127. byteOffset?: number;
  83128. }
  83129. /**
  83130. * Sparse storage of attributes that deviate from their initialization value
  83131. */
  83132. interface IAccessorSparse extends IProperty {
  83133. /**
  83134. * The number of attributes encoded in this sparse accessor
  83135. */
  83136. count: number;
  83137. /**
  83138. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83139. */
  83140. indices: IAccessorSparseIndices;
  83141. /**
  83142. * 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
  83143. */
  83144. values: IAccessorSparseValues;
  83145. }
  83146. /**
  83147. * 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
  83148. */
  83149. interface IAccessor extends IChildRootProperty {
  83150. /**
  83151. * The index of the bufferview
  83152. */
  83153. bufferView?: number;
  83154. /**
  83155. * The offset relative to the start of the bufferView in bytes
  83156. */
  83157. byteOffset?: number;
  83158. /**
  83159. * The datatype of components in the attribute
  83160. */
  83161. componentType: AccessorComponentType;
  83162. /**
  83163. * Specifies whether integer data values should be normalized
  83164. */
  83165. normalized?: boolean;
  83166. /**
  83167. * The number of attributes referenced by this accessor
  83168. */
  83169. count: number;
  83170. /**
  83171. * Specifies if the attribute is a scalar, vector, or matrix
  83172. */
  83173. type: AccessorType;
  83174. /**
  83175. * Maximum value of each component in this attribute
  83176. */
  83177. max?: number[];
  83178. /**
  83179. * Minimum value of each component in this attribute
  83180. */
  83181. min?: number[];
  83182. /**
  83183. * Sparse storage of attributes that deviate from their initialization value
  83184. */
  83185. sparse?: IAccessorSparse;
  83186. }
  83187. /**
  83188. * Targets an animation's sampler at a node's property
  83189. */
  83190. interface IAnimationChannel extends IProperty {
  83191. /**
  83192. * The index of a sampler in this animation used to compute the value for the target
  83193. */
  83194. sampler: number;
  83195. /**
  83196. * The index of the node and TRS property to target
  83197. */
  83198. target: IAnimationChannelTarget;
  83199. }
  83200. /**
  83201. * The index of the node and TRS property that an animation channel targets
  83202. */
  83203. interface IAnimationChannelTarget extends IProperty {
  83204. /**
  83205. * The index of the node to target
  83206. */
  83207. node: number;
  83208. /**
  83209. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83210. */
  83211. path: AnimationChannelTargetPath;
  83212. }
  83213. /**
  83214. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83215. */
  83216. interface IAnimationSampler extends IProperty {
  83217. /**
  83218. * The index of an accessor containing keyframe input values, e.g., time
  83219. */
  83220. input: number;
  83221. /**
  83222. * Interpolation algorithm
  83223. */
  83224. interpolation?: AnimationSamplerInterpolation;
  83225. /**
  83226. * The index of an accessor, containing keyframe output values
  83227. */
  83228. output: number;
  83229. }
  83230. /**
  83231. * A keyframe animation
  83232. */
  83233. interface IAnimation extends IChildRootProperty {
  83234. /**
  83235. * An array of channels, each of which targets an animation's sampler at a node's property
  83236. */
  83237. channels: IAnimationChannel[];
  83238. /**
  83239. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83240. */
  83241. samplers: IAnimationSampler[];
  83242. }
  83243. /**
  83244. * Metadata about the glTF asset
  83245. */
  83246. interface IAsset extends IChildRootProperty {
  83247. /**
  83248. * A copyright message suitable for display to credit the content creator
  83249. */
  83250. copyright?: string;
  83251. /**
  83252. * Tool that generated this glTF model. Useful for debugging
  83253. */
  83254. generator?: string;
  83255. /**
  83256. * The glTF version that this asset targets
  83257. */
  83258. version: string;
  83259. /**
  83260. * The minimum glTF version that this asset targets
  83261. */
  83262. minVersion?: string;
  83263. }
  83264. /**
  83265. * A buffer points to binary geometry, animation, or skins
  83266. */
  83267. interface IBuffer extends IChildRootProperty {
  83268. /**
  83269. * 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
  83270. */
  83271. uri?: string;
  83272. /**
  83273. * The length of the buffer in bytes
  83274. */
  83275. byteLength: number;
  83276. }
  83277. /**
  83278. * A view into a buffer generally representing a subset of the buffer
  83279. */
  83280. interface IBufferView extends IChildRootProperty {
  83281. /**
  83282. * The index of the buffer
  83283. */
  83284. buffer: number;
  83285. /**
  83286. * The offset into the buffer in bytes
  83287. */
  83288. byteOffset?: number;
  83289. /**
  83290. * The lenth of the bufferView in bytes
  83291. */
  83292. byteLength: number;
  83293. /**
  83294. * The stride, in bytes
  83295. */
  83296. byteStride?: number;
  83297. }
  83298. /**
  83299. * An orthographic camera containing properties to create an orthographic projection matrix
  83300. */
  83301. interface ICameraOrthographic extends IProperty {
  83302. /**
  83303. * The floating-point horizontal magnification of the view. Must not be zero
  83304. */
  83305. xmag: number;
  83306. /**
  83307. * The floating-point vertical magnification of the view. Must not be zero
  83308. */
  83309. ymag: number;
  83310. /**
  83311. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83312. */
  83313. zfar: number;
  83314. /**
  83315. * The floating-point distance to the near clipping plane
  83316. */
  83317. znear: number;
  83318. }
  83319. /**
  83320. * A perspective camera containing properties to create a perspective projection matrix
  83321. */
  83322. interface ICameraPerspective extends IProperty {
  83323. /**
  83324. * The floating-point aspect ratio of the field of view
  83325. */
  83326. aspectRatio?: number;
  83327. /**
  83328. * The floating-point vertical field of view in radians
  83329. */
  83330. yfov: number;
  83331. /**
  83332. * The floating-point distance to the far clipping plane
  83333. */
  83334. zfar?: number;
  83335. /**
  83336. * The floating-point distance to the near clipping plane
  83337. */
  83338. znear: number;
  83339. }
  83340. /**
  83341. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83342. */
  83343. interface ICamera extends IChildRootProperty {
  83344. /**
  83345. * An orthographic camera containing properties to create an orthographic projection matrix
  83346. */
  83347. orthographic?: ICameraOrthographic;
  83348. /**
  83349. * A perspective camera containing properties to create a perspective projection matrix
  83350. */
  83351. perspective?: ICameraPerspective;
  83352. /**
  83353. * Specifies if the camera uses a perspective or orthographic projection
  83354. */
  83355. type: CameraType;
  83356. }
  83357. /**
  83358. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83359. */
  83360. interface IImage extends IChildRootProperty {
  83361. /**
  83362. * 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
  83363. */
  83364. uri?: string;
  83365. /**
  83366. * The image's MIME type
  83367. */
  83368. mimeType?: ImageMimeType;
  83369. /**
  83370. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83371. */
  83372. bufferView?: number;
  83373. }
  83374. /**
  83375. * Material Normal Texture Info
  83376. */
  83377. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83378. /**
  83379. * The scalar multiplier applied to each normal vector of the normal texture
  83380. */
  83381. scale?: number;
  83382. }
  83383. /**
  83384. * Material Occlusion Texture Info
  83385. */
  83386. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83387. /**
  83388. * A scalar multiplier controlling the amount of occlusion applied
  83389. */
  83390. strength?: number;
  83391. }
  83392. /**
  83393. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83394. */
  83395. interface IMaterialPbrMetallicRoughness {
  83396. /**
  83397. * The material's base color factor
  83398. */
  83399. baseColorFactor?: number[];
  83400. /**
  83401. * The base color texture
  83402. */
  83403. baseColorTexture?: ITextureInfo;
  83404. /**
  83405. * The metalness of the material
  83406. */
  83407. metallicFactor?: number;
  83408. /**
  83409. * The roughness of the material
  83410. */
  83411. roughnessFactor?: number;
  83412. /**
  83413. * The metallic-roughness texture
  83414. */
  83415. metallicRoughnessTexture?: ITextureInfo;
  83416. }
  83417. /**
  83418. * The material appearance of a primitive
  83419. */
  83420. interface IMaterial extends IChildRootProperty {
  83421. /**
  83422. * 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
  83423. */
  83424. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83425. /**
  83426. * The normal map texture
  83427. */
  83428. normalTexture?: IMaterialNormalTextureInfo;
  83429. /**
  83430. * The occlusion map texture
  83431. */
  83432. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83433. /**
  83434. * The emissive map texture
  83435. */
  83436. emissiveTexture?: ITextureInfo;
  83437. /**
  83438. * 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
  83439. */
  83440. emissiveFactor?: number[];
  83441. /**
  83442. * The alpha rendering mode of the material
  83443. */
  83444. alphaMode?: MaterialAlphaMode;
  83445. /**
  83446. * The alpha cutoff value of the material
  83447. */
  83448. alphaCutoff?: number;
  83449. /**
  83450. * Specifies whether the material is double sided
  83451. */
  83452. doubleSided?: boolean;
  83453. }
  83454. /**
  83455. * Geometry to be rendered with the given material
  83456. */
  83457. interface IMeshPrimitive extends IProperty {
  83458. /**
  83459. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83460. */
  83461. attributes: {
  83462. [name: string]: number;
  83463. };
  83464. /**
  83465. * The index of the accessor that contains the indices
  83466. */
  83467. indices?: number;
  83468. /**
  83469. * The index of the material to apply to this primitive when rendering
  83470. */
  83471. material?: number;
  83472. /**
  83473. * The type of primitives to render. All valid values correspond to WebGL enums
  83474. */
  83475. mode?: MeshPrimitiveMode;
  83476. /**
  83477. * 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
  83478. */
  83479. targets?: {
  83480. [name: string]: number;
  83481. }[];
  83482. }
  83483. /**
  83484. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83485. */
  83486. interface IMesh extends IChildRootProperty {
  83487. /**
  83488. * An array of primitives, each defining geometry to be rendered with a material
  83489. */
  83490. primitives: IMeshPrimitive[];
  83491. /**
  83492. * Array of weights to be applied to the Morph Targets
  83493. */
  83494. weights?: number[];
  83495. }
  83496. /**
  83497. * A node in the node hierarchy
  83498. */
  83499. interface INode extends IChildRootProperty {
  83500. /**
  83501. * The index of the camera referenced by this node
  83502. */
  83503. camera?: number;
  83504. /**
  83505. * The indices of this node's children
  83506. */
  83507. children?: number[];
  83508. /**
  83509. * The index of the skin referenced by this node
  83510. */
  83511. skin?: number;
  83512. /**
  83513. * A floating-point 4x4 transformation matrix stored in column-major order
  83514. */
  83515. matrix?: number[];
  83516. /**
  83517. * The index of the mesh in this node
  83518. */
  83519. mesh?: number;
  83520. /**
  83521. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83522. */
  83523. rotation?: number[];
  83524. /**
  83525. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83526. */
  83527. scale?: number[];
  83528. /**
  83529. * The node's translation along the x, y, and z axes
  83530. */
  83531. translation?: number[];
  83532. /**
  83533. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83534. */
  83535. weights?: number[];
  83536. }
  83537. /**
  83538. * Texture sampler properties for filtering and wrapping modes
  83539. */
  83540. interface ISampler extends IChildRootProperty {
  83541. /**
  83542. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83543. */
  83544. magFilter?: TextureMagFilter;
  83545. /**
  83546. * Minification filter. All valid values correspond to WebGL enums
  83547. */
  83548. minFilter?: TextureMinFilter;
  83549. /**
  83550. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83551. */
  83552. wrapS?: TextureWrapMode;
  83553. /**
  83554. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83555. */
  83556. wrapT?: TextureWrapMode;
  83557. }
  83558. /**
  83559. * The root nodes of a scene
  83560. */
  83561. interface IScene extends IChildRootProperty {
  83562. /**
  83563. * The indices of each root node
  83564. */
  83565. nodes: number[];
  83566. }
  83567. /**
  83568. * Joints and matrices defining a skin
  83569. */
  83570. interface ISkin extends IChildRootProperty {
  83571. /**
  83572. * 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
  83573. */
  83574. inverseBindMatrices?: number;
  83575. /**
  83576. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83577. */
  83578. skeleton?: number;
  83579. /**
  83580. * 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)
  83581. */
  83582. joints: number[];
  83583. }
  83584. /**
  83585. * A texture and its sampler
  83586. */
  83587. interface ITexture extends IChildRootProperty {
  83588. /**
  83589. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83590. */
  83591. sampler?: number;
  83592. /**
  83593. * The index of the image used by this texture
  83594. */
  83595. source: number;
  83596. }
  83597. /**
  83598. * Reference to a texture
  83599. */
  83600. interface ITextureInfo extends IProperty {
  83601. /**
  83602. * The index of the texture
  83603. */
  83604. index: number;
  83605. /**
  83606. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83607. */
  83608. texCoord?: number;
  83609. }
  83610. /**
  83611. * The root object for a glTF asset
  83612. */
  83613. interface IGLTF extends IProperty {
  83614. /**
  83615. * An array of accessors. An accessor is a typed view into a bufferView
  83616. */
  83617. accessors?: IAccessor[];
  83618. /**
  83619. * An array of keyframe animations
  83620. */
  83621. animations?: IAnimation[];
  83622. /**
  83623. * Metadata about the glTF asset
  83624. */
  83625. asset: IAsset;
  83626. /**
  83627. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83628. */
  83629. buffers?: IBuffer[];
  83630. /**
  83631. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83632. */
  83633. bufferViews?: IBufferView[];
  83634. /**
  83635. * An array of cameras
  83636. */
  83637. cameras?: ICamera[];
  83638. /**
  83639. * Names of glTF extensions used somewhere in this asset
  83640. */
  83641. extensionsUsed?: string[];
  83642. /**
  83643. * Names of glTF extensions required to properly load this asset
  83644. */
  83645. extensionsRequired?: string[];
  83646. /**
  83647. * An array of images. An image defines data used to create a texture
  83648. */
  83649. images?: IImage[];
  83650. /**
  83651. * An array of materials. A material defines the appearance of a primitive
  83652. */
  83653. materials?: IMaterial[];
  83654. /**
  83655. * An array of meshes. A mesh is a set of primitives to be rendered
  83656. */
  83657. meshes?: IMesh[];
  83658. /**
  83659. * An array of nodes
  83660. */
  83661. nodes?: INode[];
  83662. /**
  83663. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83664. */
  83665. samplers?: ISampler[];
  83666. /**
  83667. * The index of the default scene
  83668. */
  83669. scene?: number;
  83670. /**
  83671. * An array of scenes
  83672. */
  83673. scenes?: IScene[];
  83674. /**
  83675. * An array of skins. A skin is defined by joints and matrices
  83676. */
  83677. skins?: ISkin[];
  83678. /**
  83679. * An array of textures
  83680. */
  83681. textures?: ITexture[];
  83682. }
  83683. /**
  83684. * The glTF validation results
  83685. * @ignore
  83686. */
  83687. interface IGLTFValidationResults {
  83688. info: {
  83689. generator: string;
  83690. hasAnimations: boolean;
  83691. hasDefaultScene: boolean;
  83692. hasMaterials: boolean;
  83693. hasMorphTargets: boolean;
  83694. hasSkins: boolean;
  83695. hasTextures: boolean;
  83696. maxAttributesUsed: number;
  83697. primitivesCount: number
  83698. };
  83699. issues: {
  83700. messages: Array<string>;
  83701. numErrors: number;
  83702. numHints: number;
  83703. numInfos: number;
  83704. numWarnings: number;
  83705. truncated: boolean
  83706. };
  83707. mimeType: string;
  83708. uri: string;
  83709. validatedAt: string;
  83710. validatorVersion: string;
  83711. }
  83712. /**
  83713. * The glTF validation options
  83714. */
  83715. interface IGLTFValidationOptions {
  83716. /** Uri to use */
  83717. uri?: string;
  83718. /** Function used to load external resources */
  83719. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83720. /** Boolean indicating that we need to validate accessor data */
  83721. validateAccessorData?: boolean;
  83722. /** max number of issues allowed */
  83723. maxIssues?: number;
  83724. /** Ignored issues */
  83725. ignoredIssues?: Array<string>;
  83726. /** Value to override severy settings */
  83727. severityOverrides?: Object;
  83728. }
  83729. /**
  83730. * The glTF validator object
  83731. * @ignore
  83732. */
  83733. interface IGLTFValidator {
  83734. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83735. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83736. }
  83737. /**
  83738. * Interfaces from the EXT_lights_image_based extension
  83739. */
  83740. /** @hidden */
  83741. interface IEXTLightsImageBased_LightReferenceImageBased {
  83742. light: number;
  83743. }
  83744. /** @hidden */
  83745. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83746. intensity: number;
  83747. rotation: number[];
  83748. specularImageSize: number;
  83749. specularImages: number[][];
  83750. irradianceCoefficients: number[][];
  83751. }
  83752. /** @hidden */
  83753. interface IEXTLightsImageBased {
  83754. lights: IEXTLightsImageBased_LightImageBased[];
  83755. }
  83756. /**
  83757. * Interfaces from the EXT_mesh_gpu_instancing extension
  83758. * !!! Experimental Extension Subject to Changes !!!
  83759. */
  83760. /** @hidden */
  83761. interface IEXTMeshGpuInstancing {
  83762. mesh?: number;
  83763. attributes: { [name: string]: number };
  83764. }
  83765. /**
  83766. * Interfaces from the KHR_draco_mesh_compression extension
  83767. */
  83768. /** @hidden */
  83769. interface IKHRDracoMeshCompression {
  83770. bufferView: number;
  83771. attributes: { [name: string]: number };
  83772. }
  83773. /**
  83774. * Interfaces from the KHR_lights_punctual extension
  83775. */
  83776. /** @hidden */
  83777. const enum IKHRLightsPunctual_LightType {
  83778. DIRECTIONAL = "directional",
  83779. POINT = "point",
  83780. SPOT = "spot"
  83781. }
  83782. /** @hidden */
  83783. interface IKHRLightsPunctual_LightReference {
  83784. light: number;
  83785. }
  83786. /** @hidden */
  83787. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83788. type: IKHRLightsPunctual_LightType;
  83789. color?: number[];
  83790. intensity?: number;
  83791. range?: number;
  83792. spot?: {
  83793. innerConeAngle?: number;
  83794. outerConeAngle?: number;
  83795. };
  83796. }
  83797. /** @hidden */
  83798. interface IKHRLightsPunctual {
  83799. lights: IKHRLightsPunctual_Light[];
  83800. }
  83801. /**
  83802. * Interfaces from the KHR_materials_clearcoat extension
  83803. * !!! Experimental Extension Subject to Changes !!!
  83804. */
  83805. /** @hidden */
  83806. interface IKHRMaterialsClearcoat {
  83807. clearcoatFactor: number;
  83808. clearcoatTexture: ITextureInfo;
  83809. clearcoatRoughnessFactor: number;
  83810. clearcoatRoughnessTexture: ITextureInfo;
  83811. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83812. }
  83813. /**
  83814. * Interfaces from the KHR_materials_ior extension
  83815. * !!! Experimental Extension Subject to Changes !!!
  83816. */
  83817. /** @hidden */
  83818. interface IKHRMaterialsIor {
  83819. ior: number;
  83820. }
  83821. /**
  83822. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83823. */
  83824. /** @hidden */
  83825. interface IKHRMaterialsPbrSpecularGlossiness {
  83826. diffuseFactor: number[];
  83827. diffuseTexture: ITextureInfo;
  83828. specularFactor: number[];
  83829. glossinessFactor: number;
  83830. specularGlossinessTexture: ITextureInfo;
  83831. }
  83832. /**
  83833. * Interfaces from the KHR_materials_sheen extension
  83834. * !!! Experimental Extension Subject to Changes !!!
  83835. */
  83836. /** @hidden */
  83837. interface IKHRMaterialsSheen {
  83838. sheenColorFactor?: number[];
  83839. sheenTexture?: ITextureInfo;
  83840. sheenRoughnessFactor?: number;
  83841. }
  83842. /**
  83843. * Interfaces from the KHR_materials_specular extension
  83844. * !!! Experimental Extension Subject to Changes !!!
  83845. */
  83846. /** @hidden */
  83847. interface IKHRMaterialsSpecular {
  83848. specularFactor: number;
  83849. specularColorFactor: number[];
  83850. specularTexture: ITextureInfo;
  83851. }
  83852. /**
  83853. * Interfaces from the KHR_materials_transmission extension
  83854. * !!! Experimental Extension Subject to Changes !!!
  83855. */
  83856. /** @hidden */
  83857. interface IKHRMaterialsTransmission {
  83858. transmissionFactor?: number;
  83859. transmissionTexture?: ITextureInfo;
  83860. }
  83861. /**
  83862. * Interfaces from the KHR_materials_variants extension
  83863. * !!! Experimental Extension Subject to Changes !!!
  83864. */
  83865. /** @hidden */
  83866. interface IKHRMaterialVariants_Mapping {
  83867. tags: string[];
  83868. material: number;
  83869. }
  83870. /** @hidden */
  83871. interface IKHRMaterialVariants {
  83872. mapping: IKHRMaterialVariants_Mapping[];
  83873. }
  83874. /**
  83875. * Interfaces from the KHR_texture_basisu extension
  83876. * !!! Experimental Extension Subject to Changes !!!
  83877. */
  83878. /** @hidden */
  83879. interface IKHRTextureBasisU {
  83880. source: number;
  83881. }
  83882. /**
  83883. * Interfaces from the KHR_texture_transform extension
  83884. */
  83885. /** @hidden */
  83886. interface IKHRTextureTransform {
  83887. offset?: number[];
  83888. rotation?: number;
  83889. scale?: number[];
  83890. texCoord?: number;
  83891. }
  83892. /**
  83893. * Interfaces from the KHR_xmp extension
  83894. * !!! Experimental Extension Subject to Changes !!!
  83895. */
  83896. /** @hidden */
  83897. interface IKHRXmp_Data {
  83898. [key: string]: unknown;
  83899. }
  83900. /** @hidden */
  83901. interface IKHRXmp_Gltf {
  83902. packets: IKHRXmp_Data[];
  83903. }
  83904. /** @hidden */
  83905. interface IKHRXmp_Node {
  83906. packet: number;
  83907. }
  83908. /**
  83909. * Interfaces from the MSFT_audio_emitter extension
  83910. */
  83911. /** @hidden */
  83912. interface IMSFTAudioEmitter_ClipReference {
  83913. clip: number;
  83914. weight?: number;
  83915. }
  83916. /** @hidden */
  83917. interface IMSFTAudioEmitter_EmittersReference {
  83918. emitters: number[];
  83919. }
  83920. /** @hidden */
  83921. const enum IMSFTAudioEmitter_DistanceModel {
  83922. linear = "linear",
  83923. inverse = "inverse",
  83924. exponential = "exponential",
  83925. }
  83926. /** @hidden */
  83927. interface IMSFTAudioEmitter_Emitter {
  83928. name?: string;
  83929. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83930. refDistance?: number;
  83931. maxDistance?: number;
  83932. rolloffFactor?: number;
  83933. innerAngle?: number;
  83934. outerAngle?: number;
  83935. loop?: boolean;
  83936. volume?: number;
  83937. clips: IMSFTAudioEmitter_ClipReference[];
  83938. }
  83939. /** @hidden */
  83940. const enum IMSFTAudioEmitter_AudioMimeType {
  83941. WAV = "audio/wav",
  83942. }
  83943. /** @hidden */
  83944. interface IMSFTAudioEmitter_Clip extends IProperty {
  83945. uri?: string;
  83946. bufferView?: number;
  83947. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83948. }
  83949. /** @hidden */
  83950. const enum IMSFTAudioEmitter_AnimationEventAction {
  83951. play = "play",
  83952. pause = "pause",
  83953. stop = "stop",
  83954. }
  83955. /** @hidden */
  83956. interface IMSFTAudioEmitter_AnimationEvent {
  83957. action: IMSFTAudioEmitter_AnimationEventAction;
  83958. emitter: number;
  83959. time: number;
  83960. startOffset?: number;
  83961. }
  83962. /**
  83963. * Interfaces from the MSFT_lod extension
  83964. */
  83965. /** @hidden */
  83966. interface IMSFTLOD {
  83967. ids: number[];
  83968. }
  83969. }
  83970. declare module BABYLON {
  83971. /** @hidden */
  83972. export var cellPixelShader: {
  83973. name: string;
  83974. shader: string;
  83975. };
  83976. }
  83977. declare module BABYLON {
  83978. /** @hidden */
  83979. export var cellVertexShader: {
  83980. name: string;
  83981. shader: string;
  83982. };
  83983. }
  83984. declare module BABYLON {
  83985. export class CellMaterial extends BABYLON.PushMaterial {
  83986. private _diffuseTexture;
  83987. diffuseTexture: BABYLON.BaseTexture;
  83988. diffuseColor: BABYLON.Color3;
  83989. _computeHighLevel: boolean;
  83990. computeHighLevel: boolean;
  83991. private _disableLighting;
  83992. disableLighting: boolean;
  83993. private _maxSimultaneousLights;
  83994. maxSimultaneousLights: number;
  83995. constructor(name: string, scene: BABYLON.Scene);
  83996. needAlphaBlending(): boolean;
  83997. needAlphaTesting(): boolean;
  83998. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83999. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84000. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84001. getAnimatables(): BABYLON.IAnimatable[];
  84002. getActiveTextures(): BABYLON.BaseTexture[];
  84003. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84004. dispose(forceDisposeEffect?: boolean): void;
  84005. getClassName(): string;
  84006. clone(name: string): CellMaterial;
  84007. serialize(): any;
  84008. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84009. }
  84010. }
  84011. declare module BABYLON {
  84012. export class CustomShaderStructure {
  84013. FragmentStore: string;
  84014. VertexStore: string;
  84015. constructor();
  84016. }
  84017. export class ShaderSpecialParts {
  84018. constructor();
  84019. Fragment_Begin: string;
  84020. Fragment_Definitions: string;
  84021. Fragment_MainBegin: string;
  84022. Fragment_Custom_Diffuse: string;
  84023. Fragment_Before_Lights: string;
  84024. Fragment_Before_Fog: string;
  84025. Fragment_Custom_Alpha: string;
  84026. Fragment_Before_FragColor: string;
  84027. Vertex_Begin: string;
  84028. Vertex_Definitions: string;
  84029. Vertex_MainBegin: string;
  84030. Vertex_Before_PositionUpdated: string;
  84031. Vertex_Before_NormalUpdated: string;
  84032. Vertex_After_WorldPosComputed: string;
  84033. Vertex_MainEnd: string;
  84034. }
  84035. export class CustomMaterial extends BABYLON.StandardMaterial {
  84036. static ShaderIndexer: number;
  84037. CustomParts: ShaderSpecialParts;
  84038. _isCreatedShader: boolean;
  84039. _createdShaderName: string;
  84040. _customUniform: string[];
  84041. _newUniforms: string[];
  84042. _newUniformInstances: {
  84043. [name: string]: any;
  84044. };
  84045. _newSamplerInstances: {
  84046. [name: string]: BABYLON.Texture;
  84047. };
  84048. _customAttributes: string[];
  84049. FragmentShader: string;
  84050. VertexShader: string;
  84051. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84052. ReviewUniform(name: string, arr: string[]): string[];
  84053. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84054. constructor(name: string, scene: BABYLON.Scene);
  84055. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84056. AddAttribute(name: string): CustomMaterial;
  84057. Fragment_Begin(shaderPart: string): CustomMaterial;
  84058. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84059. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84060. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84061. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84062. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84063. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84064. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84065. Vertex_Begin(shaderPart: string): CustomMaterial;
  84066. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84067. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84068. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84069. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84070. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84071. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84072. }
  84073. }
  84074. declare module BABYLON {
  84075. export class ShaderAlebdoParts {
  84076. constructor();
  84077. Fragment_Begin: string;
  84078. Fragment_Definitions: string;
  84079. Fragment_MainBegin: string;
  84080. Fragment_Custom_Albedo: string;
  84081. Fragment_Before_Lights: string;
  84082. Fragment_Custom_MetallicRoughness: string;
  84083. Fragment_Custom_MicroSurface: string;
  84084. Fragment_Before_Fog: string;
  84085. Fragment_Custom_Alpha: string;
  84086. Fragment_Before_FragColor: string;
  84087. Vertex_Begin: string;
  84088. Vertex_Definitions: string;
  84089. Vertex_MainBegin: string;
  84090. Vertex_Before_PositionUpdated: string;
  84091. Vertex_Before_NormalUpdated: string;
  84092. Vertex_After_WorldPosComputed: string;
  84093. Vertex_MainEnd: string;
  84094. }
  84095. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84096. static ShaderIndexer: number;
  84097. CustomParts: ShaderAlebdoParts;
  84098. _isCreatedShader: boolean;
  84099. _createdShaderName: string;
  84100. _customUniform: string[];
  84101. _newUniforms: string[];
  84102. _newUniformInstances: {
  84103. [name: string]: any;
  84104. };
  84105. _newSamplerInstances: {
  84106. [name: string]: BABYLON.Texture;
  84107. };
  84108. _customAttributes: string[];
  84109. FragmentShader: string;
  84110. VertexShader: string;
  84111. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84112. ReviewUniform(name: string, arr: string[]): string[];
  84113. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84114. constructor(name: string, scene: BABYLON.Scene);
  84115. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84116. AddAttribute(name: string): PBRCustomMaterial;
  84117. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84118. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84119. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84120. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84121. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84122. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84123. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84124. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84125. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84126. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84127. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84128. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84129. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84130. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84131. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84132. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84133. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84134. }
  84135. }
  84136. declare module BABYLON {
  84137. /** @hidden */
  84138. export var firePixelShader: {
  84139. name: string;
  84140. shader: string;
  84141. };
  84142. }
  84143. declare module BABYLON {
  84144. /** @hidden */
  84145. export var fireVertexShader: {
  84146. name: string;
  84147. shader: string;
  84148. };
  84149. }
  84150. declare module BABYLON {
  84151. export class FireMaterial extends BABYLON.PushMaterial {
  84152. private _diffuseTexture;
  84153. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84154. private _distortionTexture;
  84155. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84156. private _opacityTexture;
  84157. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84158. diffuseColor: BABYLON.Color3;
  84159. speed: number;
  84160. private _scaledDiffuse;
  84161. private _lastTime;
  84162. constructor(name: string, scene: BABYLON.Scene);
  84163. needAlphaBlending(): boolean;
  84164. needAlphaTesting(): boolean;
  84165. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84166. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84167. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84168. getAnimatables(): BABYLON.IAnimatable[];
  84169. getActiveTextures(): BABYLON.BaseTexture[];
  84170. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84171. getClassName(): string;
  84172. dispose(forceDisposeEffect?: boolean): void;
  84173. clone(name: string): FireMaterial;
  84174. serialize(): any;
  84175. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84176. }
  84177. }
  84178. declare module BABYLON {
  84179. /** @hidden */
  84180. export var furPixelShader: {
  84181. name: string;
  84182. shader: string;
  84183. };
  84184. }
  84185. declare module BABYLON {
  84186. /** @hidden */
  84187. export var furVertexShader: {
  84188. name: string;
  84189. shader: string;
  84190. };
  84191. }
  84192. declare module BABYLON {
  84193. export class FurMaterial extends BABYLON.PushMaterial {
  84194. private _diffuseTexture;
  84195. diffuseTexture: BABYLON.BaseTexture;
  84196. private _heightTexture;
  84197. heightTexture: BABYLON.BaseTexture;
  84198. diffuseColor: BABYLON.Color3;
  84199. furLength: number;
  84200. furAngle: number;
  84201. furColor: BABYLON.Color3;
  84202. furOffset: number;
  84203. furSpacing: number;
  84204. furGravity: BABYLON.Vector3;
  84205. furSpeed: number;
  84206. furDensity: number;
  84207. furOcclusion: number;
  84208. furTexture: BABYLON.DynamicTexture;
  84209. private _disableLighting;
  84210. disableLighting: boolean;
  84211. private _maxSimultaneousLights;
  84212. maxSimultaneousLights: number;
  84213. highLevelFur: boolean;
  84214. _meshes: BABYLON.AbstractMesh[];
  84215. private _furTime;
  84216. constructor(name: string, scene: BABYLON.Scene);
  84217. get furTime(): number;
  84218. set furTime(furTime: number);
  84219. needAlphaBlending(): boolean;
  84220. needAlphaTesting(): boolean;
  84221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84222. updateFur(): void;
  84223. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84224. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84225. getAnimatables(): BABYLON.IAnimatable[];
  84226. getActiveTextures(): BABYLON.BaseTexture[];
  84227. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84228. dispose(forceDisposeEffect?: boolean): void;
  84229. clone(name: string): FurMaterial;
  84230. serialize(): any;
  84231. getClassName(): string;
  84232. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84233. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84234. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84235. }
  84236. }
  84237. declare module BABYLON {
  84238. /** @hidden */
  84239. export var gradientPixelShader: {
  84240. name: string;
  84241. shader: string;
  84242. };
  84243. }
  84244. declare module BABYLON {
  84245. /** @hidden */
  84246. export var gradientVertexShader: {
  84247. name: string;
  84248. shader: string;
  84249. };
  84250. }
  84251. declare module BABYLON {
  84252. export class GradientMaterial extends BABYLON.PushMaterial {
  84253. private _maxSimultaneousLights;
  84254. maxSimultaneousLights: number;
  84255. topColor: BABYLON.Color3;
  84256. topColorAlpha: number;
  84257. bottomColor: BABYLON.Color3;
  84258. bottomColorAlpha: number;
  84259. offset: number;
  84260. scale: number;
  84261. smoothness: number;
  84262. private _disableLighting;
  84263. disableLighting: boolean;
  84264. constructor(name: string, scene: BABYLON.Scene);
  84265. needAlphaBlending(): boolean;
  84266. needAlphaTesting(): boolean;
  84267. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84268. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84269. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84270. getAnimatables(): BABYLON.IAnimatable[];
  84271. dispose(forceDisposeEffect?: boolean): void;
  84272. clone(name: string): GradientMaterial;
  84273. serialize(): any;
  84274. getClassName(): string;
  84275. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84276. }
  84277. }
  84278. declare module BABYLON {
  84279. /** @hidden */
  84280. export var gridPixelShader: {
  84281. name: string;
  84282. shader: string;
  84283. };
  84284. }
  84285. declare module BABYLON {
  84286. /** @hidden */
  84287. export var gridVertexShader: {
  84288. name: string;
  84289. shader: string;
  84290. };
  84291. }
  84292. declare module BABYLON {
  84293. /**
  84294. * The grid materials allows you to wrap any shape with a grid.
  84295. * Colors are customizable.
  84296. */
  84297. export class GridMaterial extends BABYLON.PushMaterial {
  84298. /**
  84299. * Main color of the grid (e.g. between lines)
  84300. */
  84301. mainColor: BABYLON.Color3;
  84302. /**
  84303. * Color of the grid lines.
  84304. */
  84305. lineColor: BABYLON.Color3;
  84306. /**
  84307. * The scale of the grid compared to unit.
  84308. */
  84309. gridRatio: number;
  84310. /**
  84311. * Allows setting an offset for the grid lines.
  84312. */
  84313. gridOffset: BABYLON.Vector3;
  84314. /**
  84315. * The frequency of thicker lines.
  84316. */
  84317. majorUnitFrequency: number;
  84318. /**
  84319. * The visibility of minor units in the grid.
  84320. */
  84321. minorUnitVisibility: number;
  84322. /**
  84323. * The grid opacity outside of the lines.
  84324. */
  84325. opacity: number;
  84326. /**
  84327. * Determine RBG output is premultiplied by alpha value.
  84328. */
  84329. preMultiplyAlpha: boolean;
  84330. private _opacityTexture;
  84331. opacityTexture: BABYLON.BaseTexture;
  84332. private _gridControl;
  84333. /**
  84334. * constructor
  84335. * @param name The name given to the material in order to identify it afterwards.
  84336. * @param scene The scene the material is used in.
  84337. */
  84338. constructor(name: string, scene: BABYLON.Scene);
  84339. /**
  84340. * Returns wehter or not the grid requires alpha blending.
  84341. */
  84342. needAlphaBlending(): boolean;
  84343. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84344. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84345. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84346. /**
  84347. * Dispose the material and its associated resources.
  84348. * @param forceDisposeEffect will also dispose the used effect when true
  84349. */
  84350. dispose(forceDisposeEffect?: boolean): void;
  84351. clone(name: string): GridMaterial;
  84352. serialize(): any;
  84353. getClassName(): string;
  84354. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84355. }
  84356. }
  84357. declare module BABYLON {
  84358. /** @hidden */
  84359. export var lavaPixelShader: {
  84360. name: string;
  84361. shader: string;
  84362. };
  84363. }
  84364. declare module BABYLON {
  84365. /** @hidden */
  84366. export var lavaVertexShader: {
  84367. name: string;
  84368. shader: string;
  84369. };
  84370. }
  84371. declare module BABYLON {
  84372. export class LavaMaterial extends BABYLON.PushMaterial {
  84373. private _diffuseTexture;
  84374. diffuseTexture: BABYLON.BaseTexture;
  84375. noiseTexture: BABYLON.BaseTexture;
  84376. fogColor: BABYLON.Color3;
  84377. speed: number;
  84378. movingSpeed: number;
  84379. lowFrequencySpeed: number;
  84380. fogDensity: number;
  84381. private _lastTime;
  84382. diffuseColor: BABYLON.Color3;
  84383. private _disableLighting;
  84384. disableLighting: boolean;
  84385. private _unlit;
  84386. unlit: boolean;
  84387. private _maxSimultaneousLights;
  84388. maxSimultaneousLights: number;
  84389. private _scaledDiffuse;
  84390. constructor(name: string, scene: BABYLON.Scene);
  84391. needAlphaBlending(): boolean;
  84392. needAlphaTesting(): boolean;
  84393. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84394. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84395. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84396. getAnimatables(): BABYLON.IAnimatable[];
  84397. getActiveTextures(): BABYLON.BaseTexture[];
  84398. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84399. dispose(forceDisposeEffect?: boolean): void;
  84400. clone(name: string): LavaMaterial;
  84401. serialize(): any;
  84402. getClassName(): string;
  84403. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84404. }
  84405. }
  84406. declare module BABYLON {
  84407. /** @hidden */
  84408. export var mixPixelShader: {
  84409. name: string;
  84410. shader: string;
  84411. };
  84412. }
  84413. declare module BABYLON {
  84414. /** @hidden */
  84415. export var mixVertexShader: {
  84416. name: string;
  84417. shader: string;
  84418. };
  84419. }
  84420. declare module BABYLON {
  84421. export class MixMaterial extends BABYLON.PushMaterial {
  84422. /**
  84423. * Mix textures
  84424. */
  84425. private _mixTexture1;
  84426. mixTexture1: BABYLON.BaseTexture;
  84427. private _mixTexture2;
  84428. mixTexture2: BABYLON.BaseTexture;
  84429. /**
  84430. * Diffuse textures
  84431. */
  84432. private _diffuseTexture1;
  84433. diffuseTexture1: BABYLON.Texture;
  84434. private _diffuseTexture2;
  84435. diffuseTexture2: BABYLON.Texture;
  84436. private _diffuseTexture3;
  84437. diffuseTexture3: BABYLON.Texture;
  84438. private _diffuseTexture4;
  84439. diffuseTexture4: BABYLON.Texture;
  84440. private _diffuseTexture5;
  84441. diffuseTexture5: BABYLON.Texture;
  84442. private _diffuseTexture6;
  84443. diffuseTexture6: BABYLON.Texture;
  84444. private _diffuseTexture7;
  84445. diffuseTexture7: BABYLON.Texture;
  84446. private _diffuseTexture8;
  84447. diffuseTexture8: BABYLON.Texture;
  84448. /**
  84449. * Uniforms
  84450. */
  84451. diffuseColor: BABYLON.Color3;
  84452. specularColor: BABYLON.Color3;
  84453. specularPower: number;
  84454. private _disableLighting;
  84455. disableLighting: boolean;
  84456. private _maxSimultaneousLights;
  84457. maxSimultaneousLights: number;
  84458. constructor(name: string, scene: BABYLON.Scene);
  84459. needAlphaBlending(): boolean;
  84460. needAlphaTesting(): boolean;
  84461. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84462. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84463. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84464. getAnimatables(): BABYLON.IAnimatable[];
  84465. getActiveTextures(): BABYLON.BaseTexture[];
  84466. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84467. dispose(forceDisposeEffect?: boolean): void;
  84468. clone(name: string): MixMaterial;
  84469. serialize(): any;
  84470. getClassName(): string;
  84471. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84472. }
  84473. }
  84474. declare module BABYLON {
  84475. /** @hidden */
  84476. export var normalPixelShader: {
  84477. name: string;
  84478. shader: string;
  84479. };
  84480. }
  84481. declare module BABYLON {
  84482. /** @hidden */
  84483. export var normalVertexShader: {
  84484. name: string;
  84485. shader: string;
  84486. };
  84487. }
  84488. declare module BABYLON {
  84489. export class NormalMaterial extends BABYLON.PushMaterial {
  84490. private _diffuseTexture;
  84491. diffuseTexture: BABYLON.BaseTexture;
  84492. diffuseColor: BABYLON.Color3;
  84493. private _disableLighting;
  84494. disableLighting: boolean;
  84495. private _maxSimultaneousLights;
  84496. maxSimultaneousLights: number;
  84497. constructor(name: string, scene: BABYLON.Scene);
  84498. needAlphaBlending(): boolean;
  84499. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84500. needAlphaTesting(): boolean;
  84501. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84502. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84503. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84504. getAnimatables(): BABYLON.IAnimatable[];
  84505. getActiveTextures(): BABYLON.BaseTexture[];
  84506. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84507. dispose(forceDisposeEffect?: boolean): void;
  84508. clone(name: string): NormalMaterial;
  84509. serialize(): any;
  84510. getClassName(): string;
  84511. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84512. }
  84513. }
  84514. declare module BABYLON {
  84515. /** @hidden */
  84516. export var shadowOnlyPixelShader: {
  84517. name: string;
  84518. shader: string;
  84519. };
  84520. }
  84521. declare module BABYLON {
  84522. /** @hidden */
  84523. export var shadowOnlyVertexShader: {
  84524. name: string;
  84525. shader: string;
  84526. };
  84527. }
  84528. declare module BABYLON {
  84529. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84530. private _activeLight;
  84531. private _needAlphaBlending;
  84532. constructor(name: string, scene: BABYLON.Scene);
  84533. shadowColor: BABYLON.Color3;
  84534. needAlphaBlending(): boolean;
  84535. needAlphaTesting(): boolean;
  84536. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84537. get activeLight(): BABYLON.IShadowLight;
  84538. set activeLight(light: BABYLON.IShadowLight);
  84539. private _getFirstShadowLightForMesh;
  84540. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84541. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84542. clone(name: string): ShadowOnlyMaterial;
  84543. serialize(): any;
  84544. getClassName(): string;
  84545. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84546. }
  84547. }
  84548. declare module BABYLON {
  84549. /** @hidden */
  84550. export var simplePixelShader: {
  84551. name: string;
  84552. shader: string;
  84553. };
  84554. }
  84555. declare module BABYLON {
  84556. /** @hidden */
  84557. export var simpleVertexShader: {
  84558. name: string;
  84559. shader: string;
  84560. };
  84561. }
  84562. declare module BABYLON {
  84563. export class SimpleMaterial extends BABYLON.PushMaterial {
  84564. private _diffuseTexture;
  84565. diffuseTexture: BABYLON.BaseTexture;
  84566. diffuseColor: BABYLON.Color3;
  84567. private _disableLighting;
  84568. disableLighting: boolean;
  84569. private _maxSimultaneousLights;
  84570. maxSimultaneousLights: number;
  84571. constructor(name: string, scene: BABYLON.Scene);
  84572. needAlphaBlending(): boolean;
  84573. needAlphaTesting(): boolean;
  84574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84577. getAnimatables(): BABYLON.IAnimatable[];
  84578. getActiveTextures(): BABYLON.BaseTexture[];
  84579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84580. dispose(forceDisposeEffect?: boolean): void;
  84581. clone(name: string): SimpleMaterial;
  84582. serialize(): any;
  84583. getClassName(): string;
  84584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84585. }
  84586. }
  84587. declare module BABYLON {
  84588. /** @hidden */
  84589. export var skyPixelShader: {
  84590. name: string;
  84591. shader: string;
  84592. };
  84593. }
  84594. declare module BABYLON {
  84595. /** @hidden */
  84596. export var skyVertexShader: {
  84597. name: string;
  84598. shader: string;
  84599. };
  84600. }
  84601. declare module BABYLON {
  84602. /**
  84603. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84604. * @see https://doc.babylonjs.com/extensions/sky
  84605. */
  84606. export class SkyMaterial extends BABYLON.PushMaterial {
  84607. /**
  84608. * Defines the overall luminance of sky in interval ]0, 1[.
  84609. */
  84610. luminance: number;
  84611. /**
  84612. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84613. */
  84614. turbidity: number;
  84615. /**
  84616. * Defines the sky appearance (light intensity).
  84617. */
  84618. rayleigh: number;
  84619. /**
  84620. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84621. */
  84622. mieCoefficient: number;
  84623. /**
  84624. * Defines the amount of haze particles following the Mie scattering theory.
  84625. */
  84626. mieDirectionalG: number;
  84627. /**
  84628. * Defines the distance of the sun according to the active scene camera.
  84629. */
  84630. distance: number;
  84631. /**
  84632. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84633. * "inclined".
  84634. */
  84635. inclination: number;
  84636. /**
  84637. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84638. * an object direction and a reference direction.
  84639. */
  84640. azimuth: number;
  84641. /**
  84642. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84643. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84644. */
  84645. sunPosition: BABYLON.Vector3;
  84646. /**
  84647. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84648. * .sunPosition property.
  84649. */
  84650. useSunPosition: boolean;
  84651. /**
  84652. * Defines an offset vector used to get a horizon offset.
  84653. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84654. */
  84655. cameraOffset: BABYLON.Vector3;
  84656. private _cameraPosition;
  84657. /**
  84658. * Instantiates a new sky material.
  84659. * This material allows to create dynamic and texture free
  84660. * effects for skyboxes by taking care of the atmosphere state.
  84661. * @see https://doc.babylonjs.com/extensions/sky
  84662. * @param name Define the name of the material in the scene
  84663. * @param scene Define the scene the material belong to
  84664. */
  84665. constructor(name: string, scene: BABYLON.Scene);
  84666. /**
  84667. * Specifies if the material will require alpha blending
  84668. * @returns a boolean specifying if alpha blending is needed
  84669. */
  84670. needAlphaBlending(): boolean;
  84671. /**
  84672. * Specifies if this material should be rendered in alpha test mode
  84673. * @returns false as the sky material doesn't need alpha testing.
  84674. */
  84675. needAlphaTesting(): boolean;
  84676. /**
  84677. * Get the texture used for alpha test purpose.
  84678. * @returns null as the sky material has no texture.
  84679. */
  84680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84681. /**
  84682. * Get if the submesh is ready to be used and all its information available.
  84683. * Child classes can use it to update shaders
  84684. * @param mesh defines the mesh to check
  84685. * @param subMesh defines which submesh to check
  84686. * @param useInstances specifies that instances should be used
  84687. * @returns a boolean indicating that the submesh is ready or not
  84688. */
  84689. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84690. /**
  84691. * Binds the submesh to this material by preparing the effect and shader to draw
  84692. * @param world defines the world transformation matrix
  84693. * @param mesh defines the mesh containing the submesh
  84694. * @param subMesh defines the submesh to bind the material to
  84695. */
  84696. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84697. /**
  84698. * Get the list of animatables in the material.
  84699. * @returns the list of animatables object used in the material
  84700. */
  84701. getAnimatables(): BABYLON.IAnimatable[];
  84702. /**
  84703. * Disposes the material
  84704. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84705. */
  84706. dispose(forceDisposeEffect?: boolean): void;
  84707. /**
  84708. * Makes a duplicate of the material, and gives it a new name
  84709. * @param name defines the new name for the duplicated material
  84710. * @returns the cloned material
  84711. */
  84712. clone(name: string): SkyMaterial;
  84713. /**
  84714. * Serializes this material in a JSON representation
  84715. * @returns the serialized material object
  84716. */
  84717. serialize(): any;
  84718. /**
  84719. * Gets the current class name of the material e.g. "SkyMaterial"
  84720. * Mainly use in serialization.
  84721. * @returns the class name
  84722. */
  84723. getClassName(): string;
  84724. /**
  84725. * Creates a sky material from parsed material data
  84726. * @param source defines the JSON representation of the material
  84727. * @param scene defines the hosting scene
  84728. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84729. * @returns a new sky material
  84730. */
  84731. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84732. }
  84733. }
  84734. declare module BABYLON {
  84735. /** @hidden */
  84736. export var terrainPixelShader: {
  84737. name: string;
  84738. shader: string;
  84739. };
  84740. }
  84741. declare module BABYLON {
  84742. /** @hidden */
  84743. export var terrainVertexShader: {
  84744. name: string;
  84745. shader: string;
  84746. };
  84747. }
  84748. declare module BABYLON {
  84749. export class TerrainMaterial extends BABYLON.PushMaterial {
  84750. private _mixTexture;
  84751. mixTexture: BABYLON.BaseTexture;
  84752. private _diffuseTexture1;
  84753. diffuseTexture1: BABYLON.Texture;
  84754. private _diffuseTexture2;
  84755. diffuseTexture2: BABYLON.Texture;
  84756. private _diffuseTexture3;
  84757. diffuseTexture3: BABYLON.Texture;
  84758. private _bumpTexture1;
  84759. bumpTexture1: BABYLON.Texture;
  84760. private _bumpTexture2;
  84761. bumpTexture2: BABYLON.Texture;
  84762. private _bumpTexture3;
  84763. bumpTexture3: BABYLON.Texture;
  84764. diffuseColor: BABYLON.Color3;
  84765. specularColor: BABYLON.Color3;
  84766. specularPower: number;
  84767. private _disableLighting;
  84768. disableLighting: boolean;
  84769. private _maxSimultaneousLights;
  84770. maxSimultaneousLights: number;
  84771. constructor(name: string, scene: BABYLON.Scene);
  84772. needAlphaBlending(): boolean;
  84773. needAlphaTesting(): boolean;
  84774. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84775. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84776. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84777. getAnimatables(): BABYLON.IAnimatable[];
  84778. getActiveTextures(): BABYLON.BaseTexture[];
  84779. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84780. dispose(forceDisposeEffect?: boolean): void;
  84781. clone(name: string): TerrainMaterial;
  84782. serialize(): any;
  84783. getClassName(): string;
  84784. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84785. }
  84786. }
  84787. declare module BABYLON {
  84788. /** @hidden */
  84789. export var triplanarPixelShader: {
  84790. name: string;
  84791. shader: string;
  84792. };
  84793. }
  84794. declare module BABYLON {
  84795. /** @hidden */
  84796. export var triplanarVertexShader: {
  84797. name: string;
  84798. shader: string;
  84799. };
  84800. }
  84801. declare module BABYLON {
  84802. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84803. mixTexture: BABYLON.BaseTexture;
  84804. private _diffuseTextureX;
  84805. diffuseTextureX: BABYLON.BaseTexture;
  84806. private _diffuseTextureY;
  84807. diffuseTextureY: BABYLON.BaseTexture;
  84808. private _diffuseTextureZ;
  84809. diffuseTextureZ: BABYLON.BaseTexture;
  84810. private _normalTextureX;
  84811. normalTextureX: BABYLON.BaseTexture;
  84812. private _normalTextureY;
  84813. normalTextureY: BABYLON.BaseTexture;
  84814. private _normalTextureZ;
  84815. normalTextureZ: BABYLON.BaseTexture;
  84816. tileSize: number;
  84817. diffuseColor: BABYLON.Color3;
  84818. specularColor: BABYLON.Color3;
  84819. specularPower: number;
  84820. private _disableLighting;
  84821. disableLighting: boolean;
  84822. private _maxSimultaneousLights;
  84823. maxSimultaneousLights: number;
  84824. constructor(name: string, scene: BABYLON.Scene);
  84825. needAlphaBlending(): boolean;
  84826. needAlphaTesting(): boolean;
  84827. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84828. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84829. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84830. getAnimatables(): BABYLON.IAnimatable[];
  84831. getActiveTextures(): BABYLON.BaseTexture[];
  84832. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84833. dispose(forceDisposeEffect?: boolean): void;
  84834. clone(name: string): TriPlanarMaterial;
  84835. serialize(): any;
  84836. getClassName(): string;
  84837. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84838. }
  84839. }
  84840. declare module BABYLON {
  84841. /** @hidden */
  84842. export var waterPixelShader: {
  84843. name: string;
  84844. shader: string;
  84845. };
  84846. }
  84847. declare module BABYLON {
  84848. /** @hidden */
  84849. export var waterVertexShader: {
  84850. name: string;
  84851. shader: string;
  84852. };
  84853. }
  84854. declare module BABYLON {
  84855. export class WaterMaterial extends BABYLON.PushMaterial {
  84856. renderTargetSize: BABYLON.Vector2;
  84857. private _bumpTexture;
  84858. bumpTexture: BABYLON.BaseTexture;
  84859. diffuseColor: BABYLON.Color3;
  84860. specularColor: BABYLON.Color3;
  84861. specularPower: number;
  84862. private _disableLighting;
  84863. disableLighting: boolean;
  84864. private _maxSimultaneousLights;
  84865. maxSimultaneousLights: number;
  84866. /**
  84867. * @param {number}: Represents the wind force
  84868. */
  84869. windForce: number;
  84870. /**
  84871. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84872. */
  84873. windDirection: BABYLON.Vector2;
  84874. /**
  84875. * @param {number}: Wave height, represents the height of the waves
  84876. */
  84877. waveHeight: number;
  84878. /**
  84879. * @param {number}: Bump height, represents the bump height related to the bump map
  84880. */
  84881. bumpHeight: number;
  84882. /**
  84883. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84884. */
  84885. private _bumpSuperimpose;
  84886. bumpSuperimpose: boolean;
  84887. /**
  84888. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84889. */
  84890. private _fresnelSeparate;
  84891. fresnelSeparate: boolean;
  84892. /**
  84893. * @param {boolean}: bump Waves modify the reflection.
  84894. */
  84895. private _bumpAffectsReflection;
  84896. bumpAffectsReflection: boolean;
  84897. /**
  84898. * @param {number}: The water color blended with the refraction (near)
  84899. */
  84900. waterColor: BABYLON.Color3;
  84901. /**
  84902. * @param {number}: The blend factor related to the water color
  84903. */
  84904. colorBlendFactor: number;
  84905. /**
  84906. * @param {number}: The water color blended with the reflection (far)
  84907. */
  84908. waterColor2: BABYLON.Color3;
  84909. /**
  84910. * @param {number}: The blend factor related to the water color (reflection, far)
  84911. */
  84912. colorBlendFactor2: number;
  84913. /**
  84914. * @param {number}: Represents the maximum length of a wave
  84915. */
  84916. waveLength: number;
  84917. /**
  84918. * @param {number}: Defines the waves speed
  84919. */
  84920. waveSpeed: number;
  84921. /**
  84922. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84923. * will avoid calculating useless pixels in the pixel shader of the water material.
  84924. */
  84925. disableClipPlane: boolean;
  84926. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84927. private _mesh;
  84928. private _refractionRTT;
  84929. private _reflectionRTT;
  84930. private _reflectionTransform;
  84931. private _lastTime;
  84932. private _lastDeltaTime;
  84933. private _useLogarithmicDepth;
  84934. private _waitingRenderList;
  84935. private _imageProcessingConfiguration;
  84936. private _imageProcessingObserver;
  84937. /**
  84938. * Gets a boolean indicating that current material needs to register RTT
  84939. */
  84940. get hasRenderTargetTextures(): boolean;
  84941. /**
  84942. * Constructor
  84943. */
  84944. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84945. get useLogarithmicDepth(): boolean;
  84946. set useLogarithmicDepth(value: boolean);
  84947. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84948. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84949. addToRenderList(node: any): void;
  84950. enableRenderTargets(enable: boolean): void;
  84951. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84952. get renderTargetsEnabled(): boolean;
  84953. needAlphaBlending(): boolean;
  84954. needAlphaTesting(): boolean;
  84955. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84956. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84957. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84958. private _createRenderTargets;
  84959. getAnimatables(): BABYLON.IAnimatable[];
  84960. getActiveTextures(): BABYLON.BaseTexture[];
  84961. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84962. dispose(forceDisposeEffect?: boolean): void;
  84963. clone(name: string): WaterMaterial;
  84964. serialize(): any;
  84965. getClassName(): string;
  84966. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84967. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84968. }
  84969. }
  84970. declare module BABYLON {
  84971. /** @hidden */
  84972. export var asciiartPixelShader: {
  84973. name: string;
  84974. shader: string;
  84975. };
  84976. }
  84977. declare module BABYLON {
  84978. /**
  84979. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84980. *
  84981. * It basically takes care rendering the font front the given font size to a texture.
  84982. * This is used later on in the postprocess.
  84983. */
  84984. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84985. private _font;
  84986. private _text;
  84987. private _charSize;
  84988. /**
  84989. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84990. */
  84991. get charSize(): number;
  84992. /**
  84993. * Create a new instance of the Ascii Art FontTexture class
  84994. * @param name the name of the texture
  84995. * @param font the font to use, use the W3C CSS notation
  84996. * @param text the caracter set to use in the rendering.
  84997. * @param scene the scene that owns the texture
  84998. */
  84999. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85000. /**
  85001. * Gets the max char width of a font.
  85002. * @param font the font to use, use the W3C CSS notation
  85003. * @return the max char width
  85004. */
  85005. private getFontWidth;
  85006. /**
  85007. * Gets the max char height of a font.
  85008. * @param font the font to use, use the W3C CSS notation
  85009. * @return the max char height
  85010. */
  85011. private getFontHeight;
  85012. /**
  85013. * Clones the current AsciiArtTexture.
  85014. * @return the clone of the texture.
  85015. */
  85016. clone(): AsciiArtFontTexture;
  85017. /**
  85018. * Parses a json object representing the texture and returns an instance of it.
  85019. * @param source the source JSON representation
  85020. * @param scene the scene to create the texture for
  85021. * @return the parsed texture
  85022. */
  85023. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85024. }
  85025. /**
  85026. * Option available in the Ascii Art Post Process.
  85027. */
  85028. export interface IAsciiArtPostProcessOptions {
  85029. /**
  85030. * The font to use following the w3c font definition.
  85031. */
  85032. font?: string;
  85033. /**
  85034. * The character set to use in the postprocess.
  85035. */
  85036. characterSet?: string;
  85037. /**
  85038. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85039. * This number is defined between 0 and 1;
  85040. */
  85041. mixToTile?: number;
  85042. /**
  85043. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85044. * This number is defined between 0 and 1;
  85045. */
  85046. mixToNormal?: number;
  85047. }
  85048. /**
  85049. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85050. *
  85051. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85052. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85053. */
  85054. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85055. /**
  85056. * The font texture used to render the char in the post process.
  85057. */
  85058. private _asciiArtFontTexture;
  85059. /**
  85060. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85061. * This number is defined between 0 and 1;
  85062. */
  85063. mixToTile: number;
  85064. /**
  85065. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85066. * This number is defined between 0 and 1;
  85067. */
  85068. mixToNormal: number;
  85069. /**
  85070. * Instantiates a new Ascii Art Post Process.
  85071. * @param name the name to give to the postprocess
  85072. * @camera the camera to apply the post process to.
  85073. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85074. */
  85075. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85076. }
  85077. }
  85078. declare module BABYLON {
  85079. /** @hidden */
  85080. export var digitalrainPixelShader: {
  85081. name: string;
  85082. shader: string;
  85083. };
  85084. }
  85085. declare module BABYLON {
  85086. /**
  85087. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85088. *
  85089. * It basically takes care rendering the font front the given font size to a texture.
  85090. * This is used later on in the postprocess.
  85091. */
  85092. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85093. private _font;
  85094. private _text;
  85095. private _charSize;
  85096. /**
  85097. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85098. */
  85099. get charSize(): number;
  85100. /**
  85101. * Create a new instance of the Digital Rain FontTexture class
  85102. * @param name the name of the texture
  85103. * @param font the font to use, use the W3C CSS notation
  85104. * @param text the caracter set to use in the rendering.
  85105. * @param scene the scene that owns the texture
  85106. */
  85107. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85108. /**
  85109. * Gets the max char width of a font.
  85110. * @param font the font to use, use the W3C CSS notation
  85111. * @return the max char width
  85112. */
  85113. private getFontWidth;
  85114. /**
  85115. * Gets the max char height of a font.
  85116. * @param font the font to use, use the W3C CSS notation
  85117. * @return the max char height
  85118. */
  85119. private getFontHeight;
  85120. /**
  85121. * Clones the current DigitalRainFontTexture.
  85122. * @return the clone of the texture.
  85123. */
  85124. clone(): DigitalRainFontTexture;
  85125. /**
  85126. * Parses a json object representing the texture and returns an instance of it.
  85127. * @param source the source JSON representation
  85128. * @param scene the scene to create the texture for
  85129. * @return the parsed texture
  85130. */
  85131. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85132. }
  85133. /**
  85134. * Option available in the Digital Rain Post Process.
  85135. */
  85136. export interface IDigitalRainPostProcessOptions {
  85137. /**
  85138. * The font to use following the w3c font definition.
  85139. */
  85140. font?: string;
  85141. /**
  85142. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85143. * This number is defined between 0 and 1;
  85144. */
  85145. mixToTile?: number;
  85146. /**
  85147. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85148. * This number is defined between 0 and 1;
  85149. */
  85150. mixToNormal?: number;
  85151. }
  85152. /**
  85153. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85154. *
  85155. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85156. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85157. */
  85158. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85159. /**
  85160. * The font texture used to render the char in the post process.
  85161. */
  85162. private _digitalRainFontTexture;
  85163. /**
  85164. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85165. * This number is defined between 0 and 1;
  85166. */
  85167. mixToTile: number;
  85168. /**
  85169. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85170. * This number is defined between 0 and 1;
  85171. */
  85172. mixToNormal: number;
  85173. /**
  85174. * Instantiates a new Digital Rain Post Process.
  85175. * @param name the name to give to the postprocess
  85176. * @camera the camera to apply the post process to.
  85177. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85178. */
  85179. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85180. }
  85181. }
  85182. declare module BABYLON {
  85183. /** @hidden */
  85184. export var brickProceduralTexturePixelShader: {
  85185. name: string;
  85186. shader: string;
  85187. };
  85188. }
  85189. declare module BABYLON {
  85190. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85191. private _numberOfBricksHeight;
  85192. private _numberOfBricksWidth;
  85193. private _jointColor;
  85194. private _brickColor;
  85195. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85196. updateShaderUniforms(): void;
  85197. get numberOfBricksHeight(): number;
  85198. set numberOfBricksHeight(value: number);
  85199. get numberOfBricksWidth(): number;
  85200. set numberOfBricksWidth(value: number);
  85201. get jointColor(): BABYLON.Color3;
  85202. set jointColor(value: BABYLON.Color3);
  85203. get brickColor(): BABYLON.Color3;
  85204. set brickColor(value: BABYLON.Color3);
  85205. /**
  85206. * Serializes this brick procedural texture
  85207. * @returns a serialized brick procedural texture object
  85208. */
  85209. serialize(): any;
  85210. /**
  85211. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85212. * @param parsedTexture defines parsed texture data
  85213. * @param scene defines the current scene
  85214. * @param rootUrl defines the root URL containing brick procedural texture information
  85215. * @returns a parsed Brick Procedural BABYLON.Texture
  85216. */
  85217. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85218. }
  85219. }
  85220. declare module BABYLON {
  85221. /** @hidden */
  85222. export var cloudProceduralTexturePixelShader: {
  85223. name: string;
  85224. shader: string;
  85225. };
  85226. }
  85227. declare module BABYLON {
  85228. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85229. private _skyColor;
  85230. private _cloudColor;
  85231. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85232. updateShaderUniforms(): void;
  85233. get skyColor(): BABYLON.Color4;
  85234. set skyColor(value: BABYLON.Color4);
  85235. get cloudColor(): BABYLON.Color4;
  85236. set cloudColor(value: BABYLON.Color4);
  85237. /**
  85238. * Serializes this cloud procedural texture
  85239. * @returns a serialized cloud procedural texture object
  85240. */
  85241. serialize(): any;
  85242. /**
  85243. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85244. * @param parsedTexture defines parsed texture data
  85245. * @param scene defines the current scene
  85246. * @param rootUrl defines the root URL containing cloud procedural texture information
  85247. * @returns a parsed Cloud Procedural BABYLON.Texture
  85248. */
  85249. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85250. }
  85251. }
  85252. declare module BABYLON {
  85253. /** @hidden */
  85254. export var fireProceduralTexturePixelShader: {
  85255. name: string;
  85256. shader: string;
  85257. };
  85258. }
  85259. declare module BABYLON {
  85260. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85261. private _time;
  85262. private _speed;
  85263. private _autoGenerateTime;
  85264. private _fireColors;
  85265. private _alphaThreshold;
  85266. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85267. updateShaderUniforms(): void;
  85268. render(useCameraPostProcess?: boolean): void;
  85269. static get PurpleFireColors(): BABYLON.Color3[];
  85270. static get GreenFireColors(): BABYLON.Color3[];
  85271. static get RedFireColors(): BABYLON.Color3[];
  85272. static get BlueFireColors(): BABYLON.Color3[];
  85273. get autoGenerateTime(): boolean;
  85274. set autoGenerateTime(value: boolean);
  85275. get fireColors(): BABYLON.Color3[];
  85276. set fireColors(value: BABYLON.Color3[]);
  85277. get time(): number;
  85278. set time(value: number);
  85279. get speed(): BABYLON.Vector2;
  85280. set speed(value: BABYLON.Vector2);
  85281. get alphaThreshold(): number;
  85282. set alphaThreshold(value: number);
  85283. /**
  85284. * Serializes this fire procedural texture
  85285. * @returns a serialized fire procedural texture object
  85286. */
  85287. serialize(): any;
  85288. /**
  85289. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85290. * @param parsedTexture defines parsed texture data
  85291. * @param scene defines the current scene
  85292. * @param rootUrl defines the root URL containing fire procedural texture information
  85293. * @returns a parsed Fire Procedural BABYLON.Texture
  85294. */
  85295. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85296. }
  85297. }
  85298. declare module BABYLON {
  85299. /** @hidden */
  85300. export var grassProceduralTexturePixelShader: {
  85301. name: string;
  85302. shader: string;
  85303. };
  85304. }
  85305. declare module BABYLON {
  85306. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85307. private _grassColors;
  85308. private _groundColor;
  85309. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85310. updateShaderUniforms(): void;
  85311. get grassColors(): BABYLON.Color3[];
  85312. set grassColors(value: BABYLON.Color3[]);
  85313. get groundColor(): BABYLON.Color3;
  85314. set groundColor(value: BABYLON.Color3);
  85315. /**
  85316. * Serializes this grass procedural texture
  85317. * @returns a serialized grass procedural texture object
  85318. */
  85319. serialize(): any;
  85320. /**
  85321. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85322. * @param parsedTexture defines parsed texture data
  85323. * @param scene defines the current scene
  85324. * @param rootUrl defines the root URL containing grass procedural texture information
  85325. * @returns a parsed Grass Procedural BABYLON.Texture
  85326. */
  85327. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85328. }
  85329. }
  85330. declare module BABYLON {
  85331. /** @hidden */
  85332. export var marbleProceduralTexturePixelShader: {
  85333. name: string;
  85334. shader: string;
  85335. };
  85336. }
  85337. declare module BABYLON {
  85338. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85339. private _numberOfTilesHeight;
  85340. private _numberOfTilesWidth;
  85341. private _amplitude;
  85342. private _jointColor;
  85343. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85344. updateShaderUniforms(): void;
  85345. get numberOfTilesHeight(): number;
  85346. set numberOfTilesHeight(value: number);
  85347. get amplitude(): number;
  85348. set amplitude(value: number);
  85349. get numberOfTilesWidth(): number;
  85350. set numberOfTilesWidth(value: number);
  85351. get jointColor(): BABYLON.Color3;
  85352. set jointColor(value: BABYLON.Color3);
  85353. /**
  85354. * Serializes this marble procedural texture
  85355. * @returns a serialized marble procedural texture object
  85356. */
  85357. serialize(): any;
  85358. /**
  85359. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85360. * @param parsedTexture defines parsed texture data
  85361. * @param scene defines the current scene
  85362. * @param rootUrl defines the root URL containing marble procedural texture information
  85363. * @returns a parsed Marble Procedural BABYLON.Texture
  85364. */
  85365. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85366. }
  85367. }
  85368. declare module BABYLON {
  85369. /** @hidden */
  85370. export var normalMapProceduralTexturePixelShader: {
  85371. name: string;
  85372. shader: string;
  85373. };
  85374. }
  85375. declare module BABYLON {
  85376. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85377. private _baseTexture;
  85378. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85379. updateShaderUniforms(): void;
  85380. render(useCameraPostProcess?: boolean): void;
  85381. resize(size: any, generateMipMaps: any): void;
  85382. get baseTexture(): BABYLON.Texture;
  85383. set baseTexture(texture: BABYLON.Texture);
  85384. /**
  85385. * Serializes this normal map procedural texture
  85386. * @returns a serialized normal map procedural texture object
  85387. */
  85388. serialize(): any;
  85389. /**
  85390. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85391. * @param parsedTexture defines parsed texture data
  85392. * @param scene defines the current scene
  85393. * @param rootUrl defines the root URL containing normal map procedural texture information
  85394. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85395. */
  85396. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85397. }
  85398. }
  85399. declare module BABYLON {
  85400. /** @hidden */
  85401. export var perlinNoiseProceduralTexturePixelShader: {
  85402. name: string;
  85403. shader: string;
  85404. };
  85405. }
  85406. declare module BABYLON {
  85407. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85408. time: number;
  85409. timeScale: number;
  85410. translationSpeed: number;
  85411. private _currentTranslation;
  85412. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85413. updateShaderUniforms(): void;
  85414. render(useCameraPostProcess?: boolean): void;
  85415. resize(size: any, generateMipMaps: any): void;
  85416. /**
  85417. * Serializes this perlin noise procedural texture
  85418. * @returns a serialized perlin noise procedural texture object
  85419. */
  85420. serialize(): any;
  85421. /**
  85422. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85423. * @param parsedTexture defines parsed texture data
  85424. * @param scene defines the current scene
  85425. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85426. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85427. */
  85428. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85429. }
  85430. }
  85431. declare module BABYLON {
  85432. /** @hidden */
  85433. export var roadProceduralTexturePixelShader: {
  85434. name: string;
  85435. shader: string;
  85436. };
  85437. }
  85438. declare module BABYLON {
  85439. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85440. private _roadColor;
  85441. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85442. updateShaderUniforms(): void;
  85443. get roadColor(): BABYLON.Color3;
  85444. set roadColor(value: BABYLON.Color3);
  85445. /**
  85446. * Serializes this road procedural texture
  85447. * @returns a serialized road procedural texture object
  85448. */
  85449. serialize(): any;
  85450. /**
  85451. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85452. * @param parsedTexture defines parsed texture data
  85453. * @param scene defines the current scene
  85454. * @param rootUrl defines the root URL containing road procedural texture information
  85455. * @returns a parsed Road Procedural BABYLON.Texture
  85456. */
  85457. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85458. }
  85459. }
  85460. declare module BABYLON {
  85461. /** @hidden */
  85462. export var starfieldProceduralTexturePixelShader: {
  85463. name: string;
  85464. shader: string;
  85465. };
  85466. }
  85467. declare module BABYLON {
  85468. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85469. private _time;
  85470. private _alpha;
  85471. private _beta;
  85472. private _zoom;
  85473. private _formuparam;
  85474. private _stepsize;
  85475. private _tile;
  85476. private _brightness;
  85477. private _darkmatter;
  85478. private _distfading;
  85479. private _saturation;
  85480. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85481. updateShaderUniforms(): void;
  85482. get time(): number;
  85483. set time(value: number);
  85484. get alpha(): number;
  85485. set alpha(value: number);
  85486. get beta(): number;
  85487. set beta(value: number);
  85488. get formuparam(): number;
  85489. set formuparam(value: number);
  85490. get stepsize(): number;
  85491. set stepsize(value: number);
  85492. get zoom(): number;
  85493. set zoom(value: number);
  85494. get tile(): number;
  85495. set tile(value: number);
  85496. get brightness(): number;
  85497. set brightness(value: number);
  85498. get darkmatter(): number;
  85499. set darkmatter(value: number);
  85500. get distfading(): number;
  85501. set distfading(value: number);
  85502. get saturation(): number;
  85503. set saturation(value: number);
  85504. /**
  85505. * Serializes this starfield procedural texture
  85506. * @returns a serialized starfield procedural texture object
  85507. */
  85508. serialize(): any;
  85509. /**
  85510. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85511. * @param parsedTexture defines parsed texture data
  85512. * @param scene defines the current scene
  85513. * @param rootUrl defines the root URL containing startfield procedural texture information
  85514. * @returns a parsed Starfield Procedural BABYLON.Texture
  85515. */
  85516. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85517. }
  85518. }
  85519. declare module BABYLON {
  85520. /** @hidden */
  85521. export var woodProceduralTexturePixelShader: {
  85522. name: string;
  85523. shader: string;
  85524. };
  85525. }
  85526. declare module BABYLON {
  85527. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85528. private _ampScale;
  85529. private _woodColor;
  85530. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85531. updateShaderUniforms(): void;
  85532. get ampScale(): number;
  85533. set ampScale(value: number);
  85534. get woodColor(): BABYLON.Color3;
  85535. set woodColor(value: BABYLON.Color3);
  85536. /**
  85537. * Serializes this wood procedural texture
  85538. * @returns a serialized wood procedural texture object
  85539. */
  85540. serialize(): any;
  85541. /**
  85542. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85543. * @param parsedTexture defines parsed texture data
  85544. * @param scene defines the current scene
  85545. * @param rootUrl defines the root URL containing wood procedural texture information
  85546. * @returns a parsed Wood Procedural BABYLON.Texture
  85547. */
  85548. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85549. }
  85550. }