documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825858268582785828858298583085831858328583385834858358583685837858388583985840858418584285843858448584585846858478584885849858508585185852858538585485855858568585785858858598586085861858628586385864858658586685867858688586985870858718587285873858748587585876858778587885879858808588185882858838588485885858868588785888858898589085891858928589385894858958589685897858988589985900859018590285903859048590585906859078590885909859108591185912859138591485915859168591785918859198592085921859228592385924859258592685927859288592985930859318593285933859348593585936859378593885939859408594185942859438594485945859468594785948859498595085951859528595385954859558595685957859588595985960859618596285963859648596585966859678596885969859708597185972859738597485975859768597785978859798598085981859828598385984859858598685987859888598985990859918599285993859948599585996859978599885999860008600186002860038600486005860068600786008860098601086011860128601386014860158601686017860188601986020860218602286023860248602586026860278602886029860308603186032860338603486035860368603786038860398604086041860428604386044860458604686047860488604986050860518605286053860548605586056860578605886059860608606186062860638606486065860668606786068860698607086071860728607386074860758607686077860788607986080860818608286083860848608586086860878608886089860908609186092860938609486095860968609786098860998610086101861028610386104861058610686107861088610986110861118611286113861148611586116861178611886119861208612186122861238612486125861268612786128861298613086131861328613386134861358613686137861388613986140861418614286143861448614586146861478614886149861508615186152861538615486155861568615786158861598616086161861628616386164861658616686167861688616986170861718617286173861748617586176861778617886179861808618186182861838618486185861868618786188861898619086191861928619386194861958619686197861988619986200862018620286203862048620586206862078620886209862108621186212862138621486215862168621786218862198622086221862228622386224862258622686227862288622986230862318623286233862348623586236862378623886239862408624186242862438624486245862468624786248862498625086251862528625386254862558625686257862588625986260862618626286263862648626586266862678626886269862708627186272862738627486275862768627786278862798628086281862828628386284862858628686287862888628986290862918629286293862948629586296862978629886299863008630186302863038630486305863068630786308863098631086311863128631386314863158631686317863188631986320863218632286323863248632586326863278632886329863308633186332863338633486335863368633786338863398634086341863428634386344863458634686347863488634986350863518635286353863548635586356863578635886359863608636186362863638636486365863668636786368863698637086371863728637386374863758637686377863788637986380863818638286383863848638586386863878638886389863908639186392863938639486395863968639786398863998640086401864028640386404864058640686407864088640986410864118641286413864148641586416864178641886419864208642186422864238642486425864268642786428864298643086431864328643386434864358643686437864388643986440864418644286443864448644586446864478644886449864508645186452864538645486455864568645786458864598646086461864628646386464864658646686467864688646986470864718647286473864748647586476864778647886479864808648186482864838648486485864868648786488864898649086491864928649386494864958649686497864988649986500865018650286503865048650586506865078650886509865108651186512865138651486515865168651786518865198652086521865228652386524865258652686527865288652986530865318653286533865348653586536865378653886539865408654186542865438654486545865468654786548865498655086551865528655386554865558655686557865588655986560865618656286563865648656586566865678656886569865708657186572865738657486575865768657786578865798658086581865828658386584865858658686587865888658986590865918659286593865948659586596865978659886599866008660186602866038660486605866068660786608866098661086611866128661386614866158661686617866188661986620866218662286623866248662586626866278662886629866308663186632866338663486635866368663786638866398664086641866428664386644866458664686647866488664986650866518665286653866548665586656866578665886659866608666186662866638666486665866668666786668866698667086671866728667386674866758667686677866788667986680866818668286683866848668586686866878668886689866908669186692866938669486695866968669786698866998670086701867028670386704867058670686707867088670986710867118671286713867148671586716867178671886719867208672186722867238672486725867268672786728867298673086731867328673386734867358673686737867388673986740867418674286743867448674586746867478674886749867508675186752867538675486755867568675786758867598676086761867628676386764867658676686767867688676986770867718677286773867748677586776867778677886779867808678186782867838678486785867868678786788867898679086791867928679386794867958679686797867988679986800868018680286803868048680586806868078680886809868108681186812868138681486815868168681786818868198682086821868228682386824868258682686827868288682986830868318683286833868348683586836868378683886839868408684186842868438684486845868468684786848868498685086851868528685386854868558685686857868588685986860868618686286863868648686586866868678686886869868708687186872868738687486875868768687786878868798688086881868828688386884868858688686887868888688986890868918689286893868948689586896868978689886899869008690186902869038690486905869068690786908869098691086911869128691386914869158691686917869188691986920869218692286923869248692586926869278692886929869308693186932869338693486935869368693786938869398694086941869428694386944869458694686947869488694986950869518695286953869548695586956869578695886959869608696186962869638696486965869668696786968869698697086971869728697386974869758697686977869788697986980869818698286983869848698586986869878698886989869908699186992869938699486995869968699786998869998700087001870028700387004870058700687007870088700987010870118701287013870148701587016870178701887019870208702187022870238702487025870268702787028870298703087031870328703387034870358703687037870388703987040870418704287043870448704587046870478704887049870508705187052870538705487055870568705787058870598706087061870628706387064870658706687067870688706987070870718707287073870748707587076870778707887079870808708187082870838708487085870868708787088870898709087091870928709387094870958709687097870988709987100871018710287103871048710587106871078710887109871108711187112871138711487115871168711787118871198712087121871228712387124871258712687127871288712987130871318713287133871348713587136871378713887139871408714187142871438714487145871468714787148871498715087151871528715387154871558715687157871588715987160871618716287163871648716587166871678716887169871708717187172871738717487175871768717787178871798718087181871828718387184871858718687187871888718987190871918719287193871948719587196871978719887199872008720187202872038720487205872068720787208872098721087211872128721387214872158721687217872188721987220872218722287223872248722587226872278722887229872308723187232872338723487235872368723787238872398724087241872428724387244872458724687247872488724987250872518725287253872548725587256872578725887259872608726187262872638726487265872668726787268872698727087271872728727387274872758727687277872788727987280872818728287283872848728587286872878728887289872908729187292872938729487295872968729787298872998730087301873028730387304873058730687307873088730987310873118731287313873148731587316873178731887319873208732187322873238732487325873268732787328873298733087331873328733387334873358733687337873388733987340873418734287343873448734587346873478734887349873508735187352873538735487355873568735787358873598736087361873628736387364873658736687367873688736987370873718737287373873748737587376873778737887379873808738187382873838738487385873868738787388873898739087391873928739387394873958739687397873988739987400874018740287403874048740587406874078740887409874108741187412874138741487415874168741787418874198742087421874228742387424874258742687427874288742987430874318743287433874348743587436874378743887439874408744187442874438744487445874468744787448874498745087451874528745387454874558745687457874588745987460874618746287463874648746587466874678746887469874708747187472874738747487475874768747787478874798748087481874828748387484874858748687487874888748987490
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1054. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1055. */
  1056. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1057. /**
  1058. * Constant used to retrieve the position texture index in the textures array in the prepass
  1059. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1060. */
  1061. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1062. /**
  1063. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1065. */
  1066. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1069. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1070. */
  1071. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1074. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1075. */
  1076. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve albedo index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1087. }
  1088. }
  1089. declare module BABYLON {
  1090. /**
  1091. * This represents the required contract to create a new type of texture loader.
  1092. */
  1093. export interface IInternalTextureLoader {
  1094. /**
  1095. * Defines wether the loader supports cascade loading the different faces.
  1096. */
  1097. supportCascades: boolean;
  1098. /**
  1099. * This returns if the loader support the current file information.
  1100. * @param extension defines the file extension of the file being loaded
  1101. * @param mimeType defines the optional mime type of the file being loaded
  1102. * @returns true if the loader can load the specified file
  1103. */
  1104. canLoad(extension: string, mimeType?: string): boolean;
  1105. /**
  1106. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1107. * @param data contains the texture data
  1108. * @param texture defines the BabylonJS internal texture
  1109. * @param createPolynomials will be true if polynomials have been requested
  1110. * @param onLoad defines the callback to trigger once the texture is ready
  1111. * @param onError defines the callback to trigger in case of error
  1112. */
  1113. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1114. /**
  1115. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1116. * @param data contains the texture data
  1117. * @param texture defines the BabylonJS internal texture
  1118. * @param callback defines the method to call once ready to upload
  1119. */
  1120. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1121. }
  1122. }
  1123. declare module BABYLON {
  1124. /**
  1125. * Class used to store and describe the pipeline context associated with an effect
  1126. */
  1127. export interface IPipelineContext {
  1128. /**
  1129. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1130. */
  1131. isAsync: boolean;
  1132. /**
  1133. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1134. */
  1135. isReady: boolean;
  1136. /** @hidden */
  1137. _getVertexShaderCode(): string | null;
  1138. /** @hidden */
  1139. _getFragmentShaderCode(): string | null;
  1140. /** @hidden */
  1141. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1142. }
  1143. }
  1144. declare module BABYLON {
  1145. /**
  1146. * Class used to store gfx data (like WebGLBuffer)
  1147. */
  1148. export class DataBuffer {
  1149. /**
  1150. * Gets or sets the number of objects referencing this buffer
  1151. */
  1152. references: number;
  1153. /** Gets or sets the size of the underlying buffer */
  1154. capacity: number;
  1155. /**
  1156. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1157. */
  1158. is32Bits: boolean;
  1159. /**
  1160. * Gets the underlying buffer
  1161. */
  1162. get underlyingResource(): any;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export interface IShaderProcessor {
  1168. attributeProcessor?: (attribute: string) => string;
  1169. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1170. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1171. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1172. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1173. lineProcessor?: (line: string, isFragment: boolean) => string;
  1174. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1175. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1176. }
  1177. }
  1178. declare module BABYLON {
  1179. /** @hidden */
  1180. export interface ProcessingOptions {
  1181. defines: string[];
  1182. indexParameters: any;
  1183. isFragment: boolean;
  1184. shouldUseHighPrecisionShader: boolean;
  1185. supportsUniformBuffers: boolean;
  1186. shadersRepository: string;
  1187. includesShadersStore: {
  1188. [key: string]: string;
  1189. };
  1190. processor?: IShaderProcessor;
  1191. version: string;
  1192. platformName: string;
  1193. lookForClosingBracketForUniformBuffer?: boolean;
  1194. }
  1195. }
  1196. declare module BABYLON {
  1197. /** @hidden */
  1198. export class ShaderCodeNode {
  1199. line: string;
  1200. children: ShaderCodeNode[];
  1201. additionalDefineKey?: string;
  1202. additionalDefineValue?: string;
  1203. isValid(preprocessors: {
  1204. [key: string]: string;
  1205. }): boolean;
  1206. process(preprocessors: {
  1207. [key: string]: string;
  1208. }, options: ProcessingOptions): string;
  1209. }
  1210. }
  1211. declare module BABYLON {
  1212. /** @hidden */
  1213. export class ShaderCodeCursor {
  1214. private _lines;
  1215. lineIndex: number;
  1216. get currentLine(): string;
  1217. get canRead(): boolean;
  1218. set lines(value: string[]);
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1224. process(preprocessors: {
  1225. [key: string]: string;
  1226. }, options: ProcessingOptions): string;
  1227. }
  1228. }
  1229. declare module BABYLON {
  1230. /** @hidden */
  1231. export class ShaderDefineExpression {
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. private static _OperatorPriority;
  1236. private static _Stack;
  1237. static postfixToInfix(postfix: string[]): string;
  1238. static infixToPostfix(infix: string): string[];
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderCodeTestNode extends ShaderCodeNode {
  1244. testExpression: ShaderDefineExpression;
  1245. isValid(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module BABYLON {
  1251. /** @hidden */
  1252. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1253. define: string;
  1254. not: boolean;
  1255. constructor(define: string, not?: boolean);
  1256. isTrue(preprocessors: {
  1257. [key: string]: string;
  1258. }): boolean;
  1259. }
  1260. }
  1261. declare module BABYLON {
  1262. /** @hidden */
  1263. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1264. leftOperand: ShaderDefineExpression;
  1265. rightOperand: ShaderDefineExpression;
  1266. isTrue(preprocessors: {
  1267. [key: string]: string;
  1268. }): boolean;
  1269. }
  1270. }
  1271. declare module BABYLON {
  1272. /** @hidden */
  1273. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1274. leftOperand: ShaderDefineExpression;
  1275. rightOperand: ShaderDefineExpression;
  1276. isTrue(preprocessors: {
  1277. [key: string]: string;
  1278. }): boolean;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /** @hidden */
  1283. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1284. define: string;
  1285. operand: string;
  1286. testValue: string;
  1287. constructor(define: string, operand: string, testValue: string);
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /**
  1295. * Class used to enable access to offline support
  1296. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1297. */
  1298. export interface IOfflineProvider {
  1299. /**
  1300. * Gets a boolean indicating if scene must be saved in the database
  1301. */
  1302. enableSceneOffline: boolean;
  1303. /**
  1304. * Gets a boolean indicating if textures must be saved in the database
  1305. */
  1306. enableTexturesOffline: boolean;
  1307. /**
  1308. * Open the offline support and make it available
  1309. * @param successCallback defines the callback to call on success
  1310. * @param errorCallback defines the callback to call on error
  1311. */
  1312. open(successCallback: () => void, errorCallback: () => void): void;
  1313. /**
  1314. * Loads an image from the offline support
  1315. * @param url defines the url to load from
  1316. * @param image defines the target DOM image
  1317. */
  1318. loadImage(url: string, image: HTMLImageElement): void;
  1319. /**
  1320. * Loads a file from offline support
  1321. * @param url defines the URL to load from
  1322. * @param sceneLoaded defines a callback to call on success
  1323. * @param progressCallBack defines a callback to call when progress changed
  1324. * @param errorCallback defines a callback to call on error
  1325. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1326. */
  1327. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1328. }
  1329. }
  1330. declare module BABYLON {
  1331. /**
  1332. * Class used to help managing file picking and drag'n'drop
  1333. * File Storage
  1334. */
  1335. export class FilesInputStore {
  1336. /**
  1337. * List of files ready to be loaded
  1338. */
  1339. static FilesToLoad: {
  1340. [key: string]: File;
  1341. };
  1342. }
  1343. }
  1344. declare module BABYLON {
  1345. /**
  1346. * Class used to define a retry strategy when error happens while loading assets
  1347. */
  1348. export class RetryStrategy {
  1349. /**
  1350. * Function used to defines an exponential back off strategy
  1351. * @param maxRetries defines the maximum number of retries (3 by default)
  1352. * @param baseInterval defines the interval between retries
  1353. * @returns the strategy function to use
  1354. */
  1355. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1356. }
  1357. }
  1358. declare module BABYLON {
  1359. /**
  1360. * @ignore
  1361. * Application error to support additional information when loading a file
  1362. */
  1363. export abstract class BaseError extends Error {
  1364. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1365. }
  1366. }
  1367. declare module BABYLON {
  1368. /** @ignore */
  1369. export class LoadFileError extends BaseError {
  1370. request?: WebRequest;
  1371. file?: File;
  1372. /**
  1373. * Creates a new LoadFileError
  1374. * @param message defines the message of the error
  1375. * @param request defines the optional web request
  1376. * @param file defines the optional file
  1377. */
  1378. constructor(message: string, object?: WebRequest | File);
  1379. }
  1380. /** @ignore */
  1381. export class RequestFileError extends BaseError {
  1382. request: WebRequest;
  1383. /**
  1384. * Creates a new LoadFileError
  1385. * @param message defines the message of the error
  1386. * @param request defines the optional web request
  1387. */
  1388. constructor(message: string, request: WebRequest);
  1389. }
  1390. /** @ignore */
  1391. export class ReadFileError extends BaseError {
  1392. file: File;
  1393. /**
  1394. * Creates a new ReadFileError
  1395. * @param message defines the message of the error
  1396. * @param file defines the optional file
  1397. */
  1398. constructor(message: string, file: File);
  1399. }
  1400. /**
  1401. * @hidden
  1402. */
  1403. export class FileTools {
  1404. /**
  1405. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1406. */
  1407. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1408. /**
  1409. * Gets or sets the base URL to use to load assets
  1410. */
  1411. static BaseUrl: string;
  1412. /**
  1413. * Default behaviour for cors in the application.
  1414. * It can be a string if the expected behavior is identical in the entire app.
  1415. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1416. */
  1417. static CorsBehavior: string | ((url: string | string[]) => string);
  1418. /**
  1419. * Gets or sets a function used to pre-process url before using them to load assets
  1420. */
  1421. static PreprocessUrl: (url: string) => string;
  1422. /**
  1423. * Removes unwanted characters from an url
  1424. * @param url defines the url to clean
  1425. * @returns the cleaned url
  1426. */
  1427. private static _CleanUrl;
  1428. /**
  1429. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1430. * @param url define the url we are trying
  1431. * @param element define the dom element where to configure the cors policy
  1432. */
  1433. static SetCorsBehavior(url: string | string[], element: {
  1434. crossOrigin: string | null;
  1435. }): void;
  1436. /**
  1437. * Loads an image as an HTMLImageElement.
  1438. * @param input url string, ArrayBuffer, or Blob to load
  1439. * @param onLoad callback called when the image successfully loads
  1440. * @param onError callback called when the image fails to load
  1441. * @param offlineProvider offline provider for caching
  1442. * @param mimeType optional mime type
  1443. * @returns the HTMLImageElement of the loaded image
  1444. */
  1445. 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>;
  1446. /**
  1447. * Reads a file from a File object
  1448. * @param file defines the file to load
  1449. * @param onSuccess defines the callback to call when data is loaded
  1450. * @param onProgress defines the callback to call during loading process
  1451. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1452. * @param onError defines the callback to call when an error occurs
  1453. * @returns a file request object
  1454. */
  1455. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1456. /**
  1457. * Loads a file from a url
  1458. * @param url url to load
  1459. * @param onSuccess callback called when the file successfully loads
  1460. * @param onProgress callback called while file is loading (if the server supports this mode)
  1461. * @param offlineProvider defines the offline provider for caching
  1462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1463. * @param onError callback called when the file fails to load
  1464. * @returns a file request object
  1465. */
  1466. 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;
  1467. /**
  1468. * Loads a file
  1469. * @param url url to load
  1470. * @param onSuccess callback called when the file successfully loads
  1471. * @param onProgress callback called while file is loading (if the server supports this mode)
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @param onOpened callback called when the web request is opened
  1475. * @returns a file request object
  1476. */
  1477. 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;
  1478. /**
  1479. * Checks if the loaded document was accessed via `file:`-Protocol.
  1480. * @returns boolean
  1481. */
  1482. static IsFileURL(): boolean;
  1483. }
  1484. }
  1485. declare module BABYLON {
  1486. /** @hidden */
  1487. export class ShaderProcessor {
  1488. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1489. private static _ProcessPrecision;
  1490. private static _ExtractOperation;
  1491. private static _BuildSubExpression;
  1492. private static _BuildExpression;
  1493. private static _MoveCursorWithinIf;
  1494. private static _MoveCursor;
  1495. private static _EvaluatePreProcessors;
  1496. private static _PreparePreProcessors;
  1497. private static _ProcessShaderConversion;
  1498. private static _ProcessIncludes;
  1499. /**
  1500. * Loads a file from a url
  1501. * @param url url to load
  1502. * @param onSuccess callback called when the file successfully loads
  1503. * @param onProgress callback called while file is loading (if the server supports this mode)
  1504. * @param offlineProvider defines the offline provider for caching
  1505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1506. * @param onError callback called when the file fails to load
  1507. * @returns a file request object
  1508. * @hidden
  1509. */
  1510. 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;
  1511. }
  1512. }
  1513. declare module BABYLON {
  1514. /**
  1515. * @hidden
  1516. */
  1517. export interface IColor4Like {
  1518. r: float;
  1519. g: float;
  1520. b: float;
  1521. a: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor3Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. }
  1531. /**
  1532. * @hidden
  1533. */
  1534. export interface IVector4Like {
  1535. x: float;
  1536. y: float;
  1537. z: float;
  1538. w: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector3Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. }
  1548. /**
  1549. * @hidden
  1550. */
  1551. export interface IVector2Like {
  1552. x: float;
  1553. y: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IMatrixLike {
  1559. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1560. updateFlag: int;
  1561. }
  1562. /**
  1563. * @hidden
  1564. */
  1565. export interface IViewportLike {
  1566. x: float;
  1567. y: float;
  1568. width: float;
  1569. height: float;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IPlaneLike {
  1575. normal: IVector3Like;
  1576. d: float;
  1577. normalize(): void;
  1578. }
  1579. }
  1580. declare module BABYLON {
  1581. /**
  1582. * Interface used to define common properties for effect fallbacks
  1583. */
  1584. export interface IEffectFallbacks {
  1585. /**
  1586. * Removes the defines that should be removed when falling back.
  1587. * @param currentDefines defines the current define statements for the shader.
  1588. * @param effect defines the current effect we try to compile
  1589. * @returns The resulting defines with defines of the current rank removed.
  1590. */
  1591. reduce(currentDefines: string, effect: Effect): string;
  1592. /**
  1593. * Removes the fallback from the bound mesh.
  1594. */
  1595. unBindMesh(): void;
  1596. /**
  1597. * Checks to see if more fallbacks are still availible.
  1598. */
  1599. hasMoreFallbacks: boolean;
  1600. }
  1601. }
  1602. declare module BABYLON {
  1603. /**
  1604. * Class used to evalaute queries containing `and` and `or` operators
  1605. */
  1606. export class AndOrNotEvaluator {
  1607. /**
  1608. * Evaluate a query
  1609. * @param query defines the query to evaluate
  1610. * @param evaluateCallback defines the callback used to filter result
  1611. * @returns true if the query matches
  1612. */
  1613. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1614. private static _HandleParenthesisContent;
  1615. private static _SimplifyNegation;
  1616. }
  1617. }
  1618. declare module BABYLON {
  1619. /**
  1620. * Class used to store custom tags
  1621. */
  1622. export class Tags {
  1623. /**
  1624. * Adds support for tags on the given object
  1625. * @param obj defines the object to use
  1626. */
  1627. static EnableFor(obj: any): void;
  1628. /**
  1629. * Removes tags support
  1630. * @param obj defines the object to use
  1631. */
  1632. static DisableFor(obj: any): void;
  1633. /**
  1634. * Gets a boolean indicating if the given object has tags
  1635. * @param obj defines the object to use
  1636. * @returns a boolean
  1637. */
  1638. static HasTags(obj: any): boolean;
  1639. /**
  1640. * Gets the tags available on a given object
  1641. * @param obj defines the object to use
  1642. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1643. * @returns the tags
  1644. */
  1645. static GetTags(obj: any, asString?: boolean): any;
  1646. /**
  1647. * Adds tags to an object
  1648. * @param obj defines the object to use
  1649. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1650. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1651. */
  1652. static AddTagsTo(obj: any, tagsString: string): void;
  1653. /**
  1654. * @hidden
  1655. */
  1656. static _AddTagTo(obj: any, tag: string): void;
  1657. /**
  1658. * Removes specific tags from a specific object
  1659. * @param obj defines the object to use
  1660. * @param tagsString defines the tags to remove
  1661. */
  1662. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _RemoveTagFrom(obj: any, tag: string): void;
  1667. /**
  1668. * Defines if tags hosted on an object match a given query
  1669. * @param obj defines the object to use
  1670. * @param tagsQuery defines the tag query
  1671. * @returns a boolean
  1672. */
  1673. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1674. }
  1675. }
  1676. declare module BABYLON {
  1677. /**
  1678. * Scalar computation library
  1679. */
  1680. export class Scalar {
  1681. /**
  1682. * Two pi constants convenient for computation.
  1683. */
  1684. static TwoPi: number;
  1685. /**
  1686. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1687. * @param a number
  1688. * @param b number
  1689. * @param epsilon (default = 1.401298E-45)
  1690. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1691. */
  1692. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1693. /**
  1694. * Returns a string : the upper case translation of the number i to hexadecimal.
  1695. * @param i number
  1696. * @returns the upper case translation of the number i to hexadecimal.
  1697. */
  1698. static ToHex(i: number): string;
  1699. /**
  1700. * Returns -1 if value is negative and +1 is value is positive.
  1701. * @param value the value
  1702. * @returns the value itself if it's equal to zero.
  1703. */
  1704. static Sign(value: number): number;
  1705. /**
  1706. * Returns the value itself if it's between min and max.
  1707. * Returns min if the value is lower than min.
  1708. * Returns max if the value is greater than max.
  1709. * @param value the value to clmap
  1710. * @param min the min value to clamp to (default: 0)
  1711. * @param max the max value to clamp to (default: 1)
  1712. * @returns the clamped value
  1713. */
  1714. static Clamp(value: number, min?: number, max?: number): number;
  1715. /**
  1716. * the log2 of value.
  1717. * @param value the value to compute log2 of
  1718. * @returns the log2 of value.
  1719. */
  1720. static Log2(value: number): number;
  1721. /**
  1722. * Loops the value, so that it is never larger than length and never smaller than 0.
  1723. *
  1724. * This is similar to the modulo operator but it works with floating point numbers.
  1725. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1726. * With t = 5 and length = 2.5, the result would be 0.0.
  1727. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1728. * @param value the value
  1729. * @param length the length
  1730. * @returns the looped value
  1731. */
  1732. static Repeat(value: number, length: number): number;
  1733. /**
  1734. * Normalize the value between 0.0 and 1.0 using min and max values
  1735. * @param value value to normalize
  1736. * @param min max to normalize between
  1737. * @param max min to normalize between
  1738. * @returns the normalized value
  1739. */
  1740. static Normalize(value: number, min: number, max: number): number;
  1741. /**
  1742. * Denormalize the value from 0.0 and 1.0 using min and max values
  1743. * @param normalized value to denormalize
  1744. * @param min max to denormalize between
  1745. * @param max min to denormalize between
  1746. * @returns the denormalized value
  1747. */
  1748. static Denormalize(normalized: number, min: number, max: number): number;
  1749. /**
  1750. * Calculates the shortest difference between two given angles given in degrees.
  1751. * @param current current angle in degrees
  1752. * @param target target angle in degrees
  1753. * @returns the delta
  1754. */
  1755. static DeltaAngle(current: number, target: number): number;
  1756. /**
  1757. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1758. * @param tx value
  1759. * @param length length
  1760. * @returns The returned value will move back and forth between 0 and length
  1761. */
  1762. static PingPong(tx: number, length: number): number;
  1763. /**
  1764. * Interpolates between min and max with smoothing at the limits.
  1765. *
  1766. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1767. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1768. * @param from from
  1769. * @param to to
  1770. * @param tx value
  1771. * @returns the smooth stepped value
  1772. */
  1773. static SmoothStep(from: number, to: number, tx: number): number;
  1774. /**
  1775. * Moves a value current towards target.
  1776. *
  1777. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1778. * Negative values of maxDelta pushes the value away from target.
  1779. * @param current current value
  1780. * @param target target value
  1781. * @param maxDelta max distance to move
  1782. * @returns resulting value
  1783. */
  1784. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1785. /**
  1786. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. *
  1788. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1789. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1790. * @param current current value
  1791. * @param target target value
  1792. * @param maxDelta max distance to move
  1793. * @returns resulting angle
  1794. */
  1795. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1796. /**
  1797. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1798. * @param start start value
  1799. * @param end target value
  1800. * @param amount amount to lerp between
  1801. * @returns the lerped value
  1802. */
  1803. static Lerp(start: number, end: number, amount: number): number;
  1804. /**
  1805. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1806. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1807. * @param start start value
  1808. * @param end target value
  1809. * @param amount amount to lerp between
  1810. * @returns the lerped value
  1811. */
  1812. static LerpAngle(start: number, end: number, amount: number): number;
  1813. /**
  1814. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1815. * @param a start value
  1816. * @param b target value
  1817. * @param value value between a and b
  1818. * @returns the inverseLerp value
  1819. */
  1820. static InverseLerp(a: number, b: number, value: number): number;
  1821. /**
  1822. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1823. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1824. * @param value1 spline value
  1825. * @param tangent1 spline value
  1826. * @param value2 spline value
  1827. * @param tangent2 spline value
  1828. * @param amount input value
  1829. * @returns hermite result
  1830. */
  1831. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1832. /**
  1833. * Returns a random float number between and min and max values
  1834. * @param min min value of random
  1835. * @param max max value of random
  1836. * @returns random value
  1837. */
  1838. static RandomRange(min: number, max: number): number;
  1839. /**
  1840. * This function returns percentage of a number in a given range.
  1841. *
  1842. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1843. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1844. * @param number to convert to percentage
  1845. * @param min min range
  1846. * @param max max range
  1847. * @returns the percentage
  1848. */
  1849. static RangeToPercent(number: number, min: number, max: number): number;
  1850. /**
  1851. * This function returns number that corresponds to the percentage in a given range.
  1852. *
  1853. * PercentToRange(0.34,0,100) will return 34.
  1854. * @param percent to convert to number
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the number
  1858. */
  1859. static PercentToRange(percent: number, min: number, max: number): number;
  1860. /**
  1861. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1862. * @param angle The angle to normalize in radian.
  1863. * @return The converted angle.
  1864. */
  1865. static NormalizeRadians(angle: number): number;
  1866. }
  1867. }
  1868. declare module BABYLON {
  1869. /**
  1870. * Constant used to convert a value to gamma space
  1871. * @ignorenaming
  1872. */
  1873. export const ToGammaSpace: number;
  1874. /**
  1875. * Constant used to convert a value to linear space
  1876. * @ignorenaming
  1877. */
  1878. export const ToLinearSpace = 2.2;
  1879. /**
  1880. * Constant used to define the minimal number value in Babylon.js
  1881. * @ignorenaming
  1882. */
  1883. let Epsilon: number;
  1884. }
  1885. declare module BABYLON {
  1886. /**
  1887. * Class used to represent a viewport on screen
  1888. */
  1889. export class Viewport {
  1890. /** viewport left coordinate */
  1891. x: number;
  1892. /** viewport top coordinate */
  1893. y: number;
  1894. /**viewport width */
  1895. width: number;
  1896. /** viewport height */
  1897. height: number;
  1898. /**
  1899. * Creates a Viewport object located at (x, y) and sized (width, height)
  1900. * @param x defines viewport left coordinate
  1901. * @param y defines viewport top coordinate
  1902. * @param width defines the viewport width
  1903. * @param height defines the viewport height
  1904. */
  1905. constructor(
  1906. /** viewport left coordinate */
  1907. x: number,
  1908. /** viewport top coordinate */
  1909. y: number,
  1910. /**viewport width */
  1911. width: number,
  1912. /** viewport height */
  1913. height: number);
  1914. /**
  1915. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1916. * @param renderWidth defines the rendering width
  1917. * @param renderHeight defines the rendering height
  1918. * @returns a new Viewport
  1919. */
  1920. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1921. /**
  1922. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1923. * @param renderWidth defines the rendering width
  1924. * @param renderHeight defines the rendering height
  1925. * @param ref defines the target viewport
  1926. * @returns the current viewport
  1927. */
  1928. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1929. /**
  1930. * Returns a new Viewport copied from the current one
  1931. * @returns a new Viewport
  1932. */
  1933. clone(): Viewport;
  1934. }
  1935. }
  1936. declare module BABYLON {
  1937. /**
  1938. * Class containing a set of static utilities functions for arrays.
  1939. */
  1940. export class ArrayTools {
  1941. /**
  1942. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1943. * @param size the number of element to construct and put in the array
  1944. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1945. * @returns a new array filled with new objects
  1946. */
  1947. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1948. }
  1949. }
  1950. declare module BABYLON {
  1951. /**
  1952. * Represents a plane by the equation ax + by + cz + d = 0
  1953. */
  1954. export class Plane {
  1955. private static _TmpMatrix;
  1956. /**
  1957. * Normal of the plane (a,b,c)
  1958. */
  1959. normal: Vector3;
  1960. /**
  1961. * d component of the plane
  1962. */
  1963. d: number;
  1964. /**
  1965. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1966. * @param a a component of the plane
  1967. * @param b b component of the plane
  1968. * @param c c component of the plane
  1969. * @param d d component of the plane
  1970. */
  1971. constructor(a: number, b: number, c: number, d: number);
  1972. /**
  1973. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1974. */
  1975. asArray(): number[];
  1976. /**
  1977. * @returns a new plane copied from the current Plane.
  1978. */
  1979. clone(): Plane;
  1980. /**
  1981. * @returns the string "Plane".
  1982. */
  1983. getClassName(): string;
  1984. /**
  1985. * @returns the Plane hash code.
  1986. */
  1987. getHashCode(): number;
  1988. /**
  1989. * Normalize the current Plane in place.
  1990. * @returns the updated Plane.
  1991. */
  1992. normalize(): Plane;
  1993. /**
  1994. * Applies a transformation the plane and returns the result
  1995. * @param transformation the transformation matrix to be applied to the plane
  1996. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1997. */
  1998. transform(transformation: DeepImmutable<Matrix>): Plane;
  1999. /**
  2000. * Compute the dot product between the point and the plane normal
  2001. * @param point point to calculate the dot product with
  2002. * @returns the dot product (float) of the point coordinates and the plane normal.
  2003. */
  2004. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2005. /**
  2006. * Updates the current Plane from the plane defined by the three given points.
  2007. * @param point1 one of the points used to contruct the plane
  2008. * @param point2 one of the points used to contruct the plane
  2009. * @param point3 one of the points used to contruct the plane
  2010. * @returns the updated Plane.
  2011. */
  2012. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2013. /**
  2014. * Checks if the plane is facing a given direction
  2015. * @param direction the direction to check if the plane is facing
  2016. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2017. * @returns True is the vector "direction" is the same side than the plane normal.
  2018. */
  2019. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2020. /**
  2021. * Calculates the distance to a point
  2022. * @param point point to calculate distance to
  2023. * @returns the signed distance (float) from the given point to the Plane.
  2024. */
  2025. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2026. /**
  2027. * Creates a plane from an array
  2028. * @param array the array to create a plane from
  2029. * @returns a new Plane from the given array.
  2030. */
  2031. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2032. /**
  2033. * Creates a plane from three points
  2034. * @param point1 point used to create the plane
  2035. * @param point2 point used to create the plane
  2036. * @param point3 point used to create the plane
  2037. * @returns a new Plane defined by the three given points.
  2038. */
  2039. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2040. /**
  2041. * Creates a plane from an origin point and a normal
  2042. * @param origin origin of the plane to be constructed
  2043. * @param normal normal of the plane to be constructed
  2044. * @returns a new Plane the normal vector to this plane at the given origin point.
  2045. * Note : the vector "normal" is updated because normalized.
  2046. */
  2047. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2048. /**
  2049. * Calculates the distance from a plane and a point
  2050. * @param origin origin of the plane to be constructed
  2051. * @param normal normal of the plane to be constructed
  2052. * @param point point to calculate distance to
  2053. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2054. */
  2055. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2056. }
  2057. }
  2058. declare module BABYLON {
  2059. /** @hidden */
  2060. export class PerformanceConfigurator {
  2061. /** @hidden */
  2062. static MatrixUse64Bits: boolean;
  2063. /** @hidden */
  2064. static MatrixTrackPrecisionChange: boolean;
  2065. /** @hidden */
  2066. static MatrixCurrentType: any;
  2067. /** @hidden */
  2068. static MatrixTrackedMatrices: Array<any> | null;
  2069. /** @hidden */
  2070. static SetMatrixPrecision(use64bits: boolean): void;
  2071. }
  2072. }
  2073. declare module BABYLON {
  2074. /**
  2075. * Class representing a vector containing 2 coordinates
  2076. */
  2077. export class Vector2 {
  2078. /** defines the first coordinate */
  2079. x: number;
  2080. /** defines the second coordinate */
  2081. y: number;
  2082. /**
  2083. * Creates a new Vector2 from the given x and y coordinates
  2084. * @param x defines the first coordinate
  2085. * @param y defines the second coordinate
  2086. */
  2087. constructor(
  2088. /** defines the first coordinate */
  2089. x?: number,
  2090. /** defines the second coordinate */
  2091. y?: number);
  2092. /**
  2093. * Gets a string with the Vector2 coordinates
  2094. * @returns a string with the Vector2 coordinates
  2095. */
  2096. toString(): string;
  2097. /**
  2098. * Gets class name
  2099. * @returns the string "Vector2"
  2100. */
  2101. getClassName(): string;
  2102. /**
  2103. * Gets current vector hash code
  2104. * @returns the Vector2 hash code as a number
  2105. */
  2106. getHashCode(): number;
  2107. /**
  2108. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2109. * @param array defines the source array
  2110. * @param index defines the offset in source array
  2111. * @returns the current Vector2
  2112. */
  2113. toArray(array: FloatArray, index?: number): Vector2;
  2114. /**
  2115. * Update the current vector from an array
  2116. * @param array defines the destination array
  2117. * @param index defines the offset in the destination array
  2118. * @returns the current Vector3
  2119. */
  2120. fromArray(array: FloatArray, index?: number): Vector2;
  2121. /**
  2122. * Copy the current vector to an array
  2123. * @returns a new array with 2 elements: the Vector2 coordinates.
  2124. */
  2125. asArray(): number[];
  2126. /**
  2127. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2128. * @param source defines the source Vector2
  2129. * @returns the current updated Vector2
  2130. */
  2131. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Sets the Vector2 coordinates with the given floats
  2134. * @param x defines the first coordinate
  2135. * @param y defines the second coordinate
  2136. * @returns the current updated Vector2
  2137. */
  2138. copyFromFloats(x: number, y: number): Vector2;
  2139. /**
  2140. * Sets the Vector2 coordinates with the given floats
  2141. * @param x defines the first coordinate
  2142. * @param y defines the second coordinate
  2143. * @returns the current updated Vector2
  2144. */
  2145. set(x: number, y: number): Vector2;
  2146. /**
  2147. * Add another vector with the current one
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2150. */
  2151. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2152. /**
  2153. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2154. * @param otherVector defines the other vector
  2155. * @param result defines the target vector
  2156. * @returns the unmodified current Vector2
  2157. */
  2158. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2159. /**
  2160. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2161. * @param otherVector defines the other vector
  2162. * @returns the current updated Vector2
  2163. */
  2164. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2165. /**
  2166. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns a new Vector2
  2169. */
  2170. addVector3(otherVector: Vector3): Vector2;
  2171. /**
  2172. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2173. * @param otherVector defines the other vector
  2174. * @returns a new Vector2
  2175. */
  2176. subtract(otherVector: Vector2): Vector2;
  2177. /**
  2178. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2179. * @param otherVector defines the other vector
  2180. * @param result defines the target vector
  2181. * @returns the unmodified current Vector2
  2182. */
  2183. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2184. /**
  2185. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2186. * @param otherVector defines the other vector
  2187. * @returns the current updated Vector2
  2188. */
  2189. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Multiplies in place the current Vector2 coordinates by the given ones
  2192. * @param otherVector defines the other vector
  2193. * @returns the current updated Vector2
  2194. */
  2195. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2196. /**
  2197. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @returns a new Vector2
  2200. */
  2201. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2204. * @param otherVector defines the other vector
  2205. * @param result defines the target vector
  2206. * @returns the unmodified current Vector2
  2207. */
  2208. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2209. /**
  2210. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2211. * @param x defines the first coordinate
  2212. * @param y defines the second coordinate
  2213. * @returns a new Vector2
  2214. */
  2215. multiplyByFloats(x: number, y: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2218. * @param otherVector defines the other vector
  2219. * @returns a new Vector2
  2220. */
  2221. divide(otherVector: Vector2): Vector2;
  2222. /**
  2223. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2224. * @param otherVector defines the other vector
  2225. * @param result defines the target vector
  2226. * @returns the unmodified current Vector2
  2227. */
  2228. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2229. /**
  2230. * Divides the current Vector2 coordinates by the given ones
  2231. * @param otherVector defines the other vector
  2232. * @returns the current updated Vector2
  2233. */
  2234. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 with current Vector2 negated coordinates
  2237. * @returns a new Vector2
  2238. */
  2239. negate(): Vector2;
  2240. /**
  2241. * Negate this vector in place
  2242. * @returns this
  2243. */
  2244. negateInPlace(): Vector2;
  2245. /**
  2246. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2247. * @param result defines the Vector3 object where to store the result
  2248. * @returns the current Vector2
  2249. */
  2250. negateToRef(result: Vector2): Vector2;
  2251. /**
  2252. * Multiply the Vector2 coordinates by scale
  2253. * @param scale defines the scaling factor
  2254. * @returns the current updated Vector2
  2255. */
  2256. scaleInPlace(scale: number): Vector2;
  2257. /**
  2258. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2259. * @param scale defines the scaling factor
  2260. * @returns a new Vector2
  2261. */
  2262. scale(scale: number): Vector2;
  2263. /**
  2264. * Scale the current Vector2 values by a factor to a given Vector2
  2265. * @param scale defines the scale factor
  2266. * @param result defines the Vector2 object where to store the result
  2267. * @returns the unmodified current Vector2
  2268. */
  2269. scaleToRef(scale: number, result: Vector2): Vector2;
  2270. /**
  2271. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2272. * @param scale defines the scale factor
  2273. * @param result defines the Vector2 object where to store the result
  2274. * @returns the unmodified current Vector2
  2275. */
  2276. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2277. /**
  2278. * Gets a boolean if two vectors are equals
  2279. * @param otherVector defines the other vector
  2280. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2281. */
  2282. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2283. /**
  2284. * Gets a boolean if two vectors are equals (using an epsilon value)
  2285. * @param otherVector defines the other vector
  2286. * @param epsilon defines the minimal distance to consider equality
  2287. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2288. */
  2289. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2290. /**
  2291. * Gets a new Vector2 from current Vector2 floored values
  2292. * @returns a new Vector2
  2293. */
  2294. floor(): Vector2;
  2295. /**
  2296. * Gets a new Vector2 from current Vector2 floored values
  2297. * @returns a new Vector2
  2298. */
  2299. fract(): Vector2;
  2300. /**
  2301. * Gets the length of the vector
  2302. * @returns the vector length (float)
  2303. */
  2304. length(): number;
  2305. /**
  2306. * Gets the vector squared length
  2307. * @returns the vector squared length (float)
  2308. */
  2309. lengthSquared(): number;
  2310. /**
  2311. * Normalize the vector
  2312. * @returns the current updated Vector2
  2313. */
  2314. normalize(): Vector2;
  2315. /**
  2316. * Gets a new Vector2 copied from the Vector2
  2317. * @returns a new Vector2
  2318. */
  2319. clone(): Vector2;
  2320. /**
  2321. * Gets a new Vector2(0, 0)
  2322. * @returns a new Vector2
  2323. */
  2324. static Zero(): Vector2;
  2325. /**
  2326. * Gets a new Vector2(1, 1)
  2327. * @returns a new Vector2
  2328. */
  2329. static One(): Vector2;
  2330. /**
  2331. * Gets a new Vector2 set from the given index element of the given array
  2332. * @param array defines the data source
  2333. * @param offset defines the offset in the data source
  2334. * @returns a new Vector2
  2335. */
  2336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2337. /**
  2338. * Sets "result" from the given index element of the given array
  2339. * @param array defines the data source
  2340. * @param offset defines the offset in the data source
  2341. * @param result defines the target vector
  2342. */
  2343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2344. /**
  2345. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2346. * @param value1 defines 1st point of control
  2347. * @param value2 defines 2nd point of control
  2348. * @param value3 defines 3rd point of control
  2349. * @param value4 defines 4th point of control
  2350. * @param amount defines the interpolation factor
  2351. * @returns a new Vector2
  2352. */
  2353. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2354. /**
  2355. * 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".
  2356. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2357. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2358. * @param value defines the value to clamp
  2359. * @param min defines the lower limit
  2360. * @param max defines the upper limit
  2361. * @returns a new Vector2
  2362. */
  2363. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2364. /**
  2365. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2366. * @param value1 defines the 1st control point
  2367. * @param tangent1 defines the outgoing tangent
  2368. * @param value2 defines the 2nd control point
  2369. * @param tangent2 defines the incoming tangent
  2370. * @param amount defines the interpolation factor
  2371. * @returns a new Vector2
  2372. */
  2373. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2376. * @param start defines the start vector
  2377. * @param end defines the end vector
  2378. * @param amount defines the interpolation factor
  2379. * @returns a new Vector2
  2380. */
  2381. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2382. /**
  2383. * Gets the dot product of the vector "left" and the vector "right"
  2384. * @param left defines first vector
  2385. * @param right defines second vector
  2386. * @returns the dot product (float)
  2387. */
  2388. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2389. /**
  2390. * Returns a new Vector2 equal to the normalized given vector
  2391. * @param vector defines the vector to normalize
  2392. * @returns a new Vector2
  2393. */
  2394. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2397. * @param left defines 1st vector
  2398. * @param right defines 2nd vector
  2399. * @returns a new Vector2
  2400. */
  2401. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2402. /**
  2403. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2404. * @param left defines 1st vector
  2405. * @param right defines 2nd vector
  2406. * @returns a new Vector2
  2407. */
  2408. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2409. /**
  2410. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2411. * @param vector defines the vector to transform
  2412. * @param transformation defines the matrix to apply
  2413. * @returns a new Vector2
  2414. */
  2415. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2416. /**
  2417. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2418. * @param vector defines the vector to transform
  2419. * @param transformation defines the matrix to apply
  2420. * @param result defines the target vector
  2421. */
  2422. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2423. /**
  2424. * Determines if a given vector is included in a triangle
  2425. * @param p defines the vector to test
  2426. * @param p0 defines 1st triangle point
  2427. * @param p1 defines 2nd triangle point
  2428. * @param p2 defines 3rd triangle point
  2429. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2430. */
  2431. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2432. /**
  2433. * Gets the distance between the vectors "value1" and "value2"
  2434. * @param value1 defines first vector
  2435. * @param value2 defines second vector
  2436. * @returns the distance between vectors
  2437. */
  2438. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2439. /**
  2440. * Returns the squared distance between the vectors "value1" and "value2"
  2441. * @param value1 defines first vector
  2442. * @param value2 defines second vector
  2443. * @returns the squared distance between vectors
  2444. */
  2445. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2446. /**
  2447. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2448. * @param value1 defines first vector
  2449. * @param value2 defines second vector
  2450. * @returns a new Vector2
  2451. */
  2452. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2453. /**
  2454. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2455. * @param p defines the middle point
  2456. * @param segA defines one point of the segment
  2457. * @param segB defines the other point of the segment
  2458. * @returns the shortest distance
  2459. */
  2460. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2461. }
  2462. /**
  2463. * Class used to store (x,y,z) vector representation
  2464. * A Vector3 is the main object used in 3D geometry
  2465. * It can represent etiher the coordinates of a point the space, either a direction
  2466. * Reminder: js uses a left handed forward facing system
  2467. */
  2468. export class Vector3 {
  2469. private static _UpReadOnly;
  2470. private static _ZeroReadOnly;
  2471. /** @hidden */
  2472. _x: number;
  2473. /** @hidden */
  2474. _y: number;
  2475. /** @hidden */
  2476. _z: number;
  2477. /** @hidden */
  2478. _isDirty: boolean;
  2479. /** Gets or sets the x coordinate */
  2480. get x(): number;
  2481. set x(value: number);
  2482. /** Gets or sets the y coordinate */
  2483. get y(): number;
  2484. set y(value: number);
  2485. /** Gets or sets the z coordinate */
  2486. get z(): number;
  2487. set z(value: number);
  2488. /**
  2489. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2490. * @param x defines the first coordinates (on X axis)
  2491. * @param y defines the second coordinates (on Y axis)
  2492. * @param z defines the third coordinates (on Z axis)
  2493. */
  2494. constructor(x?: number, y?: number, z?: number);
  2495. /**
  2496. * Creates a string representation of the Vector3
  2497. * @returns a string with the Vector3 coordinates.
  2498. */
  2499. toString(): string;
  2500. /**
  2501. * Gets the class name
  2502. * @returns the string "Vector3"
  2503. */
  2504. getClassName(): string;
  2505. /**
  2506. * Creates the Vector3 hash code
  2507. * @returns a number which tends to be unique between Vector3 instances
  2508. */
  2509. getHashCode(): number;
  2510. /**
  2511. * Creates an array containing three elements : the coordinates of the Vector3
  2512. * @returns a new array of numbers
  2513. */
  2514. asArray(): number[];
  2515. /**
  2516. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2517. * @param array defines the destination array
  2518. * @param index defines the offset in the destination array
  2519. * @returns the current Vector3
  2520. */
  2521. toArray(array: FloatArray, index?: number): Vector3;
  2522. /**
  2523. * Update the current vector from an array
  2524. * @param array defines the destination array
  2525. * @param index defines the offset in the destination array
  2526. * @returns the current Vector3
  2527. */
  2528. fromArray(array: FloatArray, index?: number): Vector3;
  2529. /**
  2530. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2531. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2532. */
  2533. toQuaternion(): Quaternion;
  2534. /**
  2535. * Adds the given vector to the current Vector3
  2536. * @param otherVector defines the second operand
  2537. * @returns the current updated Vector3
  2538. */
  2539. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2540. /**
  2541. * Adds the given coordinates to the current Vector3
  2542. * @param x defines the x coordinate of the operand
  2543. * @param y defines the y coordinate of the operand
  2544. * @param z defines the z coordinate of the operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2548. /**
  2549. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Subtract the given vector from the current Vector3
  2563. * @param otherVector defines the second operand
  2564. * @returns the current updated Vector3
  2565. */
  2566. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2567. /**
  2568. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2569. * @param otherVector defines the second operand
  2570. * @returns the resulting Vector3
  2571. */
  2572. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2573. /**
  2574. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2575. * @param otherVector defines the second operand
  2576. * @param result defines the Vector3 object where to store the result
  2577. * @returns the current Vector3
  2578. */
  2579. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2580. /**
  2581. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the resulting Vector3
  2586. */
  2587. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2590. * @param x defines the x coordinate of the operand
  2591. * @param y defines the y coordinate of the operand
  2592. * @param z defines the z coordinate of the operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2597. /**
  2598. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2599. * @returns a new Vector3
  2600. */
  2601. negate(): Vector3;
  2602. /**
  2603. * Negate this vector in place
  2604. * @returns this
  2605. */
  2606. negateInPlace(): Vector3;
  2607. /**
  2608. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. negateToRef(result: Vector3): Vector3;
  2613. /**
  2614. * Multiplies the Vector3 coordinates by the float "scale"
  2615. * @param scale defines the multiplier factor
  2616. * @returns the current updated Vector3
  2617. */
  2618. scaleInPlace(scale: number): Vector3;
  2619. /**
  2620. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2621. * @param scale defines the multiplier factor
  2622. * @returns a new Vector3
  2623. */
  2624. scale(scale: number): Vector3;
  2625. /**
  2626. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2627. * @param scale defines the multiplier factor
  2628. * @param result defines the Vector3 object where to store the result
  2629. * @returns the current Vector3
  2630. */
  2631. scaleToRef(scale: number, result: Vector3): Vector3;
  2632. /**
  2633. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2634. * @param scale defines the scale factor
  2635. * @param result defines the Vector3 object where to store the result
  2636. * @returns the unmodified current Vector3
  2637. */
  2638. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2639. /**
  2640. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2641. * @param origin defines the origin of the projection ray
  2642. * @param plane defines the plane to project to
  2643. * @returns the projected vector3
  2644. */
  2645. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2646. /**
  2647. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2648. * @param origin defines the origin of the projection ray
  2649. * @param plane defines the plane to project to
  2650. * @param result defines the Vector3 where to store the result
  2651. */
  2652. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2653. /**
  2654. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2655. * @param otherVector defines the second operand
  2656. * @returns true if both vectors are equals
  2657. */
  2658. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2659. /**
  2660. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2661. * @param otherVector defines the second operand
  2662. * @param epsilon defines the minimal distance to define values as equals
  2663. * @returns true if both vectors are distant less than epsilon
  2664. */
  2665. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2666. /**
  2667. * Returns true if the current Vector3 coordinates equals the given floats
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns true if both vectors are equals
  2672. */
  2673. equalsToFloats(x: number, y: number, z: number): boolean;
  2674. /**
  2675. * Multiplies the current Vector3 coordinates by the given ones
  2676. * @param otherVector defines the second operand
  2677. * @returns the current updated Vector3
  2678. */
  2679. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2682. * @param otherVector defines the second operand
  2683. * @returns the new Vector3
  2684. */
  2685. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2686. /**
  2687. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2688. * @param otherVector defines the second operand
  2689. * @param result defines the Vector3 object where to store the result
  2690. * @returns the current Vector3
  2691. */
  2692. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2693. /**
  2694. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2695. * @param x defines the x coordinate of the operand
  2696. * @param y defines the y coordinate of the operand
  2697. * @param z defines the z coordinate of the operand
  2698. * @returns the new Vector3
  2699. */
  2700. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2703. * @param otherVector defines the second operand
  2704. * @returns the new Vector3
  2705. */
  2706. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2709. * @param otherVector defines the second operand
  2710. * @param result defines the Vector3 object where to store the result
  2711. * @returns the current Vector3
  2712. */
  2713. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2714. /**
  2715. * Divides the current Vector3 coordinates by the given ones.
  2716. * @param otherVector defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. divideInPlace(otherVector: Vector3): Vector3;
  2720. /**
  2721. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2722. * @param other defines the second operand
  2723. * @returns the current updated Vector3
  2724. */
  2725. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2728. * @param other defines the second operand
  2729. * @returns the current updated Vector3
  2730. */
  2731. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2732. /**
  2733. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2734. * @param x defines the x coordinate of the operand
  2735. * @param y defines the y coordinate of the operand
  2736. * @param z defines the z coordinate of the operand
  2737. * @returns the current updated Vector3
  2738. */
  2739. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2740. /**
  2741. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2742. * @param x defines the x coordinate of the operand
  2743. * @param y defines the y coordinate of the operand
  2744. * @param z defines the z coordinate of the operand
  2745. * @returns the current updated Vector3
  2746. */
  2747. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2748. /**
  2749. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2750. * Check if is non uniform within a certain amount of decimal places to account for this
  2751. * @param epsilon the amount the values can differ
  2752. * @returns if the the vector is non uniform to a certain number of decimal places
  2753. */
  2754. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2755. /**
  2756. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2757. */
  2758. get isNonUniform(): boolean;
  2759. /**
  2760. * Gets a new Vector3 from current Vector3 floored values
  2761. * @returns a new Vector3
  2762. */
  2763. floor(): Vector3;
  2764. /**
  2765. * Gets a new Vector3 from current Vector3 floored values
  2766. * @returns a new Vector3
  2767. */
  2768. fract(): Vector3;
  2769. /**
  2770. * Gets the length of the Vector3
  2771. * @returns the length of the Vector3
  2772. */
  2773. length(): number;
  2774. /**
  2775. * Gets the squared length of the Vector3
  2776. * @returns squared length of the Vector3
  2777. */
  2778. lengthSquared(): number;
  2779. /**
  2780. * Normalize the current Vector3.
  2781. * Please note that this is an in place operation.
  2782. * @returns the current updated Vector3
  2783. */
  2784. normalize(): Vector3;
  2785. /**
  2786. * Reorders the x y z properties of the vector in place
  2787. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2788. * @returns the current updated vector
  2789. */
  2790. reorderInPlace(order: string): this;
  2791. /**
  2792. * Rotates the vector around 0,0,0 by a quaternion
  2793. * @param quaternion the rotation quaternion
  2794. * @param result vector to store the result
  2795. * @returns the resulting vector
  2796. */
  2797. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2798. /**
  2799. * Rotates a vector around a given point
  2800. * @param quaternion the rotation quaternion
  2801. * @param point the point to rotate around
  2802. * @param result vector to store the result
  2803. * @returns the resulting vector
  2804. */
  2805. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2806. /**
  2807. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2808. * The cross product is then orthogonal to both current and "other"
  2809. * @param other defines the right operand
  2810. * @returns the cross product
  2811. */
  2812. cross(other: Vector3): Vector3;
  2813. /**
  2814. * Normalize the current Vector3 with the given input length.
  2815. * Please note that this is an in place operation.
  2816. * @param len the length of the vector
  2817. * @returns the current updated Vector3
  2818. */
  2819. normalizeFromLength(len: number): Vector3;
  2820. /**
  2821. * Normalize the current Vector3 to a new vector
  2822. * @returns the new Vector3
  2823. */
  2824. normalizeToNew(): Vector3;
  2825. /**
  2826. * Normalize the current Vector3 to the reference
  2827. * @param reference define the Vector3 to update
  2828. * @returns the updated Vector3
  2829. */
  2830. normalizeToRef(reference: Vector3): Vector3;
  2831. /**
  2832. * Creates a new Vector3 copied from the current Vector3
  2833. * @returns the new Vector3
  2834. */
  2835. clone(): Vector3;
  2836. /**
  2837. * Copies the given vector coordinates to the current Vector3 ones
  2838. * @param source defines the source Vector3
  2839. * @returns the current updated Vector3
  2840. */
  2841. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2842. /**
  2843. * Copies the given floats to the current Vector3 coordinates
  2844. * @param x defines the x coordinate of the operand
  2845. * @param y defines the y coordinate of the operand
  2846. * @param z defines the z coordinate of the operand
  2847. * @returns the current updated Vector3
  2848. */
  2849. copyFromFloats(x: number, y: number, z: number): Vector3;
  2850. /**
  2851. * Copies the given floats to the current Vector3 coordinates
  2852. * @param x defines the x coordinate of the operand
  2853. * @param y defines the y coordinate of the operand
  2854. * @param z defines the z coordinate of the operand
  2855. * @returns the current updated Vector3
  2856. */
  2857. set(x: number, y: number, z: number): Vector3;
  2858. /**
  2859. * Copies the given float to the current Vector3 coordinates
  2860. * @param v defines the x, y and z coordinates of the operand
  2861. * @returns the current updated Vector3
  2862. */
  2863. setAll(v: number): Vector3;
  2864. /**
  2865. * Get the clip factor between two vectors
  2866. * @param vector0 defines the first operand
  2867. * @param vector1 defines the second operand
  2868. * @param axis defines the axis to use
  2869. * @param size defines the size along the axis
  2870. * @returns the clip factor
  2871. */
  2872. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2873. /**
  2874. * Get angle between two vectors
  2875. * @param vector0 angle between vector0 and vector1
  2876. * @param vector1 angle between vector0 and vector1
  2877. * @param normal direction of the normal
  2878. * @return the angle between vector0 and vector1
  2879. */
  2880. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2881. /**
  2882. * Returns a new Vector3 set from the index "offset" of the given array
  2883. * @param array defines the source array
  2884. * @param offset defines the offset in the source array
  2885. * @returns the new Vector3
  2886. */
  2887. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2888. /**
  2889. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2890. * @param array defines the source array
  2891. * @param offset defines the offset in the source array
  2892. * @returns the new Vector3
  2893. * @deprecated Please use FromArray instead.
  2894. */
  2895. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2896. /**
  2897. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2898. * @param array defines the source array
  2899. * @param offset defines the offset in the source array
  2900. * @param result defines the Vector3 where to store the result
  2901. */
  2902. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2903. /**
  2904. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2905. * @param array defines the source array
  2906. * @param offset defines the offset in the source array
  2907. * @param result defines the Vector3 where to store the result
  2908. * @deprecated Please use FromArrayToRef instead.
  2909. */
  2910. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2911. /**
  2912. * Sets the given vector "result" with the given floats.
  2913. * @param x defines the x coordinate of the source
  2914. * @param y defines the y coordinate of the source
  2915. * @param z defines the z coordinate of the source
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2919. /**
  2920. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2921. * @returns a new empty Vector3
  2922. */
  2923. static Zero(): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2926. * @returns a new unit Vector3
  2927. */
  2928. static One(): Vector3;
  2929. /**
  2930. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2931. * @returns a new up Vector3
  2932. */
  2933. static Up(): Vector3;
  2934. /**
  2935. * Gets a up Vector3 that must not be updated
  2936. */
  2937. static get UpReadOnly(): DeepImmutable<Vector3>;
  2938. /**
  2939. * Gets a zero Vector3 that must not be updated
  2940. */
  2941. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2942. /**
  2943. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2944. * @returns a new down Vector3
  2945. */
  2946. static Down(): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2949. * @param rightHandedSystem is the scene right-handed (negative z)
  2950. * @returns a new forward Vector3
  2951. */
  2952. static Forward(rightHandedSystem?: boolean): Vector3;
  2953. /**
  2954. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2955. * @param rightHandedSystem is the scene right-handed (negative-z)
  2956. * @returns a new forward Vector3
  2957. */
  2958. static Backward(rightHandedSystem?: boolean): Vector3;
  2959. /**
  2960. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2961. * @returns a new right Vector3
  2962. */
  2963. static Right(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2966. * @returns a new left Vector3
  2967. */
  2968. static Left(): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2971. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2972. * @param vector defines the Vector3 to transform
  2973. * @param transformation defines the transformation matrix
  2974. * @returns the transformed Vector3
  2975. */
  2976. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2977. /**
  2978. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2979. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2980. * @param vector defines the Vector3 to transform
  2981. * @param transformation defines the transformation matrix
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2987. * This method computes tranformed coordinates only, not transformed direction vectors
  2988. * @param x define the x coordinate of the source vector
  2989. * @param y define the y coordinate of the source vector
  2990. * @param z define the z coordinate of the source vector
  2991. * @param transformation defines the transformation matrix
  2992. * @param result defines the Vector3 where to store the result
  2993. */
  2994. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2995. /**
  2996. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2997. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2998. * @param vector defines the Vector3 to transform
  2999. * @param transformation defines the transformation matrix
  3000. * @returns the new Vector3
  3001. */
  3002. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3003. /**
  3004. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3005. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3006. * @param vector defines the Vector3 to transform
  3007. * @param transformation defines the transformation matrix
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3013. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3014. * @param x define the x coordinate of the source vector
  3015. * @param y define the y coordinate of the source vector
  3016. * @param z define the z coordinate of the source vector
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3023. * @param value1 defines the first control point
  3024. * @param value2 defines the second control point
  3025. * @param value3 defines the third control point
  3026. * @param value4 defines the fourth control point
  3027. * @param amount defines the amount on the spline to use
  3028. * @returns the new Vector3
  3029. */
  3030. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3031. /**
  3032. * 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"
  3033. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3034. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3035. * @param value defines the current value
  3036. * @param min defines the lower range value
  3037. * @param max defines the upper range value
  3038. * @returns the new Vector3
  3039. */
  3040. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * 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"
  3043. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3044. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3045. * @param value defines the current value
  3046. * @param min defines the lower range value
  3047. * @param max defines the upper range value
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3051. /**
  3052. * Checks if a given vector is inside a specific range
  3053. * @param v defines the vector to test
  3054. * @param min defines the minimum range
  3055. * @param max defines the maximum range
  3056. */
  3057. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3058. /**
  3059. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3060. * @param value1 defines the first control point
  3061. * @param tangent1 defines the first tangent vector
  3062. * @param value2 defines the second control point
  3063. * @param tangent2 defines the second tangent vector
  3064. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3065. * @returns the new Vector3
  3066. */
  3067. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3068. /**
  3069. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3070. * @param start defines the start value
  3071. * @param end defines the end value
  3072. * @param amount max defines amount between both (between 0 and 1)
  3073. * @returns the new Vector3
  3074. */
  3075. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3076. /**
  3077. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3078. * @param start defines the start value
  3079. * @param end defines the end value
  3080. * @param amount max defines amount between both (between 0 and 1)
  3081. * @param result defines the Vector3 where to store the result
  3082. */
  3083. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3084. /**
  3085. * Returns the dot product (float) between the vectors "left" and "right"
  3086. * @param left defines the left operand
  3087. * @param right defines the right operand
  3088. * @returns the dot product
  3089. */
  3090. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3091. /**
  3092. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3093. * The cross product is then orthogonal to both "left" and "right"
  3094. * @param left defines the left operand
  3095. * @param right defines the right operand
  3096. * @returns the cross product
  3097. */
  3098. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3099. /**
  3100. * Sets the given vector "result" with the cross product of "left" and "right"
  3101. * The cross product is then orthogonal to both "left" and "right"
  3102. * @param left defines the left operand
  3103. * @param right defines the right operand
  3104. * @param result defines the Vector3 where to store the result
  3105. */
  3106. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3107. /**
  3108. * Returns a new Vector3 as the normalization of the given vector
  3109. * @param vector defines the Vector3 to normalize
  3110. * @returns the new Vector3
  3111. */
  3112. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3113. /**
  3114. * Sets the given vector "result" with the normalization of the given first vector
  3115. * @param vector defines the Vector3 to normalize
  3116. * @param result defines the Vector3 where to store the result
  3117. */
  3118. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3119. /**
  3120. * Project a Vector3 onto screen space
  3121. * @param vector defines the Vector3 to project
  3122. * @param world defines the world matrix to use
  3123. * @param transform defines the transform (view x projection) matrix to use
  3124. * @param viewport defines the screen viewport to use
  3125. * @returns the new Vector3
  3126. */
  3127. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3128. /** @hidden */
  3129. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3130. /**
  3131. * Unproject from screen space to object space
  3132. * @param source defines the screen space Vector3 to use
  3133. * @param viewportWidth defines the current width of the viewport
  3134. * @param viewportHeight defines the current height of the viewport
  3135. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3136. * @param transform defines the transform (view x projection) matrix to use
  3137. * @returns the new Vector3
  3138. */
  3139. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param source defines the screen space Vector3 to use
  3143. * @param viewportWidth defines the current width of the viewport
  3144. * @param viewportHeight defines the current height of the viewport
  3145. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3146. * @param view defines the view matrix to use
  3147. * @param projection defines the projection matrix to use
  3148. * @returns the new Vector3
  3149. */
  3150. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3151. /**
  3152. * Unproject from screen space to object space
  3153. * @param source defines the screen space Vector3 to use
  3154. * @param viewportWidth defines the current width of the viewport
  3155. * @param viewportHeight defines the current height of the viewport
  3156. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3157. * @param view defines the view matrix to use
  3158. * @param projection defines the projection matrix to use
  3159. * @param result defines the Vector3 where to store the result
  3160. */
  3161. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3162. /**
  3163. * Unproject from screen space to object space
  3164. * @param sourceX defines the screen space x coordinate to use
  3165. * @param sourceY defines the screen space y coordinate to use
  3166. * @param sourceZ defines the screen space z coordinate to use
  3167. * @param viewportWidth defines the current width of the viewport
  3168. * @param viewportHeight defines the current height of the viewport
  3169. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3170. * @param view defines the view matrix to use
  3171. * @param projection defines the projection matrix to use
  3172. * @param result defines the Vector3 where to store the result
  3173. */
  3174. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3175. /**
  3176. * Gets the minimal coordinate values between two Vector3
  3177. * @param left defines the first operand
  3178. * @param right defines the second operand
  3179. * @returns the new Vector3
  3180. */
  3181. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3182. /**
  3183. * Gets the maximal coordinate values between two Vector3
  3184. * @param left defines the first operand
  3185. * @param right defines the second operand
  3186. * @returns the new Vector3
  3187. */
  3188. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3189. /**
  3190. * Returns the distance between the vectors "value1" and "value2"
  3191. * @param value1 defines the first operand
  3192. * @param value2 defines the second operand
  3193. * @returns the distance
  3194. */
  3195. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3196. /**
  3197. * Returns the squared distance between the vectors "value1" and "value2"
  3198. * @param value1 defines the first operand
  3199. * @param value2 defines the second operand
  3200. * @returns the squared distance
  3201. */
  3202. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3203. /**
  3204. * Returns a new Vector3 located at the center between "value1" and "value2"
  3205. * @param value1 defines the first operand
  3206. * @param value2 defines the second operand
  3207. * @returns the new Vector3
  3208. */
  3209. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3210. /**
  3211. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3212. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3213. * to something in order to rotate it from its local system to the given target system
  3214. * Note: axis1, axis2 and axis3 are normalized during this operation
  3215. * @param axis1 defines the first axis
  3216. * @param axis2 defines the second axis
  3217. * @param axis3 defines the third axis
  3218. * @returns a new Vector3
  3219. */
  3220. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3221. /**
  3222. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3223. * @param axis1 defines the first axis
  3224. * @param axis2 defines the second axis
  3225. * @param axis3 defines the third axis
  3226. * @param ref defines the Vector3 where to store the result
  3227. */
  3228. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3229. }
  3230. /**
  3231. * Vector4 class created for EulerAngle class conversion to Quaternion
  3232. */
  3233. export class Vector4 {
  3234. /** x value of the vector */
  3235. x: number;
  3236. /** y value of the vector */
  3237. y: number;
  3238. /** z value of the vector */
  3239. z: number;
  3240. /** w value of the vector */
  3241. w: number;
  3242. /**
  3243. * Creates a Vector4 object from the given floats.
  3244. * @param x x value of the vector
  3245. * @param y y value of the vector
  3246. * @param z z value of the vector
  3247. * @param w w value of the vector
  3248. */
  3249. constructor(
  3250. /** x value of the vector */
  3251. x: number,
  3252. /** y value of the vector */
  3253. y: number,
  3254. /** z value of the vector */
  3255. z: number,
  3256. /** w value of the vector */
  3257. w: number);
  3258. /**
  3259. * Returns the string with the Vector4 coordinates.
  3260. * @returns a string containing all the vector values
  3261. */
  3262. toString(): string;
  3263. /**
  3264. * Returns the string "Vector4".
  3265. * @returns "Vector4"
  3266. */
  3267. getClassName(): string;
  3268. /**
  3269. * Returns the Vector4 hash code.
  3270. * @returns a unique hash code
  3271. */
  3272. getHashCode(): number;
  3273. /**
  3274. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3275. * @returns the resulting array
  3276. */
  3277. asArray(): number[];
  3278. /**
  3279. * Populates the given array from the given index with the Vector4 coordinates.
  3280. * @param array array to populate
  3281. * @param index index of the array to start at (default: 0)
  3282. * @returns the Vector4.
  3283. */
  3284. toArray(array: FloatArray, index?: number): Vector4;
  3285. /**
  3286. * Update the current vector from an array
  3287. * @param array defines the destination array
  3288. * @param index defines the offset in the destination array
  3289. * @returns the current Vector3
  3290. */
  3291. fromArray(array: FloatArray, index?: number): Vector4;
  3292. /**
  3293. * Adds the given vector to the current Vector4.
  3294. * @param otherVector the vector to add
  3295. * @returns the updated Vector4.
  3296. */
  3297. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3300. * @param otherVector the vector to add
  3301. * @returns the resulting vector
  3302. */
  3303. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3306. * @param otherVector the vector to add
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Subtract in place the given vector from the current Vector4.
  3313. * @param otherVector the vector to subtract
  3314. * @returns the updated Vector4.
  3315. */
  3316. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3317. /**
  3318. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3319. * @param otherVector the vector to add
  3320. * @returns the new vector with the result
  3321. */
  3322. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3323. /**
  3324. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3325. * @param otherVector the vector to subtract
  3326. * @param result the vector to store the result
  3327. * @returns the current Vector4.
  3328. */
  3329. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3330. /**
  3331. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3332. */
  3333. /**
  3334. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3335. * @param x value to subtract
  3336. * @param y value to subtract
  3337. * @param z value to subtract
  3338. * @param w value to subtract
  3339. * @returns new vector containing the result
  3340. */
  3341. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3342. /**
  3343. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3344. * @param x value to subtract
  3345. * @param y value to subtract
  3346. * @param z value to subtract
  3347. * @param w value to subtract
  3348. * @param result the vector to store the result in
  3349. * @returns the current Vector4.
  3350. */
  3351. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3352. /**
  3353. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3354. * @returns a new vector with the negated values
  3355. */
  3356. negate(): Vector4;
  3357. /**
  3358. * Negate this vector in place
  3359. * @returns this
  3360. */
  3361. negateInPlace(): Vector4;
  3362. /**
  3363. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3364. * @param result defines the Vector3 object where to store the result
  3365. * @returns the current Vector4
  3366. */
  3367. negateToRef(result: Vector4): Vector4;
  3368. /**
  3369. * Multiplies the current Vector4 coordinates by scale (float).
  3370. * @param scale the number to scale with
  3371. * @returns the updated Vector4.
  3372. */
  3373. scaleInPlace(scale: number): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3376. * @param scale the number to scale with
  3377. * @returns a new vector with the result
  3378. */
  3379. scale(scale: number): Vector4;
  3380. /**
  3381. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3382. * @param scale the number to scale with
  3383. * @param result a vector to store the result in
  3384. * @returns the current Vector4.
  3385. */
  3386. scaleToRef(scale: number, result: Vector4): Vector4;
  3387. /**
  3388. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3389. * @param scale defines the scale factor
  3390. * @param result defines the Vector4 object where to store the result
  3391. * @returns the unmodified current Vector4
  3392. */
  3393. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3394. /**
  3395. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3396. * @param otherVector the vector to compare against
  3397. * @returns true if they are equal
  3398. */
  3399. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3400. /**
  3401. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3402. * @param otherVector vector to compare against
  3403. * @param epsilon (Default: very small number)
  3404. * @returns true if they are equal
  3405. */
  3406. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3407. /**
  3408. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3409. * @param x x value to compare against
  3410. * @param y y value to compare against
  3411. * @param z z value to compare against
  3412. * @param w w value to compare against
  3413. * @returns true if equal
  3414. */
  3415. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3416. /**
  3417. * Multiplies in place the current Vector4 by the given one.
  3418. * @param otherVector vector to multiple with
  3419. * @returns the updated Vector4.
  3420. */
  3421. multiplyInPlace(otherVector: Vector4): Vector4;
  3422. /**
  3423. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3424. * @param otherVector vector to multiple with
  3425. * @returns resulting new vector
  3426. */
  3427. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3430. * @param otherVector vector to multiple with
  3431. * @param result vector to store the result
  3432. * @returns the current Vector4.
  3433. */
  3434. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3435. /**
  3436. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3437. * @param x x value multiply with
  3438. * @param y y value multiply with
  3439. * @param z z value multiply with
  3440. * @param w w value multiply with
  3441. * @returns resulting new vector
  3442. */
  3443. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3444. /**
  3445. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3446. * @param otherVector vector to devide with
  3447. * @returns resulting new vector
  3448. */
  3449. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3452. * @param otherVector vector to devide with
  3453. * @param result vector to store the result
  3454. * @returns the current Vector4.
  3455. */
  3456. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3457. /**
  3458. * Divides the current Vector3 coordinates by the given ones.
  3459. * @param otherVector vector to devide with
  3460. * @returns the updated Vector3.
  3461. */
  3462. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3463. /**
  3464. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3465. * @param other defines the second operand
  3466. * @returns the current updated Vector4
  3467. */
  3468. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3469. /**
  3470. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3471. * @param other defines the second operand
  3472. * @returns the current updated Vector4
  3473. */
  3474. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3475. /**
  3476. * Gets a new Vector4 from current Vector4 floored values
  3477. * @returns a new Vector4
  3478. */
  3479. floor(): Vector4;
  3480. /**
  3481. * Gets a new Vector4 from current Vector3 floored values
  3482. * @returns a new Vector4
  3483. */
  3484. fract(): Vector4;
  3485. /**
  3486. * Returns the Vector4 length (float).
  3487. * @returns the length
  3488. */
  3489. length(): number;
  3490. /**
  3491. * Returns the Vector4 squared length (float).
  3492. * @returns the length squared
  3493. */
  3494. lengthSquared(): number;
  3495. /**
  3496. * Normalizes in place the Vector4.
  3497. * @returns the updated Vector4.
  3498. */
  3499. normalize(): Vector4;
  3500. /**
  3501. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3502. * @returns this converted to a new vector3
  3503. */
  3504. toVector3(): Vector3;
  3505. /**
  3506. * Returns a new Vector4 copied from the current one.
  3507. * @returns the new cloned vector
  3508. */
  3509. clone(): Vector4;
  3510. /**
  3511. * Updates the current Vector4 with the given one coordinates.
  3512. * @param source the source vector to copy from
  3513. * @returns the updated Vector4.
  3514. */
  3515. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3516. /**
  3517. * Updates the current Vector4 coordinates with the given floats.
  3518. * @param x float to copy from
  3519. * @param y float to copy from
  3520. * @param z float to copy from
  3521. * @param w float to copy from
  3522. * @returns the updated Vector4.
  3523. */
  3524. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3525. /**
  3526. * Updates the current Vector4 coordinates with the given floats.
  3527. * @param x float to set from
  3528. * @param y float to set from
  3529. * @param z float to set from
  3530. * @param w float to set from
  3531. * @returns the updated Vector4.
  3532. */
  3533. set(x: number, y: number, z: number, w: number): Vector4;
  3534. /**
  3535. * Copies the given float to the current Vector3 coordinates
  3536. * @param v defines the x, y, z and w coordinates of the operand
  3537. * @returns the current updated Vector3
  3538. */
  3539. setAll(v: number): Vector4;
  3540. /**
  3541. * Returns a new Vector4 set from the starting index of the given array.
  3542. * @param array the array to pull values from
  3543. * @param offset the offset into the array to start at
  3544. * @returns the new vector
  3545. */
  3546. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3547. /**
  3548. * Updates the given vector "result" from the starting index of the given array.
  3549. * @param array the array to pull values from
  3550. * @param offset the offset into the array to start at
  3551. * @param result the vector to store the result in
  3552. */
  3553. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3554. /**
  3555. * Updates the given vector "result" from the starting index of the given Float32Array.
  3556. * @param array the array to pull values from
  3557. * @param offset the offset into the array to start at
  3558. * @param result the vector to store the result in
  3559. */
  3560. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3561. /**
  3562. * Updates the given vector "result" coordinates from the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @param result the vector to the floats in
  3568. */
  3569. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3570. /**
  3571. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3572. * @returns the new vector
  3573. */
  3574. static Zero(): Vector4;
  3575. /**
  3576. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3577. * @returns the new vector
  3578. */
  3579. static One(): Vector4;
  3580. /**
  3581. * Returns a new normalized Vector4 from the given one.
  3582. * @param vector the vector to normalize
  3583. * @returns the vector
  3584. */
  3585. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3586. /**
  3587. * Updates the given vector "result" from the normalization of the given one.
  3588. * @param vector the vector to normalize
  3589. * @param result the vector to store the result in
  3590. */
  3591. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3592. /**
  3593. * Returns a vector with the minimum values from the left and right vectors
  3594. * @param left left vector to minimize
  3595. * @param right right vector to minimize
  3596. * @returns a new vector with the minimum of the left and right vector values
  3597. */
  3598. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3599. /**
  3600. * Returns a vector with the maximum values from the left and right vectors
  3601. * @param left left vector to maximize
  3602. * @param right right vector to maximize
  3603. * @returns a new vector with the maximum of the left and right vector values
  3604. */
  3605. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3606. /**
  3607. * Returns the distance (float) between the vectors "value1" and "value2".
  3608. * @param value1 value to calulate the distance between
  3609. * @param value2 value to calulate the distance between
  3610. * @return the distance between the two vectors
  3611. */
  3612. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3613. /**
  3614. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3615. * @param value1 value to calulate the distance between
  3616. * @param value2 value to calulate the distance between
  3617. * @return the distance between the two vectors squared
  3618. */
  3619. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3620. /**
  3621. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3622. * @param value1 value to calulate the center between
  3623. * @param value2 value to calulate the center between
  3624. * @return the center between the two vectors
  3625. */
  3626. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3627. /**
  3628. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3629. * This methods computes transformed normalized direction vectors only.
  3630. * @param vector the vector to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @returns the new vector
  3633. */
  3634. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3635. /**
  3636. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3637. * This methods computes transformed normalized direction vectors only.
  3638. * @param vector the vector to transform
  3639. * @param transformation the transformation matrix to apply
  3640. * @param result the vector to store the result in
  3641. */
  3642. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3643. /**
  3644. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3645. * This methods computes transformed normalized direction vectors only.
  3646. * @param x value to transform
  3647. * @param y value to transform
  3648. * @param z value to transform
  3649. * @param w value to transform
  3650. * @param transformation the transformation matrix to apply
  3651. * @param result the vector to store the results in
  3652. */
  3653. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3654. /**
  3655. * Creates a new Vector4 from a Vector3
  3656. * @param source defines the source data
  3657. * @param w defines the 4th component (default is 0)
  3658. * @returns a new Vector4
  3659. */
  3660. static FromVector3(source: Vector3, w?: number): Vector4;
  3661. }
  3662. /**
  3663. * Class used to store quaternion data
  3664. * @see https://en.wikipedia.org/wiki/Quaternion
  3665. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3666. */
  3667. export class Quaternion {
  3668. /** @hidden */
  3669. _x: number;
  3670. /** @hidden */
  3671. _y: number;
  3672. /** @hidden */
  3673. _z: number;
  3674. /** @hidden */
  3675. _w: number;
  3676. /** @hidden */
  3677. _isDirty: boolean;
  3678. /** Gets or sets the x coordinate */
  3679. get x(): number;
  3680. set x(value: number);
  3681. /** Gets or sets the y coordinate */
  3682. get y(): number;
  3683. set y(value: number);
  3684. /** Gets or sets the z coordinate */
  3685. get z(): number;
  3686. set z(value: number);
  3687. /** Gets or sets the w coordinate */
  3688. get w(): number;
  3689. set w(value: number);
  3690. /**
  3691. * Creates a new Quaternion from the given floats
  3692. * @param x defines the first component (0 by default)
  3693. * @param y defines the second component (0 by default)
  3694. * @param z defines the third component (0 by default)
  3695. * @param w defines the fourth component (1.0 by default)
  3696. */
  3697. constructor(x?: number, y?: number, z?: number, w?: number);
  3698. /**
  3699. * Gets a string representation for the current quaternion
  3700. * @returns a string with the Quaternion coordinates
  3701. */
  3702. toString(): string;
  3703. /**
  3704. * Gets the class name of the quaternion
  3705. * @returns the string "Quaternion"
  3706. */
  3707. getClassName(): string;
  3708. /**
  3709. * Gets a hash code for this quaternion
  3710. * @returns the quaternion hash code
  3711. */
  3712. getHashCode(): number;
  3713. /**
  3714. * Copy the quaternion to an array
  3715. * @returns a new array populated with 4 elements from the quaternion coordinates
  3716. */
  3717. asArray(): number[];
  3718. /**
  3719. * Check if two quaternions are equals
  3720. * @param otherQuaternion defines the second operand
  3721. * @return true if the current quaternion and the given one coordinates are strictly equals
  3722. */
  3723. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3724. /**
  3725. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3726. * @param otherQuaternion defines the other quaternion
  3727. * @param epsilon defines the minimal distance to consider equality
  3728. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3729. */
  3730. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3731. /**
  3732. * Clone the current quaternion
  3733. * @returns a new quaternion copied from the current one
  3734. */
  3735. clone(): Quaternion;
  3736. /**
  3737. * Copy a quaternion to the current one
  3738. * @param other defines the other quaternion
  3739. * @returns the updated current quaternion
  3740. */
  3741. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3742. /**
  3743. * Updates the current quaternion with the given float coordinates
  3744. * @param x defines the x coordinate
  3745. * @param y defines the y coordinate
  3746. * @param z defines the z coordinate
  3747. * @param w defines the w coordinate
  3748. * @returns the updated current quaternion
  3749. */
  3750. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3751. /**
  3752. * Updates the current quaternion from the given float coordinates
  3753. * @param x defines the x coordinate
  3754. * @param y defines the y coordinate
  3755. * @param z defines the z coordinate
  3756. * @param w defines the w coordinate
  3757. * @returns the updated current quaternion
  3758. */
  3759. set(x: number, y: number, z: number, w: number): Quaternion;
  3760. /**
  3761. * Adds two quaternions
  3762. * @param other defines the second operand
  3763. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3764. */
  3765. add(other: DeepImmutable<Quaternion>): Quaternion;
  3766. /**
  3767. * Add a quaternion to the current one
  3768. * @param other defines the quaternion to add
  3769. * @returns the current quaternion
  3770. */
  3771. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3772. /**
  3773. * Subtract two quaternions
  3774. * @param other defines the second operand
  3775. * @returns a new quaternion as the subtraction result of the given one from the current one
  3776. */
  3777. subtract(other: Quaternion): Quaternion;
  3778. /**
  3779. * Multiplies the current quaternion by a scale factor
  3780. * @param value defines the scale factor
  3781. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3782. */
  3783. scale(value: number): Quaternion;
  3784. /**
  3785. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3786. * @param scale defines the scale factor
  3787. * @param result defines the Quaternion object where to store the result
  3788. * @returns the unmodified current quaternion
  3789. */
  3790. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3791. /**
  3792. * Multiplies in place the current quaternion by a scale factor
  3793. * @param value defines the scale factor
  3794. * @returns the current modified quaternion
  3795. */
  3796. scaleInPlace(value: number): Quaternion;
  3797. /**
  3798. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3799. * @param scale defines the scale factor
  3800. * @param result defines the Quaternion object where to store the result
  3801. * @returns the unmodified current quaternion
  3802. */
  3803. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3804. /**
  3805. * Multiplies two quaternions
  3806. * @param q1 defines the second operand
  3807. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3808. */
  3809. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3810. /**
  3811. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3812. * @param q1 defines the second operand
  3813. * @param result defines the target quaternion
  3814. * @returns the current quaternion
  3815. */
  3816. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3817. /**
  3818. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3819. * @param q1 defines the second operand
  3820. * @returns the currentupdated quaternion
  3821. */
  3822. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3823. /**
  3824. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3825. * @param ref defines the target quaternion
  3826. * @returns the current quaternion
  3827. */
  3828. conjugateToRef(ref: Quaternion): Quaternion;
  3829. /**
  3830. * Conjugates in place (1-q) the current quaternion
  3831. * @returns the current updated quaternion
  3832. */
  3833. conjugateInPlace(): Quaternion;
  3834. /**
  3835. * Conjugates in place (1-q) the current quaternion
  3836. * @returns a new quaternion
  3837. */
  3838. conjugate(): Quaternion;
  3839. /**
  3840. * Gets length of current quaternion
  3841. * @returns the quaternion length (float)
  3842. */
  3843. length(): number;
  3844. /**
  3845. * Normalize in place the current quaternion
  3846. * @returns the current updated quaternion
  3847. */
  3848. normalize(): Quaternion;
  3849. /**
  3850. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3851. * @param order is a reserved parameter and is ignored for now
  3852. * @returns a new Vector3 containing the Euler angles
  3853. */
  3854. toEulerAngles(order?: string): Vector3;
  3855. /**
  3856. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3857. * @param result defines the vector which will be filled with the Euler angles
  3858. * @returns the current unchanged quaternion
  3859. */
  3860. toEulerAnglesToRef(result: Vector3): Quaternion;
  3861. /**
  3862. * Updates the given rotation matrix with the current quaternion values
  3863. * @param result defines the target matrix
  3864. * @returns the current unchanged quaternion
  3865. */
  3866. toRotationMatrix(result: Matrix): Quaternion;
  3867. /**
  3868. * Updates the current quaternion from the given rotation matrix values
  3869. * @param matrix defines the source matrix
  3870. * @returns the current updated quaternion
  3871. */
  3872. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from a rotation matrix
  3875. * @param matrix defines the source matrix
  3876. * @returns a new quaternion created from the given rotation matrix values
  3877. */
  3878. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3879. /**
  3880. * Updates the given quaternion with the given rotation matrix values
  3881. * @param matrix defines the source matrix
  3882. * @param result defines the target quaternion
  3883. */
  3884. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3885. /**
  3886. * Returns the dot product (float) between the quaternions "left" and "right"
  3887. * @param left defines the left operand
  3888. * @param right defines the right operand
  3889. * @returns the dot product
  3890. */
  3891. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3892. /**
  3893. * Checks if the two quaternions are close to each other
  3894. * @param quat0 defines the first quaternion to check
  3895. * @param quat1 defines the second quaternion to check
  3896. * @returns true if the two quaternions are close to each other
  3897. */
  3898. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3899. /**
  3900. * Creates an empty quaternion
  3901. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3902. */
  3903. static Zero(): Quaternion;
  3904. /**
  3905. * Inverse a given quaternion
  3906. * @param q defines the source quaternion
  3907. * @returns a new quaternion as the inverted current quaternion
  3908. */
  3909. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3910. /**
  3911. * Inverse a given quaternion
  3912. * @param q defines the source quaternion
  3913. * @param result the quaternion the result will be stored in
  3914. * @returns the result quaternion
  3915. */
  3916. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates an identity quaternion
  3919. * @returns the identity quaternion
  3920. */
  3921. static Identity(): Quaternion;
  3922. /**
  3923. * Gets a boolean indicating if the given quaternion is identity
  3924. * @param quaternion defines the quaternion to check
  3925. * @returns true if the quaternion is identity
  3926. */
  3927. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3928. /**
  3929. * Creates a quaternion from a rotation around an axis
  3930. * @param axis defines the axis to use
  3931. * @param angle defines the angle to use
  3932. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3933. */
  3934. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3935. /**
  3936. * Creates a rotation around an axis and stores it into the given quaternion
  3937. * @param axis defines the axis to use
  3938. * @param angle defines the angle to use
  3939. * @param result defines the target quaternion
  3940. * @returns the target quaternion
  3941. */
  3942. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3943. /**
  3944. * Creates a new quaternion from data stored into an array
  3945. * @param array defines the data source
  3946. * @param offset defines the offset in the source array where the data starts
  3947. * @returns a new quaternion
  3948. */
  3949. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3950. /**
  3951. * Updates the given quaternion "result" from the starting index of the given array.
  3952. * @param array the array to pull values from
  3953. * @param offset the offset into the array to start at
  3954. * @param result the quaternion to store the result in
  3955. */
  3956. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3957. /**
  3958. * Create a quaternion from Euler rotation angles
  3959. * @param x Pitch
  3960. * @param y Yaw
  3961. * @param z Roll
  3962. * @returns the new Quaternion
  3963. */
  3964. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3965. /**
  3966. * Updates a quaternion from Euler rotation angles
  3967. * @param x Pitch
  3968. * @param y Yaw
  3969. * @param z Roll
  3970. * @param result the quaternion to store the result
  3971. * @returns the updated quaternion
  3972. */
  3973. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3974. /**
  3975. * Create a quaternion from Euler rotation vector
  3976. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3977. * @returns the new Quaternion
  3978. */
  3979. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3980. /**
  3981. * Updates a quaternion from Euler rotation vector
  3982. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3983. * @param result the quaternion to store the result
  3984. * @returns the updated quaternion
  3985. */
  3986. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3987. /**
  3988. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3989. * @param yaw defines the rotation around Y axis
  3990. * @param pitch defines the rotation around X axis
  3991. * @param roll defines the rotation around Z axis
  3992. * @returns the new quaternion
  3993. */
  3994. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3995. /**
  3996. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3997. * @param yaw defines the rotation around Y axis
  3998. * @param pitch defines the rotation around X axis
  3999. * @param roll defines the rotation around Z axis
  4000. * @param result defines the target quaternion
  4001. */
  4002. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4003. /**
  4004. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4005. * @param alpha defines the rotation around first axis
  4006. * @param beta defines the rotation around second axis
  4007. * @param gamma defines the rotation around third axis
  4008. * @returns the new quaternion
  4009. */
  4010. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4011. /**
  4012. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4013. * @param alpha defines the rotation around first axis
  4014. * @param beta defines the rotation around second axis
  4015. * @param gamma defines the rotation around third axis
  4016. * @param result defines the target quaternion
  4017. */
  4018. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4019. /**
  4020. * 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)
  4021. * @param axis1 defines the first axis
  4022. * @param axis2 defines the second axis
  4023. * @param axis3 defines the third axis
  4024. * @returns the new quaternion
  4025. */
  4026. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4027. /**
  4028. * 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
  4029. * @param axis1 defines the first axis
  4030. * @param axis2 defines the second axis
  4031. * @param axis3 defines the third axis
  4032. * @param ref defines the target quaternion
  4033. */
  4034. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4035. /**
  4036. * Interpolates between two quaternions
  4037. * @param left defines first quaternion
  4038. * @param right defines second quaternion
  4039. * @param amount defines the gradient to use
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. /**
  4044. * Interpolates between two quaternions and stores it into a target quaternion
  4045. * @param left defines first quaternion
  4046. * @param right defines second quaternion
  4047. * @param amount defines the gradient to use
  4048. * @param result defines the target quaternion
  4049. */
  4050. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4051. /**
  4052. * Interpolate between two quaternions using Hermite interpolation
  4053. * @param value1 defines first quaternion
  4054. * @param tangent1 defines the incoming tangent
  4055. * @param value2 defines second quaternion
  4056. * @param tangent2 defines the outgoing tangent
  4057. * @param amount defines the target quaternion
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. }
  4062. /**
  4063. * Class used to store matrix data (4x4)
  4064. */
  4065. export class Matrix {
  4066. /**
  4067. * Gets the precision of matrix computations
  4068. */
  4069. static get Use64Bits(): boolean;
  4070. private static _updateFlagSeed;
  4071. private static _identityReadOnly;
  4072. private _isIdentity;
  4073. private _isIdentityDirty;
  4074. private _isIdentity3x2;
  4075. private _isIdentity3x2Dirty;
  4076. /**
  4077. * Gets the update flag of the matrix which is an unique number for the matrix.
  4078. * It will be incremented every time the matrix data change.
  4079. * You can use it to speed the comparison between two versions of the same matrix.
  4080. */
  4081. updateFlag: number;
  4082. private readonly _m;
  4083. /**
  4084. * Gets the internal data of the matrix
  4085. */
  4086. get m(): DeepImmutable<Float32Array | Array<number>>;
  4087. /** @hidden */
  4088. _markAsUpdated(): void;
  4089. /** @hidden */
  4090. private _updateIdentityStatus;
  4091. /**
  4092. * Creates an empty matrix (filled with zeros)
  4093. */
  4094. constructor();
  4095. /**
  4096. * Check if the current matrix is identity
  4097. * @returns true is the matrix is the identity matrix
  4098. */
  4099. isIdentity(): boolean;
  4100. /**
  4101. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4102. * @returns true is the matrix is the identity matrix
  4103. */
  4104. isIdentityAs3x2(): boolean;
  4105. /**
  4106. * Gets the determinant of the matrix
  4107. * @returns the matrix determinant
  4108. */
  4109. determinant(): number;
  4110. /**
  4111. * Returns the matrix as a Float32Array or Array<number>
  4112. * @returns the matrix underlying array
  4113. */
  4114. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4115. /**
  4116. * Returns the matrix as a Float32Array or Array<number>
  4117. * @returns the matrix underlying array.
  4118. */
  4119. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4120. /**
  4121. * Inverts the current matrix in place
  4122. * @returns the current inverted matrix
  4123. */
  4124. invert(): Matrix;
  4125. /**
  4126. * Sets all the matrix elements to zero
  4127. * @returns the current matrix
  4128. */
  4129. reset(): Matrix;
  4130. /**
  4131. * Adds the current matrix with a second one
  4132. * @param other defines the matrix to add
  4133. * @returns a new matrix as the addition of the current matrix and the given one
  4134. */
  4135. add(other: DeepImmutable<Matrix>): Matrix;
  4136. /**
  4137. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4138. * @param other defines the matrix to add
  4139. * @param result defines the target matrix
  4140. * @returns the current matrix
  4141. */
  4142. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4143. /**
  4144. * Adds in place the given matrix to the current matrix
  4145. * @param other defines the second operand
  4146. * @returns the current updated matrix
  4147. */
  4148. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4149. /**
  4150. * Sets the given matrix to the current inverted Matrix
  4151. * @param other defines the target matrix
  4152. * @returns the unmodified current matrix
  4153. */
  4154. invertToRef(other: Matrix): Matrix;
  4155. /**
  4156. * add a value at the specified position in the current Matrix
  4157. * @param index the index of the value within the matrix. between 0 and 15.
  4158. * @param value the value to be added
  4159. * @returns the current updated matrix
  4160. */
  4161. addAtIndex(index: number, value: number): Matrix;
  4162. /**
  4163. * mutiply the specified position in the current Matrix by a value
  4164. * @param index the index of the value within the matrix. between 0 and 15.
  4165. * @param value the value to be added
  4166. * @returns the current updated matrix
  4167. */
  4168. multiplyAtIndex(index: number, value: number): Matrix;
  4169. /**
  4170. * Inserts the translation vector (using 3 floats) in the current matrix
  4171. * @param x defines the 1st component of the translation
  4172. * @param y defines the 2nd component of the translation
  4173. * @param z defines the 3rd component of the translation
  4174. * @returns the current updated matrix
  4175. */
  4176. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4177. /**
  4178. * Adds the translation vector (using 3 floats) in the current matrix
  4179. * @param x defines the 1st component of the translation
  4180. * @param y defines the 2nd component of the translation
  4181. * @param z defines the 3rd component of the translation
  4182. * @returns the current updated matrix
  4183. */
  4184. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4185. /**
  4186. * Inserts the translation vector in the current matrix
  4187. * @param vector3 defines the translation to insert
  4188. * @returns the current updated matrix
  4189. */
  4190. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4191. /**
  4192. * Gets the translation value of the current matrix
  4193. * @returns a new Vector3 as the extracted translation from the matrix
  4194. */
  4195. getTranslation(): Vector3;
  4196. /**
  4197. * Fill a Vector3 with the extracted translation from the matrix
  4198. * @param result defines the Vector3 where to store the translation
  4199. * @returns the current matrix
  4200. */
  4201. getTranslationToRef(result: Vector3): Matrix;
  4202. /**
  4203. * Remove rotation and scaling part from the matrix
  4204. * @returns the updated matrix
  4205. */
  4206. removeRotationAndScaling(): Matrix;
  4207. /**
  4208. * Multiply two matrices
  4209. * @param other defines the second operand
  4210. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4211. */
  4212. multiply(other: DeepImmutable<Matrix>): Matrix;
  4213. /**
  4214. * Copy the current matrix from the given one
  4215. * @param other defines the source matrix
  4216. * @returns the current updated matrix
  4217. */
  4218. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4219. /**
  4220. * Populates the given array from the starting index with the current matrix values
  4221. * @param array defines the target array
  4222. * @param offset defines the offset in the target array where to start storing values
  4223. * @returns the current matrix
  4224. */
  4225. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4226. /**
  4227. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4228. * @param other defines the second operand
  4229. * @param result defines the matrix where to store the multiplication
  4230. * @returns the current matrix
  4231. */
  4232. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4233. /**
  4234. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4235. * @param other defines the second operand
  4236. * @param result defines the array where to store the multiplication
  4237. * @param offset defines the offset in the target array where to start storing values
  4238. * @returns the current matrix
  4239. */
  4240. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4241. /**
  4242. * Check equality between this matrix and a second one
  4243. * @param value defines the second matrix to compare
  4244. * @returns true is the current matrix and the given one values are strictly equal
  4245. */
  4246. equals(value: DeepImmutable<Matrix>): boolean;
  4247. /**
  4248. * Clone the current matrix
  4249. * @returns a new matrix from the current matrix
  4250. */
  4251. clone(): Matrix;
  4252. /**
  4253. * Returns the name of the current matrix class
  4254. * @returns the string "Matrix"
  4255. */
  4256. getClassName(): string;
  4257. /**
  4258. * Gets the hash code of the current matrix
  4259. * @returns the hash code
  4260. */
  4261. getHashCode(): number;
  4262. /**
  4263. * Decomposes the current Matrix into a translation, rotation and scaling components
  4264. * @param scale defines the scale vector3 given as a reference to update
  4265. * @param rotation defines the rotation quaternion given as a reference to update
  4266. * @param translation defines the translation vector3 given as a reference to update
  4267. * @returns true if operation was successful
  4268. */
  4269. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4270. /**
  4271. * Gets specific row of the matrix
  4272. * @param index defines the number of the row to get
  4273. * @returns the index-th row of the current matrix as a new Vector4
  4274. */
  4275. getRow(index: number): Nullable<Vector4>;
  4276. /**
  4277. * Sets the index-th row of the current matrix to the vector4 values
  4278. * @param index defines the number of the row to set
  4279. * @param row defines the target vector4
  4280. * @returns the updated current matrix
  4281. */
  4282. setRow(index: number, row: Vector4): Matrix;
  4283. /**
  4284. * Compute the transpose of the matrix
  4285. * @returns the new transposed matrix
  4286. */
  4287. transpose(): Matrix;
  4288. /**
  4289. * Compute the transpose of the matrix and store it in a given matrix
  4290. * @param result defines the target matrix
  4291. * @returns the current matrix
  4292. */
  4293. transposeToRef(result: Matrix): Matrix;
  4294. /**
  4295. * Sets the index-th row of the current matrix with the given 4 x float values
  4296. * @param index defines the row index
  4297. * @param x defines the x component to set
  4298. * @param y defines the y component to set
  4299. * @param z defines the z component to set
  4300. * @param w defines the w component to set
  4301. * @returns the updated current matrix
  4302. */
  4303. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4304. /**
  4305. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4306. * @param scale defines the scale factor
  4307. * @returns a new matrix
  4308. */
  4309. scale(scale: number): Matrix;
  4310. /**
  4311. * Scale the current matrix values by a factor to a given result matrix
  4312. * @param scale defines the scale factor
  4313. * @param result defines the matrix to store the result
  4314. * @returns the current matrix
  4315. */
  4316. scaleToRef(scale: number, result: Matrix): Matrix;
  4317. /**
  4318. * Scale the current matrix values by a factor and add the result to a given matrix
  4319. * @param scale defines the scale factor
  4320. * @param result defines the Matrix to store the result
  4321. * @returns the current matrix
  4322. */
  4323. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4324. /**
  4325. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4326. * @param ref matrix to store the result
  4327. */
  4328. toNormalMatrix(ref: Matrix): void;
  4329. /**
  4330. * Gets only rotation part of the current matrix
  4331. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4332. */
  4333. getRotationMatrix(): Matrix;
  4334. /**
  4335. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4336. * @param result defines the target matrix to store data to
  4337. * @returns the current matrix
  4338. */
  4339. getRotationMatrixToRef(result: Matrix): Matrix;
  4340. /**
  4341. * Toggles model matrix from being right handed to left handed in place and vice versa
  4342. */
  4343. toggleModelMatrixHandInPlace(): void;
  4344. /**
  4345. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4346. */
  4347. toggleProjectionMatrixHandInPlace(): void;
  4348. /**
  4349. * Creates a matrix from an array
  4350. * @param array defines the source array
  4351. * @param offset defines an offset in the source array
  4352. * @returns a new Matrix set from the starting index of the given array
  4353. */
  4354. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4355. /**
  4356. * Copy the content of an array into a given matrix
  4357. * @param array defines the source array
  4358. * @param offset defines an offset in the source array
  4359. * @param result defines the target matrix
  4360. */
  4361. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4362. /**
  4363. * Stores an array into a matrix after having multiplied each component by a given factor
  4364. * @param array defines the source array
  4365. * @param offset defines the offset in the source array
  4366. * @param scale defines the scaling factor
  4367. * @param result defines the target matrix
  4368. */
  4369. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4370. /**
  4371. * Gets an identity matrix that must not be updated
  4372. */
  4373. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4374. /**
  4375. * Stores a list of values (16) inside a given matrix
  4376. * @param initialM11 defines 1st value of 1st row
  4377. * @param initialM12 defines 2nd value of 1st row
  4378. * @param initialM13 defines 3rd value of 1st row
  4379. * @param initialM14 defines 4th value of 1st row
  4380. * @param initialM21 defines 1st value of 2nd row
  4381. * @param initialM22 defines 2nd value of 2nd row
  4382. * @param initialM23 defines 3rd value of 2nd row
  4383. * @param initialM24 defines 4th value of 2nd row
  4384. * @param initialM31 defines 1st value of 3rd row
  4385. * @param initialM32 defines 2nd value of 3rd row
  4386. * @param initialM33 defines 3rd value of 3rd row
  4387. * @param initialM34 defines 4th value of 3rd row
  4388. * @param initialM41 defines 1st value of 4th row
  4389. * @param initialM42 defines 2nd value of 4th row
  4390. * @param initialM43 defines 3rd value of 4th row
  4391. * @param initialM44 defines 4th value of 4th row
  4392. * @param result defines the target matrix
  4393. */
  4394. 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;
  4395. /**
  4396. * Creates new matrix from a list of values (16)
  4397. * @param initialM11 defines 1st value of 1st row
  4398. * @param initialM12 defines 2nd value of 1st row
  4399. * @param initialM13 defines 3rd value of 1st row
  4400. * @param initialM14 defines 4th value of 1st row
  4401. * @param initialM21 defines 1st value of 2nd row
  4402. * @param initialM22 defines 2nd value of 2nd row
  4403. * @param initialM23 defines 3rd value of 2nd row
  4404. * @param initialM24 defines 4th value of 2nd row
  4405. * @param initialM31 defines 1st value of 3rd row
  4406. * @param initialM32 defines 2nd value of 3rd row
  4407. * @param initialM33 defines 3rd value of 3rd row
  4408. * @param initialM34 defines 4th value of 3rd row
  4409. * @param initialM41 defines 1st value of 4th row
  4410. * @param initialM42 defines 2nd value of 4th row
  4411. * @param initialM43 defines 3rd value of 4th row
  4412. * @param initialM44 defines 4th value of 4th row
  4413. * @returns the new matrix
  4414. */
  4415. 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;
  4416. /**
  4417. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4418. * @param scale defines the scale vector3
  4419. * @param rotation defines the rotation quaternion
  4420. * @param translation defines the translation vector3
  4421. * @returns a new matrix
  4422. */
  4423. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4426. * @param scale defines the scale vector3
  4427. * @param rotation defines the rotation quaternion
  4428. * @param translation defines the translation vector3
  4429. * @param result defines the target matrix
  4430. */
  4431. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4432. /**
  4433. * Creates a new identity matrix
  4434. * @returns a new identity matrix
  4435. */
  4436. static Identity(): Matrix;
  4437. /**
  4438. * Creates a new identity matrix and stores the result in a given matrix
  4439. * @param result defines the target matrix
  4440. */
  4441. static IdentityToRef(result: Matrix): void;
  4442. /**
  4443. * Creates a new zero matrix
  4444. * @returns a new zero matrix
  4445. */
  4446. static Zero(): Matrix;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the X axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationX(angle: number): Matrix;
  4453. /**
  4454. * Creates a new matrix as the invert of a given matrix
  4455. * @param source defines the source matrix
  4456. * @returns the new matrix
  4457. */
  4458. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4461. * @param angle defines the angle (in radians) to use
  4462. * @param result defines the target matrix
  4463. */
  4464. static RotationXToRef(angle: number, result: Matrix): void;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Y axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationY(angle: number): Matrix;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4473. * @param angle defines the angle (in radians) to use
  4474. * @param result defines the target matrix
  4475. */
  4476. static RotationYToRef(angle: number, result: Matrix): void;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the Z axis
  4479. * @param angle defines the angle (in radians) to use
  4480. * @return the new matrix
  4481. */
  4482. static RotationZ(angle: number): Matrix;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4485. * @param angle defines the angle (in radians) to use
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationZToRef(angle: number, result: Matrix): void;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the given axis
  4491. * @param axis defines the axis to use
  4492. * @param angle defines the angle (in radians) to use
  4493. * @return the new matrix
  4494. */
  4495. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4496. /**
  4497. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4498. * @param axis defines the axis to use
  4499. * @param angle defines the angle (in radians) to use
  4500. * @param result defines the target matrix
  4501. */
  4502. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4503. /**
  4504. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4505. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4506. * @param from defines the vector to align
  4507. * @param to defines the vector to align to
  4508. * @param result defines the target matrix
  4509. */
  4510. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4511. /**
  4512. * Creates a rotation matrix
  4513. * @param yaw defines the yaw angle in radians (Y axis)
  4514. * @param pitch defines the pitch angle in radians (X axis)
  4515. * @param roll defines the roll angle in radians (Z axis)
  4516. * @returns the new rotation matrix
  4517. */
  4518. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4519. /**
  4520. * Creates a rotation matrix and stores it in a given matrix
  4521. * @param yaw defines the yaw angle in radians (Y axis)
  4522. * @param pitch defines the pitch angle in radians (X axis)
  4523. * @param roll defines the roll angle in radians (Z axis)
  4524. * @param result defines the target matrix
  4525. */
  4526. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4527. /**
  4528. * Creates a scaling matrix
  4529. * @param x defines the scale factor on X axis
  4530. * @param y defines the scale factor on Y axis
  4531. * @param z defines the scale factor on Z axis
  4532. * @returns the new matrix
  4533. */
  4534. static Scaling(x: number, y: number, z: number): Matrix;
  4535. /**
  4536. * Creates a scaling matrix and stores it in a given matrix
  4537. * @param x defines the scale factor on X axis
  4538. * @param y defines the scale factor on Y axis
  4539. * @param z defines the scale factor on Z axis
  4540. * @param result defines the target matrix
  4541. */
  4542. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4543. /**
  4544. * Creates a translation matrix
  4545. * @param x defines the translation on X axis
  4546. * @param y defines the translation on Y axis
  4547. * @param z defines the translationon Z axis
  4548. * @returns the new matrix
  4549. */
  4550. static Translation(x: number, y: number, z: number): Matrix;
  4551. /**
  4552. * Creates a translation matrix and stores it in a given matrix
  4553. * @param x defines the translation on X axis
  4554. * @param y defines the translation on Y axis
  4555. * @param z defines the translationon Z axis
  4556. * @param result defines the target matrix
  4557. */
  4558. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4559. /**
  4560. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4561. * @param startValue defines the start value
  4562. * @param endValue defines the end value
  4563. * @param gradient defines the gradient factor
  4564. * @returns the new matrix
  4565. */
  4566. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4567. /**
  4568. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4569. * @param startValue defines the start value
  4570. * @param endValue defines the end value
  4571. * @param gradient defines the gradient factor
  4572. * @param result defines the Matrix object where to store data
  4573. */
  4574. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4575. /**
  4576. * Builds a new matrix whose values are computed by:
  4577. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4578. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4579. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4580. * @param startValue defines the first matrix
  4581. * @param endValue defines the second matrix
  4582. * @param gradient defines the gradient between the two matrices
  4583. * @returns the new matrix
  4584. */
  4585. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4586. /**
  4587. * Update a matrix to values which are computed by:
  4588. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4589. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4590. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4591. * @param startValue defines the first matrix
  4592. * @param endValue defines the second matrix
  4593. * @param gradient defines the gradient between the two matrices
  4594. * @param result defines the target matrix
  4595. */
  4596. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in left handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in left handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * 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"
  4617. * This function works in right handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * 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".
  4626. * This function works in right handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param width defines the viewport width
  4636. * @param height defines the viewport height
  4637. * @param znear defines the near clip plane
  4638. * @param zfar defines the far clip plane
  4639. * @returns a new matrix as a left-handed orthographic projection matrix
  4640. */
  4641. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4642. /**
  4643. * Store a left-handed orthographic projection to a given matrix
  4644. * @param width defines the viewport width
  4645. * @param height defines the viewport height
  4646. * @param znear defines the near clip plane
  4647. * @param zfar defines the far clip plane
  4648. * @param result defines the target matrix
  4649. */
  4650. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param left defines the viewport left coordinate
  4654. * @param right defines the viewport right coordinate
  4655. * @param bottom defines the viewport bottom coordinate
  4656. * @param top defines the viewport top coordinate
  4657. * @param znear defines the near clip plane
  4658. * @param zfar defines the far clip plane
  4659. * @returns a new matrix as a left-handed orthographic projection matrix
  4660. */
  4661. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4662. /**
  4663. * Stores a left-handed orthographic projection into a given matrix
  4664. * @param left defines the viewport left coordinate
  4665. * @param right defines the viewport right coordinate
  4666. * @param bottom defines the viewport bottom coordinate
  4667. * @param top defines the viewport top coordinate
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Creates a right-handed orthographic projection matrix
  4675. * @param left defines the viewport left coordinate
  4676. * @param right defines the viewport right coordinate
  4677. * @param bottom defines the viewport bottom coordinate
  4678. * @param top defines the viewport top coordinate
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a right-handed orthographic projection matrix
  4682. */
  4683. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a right-handed orthographic projection into a given matrix
  4686. * @param left defines the viewport left coordinate
  4687. * @param right defines the viewport right coordinate
  4688. * @param bottom defines the viewport bottom coordinate
  4689. * @param top defines the viewport top coordinate
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. */
  4694. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4695. /**
  4696. * Creates a left-handed perspective projection matrix
  4697. * @param width defines the viewport width
  4698. * @param height defines the viewport height
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @returns a new matrix as a left-handed perspective projection matrix
  4702. */
  4703. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4704. /**
  4705. * Creates a left-handed perspective projection matrix
  4706. * @param fov defines the horizontal field of view
  4707. * @param aspect defines the aspect ratio
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @returns a new matrix as a left-handed perspective projection matrix
  4711. */
  4712. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4713. /**
  4714. * Stores a left-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 defines the far clip plane
  4719. * @param result defines the target matrix
  4720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4721. */
  4722. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4723. /**
  4724. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4725. * @param fov defines the horizontal field of view
  4726. * @param aspect defines the aspect ratio
  4727. * @param znear defines the near clip plane
  4728. * @param zfar not used as infinity is used as far clip
  4729. * @param result defines the target matrix
  4730. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4731. */
  4732. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4733. /**
  4734. * Creates a right-handed perspective projection matrix
  4735. * @param fov defines the horizontal field of view
  4736. * @param aspect defines the aspect ratio
  4737. * @param znear defines the near clip plane
  4738. * @param zfar defines the far clip plane
  4739. * @returns a new matrix as a right-handed perspective projection matrix
  4740. */
  4741. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4742. /**
  4743. * Stores a right-handed perspective projection into a given matrix
  4744. * @param fov defines the horizontal field of view
  4745. * @param aspect defines the aspect ratio
  4746. * @param znear defines the near clip plane
  4747. * @param zfar defines the far clip plane
  4748. * @param result defines the target matrix
  4749. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4750. */
  4751. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4752. /**
  4753. * Stores a right-handed perspective projection into a given matrix
  4754. * @param fov defines the horizontal field of view
  4755. * @param aspect defines the aspect ratio
  4756. * @param znear defines the near clip plane
  4757. * @param zfar not used as infinity is used as far clip
  4758. * @param result defines the target matrix
  4759. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4760. */
  4761. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4762. /**
  4763. * Stores a perspective projection for WebVR info a given matrix
  4764. * @param fov defines the field of view
  4765. * @param znear defines the near clip plane
  4766. * @param zfar defines the far clip plane
  4767. * @param result defines the target matrix
  4768. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4769. */
  4770. static PerspectiveFovWebVRToRef(fov: {
  4771. upDegrees: number;
  4772. downDegrees: number;
  4773. leftDegrees: number;
  4774. rightDegrees: number;
  4775. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4776. /**
  4777. * Computes a complete transformation matrix
  4778. * @param viewport defines the viewport to use
  4779. * @param world defines the world matrix
  4780. * @param view defines the view matrix
  4781. * @param projection defines the projection matrix
  4782. * @param zmin defines the near clip plane
  4783. * @param zmax defines the far clip plane
  4784. * @returns the transformation matrix
  4785. */
  4786. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4787. /**
  4788. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4789. * @param matrix defines the matrix to use
  4790. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4791. */
  4792. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4793. /**
  4794. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4795. * @param matrix defines the matrix to use
  4796. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4797. */
  4798. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4799. /**
  4800. * Compute the transpose of a given matrix
  4801. * @param matrix defines the matrix to transpose
  4802. * @returns the new matrix
  4803. */
  4804. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4805. /**
  4806. * Compute the transpose of a matrix and store it in a target matrix
  4807. * @param matrix defines the matrix to transpose
  4808. * @param result defines the target matrix
  4809. */
  4810. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4811. /**
  4812. * Computes a reflection matrix from a plane
  4813. * @param plane defines the reflection plane
  4814. * @returns a new matrix
  4815. */
  4816. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4817. /**
  4818. * Computes a reflection matrix from a plane
  4819. * @param plane defines the reflection plane
  4820. * @param result defines the target matrix
  4821. */
  4822. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4823. /**
  4824. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4825. * @param xaxis defines the value of the 1st axis
  4826. * @param yaxis defines the value of the 2nd axis
  4827. * @param zaxis defines the value of the 3rd axis
  4828. * @param result defines the target matrix
  4829. */
  4830. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4831. /**
  4832. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4833. * @param quat defines the quaternion to use
  4834. * @param result defines the target matrix
  4835. */
  4836. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4837. }
  4838. /**
  4839. * @hidden
  4840. */
  4841. export class TmpVectors {
  4842. static Vector2: Vector2[];
  4843. static Vector3: Vector3[];
  4844. static Vector4: Vector4[];
  4845. static Quaternion: Quaternion[];
  4846. static Matrix: Matrix[];
  4847. }
  4848. }
  4849. declare module BABYLON {
  4850. /**
  4851. * Defines potential orientation for back face culling
  4852. */
  4853. export enum Orientation {
  4854. /**
  4855. * Clockwise
  4856. */
  4857. CW = 0,
  4858. /** Counter clockwise */
  4859. CCW = 1
  4860. }
  4861. /** Class used to represent a Bezier curve */
  4862. export class BezierCurve {
  4863. /**
  4864. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4865. * @param t defines the time
  4866. * @param x1 defines the left coordinate on X axis
  4867. * @param y1 defines the left coordinate on Y axis
  4868. * @param x2 defines the right coordinate on X axis
  4869. * @param y2 defines the right coordinate on Y axis
  4870. * @returns the interpolated value
  4871. */
  4872. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4873. }
  4874. /**
  4875. * Defines angle representation
  4876. */
  4877. export class Angle {
  4878. private _radians;
  4879. /**
  4880. * Creates an Angle object of "radians" radians (float).
  4881. * @param radians the angle in radians
  4882. */
  4883. constructor(radians: number);
  4884. /**
  4885. * Get value in degrees
  4886. * @returns the Angle value in degrees (float)
  4887. */
  4888. degrees(): number;
  4889. /**
  4890. * Get value in radians
  4891. * @returns the Angle value in radians (float)
  4892. */
  4893. radians(): number;
  4894. /**
  4895. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4896. * @param a defines first point as the origin
  4897. * @param b defines point
  4898. * @returns a new Angle
  4899. */
  4900. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4901. /**
  4902. * Gets a new Angle object from the given float in radians
  4903. * @param radians defines the angle value in radians
  4904. * @returns a new Angle
  4905. */
  4906. static FromRadians(radians: number): Angle;
  4907. /**
  4908. * Gets a new Angle object from the given float in degrees
  4909. * @param degrees defines the angle value in degrees
  4910. * @returns a new Angle
  4911. */
  4912. static FromDegrees(degrees: number): Angle;
  4913. }
  4914. /**
  4915. * This represents an arc in a 2d space.
  4916. */
  4917. export class Arc2 {
  4918. /** Defines the start point of the arc */
  4919. startPoint: Vector2;
  4920. /** Defines the mid point of the arc */
  4921. midPoint: Vector2;
  4922. /** Defines the end point of the arc */
  4923. endPoint: Vector2;
  4924. /**
  4925. * Defines the center point of the arc.
  4926. */
  4927. centerPoint: Vector2;
  4928. /**
  4929. * Defines the radius of the arc.
  4930. */
  4931. radius: number;
  4932. /**
  4933. * Defines the angle of the arc (from mid point to end point).
  4934. */
  4935. angle: Angle;
  4936. /**
  4937. * Defines the start angle of the arc (from start point to middle point).
  4938. */
  4939. startAngle: Angle;
  4940. /**
  4941. * Defines the orientation of the arc (clock wise/counter clock wise).
  4942. */
  4943. orientation: Orientation;
  4944. /**
  4945. * Creates an Arc object from the three given points : start, middle and end.
  4946. * @param startPoint Defines the start point of the arc
  4947. * @param midPoint Defines the midlle point of the arc
  4948. * @param endPoint Defines the end point of the arc
  4949. */
  4950. constructor(
  4951. /** Defines the start point of the arc */
  4952. startPoint: Vector2,
  4953. /** Defines the mid point of the arc */
  4954. midPoint: Vector2,
  4955. /** Defines the end point of the arc */
  4956. endPoint: Vector2);
  4957. }
  4958. /**
  4959. * Represents a 2D path made up of multiple 2D points
  4960. */
  4961. export class Path2 {
  4962. private _points;
  4963. private _length;
  4964. /**
  4965. * If the path start and end point are the same
  4966. */
  4967. closed: boolean;
  4968. /**
  4969. * Creates a Path2 object from the starting 2D coordinates x and y.
  4970. * @param x the starting points x value
  4971. * @param y the starting points y value
  4972. */
  4973. constructor(x: number, y: number);
  4974. /**
  4975. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4976. * @param x the added points x value
  4977. * @param y the added points y value
  4978. * @returns the updated Path2.
  4979. */
  4980. addLineTo(x: number, y: number): Path2;
  4981. /**
  4982. * 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.
  4983. * @param midX middle point x value
  4984. * @param midY middle point y value
  4985. * @param endX end point x value
  4986. * @param endY end point y value
  4987. * @param numberOfSegments (default: 36)
  4988. * @returns the updated Path2.
  4989. */
  4990. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4991. /**
  4992. * Closes the Path2.
  4993. * @returns the Path2.
  4994. */
  4995. close(): Path2;
  4996. /**
  4997. * Gets the sum of the distance between each sequential point in the path
  4998. * @returns the Path2 total length (float).
  4999. */
  5000. length(): number;
  5001. /**
  5002. * Gets the points which construct the path
  5003. * @returns the Path2 internal array of points.
  5004. */
  5005. getPoints(): Vector2[];
  5006. /**
  5007. * Retreives the point at the distance aways from the starting point
  5008. * @param normalizedLengthPosition the length along the path to retreive the point from
  5009. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5010. */
  5011. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5012. /**
  5013. * Creates a new path starting from an x and y position
  5014. * @param x starting x value
  5015. * @param y starting y value
  5016. * @returns a new Path2 starting at the coordinates (x, y).
  5017. */
  5018. static StartingAt(x: number, y: number): Path2;
  5019. }
  5020. /**
  5021. * Represents a 3D path made up of multiple 3D points
  5022. */
  5023. export class Path3D {
  5024. /**
  5025. * an array of Vector3, the curve axis of the Path3D
  5026. */
  5027. path: Vector3[];
  5028. private _curve;
  5029. private _distances;
  5030. private _tangents;
  5031. private _normals;
  5032. private _binormals;
  5033. private _raw;
  5034. private _alignTangentsWithPath;
  5035. private readonly _pointAtData;
  5036. /**
  5037. * new Path3D(path, normal, raw)
  5038. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5039. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5040. * @param path an array of Vector3, the curve axis of the Path3D
  5041. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5042. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5043. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5044. */
  5045. constructor(
  5046. /**
  5047. * an array of Vector3, the curve axis of the Path3D
  5048. */
  5049. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5050. /**
  5051. * Returns the Path3D array of successive Vector3 designing its curve.
  5052. * @returns the Path3D array of successive Vector3 designing its curve.
  5053. */
  5054. getCurve(): Vector3[];
  5055. /**
  5056. * Returns the Path3D array of successive Vector3 designing its curve.
  5057. * @returns the Path3D array of successive Vector3 designing its curve.
  5058. */
  5059. getPoints(): Vector3[];
  5060. /**
  5061. * @returns the computed length (float) of the path.
  5062. */
  5063. length(): number;
  5064. /**
  5065. * Returns an array populated with tangent vectors on each Path3D curve point.
  5066. * @returns an array populated with tangent vectors on each Path3D curve point.
  5067. */
  5068. getTangents(): Vector3[];
  5069. /**
  5070. * Returns an array populated with normal vectors on each Path3D curve point.
  5071. * @returns an array populated with normal vectors on each Path3D curve point.
  5072. */
  5073. getNormals(): Vector3[];
  5074. /**
  5075. * Returns an array populated with binormal vectors on each Path3D curve point.
  5076. * @returns an array populated with binormal vectors on each Path3D curve point.
  5077. */
  5078. getBinormals(): Vector3[];
  5079. /**
  5080. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5081. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5082. */
  5083. getDistances(): number[];
  5084. /**
  5085. * Returns an interpolated point along this path
  5086. * @param position the position of the point along this path, from 0.0 to 1.0
  5087. * @returns a new Vector3 as the point
  5088. */
  5089. getPointAt(position: number): Vector3;
  5090. /**
  5091. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5092. * @param position the position of the point along this path, from 0.0 to 1.0
  5093. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5094. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5095. */
  5096. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5097. /**
  5098. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5099. * @param position the position of the point along this path, from 0.0 to 1.0
  5100. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5101. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5102. */
  5103. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5104. /**
  5105. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5108. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5109. */
  5110. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5111. /**
  5112. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5113. * @param position the position of the point along this path, from 0.0 to 1.0
  5114. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5115. */
  5116. getDistanceAt(position: number): number;
  5117. /**
  5118. * Returns the array index of the previous point of an interpolated point along this path
  5119. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5120. * @returns the array index
  5121. */
  5122. getPreviousPointIndexAt(position: number): number;
  5123. /**
  5124. * 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)
  5125. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5126. * @returns the sub position
  5127. */
  5128. getSubPositionAt(position: number): number;
  5129. /**
  5130. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5131. * @param target the vector of which to get the closest position to
  5132. * @returns the position of the closest virtual point on this path to the target vector
  5133. */
  5134. getClosestPositionTo(target: Vector3): number;
  5135. /**
  5136. * Returns a sub path (slice) of this path
  5137. * @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
  5138. * @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
  5139. * @returns a sub path (slice) of this path
  5140. */
  5141. slice(start?: number, end?: number): Path3D;
  5142. /**
  5143. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5144. * @param path path which all values are copied into the curves points
  5145. * @param firstNormal which should be projected onto the curve
  5146. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5147. * @returns the same object updated.
  5148. */
  5149. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5150. private _compute;
  5151. private _getFirstNonNullVector;
  5152. private _getLastNonNullVector;
  5153. private _normalVector;
  5154. /**
  5155. * Updates the point at data for an interpolated point along this curve
  5156. * @param position the position of the point along this curve, from 0.0 to 1.0
  5157. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5158. * @returns the (updated) point at data
  5159. */
  5160. private _updatePointAtData;
  5161. /**
  5162. * Updates the point at data from the specified parameters
  5163. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5164. * @param point the interpolated point
  5165. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5166. */
  5167. private _setPointAtData;
  5168. /**
  5169. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5170. */
  5171. private _updateInterpolationMatrix;
  5172. }
  5173. /**
  5174. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5175. * A Curve3 is designed from a series of successive Vector3.
  5176. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5177. */
  5178. export class Curve3 {
  5179. private _points;
  5180. private _length;
  5181. /**
  5182. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5183. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5184. * @param v1 (Vector3) the control point
  5185. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5186. * @param nbPoints (integer) the wanted number of points in the curve
  5187. * @returns the created Curve3
  5188. */
  5189. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5190. /**
  5191. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5192. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5193. * @param v1 (Vector3) the first control point
  5194. * @param v2 (Vector3) the second control point
  5195. * @param v3 (Vector3) the end point of the Cubic Bezier
  5196. * @param nbPoints (integer) the wanted number of points in the curve
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5200. /**
  5201. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5202. * @param p1 (Vector3) the origin point of the Hermite Spline
  5203. * @param t1 (Vector3) the tangent vector at the origin point
  5204. * @param p2 (Vector3) the end point of the Hermite Spline
  5205. * @param t2 (Vector3) the tangent vector at the end point
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a CatmullRom Spline curve :
  5212. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5213. * @param nbPoints (integer) the wanted number of points between each curve control points
  5214. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5215. * @returns the created Curve3
  5216. */
  5217. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5218. /**
  5219. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5220. * A Curve3 is designed from a series of successive Vector3.
  5221. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5222. * @param points points which make up the curve
  5223. */
  5224. constructor(points: Vector3[]);
  5225. /**
  5226. * @returns the Curve3 stored array of successive Vector3
  5227. */
  5228. getPoints(): Vector3[];
  5229. /**
  5230. * @returns the computed length (float) of the curve.
  5231. */
  5232. length(): number;
  5233. /**
  5234. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5235. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5236. * curveA and curveB keep unchanged.
  5237. * @param curve the curve to continue from this curve
  5238. * @returns the newly constructed curve
  5239. */
  5240. continue(curve: DeepImmutable<Curve3>): Curve3;
  5241. private _computeLength;
  5242. }
  5243. }
  5244. declare module BABYLON {
  5245. /**
  5246. * This represents the main contract an easing function should follow.
  5247. * Easing functions are used throughout the animation system.
  5248. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export interface IEasingFunction {
  5251. /**
  5252. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5253. * of the easing function.
  5254. * The link below provides some of the most common examples of easing functions.
  5255. * @see https://easings.net/
  5256. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5257. * @returns the corresponding value on the curve defined by the easing function
  5258. */
  5259. ease(gradient: number): number;
  5260. }
  5261. /**
  5262. * Base class used for every default easing function.
  5263. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5264. */
  5265. export class EasingFunction implements IEasingFunction {
  5266. /**
  5267. * Interpolation follows the mathematical formula associated with the easing function.
  5268. */
  5269. static readonly EASINGMODE_EASEIN: number;
  5270. /**
  5271. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5272. */
  5273. static readonly EASINGMODE_EASEOUT: number;
  5274. /**
  5275. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5276. */
  5277. static readonly EASINGMODE_EASEINOUT: number;
  5278. private _easingMode;
  5279. /**
  5280. * Sets the easing mode of the current function.
  5281. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5282. */
  5283. setEasingMode(easingMode: number): void;
  5284. /**
  5285. * Gets the current easing mode.
  5286. * @returns the easing mode
  5287. */
  5288. getEasingMode(): number;
  5289. /**
  5290. * @hidden
  5291. */
  5292. easeInCore(gradient: number): number;
  5293. /**
  5294. * Given an input gradient between 0 and 1, this returns the corresponding value
  5295. * of the easing function.
  5296. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5297. * @returns the corresponding value on the curve defined by the easing function
  5298. */
  5299. ease(gradient: number): number;
  5300. }
  5301. /**
  5302. * Easing function with a circle shape (see link below).
  5303. * @see https://easings.net/#easeInCirc
  5304. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5305. */
  5306. export class CircleEase extends EasingFunction implements IEasingFunction {
  5307. /** @hidden */
  5308. easeInCore(gradient: number): number;
  5309. }
  5310. /**
  5311. * Easing function with a ease back shape (see link below).
  5312. * @see https://easings.net/#easeInBack
  5313. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5314. */
  5315. export class BackEase extends EasingFunction implements IEasingFunction {
  5316. /** Defines the amplitude of the function */
  5317. amplitude: number;
  5318. /**
  5319. * Instantiates a back ease easing
  5320. * @see https://easings.net/#easeInBack
  5321. * @param amplitude Defines the amplitude of the function
  5322. */
  5323. constructor(
  5324. /** Defines the amplitude of the function */
  5325. amplitude?: number);
  5326. /** @hidden */
  5327. easeInCore(gradient: number): number;
  5328. }
  5329. /**
  5330. * Easing function with a bouncing shape (see link below).
  5331. * @see https://easings.net/#easeInBounce
  5332. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5333. */
  5334. export class BounceEase extends EasingFunction implements IEasingFunction {
  5335. /** Defines the number of bounces */
  5336. bounces: number;
  5337. /** Defines the amplitude of the bounce */
  5338. bounciness: number;
  5339. /**
  5340. * Instantiates a bounce easing
  5341. * @see https://easings.net/#easeInBounce
  5342. * @param bounces Defines the number of bounces
  5343. * @param bounciness Defines the amplitude of the bounce
  5344. */
  5345. constructor(
  5346. /** Defines the number of bounces */
  5347. bounces?: number,
  5348. /** Defines the amplitude of the bounce */
  5349. bounciness?: number);
  5350. /** @hidden */
  5351. easeInCore(gradient: number): number;
  5352. }
  5353. /**
  5354. * Easing function with a power of 3 shape (see link below).
  5355. * @see https://easings.net/#easeInCubic
  5356. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5357. */
  5358. export class CubicEase extends EasingFunction implements IEasingFunction {
  5359. /** @hidden */
  5360. easeInCore(gradient: number): number;
  5361. }
  5362. /**
  5363. * Easing function with an elastic shape (see link below).
  5364. * @see https://easings.net/#easeInElastic
  5365. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5366. */
  5367. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5368. /** Defines the number of oscillations*/
  5369. oscillations: number;
  5370. /** Defines the amplitude of the oscillations*/
  5371. springiness: number;
  5372. /**
  5373. * Instantiates an elastic easing function
  5374. * @see https://easings.net/#easeInElastic
  5375. * @param oscillations Defines the number of oscillations
  5376. * @param springiness Defines the amplitude of the oscillations
  5377. */
  5378. constructor(
  5379. /** Defines the number of oscillations*/
  5380. oscillations?: number,
  5381. /** Defines the amplitude of the oscillations*/
  5382. springiness?: number);
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with an exponential shape (see link below).
  5388. * @see https://easings.net/#easeInExpo
  5389. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the exponent of the function */
  5393. exponent: number;
  5394. /**
  5395. * Instantiates an exponential easing function
  5396. * @see https://easings.net/#easeInExpo
  5397. * @param exponent Defines the exponent of the function
  5398. */
  5399. constructor(
  5400. /** Defines the exponent of the function */
  5401. exponent?: number);
  5402. /** @hidden */
  5403. easeInCore(gradient: number): number;
  5404. }
  5405. /**
  5406. * Easing function with a power shape (see link below).
  5407. * @see https://easings.net/#easeInQuad
  5408. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5409. */
  5410. export class PowerEase extends EasingFunction implements IEasingFunction {
  5411. /** Defines the power of the function */
  5412. power: number;
  5413. /**
  5414. * Instantiates an power base easing function
  5415. * @see https://easings.net/#easeInQuad
  5416. * @param power Defines the power of the function
  5417. */
  5418. constructor(
  5419. /** Defines the power of the function */
  5420. power?: number);
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 2 shape (see link below).
  5426. * @see https://easings.net/#easeInQuad
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a power of 4 shape (see link below).
  5435. * @see https://easings.net/#easeInQuart
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a power of 5 shape (see link below).
  5444. * @see https://easings.net/#easeInQuint
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5448. /** @hidden */
  5449. easeInCore(gradient: number): number;
  5450. }
  5451. /**
  5452. * Easing function with a sin shape (see link below).
  5453. * @see https://easings.net/#easeInSine
  5454. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5455. */
  5456. export class SineEase extends EasingFunction implements IEasingFunction {
  5457. /** @hidden */
  5458. easeInCore(gradient: number): number;
  5459. }
  5460. /**
  5461. * Easing function with a bezier shape (see link below).
  5462. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5463. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5464. */
  5465. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5466. /** Defines the x component of the start tangent in the bezier curve */
  5467. x1: number;
  5468. /** Defines the y component of the start tangent in the bezier curve */
  5469. y1: number;
  5470. /** Defines the x component of the end tangent in the bezier curve */
  5471. x2: number;
  5472. /** Defines the y component of the end tangent in the bezier curve */
  5473. y2: number;
  5474. /**
  5475. * Instantiates a bezier function
  5476. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5477. * @param x1 Defines the x component of the start tangent in the bezier curve
  5478. * @param y1 Defines the y component of the start tangent in the bezier curve
  5479. * @param x2 Defines the x component of the end tangent in the bezier curve
  5480. * @param y2 Defines the y component of the end tangent in the bezier curve
  5481. */
  5482. constructor(
  5483. /** Defines the x component of the start tangent in the bezier curve */
  5484. x1?: number,
  5485. /** Defines the y component of the start tangent in the bezier curve */
  5486. y1?: number,
  5487. /** Defines the x component of the end tangent in the bezier curve */
  5488. x2?: number,
  5489. /** Defines the y component of the end tangent in the bezier curve */
  5490. y2?: number);
  5491. /** @hidden */
  5492. easeInCore(gradient: number): number;
  5493. }
  5494. }
  5495. declare module BABYLON {
  5496. /**
  5497. * Class used to hold a RBG color
  5498. */
  5499. export class Color3 {
  5500. /**
  5501. * Defines the red component (between 0 and 1, default is 0)
  5502. */
  5503. r: number;
  5504. /**
  5505. * Defines the green component (between 0 and 1, default is 0)
  5506. */
  5507. g: number;
  5508. /**
  5509. * Defines the blue component (between 0 and 1, default is 0)
  5510. */
  5511. b: number;
  5512. /**
  5513. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5514. * @param r defines the red component (between 0 and 1, default is 0)
  5515. * @param g defines the green component (between 0 and 1, default is 0)
  5516. * @param b defines the blue component (between 0 and 1, default is 0)
  5517. */
  5518. constructor(
  5519. /**
  5520. * Defines the red component (between 0 and 1, default is 0)
  5521. */
  5522. r?: number,
  5523. /**
  5524. * Defines the green component (between 0 and 1, default is 0)
  5525. */
  5526. g?: number,
  5527. /**
  5528. * Defines the blue component (between 0 and 1, default is 0)
  5529. */
  5530. b?: number);
  5531. /**
  5532. * Creates a string with the Color3 current values
  5533. * @returns the string representation of the Color3 object
  5534. */
  5535. toString(): string;
  5536. /**
  5537. * Returns the string "Color3"
  5538. * @returns "Color3"
  5539. */
  5540. getClassName(): string;
  5541. /**
  5542. * Compute the Color3 hash code
  5543. * @returns an unique number that can be used to hash Color3 objects
  5544. */
  5545. getHashCode(): number;
  5546. /**
  5547. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5548. * @param array defines the array where to store the r,g,b components
  5549. * @param index defines an optional index in the target array to define where to start storing values
  5550. * @returns the current Color3 object
  5551. */
  5552. toArray(array: FloatArray, index?: number): Color3;
  5553. /**
  5554. * Update the current color with values stored in an array from the starting index of the given array
  5555. * @param array defines the source array
  5556. * @param offset defines an offset in the source array
  5557. * @returns the current Color3 object
  5558. */
  5559. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5560. /**
  5561. * Returns a new Color4 object from the current Color3 and the given alpha
  5562. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5563. * @returns a new Color4 object
  5564. */
  5565. toColor4(alpha?: number): Color4;
  5566. /**
  5567. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5568. * @returns the new array
  5569. */
  5570. asArray(): number[];
  5571. /**
  5572. * Returns the luminance value
  5573. * @returns a float value
  5574. */
  5575. toLuminance(): number;
  5576. /**
  5577. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5578. * @param otherColor defines the second operand
  5579. * @returns the new Color3 object
  5580. */
  5581. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5582. /**
  5583. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5584. * @param otherColor defines the second operand
  5585. * @param result defines the Color3 object where to store the result
  5586. * @returns the current Color3
  5587. */
  5588. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5589. /**
  5590. * Determines equality between Color3 objects
  5591. * @param otherColor defines the second operand
  5592. * @returns true if the rgb values are equal to the given ones
  5593. */
  5594. equals(otherColor: DeepImmutable<Color3>): boolean;
  5595. /**
  5596. * Determines equality between the current Color3 object and a set of r,b,g values
  5597. * @param r defines the red component to check
  5598. * @param g defines the green component to check
  5599. * @param b defines the blue component to check
  5600. * @returns true if the rgb values are equal to the given ones
  5601. */
  5602. equalsFloats(r: number, g: number, b: number): boolean;
  5603. /**
  5604. * Multiplies in place each rgb value by scale
  5605. * @param scale defines the scaling factor
  5606. * @returns the updated Color3
  5607. */
  5608. scale(scale: number): Color3;
  5609. /**
  5610. * Multiplies the rgb values by scale and stores the result into "result"
  5611. * @param scale defines the scaling factor
  5612. * @param result defines the Color3 object where to store the result
  5613. * @returns the unmodified current Color3
  5614. */
  5615. scaleToRef(scale: number, result: Color3): Color3;
  5616. /**
  5617. * Scale the current Color3 values by a factor and add the result to a given Color3
  5618. * @param scale defines the scale factor
  5619. * @param result defines color to store the result into
  5620. * @returns the unmodified current Color3
  5621. */
  5622. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5623. /**
  5624. * Clamps the rgb values by the min and max values and stores the result into "result"
  5625. * @param min defines minimum clamping value (default is 0)
  5626. * @param max defines maximum clamping value (default is 1)
  5627. * @param result defines color to store the result into
  5628. * @returns the original Color3
  5629. */
  5630. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5631. /**
  5632. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5633. * @param otherColor defines the second operand
  5634. * @returns the new Color3
  5635. */
  5636. add(otherColor: DeepImmutable<Color3>): Color3;
  5637. /**
  5638. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5639. * @param otherColor defines the second operand
  5640. * @param result defines Color3 object to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5644. /**
  5645. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5646. * @param otherColor defines the second operand
  5647. * @returns the new Color3
  5648. */
  5649. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5652. * @param otherColor defines the second operand
  5653. * @param result defines Color3 object to store the result into
  5654. * @returns the unmodified current Color3
  5655. */
  5656. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5657. /**
  5658. * Copy the current object
  5659. * @returns a new Color3 copied the current one
  5660. */
  5661. clone(): Color3;
  5662. /**
  5663. * Copies the rgb values from the source in the current Color3
  5664. * @param source defines the source Color3 object
  5665. * @returns the updated Color3 object
  5666. */
  5667. copyFrom(source: DeepImmutable<Color3>): Color3;
  5668. /**
  5669. * Updates the Color3 rgb values from the given floats
  5670. * @param r defines the red component to read from
  5671. * @param g defines the green component to read from
  5672. * @param b defines the blue component to read from
  5673. * @returns the current Color3 object
  5674. */
  5675. copyFromFloats(r: number, g: number, b: number): Color3;
  5676. /**
  5677. * Updates the Color3 rgb values from the given floats
  5678. * @param r defines the red component to read from
  5679. * @param g defines the green component to read from
  5680. * @param b defines the blue component to read from
  5681. * @returns the current Color3 object
  5682. */
  5683. set(r: number, g: number, b: number): Color3;
  5684. /**
  5685. * Compute the Color3 hexadecimal code as a string
  5686. * @returns a string containing the hexadecimal representation of the Color3 object
  5687. */
  5688. toHexString(): string;
  5689. /**
  5690. * Computes a new Color3 converted from the current one to linear space
  5691. * @returns a new Color3 object
  5692. */
  5693. toLinearSpace(): Color3;
  5694. /**
  5695. * Converts current color in rgb space to HSV values
  5696. * @returns a new color3 representing the HSV values
  5697. */
  5698. toHSV(): Color3;
  5699. /**
  5700. * Converts current color in rgb space to HSV values
  5701. * @param result defines the Color3 where to store the HSV values
  5702. */
  5703. toHSVToRef(result: Color3): void;
  5704. /**
  5705. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5706. * @param convertedColor defines the Color3 object where to store the linear space version
  5707. * @returns the unmodified Color3
  5708. */
  5709. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to gamma space
  5712. * @returns a new Color3 object
  5713. */
  5714. toGammaSpace(): Color3;
  5715. /**
  5716. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5717. * @param convertedColor defines the Color3 object where to store the gamma space version
  5718. * @returns the unmodified Color3
  5719. */
  5720. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5721. private static _BlackReadOnly;
  5722. /**
  5723. * Convert Hue, saturation and value to a Color3 (RGB)
  5724. * @param hue defines the hue
  5725. * @param saturation defines the saturation
  5726. * @param value defines the value
  5727. * @param result defines the Color3 where to store the RGB values
  5728. */
  5729. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5730. /**
  5731. * Creates a new Color3 from the string containing valid hexadecimal values
  5732. * @param hex defines a string containing valid hexadecimal values
  5733. * @returns a new Color3 object
  5734. */
  5735. static FromHexString(hex: string): Color3;
  5736. /**
  5737. * Creates a new Color3 from the starting index of the given array
  5738. * @param array defines the source array
  5739. * @param offset defines an offset in the source array
  5740. * @returns a new Color3 object
  5741. */
  5742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5743. /**
  5744. * Creates a new Color3 from the starting index element of the given array
  5745. * @param array defines the source array to read from
  5746. * @param offset defines the offset in the source array
  5747. * @param result defines the target Color3 object
  5748. */
  5749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5750. /**
  5751. * Creates a new Color3 from integer values (< 256)
  5752. * @param r defines the red component to read from (value between 0 and 255)
  5753. * @param g defines the green component to read from (value between 0 and 255)
  5754. * @param b defines the blue component to read from (value between 0 and 255)
  5755. * @returns a new Color3 object
  5756. */
  5757. static FromInts(r: number, g: number, b: number): Color3;
  5758. /**
  5759. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5760. * @param start defines the start Color3 value
  5761. * @param end defines the end Color3 value
  5762. * @param amount defines the gradient value between start and end
  5763. * @returns a new Color3 object
  5764. */
  5765. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5766. /**
  5767. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5768. * @param left defines the start value
  5769. * @param right defines the end value
  5770. * @param amount defines the gradient factor
  5771. * @param result defines the Color3 object where to store the result
  5772. */
  5773. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5774. /**
  5775. * Returns a Color3 value containing a red color
  5776. * @returns a new Color3 object
  5777. */
  5778. static Red(): Color3;
  5779. /**
  5780. * Returns a Color3 value containing a green color
  5781. * @returns a new Color3 object
  5782. */
  5783. static Green(): Color3;
  5784. /**
  5785. * Returns a Color3 value containing a blue color
  5786. * @returns a new Color3 object
  5787. */
  5788. static Blue(): Color3;
  5789. /**
  5790. * Returns a Color3 value containing a black color
  5791. * @returns a new Color3 object
  5792. */
  5793. static Black(): Color3;
  5794. /**
  5795. * Gets a Color3 value containing a black color that must not be updated
  5796. */
  5797. static get BlackReadOnly(): DeepImmutable<Color3>;
  5798. /**
  5799. * Returns a Color3 value containing a white color
  5800. * @returns a new Color3 object
  5801. */
  5802. static White(): Color3;
  5803. /**
  5804. * Returns a Color3 value containing a purple color
  5805. * @returns a new Color3 object
  5806. */
  5807. static Purple(): Color3;
  5808. /**
  5809. * Returns a Color3 value containing a magenta color
  5810. * @returns a new Color3 object
  5811. */
  5812. static Magenta(): Color3;
  5813. /**
  5814. * Returns a Color3 value containing a yellow color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Yellow(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a gray color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Gray(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a teal color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Teal(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a random color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Random(): Color3;
  5833. }
  5834. /**
  5835. * Class used to hold a RBGA color
  5836. */
  5837. export class Color4 {
  5838. /**
  5839. * Defines the red component (between 0 and 1, default is 0)
  5840. */
  5841. r: number;
  5842. /**
  5843. * Defines the green component (between 0 and 1, default is 0)
  5844. */
  5845. g: number;
  5846. /**
  5847. * Defines the blue component (between 0 and 1, default is 0)
  5848. */
  5849. b: number;
  5850. /**
  5851. * Defines the alpha component (between 0 and 1, default is 1)
  5852. */
  5853. a: number;
  5854. /**
  5855. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5856. * @param r defines the red component (between 0 and 1, default is 0)
  5857. * @param g defines the green component (between 0 and 1, default is 0)
  5858. * @param b defines the blue component (between 0 and 1, default is 0)
  5859. * @param a defines the alpha component (between 0 and 1, default is 1)
  5860. */
  5861. constructor(
  5862. /**
  5863. * Defines the red component (between 0 and 1, default is 0)
  5864. */
  5865. r?: number,
  5866. /**
  5867. * Defines the green component (between 0 and 1, default is 0)
  5868. */
  5869. g?: number,
  5870. /**
  5871. * Defines the blue component (between 0 and 1, default is 0)
  5872. */
  5873. b?: number,
  5874. /**
  5875. * Defines the alpha component (between 0 and 1, default is 1)
  5876. */
  5877. a?: number);
  5878. /**
  5879. * Adds in place the given Color4 values to the current Color4 object
  5880. * @param right defines the second operand
  5881. * @returns the current updated Color4 object
  5882. */
  5883. addInPlace(right: DeepImmutable<Color4>): Color4;
  5884. /**
  5885. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5886. * @returns the new array
  5887. */
  5888. asArray(): number[];
  5889. /**
  5890. * Stores from the starting index in the given array the Color4 successive values
  5891. * @param array defines the array where to store the r,g,b components
  5892. * @param index defines an optional index in the target array to define where to start storing values
  5893. * @returns the current Color4 object
  5894. */
  5895. toArray(array: number[], index?: number): Color4;
  5896. /**
  5897. * Update the current color with values stored in an array from the starting index of the given array
  5898. * @param array defines the source array
  5899. * @param offset defines an offset in the source array
  5900. * @returns the current Color4 object
  5901. */
  5902. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5903. /**
  5904. * Determines equality between Color4 objects
  5905. * @param otherColor defines the second operand
  5906. * @returns true if the rgba values are equal to the given ones
  5907. */
  5908. equals(otherColor: DeepImmutable<Color4>): boolean;
  5909. /**
  5910. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5911. * @param right defines the second operand
  5912. * @returns a new Color4 object
  5913. */
  5914. add(right: DeepImmutable<Color4>): Color4;
  5915. /**
  5916. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5917. * @param right defines the second operand
  5918. * @returns a new Color4 object
  5919. */
  5920. subtract(right: DeepImmutable<Color4>): Color4;
  5921. /**
  5922. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5923. * @param right defines the second operand
  5924. * @param result defines the Color4 object where to store the result
  5925. * @returns the current Color4 object
  5926. */
  5927. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5928. /**
  5929. * Creates a new Color4 with the current Color4 values multiplied by scale
  5930. * @param scale defines the scaling factor to apply
  5931. * @returns a new Color4 object
  5932. */
  5933. scale(scale: number): Color4;
  5934. /**
  5935. * Multiplies the current Color4 values by scale and stores the result in "result"
  5936. * @param scale defines the scaling factor to apply
  5937. * @param result defines the Color4 object where to store the result
  5938. * @returns the current unmodified Color4
  5939. */
  5940. scaleToRef(scale: number, result: Color4): Color4;
  5941. /**
  5942. * Scale the current Color4 values by a factor and add the result to a given Color4
  5943. * @param scale defines the scale factor
  5944. * @param result defines the Color4 object where to store the result
  5945. * @returns the unmodified current Color4
  5946. */
  5947. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5948. /**
  5949. * Clamps the rgb values by the min and max values and stores the result into "result"
  5950. * @param min defines minimum clamping value (default is 0)
  5951. * @param max defines maximum clamping value (default is 1)
  5952. * @param result defines color to store the result into.
  5953. * @returns the cuurent Color4
  5954. */
  5955. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5956. /**
  5957. * Multipy an Color4 value by another and return a new Color4 object
  5958. * @param color defines the Color4 value to multiply by
  5959. * @returns a new Color4 object
  5960. */
  5961. multiply(color: Color4): Color4;
  5962. /**
  5963. * Multipy a Color4 value by another and push the result in a reference value
  5964. * @param color defines the Color4 value to multiply by
  5965. * @param result defines the Color4 to fill the result in
  5966. * @returns the result Color4
  5967. */
  5968. multiplyToRef(color: Color4, result: Color4): Color4;
  5969. /**
  5970. * Creates a string with the Color4 current values
  5971. * @returns the string representation of the Color4 object
  5972. */
  5973. toString(): string;
  5974. /**
  5975. * Returns the string "Color4"
  5976. * @returns "Color4"
  5977. */
  5978. getClassName(): string;
  5979. /**
  5980. * Compute the Color4 hash code
  5981. * @returns an unique number that can be used to hash Color4 objects
  5982. */
  5983. getHashCode(): number;
  5984. /**
  5985. * Creates a new Color4 copied from the current one
  5986. * @returns a new Color4 object
  5987. */
  5988. clone(): Color4;
  5989. /**
  5990. * Copies the given Color4 values into the current one
  5991. * @param source defines the source Color4 object
  5992. * @returns the current updated Color4 object
  5993. */
  5994. copyFrom(source: Color4): Color4;
  5995. /**
  5996. * Copies the given float values into the current one
  5997. * @param r defines the red component to read from
  5998. * @param g defines the green component to read from
  5999. * @param b defines the blue component to read from
  6000. * @param a defines the alpha component to read from
  6001. * @returns the current updated Color4 object
  6002. */
  6003. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6004. /**
  6005. * Copies the given float values into the current one
  6006. * @param r defines the red component to read from
  6007. * @param g defines the green component to read from
  6008. * @param b defines the blue component to read from
  6009. * @param a defines the alpha component to read from
  6010. * @returns the current updated Color4 object
  6011. */
  6012. set(r: number, g: number, b: number, a: number): Color4;
  6013. /**
  6014. * Compute the Color4 hexadecimal code as a string
  6015. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6016. * @returns a string containing the hexadecimal representation of the Color4 object
  6017. */
  6018. toHexString(returnAsColor3?: boolean): string;
  6019. /**
  6020. * Computes a new Color4 converted from the current one to linear space
  6021. * @returns a new Color4 object
  6022. */
  6023. toLinearSpace(): Color4;
  6024. /**
  6025. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6026. * @param convertedColor defines the Color4 object where to store the linear space version
  6027. * @returns the unmodified Color4
  6028. */
  6029. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6030. /**
  6031. * Computes a new Color4 converted from the current one to gamma space
  6032. * @returns a new Color4 object
  6033. */
  6034. toGammaSpace(): Color4;
  6035. /**
  6036. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6037. * @param convertedColor defines the Color4 object where to store the gamma space version
  6038. * @returns the unmodified Color4
  6039. */
  6040. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6041. /**
  6042. * Creates a new Color4 from the string containing valid hexadecimal values
  6043. * @param hex defines a string containing valid hexadecimal values
  6044. * @returns a new Color4 object
  6045. */
  6046. static FromHexString(hex: string): Color4;
  6047. /**
  6048. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6049. * @param left defines the start value
  6050. * @param right defines the end value
  6051. * @param amount defines the gradient factor
  6052. * @returns a new Color4 object
  6053. */
  6054. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6055. /**
  6056. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6057. * @param left defines the start value
  6058. * @param right defines the end value
  6059. * @param amount defines the gradient factor
  6060. * @param result defines the Color4 object where to store data
  6061. */
  6062. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6063. /**
  6064. * Creates a new Color4 from a Color3 and an alpha value
  6065. * @param color3 defines the source Color3 to read from
  6066. * @param alpha defines the alpha component (1.0 by default)
  6067. * @returns a new Color4 object
  6068. */
  6069. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6070. /**
  6071. * Creates a new Color4 from the starting index element of the given array
  6072. * @param array defines the source array to read from
  6073. * @param offset defines the offset in the source array
  6074. * @returns a new Color4 object
  6075. */
  6076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6077. /**
  6078. * Creates a new Color4 from the starting index element of the given array
  6079. * @param array defines the source array to read from
  6080. * @param offset defines the offset in the source array
  6081. * @param result defines the target Color4 object
  6082. */
  6083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6084. /**
  6085. * Creates a new Color3 from integer values (< 256)
  6086. * @param r defines the red component to read from (value between 0 and 255)
  6087. * @param g defines the green component to read from (value between 0 and 255)
  6088. * @param b defines the blue component to read from (value between 0 and 255)
  6089. * @param a defines the alpha component to read from (value between 0 and 255)
  6090. * @returns a new Color3 object
  6091. */
  6092. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6093. /**
  6094. * Check the content of a given array and convert it to an array containing RGBA data
  6095. * If the original array was already containing count * 4 values then it is returned directly
  6096. * @param colors defines the array to check
  6097. * @param count defines the number of RGBA data to expect
  6098. * @returns an array containing count * 4 values (RGBA)
  6099. */
  6100. static CheckColors4(colors: number[], count: number): number[];
  6101. }
  6102. /**
  6103. * @hidden
  6104. */
  6105. export class TmpColors {
  6106. static Color3: Color3[];
  6107. static Color4: Color4[];
  6108. }
  6109. }
  6110. declare module BABYLON {
  6111. /**
  6112. * Defines an interface which represents an animation key frame
  6113. */
  6114. export interface IAnimationKey {
  6115. /**
  6116. * Frame of the key frame
  6117. */
  6118. frame: number;
  6119. /**
  6120. * Value at the specifies key frame
  6121. */
  6122. value: any;
  6123. /**
  6124. * The input tangent for the cubic hermite spline
  6125. */
  6126. inTangent?: any;
  6127. /**
  6128. * The output tangent for the cubic hermite spline
  6129. */
  6130. outTangent?: any;
  6131. /**
  6132. * The animation interpolation type
  6133. */
  6134. interpolation?: AnimationKeyInterpolation;
  6135. }
  6136. /**
  6137. * Enum for the animation key frame interpolation type
  6138. */
  6139. export enum AnimationKeyInterpolation {
  6140. /**
  6141. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6142. */
  6143. STEP = 1
  6144. }
  6145. }
  6146. declare module BABYLON {
  6147. /**
  6148. * Represents the range of an animation
  6149. */
  6150. export class AnimationRange {
  6151. /**The name of the animation range**/
  6152. name: string;
  6153. /**The starting frame of the animation */
  6154. from: number;
  6155. /**The ending frame of the animation*/
  6156. to: number;
  6157. /**
  6158. * Initializes the range of an animation
  6159. * @param name The name of the animation range
  6160. * @param from The starting frame of the animation
  6161. * @param to The ending frame of the animation
  6162. */
  6163. constructor(
  6164. /**The name of the animation range**/
  6165. name: string,
  6166. /**The starting frame of the animation */
  6167. from: number,
  6168. /**The ending frame of the animation*/
  6169. to: number);
  6170. /**
  6171. * Makes a copy of the animation range
  6172. * @returns A copy of the animation range
  6173. */
  6174. clone(): AnimationRange;
  6175. }
  6176. }
  6177. declare module BABYLON {
  6178. /**
  6179. * Composed of a frame, and an action function
  6180. */
  6181. export class AnimationEvent {
  6182. /** The frame for which the event is triggered **/
  6183. frame: number;
  6184. /** The event to perform when triggered **/
  6185. action: (currentFrame: number) => void;
  6186. /** Specifies if the event should be triggered only once**/
  6187. onlyOnce?: boolean | undefined;
  6188. /**
  6189. * Specifies if the animation event is done
  6190. */
  6191. isDone: boolean;
  6192. /**
  6193. * Initializes the animation event
  6194. * @param frame The frame for which the event is triggered
  6195. * @param action The event to perform when triggered
  6196. * @param onlyOnce Specifies if the event should be triggered only once
  6197. */
  6198. constructor(
  6199. /** The frame for which the event is triggered **/
  6200. frame: number,
  6201. /** The event to perform when triggered **/
  6202. action: (currentFrame: number) => void,
  6203. /** Specifies if the event should be triggered only once**/
  6204. onlyOnce?: boolean | undefined);
  6205. /** @hidden */
  6206. _clone(): AnimationEvent;
  6207. }
  6208. }
  6209. declare module BABYLON {
  6210. /**
  6211. * Interface used to define a behavior
  6212. */
  6213. export interface Behavior<T> {
  6214. /** gets or sets behavior's name */
  6215. name: string;
  6216. /**
  6217. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6218. */
  6219. init(): void;
  6220. /**
  6221. * Called when the behavior is attached to a target
  6222. * @param target defines the target where the behavior is attached to
  6223. */
  6224. attach(target: T): void;
  6225. /**
  6226. * Called when the behavior is detached from its target
  6227. */
  6228. detach(): void;
  6229. }
  6230. /**
  6231. * Interface implemented by classes supporting behaviors
  6232. */
  6233. export interface IBehaviorAware<T> {
  6234. /**
  6235. * Attach a behavior
  6236. * @param behavior defines the behavior to attach
  6237. * @returns the current host
  6238. */
  6239. addBehavior(behavior: Behavior<T>): T;
  6240. /**
  6241. * Remove a behavior from the current object
  6242. * @param behavior defines the behavior to detach
  6243. * @returns the current host
  6244. */
  6245. removeBehavior(behavior: Behavior<T>): T;
  6246. /**
  6247. * Gets a behavior using its name to search
  6248. * @param name defines the name to search
  6249. * @returns the behavior or null if not found
  6250. */
  6251. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6252. }
  6253. }
  6254. declare module BABYLON {
  6255. /**
  6256. * Defines an array and its length.
  6257. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6258. */
  6259. export interface ISmartArrayLike<T> {
  6260. /**
  6261. * The data of the array.
  6262. */
  6263. data: Array<T>;
  6264. /**
  6265. * The active length of the array.
  6266. */
  6267. length: number;
  6268. }
  6269. /**
  6270. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6271. */
  6272. export class SmartArray<T> implements ISmartArrayLike<T> {
  6273. /**
  6274. * The full set of data from the array.
  6275. */
  6276. data: Array<T>;
  6277. /**
  6278. * The active length of the array.
  6279. */
  6280. length: number;
  6281. protected _id: number;
  6282. /**
  6283. * Instantiates a Smart Array.
  6284. * @param capacity defines the default capacity of the array.
  6285. */
  6286. constructor(capacity: number);
  6287. /**
  6288. * Pushes a value at the end of the active data.
  6289. * @param value defines the object to push in the array.
  6290. */
  6291. push(value: T): void;
  6292. /**
  6293. * Iterates over the active data and apply the lambda to them.
  6294. * @param func defines the action to apply on each value.
  6295. */
  6296. forEach(func: (content: T) => void): void;
  6297. /**
  6298. * Sorts the full sets of data.
  6299. * @param compareFn defines the comparison function to apply.
  6300. */
  6301. sort(compareFn: (a: T, b: T) => number): void;
  6302. /**
  6303. * Resets the active data to an empty array.
  6304. */
  6305. reset(): void;
  6306. /**
  6307. * Releases all the data from the array as well as the array.
  6308. */
  6309. dispose(): void;
  6310. /**
  6311. * Concats the active data with a given array.
  6312. * @param array defines the data to concatenate with.
  6313. */
  6314. concat(array: any): void;
  6315. /**
  6316. * Returns the position of a value in the active data.
  6317. * @param value defines the value to find the index for
  6318. * @returns the index if found in the active data otherwise -1
  6319. */
  6320. indexOf(value: T): number;
  6321. /**
  6322. * Returns whether an element is part of the active data.
  6323. * @param value defines the value to look for
  6324. * @returns true if found in the active data otherwise false
  6325. */
  6326. contains(value: T): boolean;
  6327. private static _GlobalId;
  6328. }
  6329. /**
  6330. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6331. * The data in this array can only be present once
  6332. */
  6333. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6334. private _duplicateId;
  6335. /**
  6336. * Pushes a value at the end of the active data.
  6337. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6338. * @param value defines the object to push in the array.
  6339. */
  6340. push(value: T): void;
  6341. /**
  6342. * Pushes a value at the end of the active data.
  6343. * If the data is already present, it won t be added again
  6344. * @param value defines the object to push in the array.
  6345. * @returns true if added false if it was already present
  6346. */
  6347. pushNoDuplicate(value: T): boolean;
  6348. /**
  6349. * Resets the active data to an empty array.
  6350. */
  6351. reset(): void;
  6352. /**
  6353. * Concats the active data with a given array.
  6354. * This ensures no dupplicate will be present in the result.
  6355. * @param array defines the data to concatenate with.
  6356. */
  6357. concatWithNoDuplicate(array: any): void;
  6358. }
  6359. }
  6360. declare module BABYLON {
  6361. /**
  6362. * @ignore
  6363. * This is a list of all the different input types that are available in the application.
  6364. * Fo instance: ArcRotateCameraGamepadInput...
  6365. */
  6366. export var CameraInputTypes: {};
  6367. /**
  6368. * This is the contract to implement in order to create a new input class.
  6369. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6370. */
  6371. export interface ICameraInput<TCamera extends Camera> {
  6372. /**
  6373. * Defines the camera the input is attached to.
  6374. */
  6375. camera: Nullable<TCamera>;
  6376. /**
  6377. * Gets the class name of the current intput.
  6378. * @returns the class name
  6379. */
  6380. getClassName(): string;
  6381. /**
  6382. * Get the friendly name associated with the input class.
  6383. * @returns the input friendly name
  6384. */
  6385. getSimpleName(): string;
  6386. /**
  6387. * Attach the input controls to a specific dom element to get the input from.
  6388. * @param element Defines the element the controls should be listened from
  6389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6390. */
  6391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6392. /**
  6393. * Detach the current controls from the specified dom element.
  6394. * @param element Defines the element to stop listening the inputs from
  6395. */
  6396. detachControl(element: Nullable<HTMLElement>): void;
  6397. /**
  6398. * Update the current camera state depending on the inputs that have been used this frame.
  6399. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6400. */
  6401. checkInputs?: () => void;
  6402. }
  6403. /**
  6404. * Represents a map of input types to input instance or input index to input instance.
  6405. */
  6406. export interface CameraInputsMap<TCamera extends Camera> {
  6407. /**
  6408. * Accessor to the input by input type.
  6409. */
  6410. [name: string]: ICameraInput<TCamera>;
  6411. /**
  6412. * Accessor to the input by input index.
  6413. */
  6414. [idx: number]: ICameraInput<TCamera>;
  6415. }
  6416. /**
  6417. * This represents the input manager used within a camera.
  6418. * It helps dealing with all the different kind of input attached to a camera.
  6419. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6420. */
  6421. export class CameraInputsManager<TCamera extends Camera> {
  6422. /**
  6423. * Defines the list of inputs attahed to the camera.
  6424. */
  6425. attached: CameraInputsMap<TCamera>;
  6426. /**
  6427. * Defines the dom element the camera is collecting inputs from.
  6428. * This is null if the controls have not been attached.
  6429. */
  6430. attachedElement: Nullable<HTMLElement>;
  6431. /**
  6432. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6433. */
  6434. noPreventDefault: boolean;
  6435. /**
  6436. * Defined the camera the input manager belongs to.
  6437. */
  6438. camera: TCamera;
  6439. /**
  6440. * Update the current camera state depending on the inputs that have been used this frame.
  6441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6442. */
  6443. checkInputs: () => void;
  6444. /**
  6445. * Instantiate a new Camera Input Manager.
  6446. * @param camera Defines the camera the input manager blongs to
  6447. */
  6448. constructor(camera: TCamera);
  6449. /**
  6450. * Add an input method to a camera
  6451. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6452. * @param input camera input method
  6453. */
  6454. add(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Remove a specific input method from a camera
  6457. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6458. * @param inputToRemove camera input method
  6459. */
  6460. remove(inputToRemove: ICameraInput<TCamera>): void;
  6461. /**
  6462. * Remove a specific input type from a camera
  6463. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6464. * @param inputType the type of the input to remove
  6465. */
  6466. removeByType(inputType: string): void;
  6467. private _addCheckInputs;
  6468. /**
  6469. * Attach the input controls to the currently attached dom element to listen the events from.
  6470. * @param input Defines the input to attach
  6471. */
  6472. attachInput(input: ICameraInput<TCamera>): void;
  6473. /**
  6474. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6475. * @param element Defines the dom element to collect the events from
  6476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6477. */
  6478. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6479. /**
  6480. * Detach the current manager inputs controls from a specific dom element.
  6481. * @param element Defines the dom element to collect the events from
  6482. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6483. */
  6484. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6485. /**
  6486. * Rebuild the dynamic inputCheck function from the current list of
  6487. * defined inputs in the manager.
  6488. */
  6489. rebuildInputCheck(): void;
  6490. /**
  6491. * Remove all attached input methods from a camera
  6492. */
  6493. clear(): void;
  6494. /**
  6495. * Serialize the current input manager attached to a camera.
  6496. * This ensures than once parsed,
  6497. * the input associated to the camera will be identical to the current ones
  6498. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6499. */
  6500. serialize(serializedCamera: any): void;
  6501. /**
  6502. * Parses an input manager serialized JSON to restore the previous list of inputs
  6503. * and states associated to a camera.
  6504. * @param parsedCamera Defines the JSON to parse
  6505. */
  6506. parse(parsedCamera: any): void;
  6507. }
  6508. }
  6509. declare module BABYLON {
  6510. /**
  6511. * Class used to store data that will be store in GPU memory
  6512. */
  6513. export class Buffer {
  6514. private _engine;
  6515. private _buffer;
  6516. /** @hidden */
  6517. _data: Nullable<DataArray>;
  6518. private _updatable;
  6519. private _instanced;
  6520. private _divisor;
  6521. /**
  6522. * Gets the byte stride.
  6523. */
  6524. readonly byteStride: number;
  6525. /**
  6526. * Constructor
  6527. * @param engine the engine
  6528. * @param data the data to use for this buffer
  6529. * @param updatable whether the data is updatable
  6530. * @param stride the stride (optional)
  6531. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6532. * @param instanced whether the buffer is instanced (optional)
  6533. * @param useBytes set to true if the stride in in bytes (optional)
  6534. * @param divisor sets an optional divisor for instances (1 by default)
  6535. */
  6536. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6537. /**
  6538. * Create a new VertexBuffer based on the current buffer
  6539. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6540. * @param offset defines offset in the buffer (0 by default)
  6541. * @param size defines the size in floats of attributes (position is 3 for instance)
  6542. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6543. * @param instanced defines if the vertex buffer contains indexed data
  6544. * @param useBytes defines if the offset and stride are in bytes *
  6545. * @param divisor sets an optional divisor for instances (1 by default)
  6546. * @returns the new vertex buffer
  6547. */
  6548. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6549. /**
  6550. * Gets a boolean indicating if the Buffer is updatable?
  6551. * @returns true if the buffer is updatable
  6552. */
  6553. isUpdatable(): boolean;
  6554. /**
  6555. * Gets current buffer's data
  6556. * @returns a DataArray or null
  6557. */
  6558. getData(): Nullable<DataArray>;
  6559. /**
  6560. * Gets underlying native buffer
  6561. * @returns underlying native buffer
  6562. */
  6563. getBuffer(): Nullable<DataBuffer>;
  6564. /**
  6565. * Gets the stride in float32 units (i.e. byte stride / 4).
  6566. * May not be an integer if the byte stride is not divisible by 4.
  6567. * @returns the stride in float32 units
  6568. * @deprecated Please use byteStride instead.
  6569. */
  6570. getStrideSize(): number;
  6571. /**
  6572. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6573. * @param data defines the data to store
  6574. */
  6575. create(data?: Nullable<DataArray>): void;
  6576. /** @hidden */
  6577. _rebuild(): void;
  6578. /**
  6579. * Update current buffer data
  6580. * @param data defines the data to store
  6581. */
  6582. update(data: DataArray): void;
  6583. /**
  6584. * Updates the data directly.
  6585. * @param data the new data
  6586. * @param offset the new offset
  6587. * @param vertexCount the vertex count (optional)
  6588. * @param useBytes set to true if the offset is in bytes
  6589. */
  6590. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6591. /**
  6592. * Release all resources
  6593. */
  6594. dispose(): void;
  6595. }
  6596. /**
  6597. * Specialized buffer used to store vertex data
  6598. */
  6599. export class VertexBuffer {
  6600. /** @hidden */
  6601. _buffer: Buffer;
  6602. private _kind;
  6603. private _size;
  6604. private _ownsBuffer;
  6605. private _instanced;
  6606. private _instanceDivisor;
  6607. /**
  6608. * The byte type.
  6609. */
  6610. static readonly BYTE: number;
  6611. /**
  6612. * The unsigned byte type.
  6613. */
  6614. static readonly UNSIGNED_BYTE: number;
  6615. /**
  6616. * The short type.
  6617. */
  6618. static readonly SHORT: number;
  6619. /**
  6620. * The unsigned short type.
  6621. */
  6622. static readonly UNSIGNED_SHORT: number;
  6623. /**
  6624. * The integer type.
  6625. */
  6626. static readonly INT: number;
  6627. /**
  6628. * The unsigned integer type.
  6629. */
  6630. static readonly UNSIGNED_INT: number;
  6631. /**
  6632. * The float type.
  6633. */
  6634. static readonly FLOAT: number;
  6635. /**
  6636. * Gets or sets the instance divisor when in instanced mode
  6637. */
  6638. get instanceDivisor(): number;
  6639. set instanceDivisor(value: number);
  6640. /**
  6641. * Gets the byte stride.
  6642. */
  6643. readonly byteStride: number;
  6644. /**
  6645. * Gets the byte offset.
  6646. */
  6647. readonly byteOffset: number;
  6648. /**
  6649. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6650. */
  6651. readonly normalized: boolean;
  6652. /**
  6653. * Gets the data type of each component in the array.
  6654. */
  6655. readonly type: number;
  6656. /**
  6657. * Constructor
  6658. * @param engine the engine
  6659. * @param data the data to use for this vertex buffer
  6660. * @param kind the vertex buffer kind
  6661. * @param updatable whether the data is updatable
  6662. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6663. * @param stride the stride (optional)
  6664. * @param instanced whether the buffer is instanced (optional)
  6665. * @param offset the offset of the data (optional)
  6666. * @param size the number of components (optional)
  6667. * @param type the type of the component (optional)
  6668. * @param normalized whether the data contains normalized data (optional)
  6669. * @param useBytes set to true if stride and offset are in bytes (optional)
  6670. * @param divisor defines the instance divisor to use (1 by default)
  6671. */
  6672. 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);
  6673. /** @hidden */
  6674. _rebuild(): void;
  6675. /**
  6676. * Returns the kind of the VertexBuffer (string)
  6677. * @returns a string
  6678. */
  6679. getKind(): string;
  6680. /**
  6681. * Gets a boolean indicating if the VertexBuffer is updatable?
  6682. * @returns true if the buffer is updatable
  6683. */
  6684. isUpdatable(): boolean;
  6685. /**
  6686. * Gets current buffer's data
  6687. * @returns a DataArray or null
  6688. */
  6689. getData(): Nullable<DataArray>;
  6690. /**
  6691. * Gets underlying native buffer
  6692. * @returns underlying native buffer
  6693. */
  6694. getBuffer(): Nullable<DataBuffer>;
  6695. /**
  6696. * Gets the stride in float32 units (i.e. byte stride / 4).
  6697. * May not be an integer if the byte stride is not divisible by 4.
  6698. * @returns the stride in float32 units
  6699. * @deprecated Please use byteStride instead.
  6700. */
  6701. getStrideSize(): number;
  6702. /**
  6703. * Returns the offset as a multiple of the type byte length.
  6704. * @returns the offset in bytes
  6705. * @deprecated Please use byteOffset instead.
  6706. */
  6707. getOffset(): number;
  6708. /**
  6709. * Returns the number of components per vertex attribute (integer)
  6710. * @returns the size in float
  6711. */
  6712. getSize(): number;
  6713. /**
  6714. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6715. * @returns true if this buffer is instanced
  6716. */
  6717. getIsInstanced(): boolean;
  6718. /**
  6719. * Returns the instancing divisor, zero for non-instanced (integer).
  6720. * @returns a number
  6721. */
  6722. getInstanceDivisor(): number;
  6723. /**
  6724. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6725. * @param data defines the data to store
  6726. */
  6727. create(data?: DataArray): void;
  6728. /**
  6729. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6730. * This function will create a new buffer if the current one is not updatable
  6731. * @param data defines the data to store
  6732. */
  6733. update(data: DataArray): void;
  6734. /**
  6735. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6736. * Returns the directly updated WebGLBuffer.
  6737. * @param data the new data
  6738. * @param offset the new offset
  6739. * @param useBytes set to true if the offset is in bytes
  6740. */
  6741. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6742. /**
  6743. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6744. */
  6745. dispose(): void;
  6746. /**
  6747. * Enumerates each value of this vertex buffer as numbers.
  6748. * @param count the number of values to enumerate
  6749. * @param callback the callback function called for each value
  6750. */
  6751. forEach(count: number, callback: (value: number, index: number) => void): void;
  6752. /**
  6753. * Positions
  6754. */
  6755. static readonly PositionKind: string;
  6756. /**
  6757. * Normals
  6758. */
  6759. static readonly NormalKind: string;
  6760. /**
  6761. * Tangents
  6762. */
  6763. static readonly TangentKind: string;
  6764. /**
  6765. * Texture coordinates
  6766. */
  6767. static readonly UVKind: string;
  6768. /**
  6769. * Texture coordinates 2
  6770. */
  6771. static readonly UV2Kind: string;
  6772. /**
  6773. * Texture coordinates 3
  6774. */
  6775. static readonly UV3Kind: string;
  6776. /**
  6777. * Texture coordinates 4
  6778. */
  6779. static readonly UV4Kind: string;
  6780. /**
  6781. * Texture coordinates 5
  6782. */
  6783. static readonly UV5Kind: string;
  6784. /**
  6785. * Texture coordinates 6
  6786. */
  6787. static readonly UV6Kind: string;
  6788. /**
  6789. * Colors
  6790. */
  6791. static readonly ColorKind: string;
  6792. /**
  6793. * Matrix indices (for bones)
  6794. */
  6795. static readonly MatricesIndicesKind: string;
  6796. /**
  6797. * Matrix weights (for bones)
  6798. */
  6799. static readonly MatricesWeightsKind: string;
  6800. /**
  6801. * Additional matrix indices (for bones)
  6802. */
  6803. static readonly MatricesIndicesExtraKind: string;
  6804. /**
  6805. * Additional matrix weights (for bones)
  6806. */
  6807. static readonly MatricesWeightsExtraKind: string;
  6808. /**
  6809. * Deduces the stride given a kind.
  6810. * @param kind The kind string to deduce
  6811. * @returns The deduced stride
  6812. */
  6813. static DeduceStride(kind: string): number;
  6814. /**
  6815. * Gets the byte length of the given type.
  6816. * @param type the type
  6817. * @returns the number of bytes
  6818. */
  6819. static GetTypeByteLength(type: number): number;
  6820. /**
  6821. * Enumerates each value of the given parameters as numbers.
  6822. * @param data the data to enumerate
  6823. * @param byteOffset the byte offset of the data
  6824. * @param byteStride the byte stride of the data
  6825. * @param componentCount the number of components per element
  6826. * @param componentType the type of the component
  6827. * @param count the number of values to enumerate
  6828. * @param normalized whether the data is normalized
  6829. * @param callback the callback function called for each value
  6830. */
  6831. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6832. private static _GetFloatValue;
  6833. }
  6834. }
  6835. declare module BABYLON {
  6836. /**
  6837. * The options Interface for creating a Capsule Mesh
  6838. */
  6839. export interface ICreateCapsuleOptions {
  6840. /** The Orientation of the capsule. Default : Vector3.Up() */
  6841. orientation?: Vector3;
  6842. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6843. subdivisions: number;
  6844. /** Number of cylindrical segments on the capsule. */
  6845. tessellation: number;
  6846. /** Height or Length of the capsule. */
  6847. height: number;
  6848. /** Radius of the capsule. */
  6849. radius: number;
  6850. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6851. capSubdivisions: number;
  6852. /** Overwrite for the top radius. */
  6853. radiusTop?: number;
  6854. /** Overwrite for the bottom radius. */
  6855. radiusBottom?: number;
  6856. /** Overwrite for the top capSubdivisions. */
  6857. topCapSubdivisions?: number;
  6858. /** Overwrite for the bottom capSubdivisions. */
  6859. bottomCapSubdivisions?: number;
  6860. }
  6861. /**
  6862. * Class containing static functions to help procedurally build meshes
  6863. */
  6864. export class CapsuleBuilder {
  6865. /**
  6866. * Creates a capsule or a pill mesh
  6867. * @param name defines the name of the mesh
  6868. * @param options The constructors options.
  6869. * @param scene The scene the mesh is scoped to.
  6870. * @returns Capsule Mesh
  6871. */
  6872. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6873. }
  6874. }
  6875. declare module BABYLON {
  6876. /**
  6877. * @hidden
  6878. */
  6879. export class IntersectionInfo {
  6880. bu: Nullable<number>;
  6881. bv: Nullable<number>;
  6882. distance: number;
  6883. faceId: number;
  6884. subMeshId: number;
  6885. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6886. }
  6887. }
  6888. declare module BABYLON {
  6889. /**
  6890. * Class used to store bounding sphere information
  6891. */
  6892. export class BoundingSphere {
  6893. /**
  6894. * Gets the center of the bounding sphere in local space
  6895. */
  6896. readonly center: Vector3;
  6897. /**
  6898. * Radius of the bounding sphere in local space
  6899. */
  6900. radius: number;
  6901. /**
  6902. * Gets the center of the bounding sphere in world space
  6903. */
  6904. readonly centerWorld: Vector3;
  6905. /**
  6906. * Radius of the bounding sphere in world space
  6907. */
  6908. radiusWorld: number;
  6909. /**
  6910. * Gets the minimum vector in local space
  6911. */
  6912. readonly minimum: Vector3;
  6913. /**
  6914. * Gets the maximum vector in local space
  6915. */
  6916. readonly maximum: Vector3;
  6917. private _worldMatrix;
  6918. private static readonly TmpVector3;
  6919. /**
  6920. * Creates a new bounding sphere
  6921. * @param min defines the minimum vector (in local space)
  6922. * @param max defines the maximum vector (in local space)
  6923. * @param worldMatrix defines the new world matrix
  6924. */
  6925. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6926. /**
  6927. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6928. * @param min defines the new minimum vector (in local space)
  6929. * @param max defines the new maximum vector (in local space)
  6930. * @param worldMatrix defines the new world matrix
  6931. */
  6932. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6933. /**
  6934. * Scale the current bounding sphere by applying a scale factor
  6935. * @param factor defines the scale factor to apply
  6936. * @returns the current bounding box
  6937. */
  6938. scale(factor: number): BoundingSphere;
  6939. /**
  6940. * Gets the world matrix of the bounding box
  6941. * @returns a matrix
  6942. */
  6943. getWorldMatrix(): DeepImmutable<Matrix>;
  6944. /** @hidden */
  6945. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6946. /**
  6947. * Tests if the bounding sphere is intersecting the frustum planes
  6948. * @param frustumPlanes defines the frustum planes to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6952. /**
  6953. * Tests if the bounding sphere center is in between the frustum planes.
  6954. * Used for optimistic fast inclusion.
  6955. * @param frustumPlanes defines the frustum planes to test
  6956. * @returns true if the sphere center is in between the frustum planes
  6957. */
  6958. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6959. /**
  6960. * Tests if a point is inside the bounding sphere
  6961. * @param point defines the point to test
  6962. * @returns true if the point is inside the bounding sphere
  6963. */
  6964. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6965. /**
  6966. * Checks if two sphere intersct
  6967. * @param sphere0 sphere 0
  6968. * @param sphere1 sphere 1
  6969. * @returns true if the speres intersect
  6970. */
  6971. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6972. }
  6973. }
  6974. declare module BABYLON {
  6975. /**
  6976. * Class used to store bounding box information
  6977. */
  6978. export class BoundingBox implements ICullable {
  6979. /**
  6980. * Gets the 8 vectors representing the bounding box in local space
  6981. */
  6982. readonly vectors: Vector3[];
  6983. /**
  6984. * Gets the center of the bounding box in local space
  6985. */
  6986. readonly center: Vector3;
  6987. /**
  6988. * Gets the center of the bounding box in world space
  6989. */
  6990. readonly centerWorld: Vector3;
  6991. /**
  6992. * Gets the extend size in local space
  6993. */
  6994. readonly extendSize: Vector3;
  6995. /**
  6996. * Gets the extend size in world space
  6997. */
  6998. readonly extendSizeWorld: Vector3;
  6999. /**
  7000. * Gets the OBB (object bounding box) directions
  7001. */
  7002. readonly directions: Vector3[];
  7003. /**
  7004. * Gets the 8 vectors representing the bounding box in world space
  7005. */
  7006. readonly vectorsWorld: Vector3[];
  7007. /**
  7008. * Gets the minimum vector in world space
  7009. */
  7010. readonly minimumWorld: Vector3;
  7011. /**
  7012. * Gets the maximum vector in world space
  7013. */
  7014. readonly maximumWorld: Vector3;
  7015. /**
  7016. * Gets the minimum vector in local space
  7017. */
  7018. readonly minimum: Vector3;
  7019. /**
  7020. * Gets the maximum vector in local space
  7021. */
  7022. readonly maximum: Vector3;
  7023. private _worldMatrix;
  7024. private static readonly TmpVector3;
  7025. /**
  7026. * @hidden
  7027. */
  7028. _tag: number;
  7029. /**
  7030. * Creates a new bounding box
  7031. * @param min defines the minimum vector (in local space)
  7032. * @param max defines the maximum vector (in local space)
  7033. * @param worldMatrix defines the new world matrix
  7034. */
  7035. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7036. /**
  7037. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7038. * @param min defines the new minimum vector (in local space)
  7039. * @param max defines the new maximum vector (in local space)
  7040. * @param worldMatrix defines the new world matrix
  7041. */
  7042. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Scale the current bounding box by applying a scale factor
  7045. * @param factor defines the scale factor to apply
  7046. * @returns the current bounding box
  7047. */
  7048. scale(factor: number): BoundingBox;
  7049. /**
  7050. * Gets the world matrix of the bounding box
  7051. * @returns a matrix
  7052. */
  7053. getWorldMatrix(): DeepImmutable<Matrix>;
  7054. /** @hidden */
  7055. _update(world: DeepImmutable<Matrix>): void;
  7056. /**
  7057. * Tests if the bounding box is intersecting the frustum planes
  7058. * @param frustumPlanes defines the frustum planes to test
  7059. * @returns true if there is an intersection
  7060. */
  7061. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /**
  7063. * Tests if the bounding box is entirely inside the frustum planes
  7064. * @param frustumPlanes defines the frustum planes to test
  7065. * @returns true if there is an inclusion
  7066. */
  7067. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7068. /**
  7069. * Tests if a point is inside the bounding box
  7070. * @param point defines the point to test
  7071. * @returns true if the point is inside the bounding box
  7072. */
  7073. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if the bounding box intersects with a bounding sphere
  7076. * @param sphere defines the sphere to test
  7077. * @returns true if there is an intersection
  7078. */
  7079. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7080. /**
  7081. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7082. * @param min defines the min vector to use
  7083. * @param max defines the max vector to use
  7084. * @returns true if there is an intersection
  7085. */
  7086. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7087. /**
  7088. * Tests if two bounding boxes are intersections
  7089. * @param box0 defines the first box to test
  7090. * @param box1 defines the second box to test
  7091. * @returns true if there is an intersection
  7092. */
  7093. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7094. /**
  7095. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7096. * @param minPoint defines the minimum vector of the bounding box
  7097. * @param maxPoint defines the maximum vector of the bounding box
  7098. * @param sphereCenter defines the sphere center
  7099. * @param sphereRadius defines the sphere radius
  7100. * @returns true if there is an intersection
  7101. */
  7102. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7103. /**
  7104. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7105. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7106. * @param frustumPlanes defines the frustum planes to test
  7107. * @return true if there is an inclusion
  7108. */
  7109. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7110. /**
  7111. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7112. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7113. * @param frustumPlanes defines the frustum planes to test
  7114. * @return true if there is an intersection
  7115. */
  7116. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7117. }
  7118. }
  7119. declare module BABYLON {
  7120. /** @hidden */
  7121. export class Collider {
  7122. /** Define if a collision was found */
  7123. collisionFound: boolean;
  7124. /**
  7125. * Define last intersection point in local space
  7126. */
  7127. intersectionPoint: Vector3;
  7128. /**
  7129. * Define last collided mesh
  7130. */
  7131. collidedMesh: Nullable<AbstractMesh>;
  7132. private _collisionPoint;
  7133. private _planeIntersectionPoint;
  7134. private _tempVector;
  7135. private _tempVector2;
  7136. private _tempVector3;
  7137. private _tempVector4;
  7138. private _edge;
  7139. private _baseToVertex;
  7140. private _destinationPoint;
  7141. private _slidePlaneNormal;
  7142. private _displacementVector;
  7143. /** @hidden */
  7144. _radius: Vector3;
  7145. /** @hidden */
  7146. _retry: number;
  7147. private _velocity;
  7148. private _basePoint;
  7149. private _epsilon;
  7150. /** @hidden */
  7151. _velocityWorldLength: number;
  7152. /** @hidden */
  7153. _basePointWorld: Vector3;
  7154. private _velocityWorld;
  7155. private _normalizedVelocity;
  7156. /** @hidden */
  7157. _initialVelocity: Vector3;
  7158. /** @hidden */
  7159. _initialPosition: Vector3;
  7160. private _nearestDistance;
  7161. private _collisionMask;
  7162. get collisionMask(): number;
  7163. set collisionMask(mask: number);
  7164. /**
  7165. * Gets the plane normal used to compute the sliding response (in local space)
  7166. */
  7167. get slidePlaneNormal(): Vector3;
  7168. /** @hidden */
  7169. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7170. /** @hidden */
  7171. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7172. /** @hidden */
  7173. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7174. /** @hidden */
  7175. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7176. /** @hidden */
  7177. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _getResponse(pos: Vector3, vel: Vector3): void;
  7180. }
  7181. }
  7182. declare module BABYLON {
  7183. /**
  7184. * Interface for cullable objects
  7185. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7186. */
  7187. export interface ICullable {
  7188. /**
  7189. * Checks if the object or part of the object is in the frustum
  7190. * @param frustumPlanes Camera near/planes
  7191. * @returns true if the object is in frustum otherwise false
  7192. */
  7193. isInFrustum(frustumPlanes: Plane[]): boolean;
  7194. /**
  7195. * Checks if a cullable object (mesh...) is in the camera frustum
  7196. * Unlike isInFrustum this cheks the full bounding box
  7197. * @param frustumPlanes Camera near/planes
  7198. * @returns true if the object is in frustum otherwise false
  7199. */
  7200. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7201. }
  7202. /**
  7203. * Info for a bounding data of a mesh
  7204. */
  7205. export class BoundingInfo implements ICullable {
  7206. /**
  7207. * Bounding box for the mesh
  7208. */
  7209. readonly boundingBox: BoundingBox;
  7210. /**
  7211. * Bounding sphere for the mesh
  7212. */
  7213. readonly boundingSphere: BoundingSphere;
  7214. private _isLocked;
  7215. private static readonly TmpVector3;
  7216. /**
  7217. * Constructs bounding info
  7218. * @param minimum min vector of the bounding box/sphere
  7219. * @param maximum max vector of the bounding box/sphere
  7220. * @param worldMatrix defines the new world matrix
  7221. */
  7222. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7223. /**
  7224. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7225. * @param min defines the new minimum vector (in local space)
  7226. * @param max defines the new maximum vector (in local space)
  7227. * @param worldMatrix defines the new world matrix
  7228. */
  7229. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7230. /**
  7231. * min vector of the bounding box/sphere
  7232. */
  7233. get minimum(): Vector3;
  7234. /**
  7235. * max vector of the bounding box/sphere
  7236. */
  7237. get maximum(): Vector3;
  7238. /**
  7239. * If the info is locked and won't be updated to avoid perf overhead
  7240. */
  7241. get isLocked(): boolean;
  7242. set isLocked(value: boolean);
  7243. /**
  7244. * Updates the bounding sphere and box
  7245. * @param world world matrix to be used to update
  7246. */
  7247. update(world: DeepImmutable<Matrix>): void;
  7248. /**
  7249. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7250. * @param center New center of the bounding info
  7251. * @param extend New extend of the bounding info
  7252. * @returns the current bounding info
  7253. */
  7254. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7255. /**
  7256. * Scale the current bounding info by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding info
  7259. */
  7260. scale(factor: number): BoundingInfo;
  7261. /**
  7262. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7263. * @param frustumPlanes defines the frustum to test
  7264. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7265. * @returns true if the bounding info is in the frustum planes
  7266. */
  7267. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7268. /**
  7269. * Gets the world distance between the min and max points of the bounding box
  7270. */
  7271. get diagonalLength(): number;
  7272. /**
  7273. * Checks if a cullable object (mesh...) is in the camera frustum
  7274. * Unlike isInFrustum this cheks the full bounding box
  7275. * @param frustumPlanes Camera near/planes
  7276. * @returns true if the object is in frustum otherwise false
  7277. */
  7278. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7279. /** @hidden */
  7280. _checkCollision(collider: Collider): boolean;
  7281. /**
  7282. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7283. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7284. * @param point the point to check intersection with
  7285. * @returns if the point intersects
  7286. */
  7287. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7288. /**
  7289. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param boundingInfo the bounding info to check intersection with
  7292. * @param precise if the intersection should be done using OBB
  7293. * @returns if the bounding info intersects
  7294. */
  7295. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. /**
  7300. * Extracts minimum and maximum values from a list of indexed positions
  7301. * @param positions defines the positions to use
  7302. * @param indices defines the indices to the positions
  7303. * @param indexStart defines the start index
  7304. * @param indexCount defines the end index
  7305. * @param bias defines bias value to add to the result
  7306. * @return minimum and maximum values
  7307. */
  7308. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7309. minimum: Vector3;
  7310. maximum: Vector3;
  7311. };
  7312. /**
  7313. * Extracts minimum and maximum values from a list of positions
  7314. * @param positions defines the positions to use
  7315. * @param start defines the start index in the positions array
  7316. * @param count defines the number of positions to handle
  7317. * @param bias defines bias value to add to the result
  7318. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7319. * @return minimum and maximum values
  7320. */
  7321. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7322. minimum: Vector3;
  7323. maximum: Vector3;
  7324. };
  7325. }
  7326. declare module BABYLON {
  7327. /** @hidden */
  7328. export class WebGLDataBuffer extends DataBuffer {
  7329. private _buffer;
  7330. constructor(resource: WebGLBuffer);
  7331. get underlyingResource(): any;
  7332. }
  7333. }
  7334. declare module BABYLON {
  7335. /** @hidden */
  7336. export class WebGLPipelineContext implements IPipelineContext {
  7337. engine: ThinEngine;
  7338. program: Nullable<WebGLProgram>;
  7339. context?: WebGLRenderingContext;
  7340. vertexShader?: WebGLShader;
  7341. fragmentShader?: WebGLShader;
  7342. isParallelCompiled: boolean;
  7343. onCompiled?: () => void;
  7344. transformFeedback?: WebGLTransformFeedback | null;
  7345. vertexCompilationError: Nullable<string>;
  7346. fragmentCompilationError: Nullable<string>;
  7347. programLinkError: Nullable<string>;
  7348. programValidationError: Nullable<string>;
  7349. get isAsync(): boolean;
  7350. get isReady(): boolean;
  7351. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7352. _getVertexShaderCode(): string | null;
  7353. _getFragmentShaderCode(): string | null;
  7354. }
  7355. }
  7356. declare module BABYLON {
  7357. interface ThinEngine {
  7358. /**
  7359. * Create an uniform buffer
  7360. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7361. * @param elements defines the content of the uniform buffer
  7362. * @returns the webGL uniform buffer
  7363. */
  7364. createUniformBuffer(elements: FloatArray): DataBuffer;
  7365. /**
  7366. * Create a dynamic uniform buffer
  7367. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7368. * @param elements defines the content of the uniform buffer
  7369. * @returns the webGL uniform buffer
  7370. */
  7371. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7372. /**
  7373. * Update an existing uniform buffer
  7374. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7375. * @param uniformBuffer defines the target uniform buffer
  7376. * @param elements defines the content to update
  7377. * @param offset defines the offset in the uniform buffer where update should start
  7378. * @param count defines the size of the data to update
  7379. */
  7380. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7381. /**
  7382. * Bind an uniform buffer to the current webGL context
  7383. * @param buffer defines the buffer to bind
  7384. */
  7385. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7386. /**
  7387. * Bind a buffer to the current webGL context at a given location
  7388. * @param buffer defines the buffer to bind
  7389. * @param location defines the index where to bind the buffer
  7390. */
  7391. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7392. /**
  7393. * Bind a specific block at a given index in a specific shader program
  7394. * @param pipelineContext defines the pipeline context to use
  7395. * @param blockName defines the block name
  7396. * @param index defines the index where to bind the block
  7397. */
  7398. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7399. }
  7400. }
  7401. declare module BABYLON {
  7402. /**
  7403. * Uniform buffer objects.
  7404. *
  7405. * Handles blocks of uniform on the GPU.
  7406. *
  7407. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7408. *
  7409. * For more information, please refer to :
  7410. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7411. */
  7412. export class UniformBuffer {
  7413. private _engine;
  7414. private _buffer;
  7415. private _data;
  7416. private _bufferData;
  7417. private _dynamic?;
  7418. private _uniformLocations;
  7419. private _uniformSizes;
  7420. private _uniformLocationPointer;
  7421. private _needSync;
  7422. private _noUBO;
  7423. private _currentEffect;
  7424. /** @hidden */
  7425. _alreadyBound: boolean;
  7426. private static _MAX_UNIFORM_SIZE;
  7427. private static _tempBuffer;
  7428. /**
  7429. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7434. /**
  7435. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7436. * This is dynamic to allow compat with webgl 1 and 2.
  7437. * You will need to pass the name of the uniform as well as the value.
  7438. */
  7439. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7440. /**
  7441. * Lambda to Update a single float in a uniform buffer.
  7442. * This is dynamic to allow compat with webgl 1 and 2.
  7443. * You will need to pass the name of the uniform as well as the value.
  7444. */
  7445. updateFloat: (name: string, x: number) => void;
  7446. /**
  7447. * Lambda to Update a vec2 of float in a uniform buffer.
  7448. * This is dynamic to allow compat with webgl 1 and 2.
  7449. * You will need to pass the name of the uniform as well as the value.
  7450. */
  7451. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7452. /**
  7453. * Lambda to Update a vec3 of float in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7458. /**
  7459. * Lambda to Update a vec4 of float in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7464. /**
  7465. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateMatrix: (name: string, mat: Matrix) => void;
  7470. /**
  7471. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateVector3: (name: string, vector: Vector3) => void;
  7476. /**
  7477. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateVector4: (name: string, vector: Vector4) => void;
  7482. /**
  7483. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7494. /**
  7495. * Instantiates a new Uniform buffer objects.
  7496. *
  7497. * Handles blocks of uniform on the GPU.
  7498. *
  7499. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7500. *
  7501. * For more information, please refer to :
  7502. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7503. * @param engine Define the engine the buffer is associated with
  7504. * @param data Define the data contained in the buffer
  7505. * @param dynamic Define if the buffer is updatable
  7506. */
  7507. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7508. /**
  7509. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7510. * or just falling back on setUniformXXX calls.
  7511. */
  7512. get useUbo(): boolean;
  7513. /**
  7514. * Indicates if the WebGL underlying uniform buffer is in sync
  7515. * with the javascript cache data.
  7516. */
  7517. get isSync(): boolean;
  7518. /**
  7519. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7520. * Also, a dynamic UniformBuffer will disable cache verification and always
  7521. * update the underlying WebGL uniform buffer to the GPU.
  7522. * @returns if Dynamic, otherwise false
  7523. */
  7524. isDynamic(): boolean;
  7525. /**
  7526. * The data cache on JS side.
  7527. * @returns the underlying data as a float array
  7528. */
  7529. getData(): Float32Array;
  7530. /**
  7531. * The underlying WebGL Uniform buffer.
  7532. * @returns the webgl buffer
  7533. */
  7534. getBuffer(): Nullable<DataBuffer>;
  7535. /**
  7536. * std140 layout specifies how to align data within an UBO structure.
  7537. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7538. * for specs.
  7539. */
  7540. private _fillAlignment;
  7541. /**
  7542. * Adds an uniform in the buffer.
  7543. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7544. * for the layout to be correct !
  7545. * @param name Name of the uniform, as used in the uniform block in the shader.
  7546. * @param size Data size, or data directly.
  7547. */
  7548. addUniform(name: string, size: number | number[]): void;
  7549. /**
  7550. * Adds a Matrix 4x4 to the uniform buffer.
  7551. * @param name Name of the uniform, as used in the uniform block in the shader.
  7552. * @param mat A 4x4 matrix.
  7553. */
  7554. addMatrix(name: string, mat: Matrix): void;
  7555. /**
  7556. * Adds a vec2 to the uniform buffer.
  7557. * @param name Name of the uniform, as used in the uniform block in the shader.
  7558. * @param x Define the x component value of the vec2
  7559. * @param y Define the y component value of the vec2
  7560. */
  7561. addFloat2(name: string, x: number, y: number): void;
  7562. /**
  7563. * Adds a vec3 to the uniform buffer.
  7564. * @param name Name of the uniform, as used in the uniform block in the shader.
  7565. * @param x Define the x component value of the vec3
  7566. * @param y Define the y component value of the vec3
  7567. * @param z Define the z component value of the vec3
  7568. */
  7569. addFloat3(name: string, x: number, y: number, z: number): void;
  7570. /**
  7571. * Adds a vec3 to the uniform buffer.
  7572. * @param name Name of the uniform, as used in the uniform block in the shader.
  7573. * @param color Define the vec3 from a Color
  7574. */
  7575. addColor3(name: string, color: Color3): void;
  7576. /**
  7577. * Adds a vec4 to the uniform buffer.
  7578. * @param name Name of the uniform, as used in the uniform block in the shader.
  7579. * @param color Define the rgb components from a Color
  7580. * @param alpha Define the a component of the vec4
  7581. */
  7582. addColor4(name: string, color: Color3, alpha: number): void;
  7583. /**
  7584. * Adds a vec3 to the uniform buffer.
  7585. * @param name Name of the uniform, as used in the uniform block in the shader.
  7586. * @param vector Define the vec3 components from a Vector
  7587. */
  7588. addVector3(name: string, vector: Vector3): void;
  7589. /**
  7590. * Adds a Matrix 3x3 to the uniform buffer.
  7591. * @param name Name of the uniform, as used in the uniform block in the shader.
  7592. */
  7593. addMatrix3x3(name: string): void;
  7594. /**
  7595. * Adds a Matrix 2x2 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. */
  7598. addMatrix2x2(name: string): void;
  7599. /**
  7600. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7601. */
  7602. create(): void;
  7603. /** @hidden */
  7604. _rebuild(): void;
  7605. /**
  7606. * Updates the WebGL Uniform Buffer on the GPU.
  7607. * If the `dynamic` flag is set to true, no cache comparison is done.
  7608. * Otherwise, the buffer will be updated only if the cache differs.
  7609. */
  7610. update(): void;
  7611. /**
  7612. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7613. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7614. * @param data Define the flattened data
  7615. * @param size Define the size of the data.
  7616. */
  7617. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7618. private _valueCache;
  7619. private _cacheMatrix;
  7620. private _updateMatrix3x3ForUniform;
  7621. private _updateMatrix3x3ForEffect;
  7622. private _updateMatrix2x2ForEffect;
  7623. private _updateMatrix2x2ForUniform;
  7624. private _updateFloatForEffect;
  7625. private _updateFloatForUniform;
  7626. private _updateFloat2ForEffect;
  7627. private _updateFloat2ForUniform;
  7628. private _updateFloat3ForEffect;
  7629. private _updateFloat3ForUniform;
  7630. private _updateFloat4ForEffect;
  7631. private _updateFloat4ForUniform;
  7632. private _updateMatrixForEffect;
  7633. private _updateMatrixForUniform;
  7634. private _updateVector3ForEffect;
  7635. private _updateVector3ForUniform;
  7636. private _updateVector4ForEffect;
  7637. private _updateVector4ForUniform;
  7638. private _updateColor3ForEffect;
  7639. private _updateColor3ForUniform;
  7640. private _updateColor4ForEffect;
  7641. private _updateColor4ForUniform;
  7642. /**
  7643. * Sets a sampler uniform on the effect.
  7644. * @param name Define the name of the sampler.
  7645. * @param texture Define the texture to set in the sampler
  7646. */
  7647. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7648. /**
  7649. * Directly updates the value of the uniform in the cache AND on the GPU.
  7650. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7651. * @param data Define the flattened data
  7652. */
  7653. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7654. /**
  7655. * Binds this uniform buffer to an effect.
  7656. * @param effect Define the effect to bind the buffer to
  7657. * @param name Name of the uniform block in the shader.
  7658. */
  7659. bindToEffect(effect: Effect, name: string): void;
  7660. /**
  7661. * Disposes the uniform buffer.
  7662. */
  7663. dispose(): void;
  7664. }
  7665. }
  7666. declare module BABYLON {
  7667. /**
  7668. * Enum that determines the text-wrapping mode to use.
  7669. */
  7670. export enum InspectableType {
  7671. /**
  7672. * Checkbox for booleans
  7673. */
  7674. Checkbox = 0,
  7675. /**
  7676. * Sliders for numbers
  7677. */
  7678. Slider = 1,
  7679. /**
  7680. * Vector3
  7681. */
  7682. Vector3 = 2,
  7683. /**
  7684. * Quaternions
  7685. */
  7686. Quaternion = 3,
  7687. /**
  7688. * Color3
  7689. */
  7690. Color3 = 4,
  7691. /**
  7692. * String
  7693. */
  7694. String = 5
  7695. }
  7696. /**
  7697. * Interface used to define custom inspectable properties.
  7698. * This interface is used by the inspector to display custom property grids
  7699. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7700. */
  7701. export interface IInspectable {
  7702. /**
  7703. * Gets the label to display
  7704. */
  7705. label: string;
  7706. /**
  7707. * Gets the name of the property to edit
  7708. */
  7709. propertyName: string;
  7710. /**
  7711. * Gets the type of the editor to use
  7712. */
  7713. type: InspectableType;
  7714. /**
  7715. * Gets the minimum value of the property when using in "slider" mode
  7716. */
  7717. min?: number;
  7718. /**
  7719. * Gets the maximum value of the property when using in "slider" mode
  7720. */
  7721. max?: number;
  7722. /**
  7723. * Gets the setp to use when using in "slider" mode
  7724. */
  7725. step?: number;
  7726. }
  7727. }
  7728. declare module BABYLON {
  7729. /**
  7730. * Class used to provide helper for timing
  7731. */
  7732. export class TimingTools {
  7733. /**
  7734. * Polyfill for setImmediate
  7735. * @param action defines the action to execute after the current execution block
  7736. */
  7737. static SetImmediate(action: () => void): void;
  7738. }
  7739. }
  7740. declare module BABYLON {
  7741. /**
  7742. * Class used to enable instatition of objects by class name
  7743. */
  7744. export class InstantiationTools {
  7745. /**
  7746. * Use this object to register external classes like custom textures or material
  7747. * to allow the laoders to instantiate them
  7748. */
  7749. static RegisteredExternalClasses: {
  7750. [key: string]: Object;
  7751. };
  7752. /**
  7753. * Tries to instantiate a new object from a given class name
  7754. * @param className defines the class name to instantiate
  7755. * @returns the new object or null if the system was not able to do the instantiation
  7756. */
  7757. static Instantiate(className: string): any;
  7758. }
  7759. }
  7760. declare module BABYLON {
  7761. /**
  7762. * Define options used to create a depth texture
  7763. */
  7764. export class DepthTextureCreationOptions {
  7765. /** Specifies whether or not a stencil should be allocated in the texture */
  7766. generateStencil?: boolean;
  7767. /** Specifies whether or not bilinear filtering is enable on the texture */
  7768. bilinearFiltering?: boolean;
  7769. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7770. comparisonFunction?: number;
  7771. /** Specifies if the created texture is a cube texture */
  7772. isCube?: boolean;
  7773. }
  7774. }
  7775. declare module BABYLON {
  7776. interface ThinEngine {
  7777. /**
  7778. * Creates a depth stencil cube texture.
  7779. * This is only available in WebGL 2.
  7780. * @param size The size of face edge in the cube texture.
  7781. * @param options The options defining the cube texture.
  7782. * @returns The cube texture
  7783. */
  7784. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7785. /**
  7786. * Creates a cube texture
  7787. * @param rootUrl defines the url where the files to load is located
  7788. * @param scene defines the current scene
  7789. * @param files defines the list of files to load (1 per face)
  7790. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7791. * @param onLoad defines an optional callback raised when the texture is loaded
  7792. * @param onError defines an optional callback raised if there is an issue to load the texture
  7793. * @param format defines the format of the data
  7794. * @param forcedExtension defines the extension to use to pick the right loader
  7795. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7796. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7797. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7798. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7799. * @returns the cube texture as an InternalTexture
  7800. */
  7801. 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;
  7802. /**
  7803. * Creates a cube texture
  7804. * @param rootUrl defines the url where the files to load is located
  7805. * @param scene defines the current scene
  7806. * @param files defines the list of files to load (1 per face)
  7807. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7808. * @param onLoad defines an optional callback raised when the texture is loaded
  7809. * @param onError defines an optional callback raised if there is an issue to load the texture
  7810. * @param format defines the format of the data
  7811. * @param forcedExtension defines the extension to use to pick the right loader
  7812. * @returns the cube texture as an InternalTexture
  7813. */
  7814. 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;
  7815. /**
  7816. * Creates a cube texture
  7817. * @param rootUrl defines the url where the files to load is located
  7818. * @param scene defines the current scene
  7819. * @param files defines the list of files to load (1 per face)
  7820. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7821. * @param onLoad defines an optional callback raised when the texture is loaded
  7822. * @param onError defines an optional callback raised if there is an issue to load the texture
  7823. * @param format defines the format of the data
  7824. * @param forcedExtension defines the extension to use to pick the right loader
  7825. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7826. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7827. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. 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;
  7831. /** @hidden */
  7832. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7833. /** @hidden */
  7834. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7835. /** @hidden */
  7836. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7837. /** @hidden */
  7838. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7839. /**
  7840. * @hidden
  7841. */
  7842. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7843. }
  7844. }
  7845. declare module BABYLON {
  7846. /**
  7847. * Class for creating a cube texture
  7848. */
  7849. export class CubeTexture extends BaseTexture {
  7850. private _delayedOnLoad;
  7851. /**
  7852. * Observable triggered once the texture has been loaded.
  7853. */
  7854. onLoadObservable: Observable<CubeTexture>;
  7855. /**
  7856. * The url of the texture
  7857. */
  7858. url: string;
  7859. /**
  7860. * Gets or sets the center of the bounding box associated with the cube texture.
  7861. * It must define where the camera used to render the texture was set
  7862. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7863. */
  7864. boundingBoxPosition: Vector3;
  7865. private _boundingBoxSize;
  7866. /**
  7867. * Gets or sets the size of the bounding box associated with the cube texture
  7868. * When defined, the cubemap will switch to local mode
  7869. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7870. * @example https://www.babylonjs-playground.com/#RNASML
  7871. */
  7872. set boundingBoxSize(value: Vector3);
  7873. /**
  7874. * Returns the bounding box size
  7875. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7876. */
  7877. get boundingBoxSize(): Vector3;
  7878. protected _rotationY: number;
  7879. /**
  7880. * Sets texture matrix rotation angle around Y axis in radians.
  7881. */
  7882. set rotationY(value: number);
  7883. /**
  7884. * Gets texture matrix rotation angle around Y axis radians.
  7885. */
  7886. get rotationY(): number;
  7887. /**
  7888. * Are mip maps generated for this texture or not.
  7889. */
  7890. get noMipmap(): boolean;
  7891. private _noMipmap;
  7892. private _files;
  7893. protected _forcedExtension: Nullable<string>;
  7894. private _extensions;
  7895. private _textureMatrix;
  7896. private _format;
  7897. private _createPolynomials;
  7898. /**
  7899. * Creates a cube texture from an array of image urls
  7900. * @param files defines an array of image urls
  7901. * @param scene defines the hosting scene
  7902. * @param noMipmap specifies if mip maps are not used
  7903. * @returns a cube texture
  7904. */
  7905. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7906. /**
  7907. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7908. * @param url defines the url of the prefiltered texture
  7909. * @param scene defines the scene the texture is attached to
  7910. * @param forcedExtension defines the extension of the file if different from the url
  7911. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7912. * @return the prefiltered texture
  7913. */
  7914. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7915. /**
  7916. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7917. * as prefiltered data.
  7918. * @param rootUrl defines the url of the texture or the root name of the six images
  7919. * @param null defines the scene or engine the texture is attached to
  7920. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7921. * @param noMipmap defines if mipmaps should be created or not
  7922. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7923. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7924. * @param onError defines a callback triggered in case of error during load
  7925. * @param format defines the internal format to use for the texture once loaded
  7926. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7927. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7928. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7929. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7930. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7931. * @return the cube texture
  7932. */
  7933. 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);
  7934. /**
  7935. * Get the current class name of the texture useful for serialization or dynamic coding.
  7936. * @returns "CubeTexture"
  7937. */
  7938. getClassName(): string;
  7939. /**
  7940. * Update the url (and optional buffer) of this texture if url was null during construction.
  7941. * @param url the url of the texture
  7942. * @param forcedExtension defines the extension to use
  7943. * @param onLoad callback called when the texture is loaded (defaults to null)
  7944. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7945. */
  7946. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7947. /**
  7948. * Delays loading of the cube texture
  7949. * @param forcedExtension defines the extension to use
  7950. */
  7951. delayLoad(forcedExtension?: string): void;
  7952. /**
  7953. * Returns the reflection texture matrix
  7954. * @returns the reflection texture matrix
  7955. */
  7956. getReflectionTextureMatrix(): Matrix;
  7957. /**
  7958. * Sets the reflection texture matrix
  7959. * @param value Reflection texture matrix
  7960. */
  7961. setReflectionTextureMatrix(value: Matrix): void;
  7962. /**
  7963. * Parses text to create a cube texture
  7964. * @param parsedTexture define the serialized text to read from
  7965. * @param scene defines the hosting scene
  7966. * @param rootUrl defines the root url of the cube texture
  7967. * @returns a cube texture
  7968. */
  7969. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7970. /**
  7971. * Makes a clone, or deep copy, of the cube texture
  7972. * @returns a new cube texture
  7973. */
  7974. clone(): CubeTexture;
  7975. }
  7976. }
  7977. declare module BABYLON {
  7978. /**
  7979. * Manages the defines for the Material
  7980. */
  7981. export class MaterialDefines {
  7982. /** @hidden */
  7983. protected _keys: string[];
  7984. private _isDirty;
  7985. /** @hidden */
  7986. _renderId: number;
  7987. /** @hidden */
  7988. _areLightsDirty: boolean;
  7989. /** @hidden */
  7990. _areLightsDisposed: boolean;
  7991. /** @hidden */
  7992. _areAttributesDirty: boolean;
  7993. /** @hidden */
  7994. _areTexturesDirty: boolean;
  7995. /** @hidden */
  7996. _areFresnelDirty: boolean;
  7997. /** @hidden */
  7998. _areMiscDirty: boolean;
  7999. /** @hidden */
  8000. _areImageProcessingDirty: boolean;
  8001. /** @hidden */
  8002. _normals: boolean;
  8003. /** @hidden */
  8004. _uvs: boolean;
  8005. /** @hidden */
  8006. _needNormals: boolean;
  8007. /** @hidden */
  8008. _needUVs: boolean;
  8009. [id: string]: any;
  8010. /**
  8011. * Specifies if the material needs to be re-calculated
  8012. */
  8013. get isDirty(): boolean;
  8014. /**
  8015. * Marks the material to indicate that it has been re-calculated
  8016. */
  8017. markAsProcessed(): void;
  8018. /**
  8019. * Marks the material to indicate that it needs to be re-calculated
  8020. */
  8021. markAsUnprocessed(): void;
  8022. /**
  8023. * Marks the material to indicate all of its defines need to be re-calculated
  8024. */
  8025. markAllAsDirty(): void;
  8026. /**
  8027. * Marks the material to indicate that image processing needs to be re-calculated
  8028. */
  8029. markAsImageProcessingDirty(): void;
  8030. /**
  8031. * Marks the material to indicate the lights need to be re-calculated
  8032. * @param disposed Defines whether the light is dirty due to dispose or not
  8033. */
  8034. markAsLightDirty(disposed?: boolean): void;
  8035. /**
  8036. * Marks the attribute state as changed
  8037. */
  8038. markAsAttributesDirty(): void;
  8039. /**
  8040. * Marks the texture state as changed
  8041. */
  8042. markAsTexturesDirty(): void;
  8043. /**
  8044. * Marks the fresnel state as changed
  8045. */
  8046. markAsFresnelDirty(): void;
  8047. /**
  8048. * Marks the misc state as changed
  8049. */
  8050. markAsMiscDirty(): void;
  8051. /**
  8052. * Rebuilds the material defines
  8053. */
  8054. rebuild(): void;
  8055. /**
  8056. * Specifies if two material defines are equal
  8057. * @param other - A material define instance to compare to
  8058. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8059. */
  8060. isEqual(other: MaterialDefines): boolean;
  8061. /**
  8062. * Clones this instance's defines to another instance
  8063. * @param other - material defines to clone values to
  8064. */
  8065. cloneTo(other: MaterialDefines): void;
  8066. /**
  8067. * Resets the material define values
  8068. */
  8069. reset(): void;
  8070. /**
  8071. * Converts the material define values to a string
  8072. * @returns - String of material define information
  8073. */
  8074. toString(): string;
  8075. }
  8076. }
  8077. declare module BABYLON {
  8078. /**
  8079. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8080. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8081. * 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;
  8082. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8083. */
  8084. export class ColorCurves {
  8085. private _dirty;
  8086. private _tempColor;
  8087. private _globalCurve;
  8088. private _highlightsCurve;
  8089. private _midtonesCurve;
  8090. private _shadowsCurve;
  8091. private _positiveCurve;
  8092. private _negativeCurve;
  8093. private _globalHue;
  8094. private _globalDensity;
  8095. private _globalSaturation;
  8096. private _globalExposure;
  8097. /**
  8098. * Gets the global Hue value.
  8099. * 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).
  8100. */
  8101. get globalHue(): number;
  8102. /**
  8103. * Sets the global Hue value.
  8104. * 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).
  8105. */
  8106. set globalHue(value: number);
  8107. /**
  8108. * Gets the global Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. get globalDensity(): number;
  8113. /**
  8114. * Sets the global Density value.
  8115. * 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.
  8116. * Values less than zero provide a filter of opposite hue.
  8117. */
  8118. set globalDensity(value: number);
  8119. /**
  8120. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  8122. */
  8123. get globalSaturation(): number;
  8124. /**
  8125. * Sets the global Saturation value.
  8126. * 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.
  8127. */
  8128. set globalSaturation(value: number);
  8129. /**
  8130. * Gets the global Exposure value.
  8131. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8132. */
  8133. get globalExposure(): number;
  8134. /**
  8135. * Sets the global Exposure value.
  8136. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8137. */
  8138. set globalExposure(value: number);
  8139. private _highlightsHue;
  8140. private _highlightsDensity;
  8141. private _highlightsSaturation;
  8142. private _highlightsExposure;
  8143. /**
  8144. * Gets the highlights Hue value.
  8145. * 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).
  8146. */
  8147. get highlightsHue(): number;
  8148. /**
  8149. * Sets the highlights Hue value.
  8150. * 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).
  8151. */
  8152. set highlightsHue(value: number);
  8153. /**
  8154. * Gets the highlights Density value.
  8155. * 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.
  8156. * Values less than zero provide a filter of opposite hue.
  8157. */
  8158. get highlightsDensity(): number;
  8159. /**
  8160. * Sets the highlights Density value.
  8161. * 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.
  8162. * Values less than zero provide a filter of opposite hue.
  8163. */
  8164. set highlightsDensity(value: number);
  8165. /**
  8166. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  8168. */
  8169. get highlightsSaturation(): number;
  8170. /**
  8171. * Sets the highlights Saturation value.
  8172. * 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.
  8173. */
  8174. set highlightsSaturation(value: number);
  8175. /**
  8176. * Gets the highlights Exposure value.
  8177. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8178. */
  8179. get highlightsExposure(): number;
  8180. /**
  8181. * Sets the highlights Exposure value.
  8182. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8183. */
  8184. set highlightsExposure(value: number);
  8185. private _midtonesHue;
  8186. private _midtonesDensity;
  8187. private _midtonesSaturation;
  8188. private _midtonesExposure;
  8189. /**
  8190. * Gets the midtones Hue value.
  8191. * 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).
  8192. */
  8193. get midtonesHue(): number;
  8194. /**
  8195. * Sets the midtones Hue value.
  8196. * 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).
  8197. */
  8198. set midtonesHue(value: number);
  8199. /**
  8200. * Gets the midtones Density value.
  8201. * 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.
  8202. * Values less than zero provide a filter of opposite hue.
  8203. */
  8204. get midtonesDensity(): number;
  8205. /**
  8206. * Sets the midtones Density value.
  8207. * 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.
  8208. * Values less than zero provide a filter of opposite hue.
  8209. */
  8210. set midtonesDensity(value: number);
  8211. /**
  8212. * Gets the midtones Saturation value.
  8213. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8214. */
  8215. get midtonesSaturation(): number;
  8216. /**
  8217. * Sets the midtones Saturation value.
  8218. * 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.
  8219. */
  8220. set midtonesSaturation(value: number);
  8221. /**
  8222. * Gets the midtones Exposure value.
  8223. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8224. */
  8225. get midtonesExposure(): number;
  8226. /**
  8227. * Sets the midtones Exposure value.
  8228. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8229. */
  8230. set midtonesExposure(value: number);
  8231. private _shadowsHue;
  8232. private _shadowsDensity;
  8233. private _shadowsSaturation;
  8234. private _shadowsExposure;
  8235. /**
  8236. * Gets the shadows Hue value.
  8237. * 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).
  8238. */
  8239. get shadowsHue(): number;
  8240. /**
  8241. * Sets the shadows Hue value.
  8242. * 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).
  8243. */
  8244. set shadowsHue(value: number);
  8245. /**
  8246. * Gets the shadows Density value.
  8247. * 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.
  8248. * Values less than zero provide a filter of opposite hue.
  8249. */
  8250. get shadowsDensity(): number;
  8251. /**
  8252. * Sets the shadows Density value.
  8253. * 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.
  8254. * Values less than zero provide a filter of opposite hue.
  8255. */
  8256. set shadowsDensity(value: number);
  8257. /**
  8258. * Gets the shadows Saturation value.
  8259. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8260. */
  8261. get shadowsSaturation(): number;
  8262. /**
  8263. * Sets the shadows Saturation value.
  8264. * 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.
  8265. */
  8266. set shadowsSaturation(value: number);
  8267. /**
  8268. * Gets the shadows Exposure value.
  8269. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8270. */
  8271. get shadowsExposure(): number;
  8272. /**
  8273. * Sets the shadows Exposure value.
  8274. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8275. */
  8276. set shadowsExposure(value: number);
  8277. /**
  8278. * Returns the class name
  8279. * @returns The class name
  8280. */
  8281. getClassName(): string;
  8282. /**
  8283. * Binds the color curves to the shader.
  8284. * @param colorCurves The color curve to bind
  8285. * @param effect The effect to bind to
  8286. * @param positiveUniform The positive uniform shader parameter
  8287. * @param neutralUniform The neutral uniform shader parameter
  8288. * @param negativeUniform The negative uniform shader parameter
  8289. */
  8290. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8291. /**
  8292. * Prepare the list of uniforms associated with the ColorCurves effects.
  8293. * @param uniformsList The list of uniforms used in the effect
  8294. */
  8295. static PrepareUniforms(uniformsList: string[]): void;
  8296. /**
  8297. * Returns color grading data based on a hue, density, saturation and exposure value.
  8298. * @param filterHue The hue of the color filter.
  8299. * @param filterDensity The density of the color filter.
  8300. * @param saturation The saturation.
  8301. * @param exposure The exposure.
  8302. * @param result The result data container.
  8303. */
  8304. private getColorGradingDataToRef;
  8305. /**
  8306. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8307. * @param value The input slider value in range [-100,100].
  8308. * @returns Adjusted value.
  8309. */
  8310. private static applyColorGradingSliderNonlinear;
  8311. /**
  8312. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8313. * @param hue The hue (H) input.
  8314. * @param saturation The saturation (S) input.
  8315. * @param brightness The brightness (B) input.
  8316. * @result An RGBA color represented as Vector4.
  8317. */
  8318. private static fromHSBToRef;
  8319. /**
  8320. * Returns a value clamped between min and max
  8321. * @param value The value to clamp
  8322. * @param min The minimum of value
  8323. * @param max The maximum of value
  8324. * @returns The clamped value.
  8325. */
  8326. private static clamp;
  8327. /**
  8328. * Clones the current color curve instance.
  8329. * @return The cloned curves
  8330. */
  8331. clone(): ColorCurves;
  8332. /**
  8333. * Serializes the current color curve instance to a json representation.
  8334. * @return a JSON representation
  8335. */
  8336. serialize(): any;
  8337. /**
  8338. * Parses the color curve from a json representation.
  8339. * @param source the JSON source to parse
  8340. * @return The parsed curves
  8341. */
  8342. static Parse(source: any): ColorCurves;
  8343. }
  8344. }
  8345. declare module BABYLON {
  8346. /**
  8347. * Interface to follow in your material defines to integrate easily the
  8348. * Image proccessing functions.
  8349. * @hidden
  8350. */
  8351. export interface IImageProcessingConfigurationDefines {
  8352. IMAGEPROCESSING: boolean;
  8353. VIGNETTE: boolean;
  8354. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8355. VIGNETTEBLENDMODEOPAQUE: boolean;
  8356. TONEMAPPING: boolean;
  8357. TONEMAPPING_ACES: boolean;
  8358. CONTRAST: boolean;
  8359. EXPOSURE: boolean;
  8360. COLORCURVES: boolean;
  8361. COLORGRADING: boolean;
  8362. COLORGRADING3D: boolean;
  8363. SAMPLER3DGREENDEPTH: boolean;
  8364. SAMPLER3DBGRMAP: boolean;
  8365. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8366. }
  8367. /**
  8368. * @hidden
  8369. */
  8370. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8371. IMAGEPROCESSING: boolean;
  8372. VIGNETTE: boolean;
  8373. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8374. VIGNETTEBLENDMODEOPAQUE: boolean;
  8375. TONEMAPPING: boolean;
  8376. TONEMAPPING_ACES: boolean;
  8377. CONTRAST: boolean;
  8378. COLORCURVES: boolean;
  8379. COLORGRADING: boolean;
  8380. COLORGRADING3D: boolean;
  8381. SAMPLER3DGREENDEPTH: boolean;
  8382. SAMPLER3DBGRMAP: boolean;
  8383. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8384. EXPOSURE: boolean;
  8385. constructor();
  8386. }
  8387. /**
  8388. * This groups together the common properties used for image processing either in direct forward pass
  8389. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8390. * or not.
  8391. */
  8392. export class ImageProcessingConfiguration {
  8393. /**
  8394. * Default tone mapping applied in BabylonJS.
  8395. */
  8396. static readonly TONEMAPPING_STANDARD: number;
  8397. /**
  8398. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8399. * to other engines rendering to increase portability.
  8400. */
  8401. static readonly TONEMAPPING_ACES: number;
  8402. /**
  8403. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8404. */
  8405. colorCurves: Nullable<ColorCurves>;
  8406. private _colorCurvesEnabled;
  8407. /**
  8408. * Gets wether the color curves effect is enabled.
  8409. */
  8410. get colorCurvesEnabled(): boolean;
  8411. /**
  8412. * Sets wether the color curves effect is enabled.
  8413. */
  8414. set colorCurvesEnabled(value: boolean);
  8415. private _colorGradingTexture;
  8416. /**
  8417. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8418. */
  8419. get colorGradingTexture(): Nullable<BaseTexture>;
  8420. /**
  8421. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8422. */
  8423. set colorGradingTexture(value: Nullable<BaseTexture>);
  8424. private _colorGradingEnabled;
  8425. /**
  8426. * Gets wether the color grading effect is enabled.
  8427. */
  8428. get colorGradingEnabled(): boolean;
  8429. /**
  8430. * Sets wether the color grading effect is enabled.
  8431. */
  8432. set colorGradingEnabled(value: boolean);
  8433. private _colorGradingWithGreenDepth;
  8434. /**
  8435. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8436. */
  8437. get colorGradingWithGreenDepth(): boolean;
  8438. /**
  8439. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8440. */
  8441. set colorGradingWithGreenDepth(value: boolean);
  8442. private _colorGradingBGR;
  8443. /**
  8444. * Gets wether the color grading texture contains BGR values.
  8445. */
  8446. get colorGradingBGR(): boolean;
  8447. /**
  8448. * Sets wether the color grading texture contains BGR values.
  8449. */
  8450. set colorGradingBGR(value: boolean);
  8451. /** @hidden */
  8452. _exposure: number;
  8453. /**
  8454. * Gets the Exposure used in the effect.
  8455. */
  8456. get exposure(): number;
  8457. /**
  8458. * Sets the Exposure used in the effect.
  8459. */
  8460. set exposure(value: number);
  8461. private _toneMappingEnabled;
  8462. /**
  8463. * Gets wether the tone mapping effect is enabled.
  8464. */
  8465. get toneMappingEnabled(): boolean;
  8466. /**
  8467. * Sets wether the tone mapping effect is enabled.
  8468. */
  8469. set toneMappingEnabled(value: boolean);
  8470. private _toneMappingType;
  8471. /**
  8472. * Gets the type of tone mapping effect.
  8473. */
  8474. get toneMappingType(): number;
  8475. /**
  8476. * Sets the type of tone mapping effect used in BabylonJS.
  8477. */
  8478. set toneMappingType(value: number);
  8479. protected _contrast: number;
  8480. /**
  8481. * Gets the contrast used in the effect.
  8482. */
  8483. get contrast(): number;
  8484. /**
  8485. * Sets the contrast used in the effect.
  8486. */
  8487. set contrast(value: number);
  8488. /**
  8489. * Vignette stretch size.
  8490. */
  8491. vignetteStretch: number;
  8492. /**
  8493. * Vignette centre X Offset.
  8494. */
  8495. vignetteCentreX: number;
  8496. /**
  8497. * Vignette centre Y Offset.
  8498. */
  8499. vignetteCentreY: number;
  8500. /**
  8501. * Vignette weight or intensity of the vignette effect.
  8502. */
  8503. vignetteWeight: number;
  8504. /**
  8505. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8506. * if vignetteEnabled is set to true.
  8507. */
  8508. vignetteColor: Color4;
  8509. /**
  8510. * Camera field of view used by the Vignette effect.
  8511. */
  8512. vignetteCameraFov: number;
  8513. private _vignetteBlendMode;
  8514. /**
  8515. * Gets the vignette blend mode allowing different kind of effect.
  8516. */
  8517. get vignetteBlendMode(): number;
  8518. /**
  8519. * Sets the vignette blend mode allowing different kind of effect.
  8520. */
  8521. set vignetteBlendMode(value: number);
  8522. private _vignetteEnabled;
  8523. /**
  8524. * Gets wether the vignette effect is enabled.
  8525. */
  8526. get vignetteEnabled(): boolean;
  8527. /**
  8528. * Sets wether the vignette effect is enabled.
  8529. */
  8530. set vignetteEnabled(value: boolean);
  8531. private _applyByPostProcess;
  8532. /**
  8533. * Gets wether the image processing is applied through a post process or not.
  8534. */
  8535. get applyByPostProcess(): boolean;
  8536. /**
  8537. * Sets wether the image processing is applied through a post process or not.
  8538. */
  8539. set applyByPostProcess(value: boolean);
  8540. private _isEnabled;
  8541. /**
  8542. * Gets wether the image processing is enabled or not.
  8543. */
  8544. get isEnabled(): boolean;
  8545. /**
  8546. * Sets wether the image processing is enabled or not.
  8547. */
  8548. set isEnabled(value: boolean);
  8549. /**
  8550. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8551. */
  8552. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8553. /**
  8554. * Method called each time the image processing information changes requires to recompile the effect.
  8555. */
  8556. protected _updateParameters(): void;
  8557. /**
  8558. * Gets the current class name.
  8559. * @return "ImageProcessingConfiguration"
  8560. */
  8561. getClassName(): string;
  8562. /**
  8563. * Prepare the list of uniforms associated with the Image Processing effects.
  8564. * @param uniforms The list of uniforms used in the effect
  8565. * @param defines the list of defines currently in use
  8566. */
  8567. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8568. /**
  8569. * Prepare the list of samplers associated with the Image Processing effects.
  8570. * @param samplersList The list of uniforms used in the effect
  8571. * @param defines the list of defines currently in use
  8572. */
  8573. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8574. /**
  8575. * Prepare the list of defines associated to the shader.
  8576. * @param defines the list of defines to complete
  8577. * @param forPostProcess Define if we are currently in post process mode or not
  8578. */
  8579. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8580. /**
  8581. * Returns true if all the image processing information are ready.
  8582. * @returns True if ready, otherwise, false
  8583. */
  8584. isReady(): boolean;
  8585. /**
  8586. * Binds the image processing to the shader.
  8587. * @param effect The effect to bind to
  8588. * @param overrideAspectRatio Override the aspect ratio of the effect
  8589. */
  8590. bind(effect: Effect, overrideAspectRatio?: number): void;
  8591. /**
  8592. * Clones the current image processing instance.
  8593. * @return The cloned image processing
  8594. */
  8595. clone(): ImageProcessingConfiguration;
  8596. /**
  8597. * Serializes the current image processing instance to a json representation.
  8598. * @return a JSON representation
  8599. */
  8600. serialize(): any;
  8601. /**
  8602. * Parses the image processing from a json representation.
  8603. * @param source the JSON source to parse
  8604. * @return The parsed image processing
  8605. */
  8606. static Parse(source: any): ImageProcessingConfiguration;
  8607. private static _VIGNETTEMODE_MULTIPLY;
  8608. private static _VIGNETTEMODE_OPAQUE;
  8609. /**
  8610. * Used to apply the vignette as a mix with the pixel color.
  8611. */
  8612. static get VIGNETTEMODE_MULTIPLY(): number;
  8613. /**
  8614. * Used to apply the vignette as a replacement of the pixel color.
  8615. */
  8616. static get VIGNETTEMODE_OPAQUE(): number;
  8617. }
  8618. }
  8619. declare module BABYLON {
  8620. /** @hidden */
  8621. export var postprocessVertexShader: {
  8622. name: string;
  8623. shader: string;
  8624. };
  8625. }
  8626. declare module BABYLON {
  8627. /**
  8628. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8629. */
  8630. export type RenderTargetTextureSize = number | {
  8631. width: number;
  8632. height: number;
  8633. layers?: number;
  8634. };
  8635. interface ThinEngine {
  8636. /**
  8637. * Creates a new render target texture
  8638. * @param size defines the size of the texture
  8639. * @param options defines the options used to create the texture
  8640. * @returns a new render target texture stored in an InternalTexture
  8641. */
  8642. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8643. /**
  8644. * Creates a depth stencil texture.
  8645. * This is only available in WebGL 2 or with the depth texture extension available.
  8646. * @param size The size of face edge in the texture.
  8647. * @param options The options defining the texture.
  8648. * @returns The texture
  8649. */
  8650. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8651. /** @hidden */
  8652. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8653. }
  8654. }
  8655. declare module BABYLON {
  8656. /**
  8657. * Defines the kind of connection point for node based material
  8658. */
  8659. export enum NodeMaterialBlockConnectionPointTypes {
  8660. /** Float */
  8661. Float = 1,
  8662. /** Int */
  8663. Int = 2,
  8664. /** Vector2 */
  8665. Vector2 = 4,
  8666. /** Vector3 */
  8667. Vector3 = 8,
  8668. /** Vector4 */
  8669. Vector4 = 16,
  8670. /** Color3 */
  8671. Color3 = 32,
  8672. /** Color4 */
  8673. Color4 = 64,
  8674. /** Matrix */
  8675. Matrix = 128,
  8676. /** Custom object */
  8677. Object = 256,
  8678. /** Detect type based on connection */
  8679. AutoDetect = 1024,
  8680. /** Output type that will be defined by input type */
  8681. BasedOnInput = 2048
  8682. }
  8683. }
  8684. declare module BABYLON {
  8685. /**
  8686. * Enum used to define the target of a block
  8687. */
  8688. export enum NodeMaterialBlockTargets {
  8689. /** Vertex shader */
  8690. Vertex = 1,
  8691. /** Fragment shader */
  8692. Fragment = 2,
  8693. /** Neutral */
  8694. Neutral = 4,
  8695. /** Vertex and Fragment */
  8696. VertexAndFragment = 3
  8697. }
  8698. }
  8699. declare module BABYLON {
  8700. /**
  8701. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8702. */
  8703. export enum NodeMaterialBlockConnectionPointMode {
  8704. /** Value is an uniform */
  8705. Uniform = 0,
  8706. /** Value is a mesh attribute */
  8707. Attribute = 1,
  8708. /** Value is a varying between vertex and fragment shaders */
  8709. Varying = 2,
  8710. /** Mode is undefined */
  8711. Undefined = 3
  8712. }
  8713. }
  8714. declare module BABYLON {
  8715. /**
  8716. * Enum used to define system values e.g. values automatically provided by the system
  8717. */
  8718. export enum NodeMaterialSystemValues {
  8719. /** World */
  8720. World = 1,
  8721. /** View */
  8722. View = 2,
  8723. /** Projection */
  8724. Projection = 3,
  8725. /** ViewProjection */
  8726. ViewProjection = 4,
  8727. /** WorldView */
  8728. WorldView = 5,
  8729. /** WorldViewProjection */
  8730. WorldViewProjection = 6,
  8731. /** CameraPosition */
  8732. CameraPosition = 7,
  8733. /** Fog Color */
  8734. FogColor = 8,
  8735. /** Delta time */
  8736. DeltaTime = 9
  8737. }
  8738. }
  8739. declare module BABYLON {
  8740. /** Defines supported spaces */
  8741. export enum Space {
  8742. /** Local (object) space */
  8743. LOCAL = 0,
  8744. /** World space */
  8745. WORLD = 1,
  8746. /** Bone space */
  8747. BONE = 2
  8748. }
  8749. /** Defines the 3 main axes */
  8750. export class Axis {
  8751. /** X axis */
  8752. static X: Vector3;
  8753. /** Y axis */
  8754. static Y: Vector3;
  8755. /** Z axis */
  8756. static Z: Vector3;
  8757. }
  8758. }
  8759. declare module BABYLON {
  8760. /**
  8761. * Represents a camera frustum
  8762. */
  8763. export class Frustum {
  8764. /**
  8765. * Gets the planes representing the frustum
  8766. * @param transform matrix to be applied to the returned planes
  8767. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8768. */
  8769. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8770. /**
  8771. * Gets the near frustum plane transformed by the transform matrix
  8772. * @param transform transformation matrix to be applied to the resulting frustum plane
  8773. * @param frustumPlane the resuling frustum plane
  8774. */
  8775. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8776. /**
  8777. * Gets the far frustum plane transformed by the transform matrix
  8778. * @param transform transformation matrix to be applied to the resulting frustum plane
  8779. * @param frustumPlane the resuling frustum plane
  8780. */
  8781. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8782. /**
  8783. * Gets the left frustum plane transformed by the transform matrix
  8784. * @param transform transformation matrix to be applied to the resulting frustum plane
  8785. * @param frustumPlane the resuling frustum plane
  8786. */
  8787. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8788. /**
  8789. * Gets the right frustum plane transformed by the transform matrix
  8790. * @param transform transformation matrix to be applied to the resulting frustum plane
  8791. * @param frustumPlane the resuling frustum plane
  8792. */
  8793. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8794. /**
  8795. * Gets the top frustum plane transformed by the transform matrix
  8796. * @param transform transformation matrix to be applied to the resulting frustum plane
  8797. * @param frustumPlane the resuling frustum plane
  8798. */
  8799. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8800. /**
  8801. * Gets the bottom frustum plane transformed by the transform matrix
  8802. * @param transform transformation matrix to be applied to the resulting frustum plane
  8803. * @param frustumPlane the resuling frustum plane
  8804. */
  8805. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8806. /**
  8807. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8808. * @param transform transformation matrix to be applied to the resulting frustum planes
  8809. * @param frustumPlanes the resuling frustum planes
  8810. */
  8811. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8812. }
  8813. }
  8814. declare module BABYLON {
  8815. /**
  8816. * Interface for the size containing width and height
  8817. */
  8818. export interface ISize {
  8819. /**
  8820. * Width
  8821. */
  8822. width: number;
  8823. /**
  8824. * Heighht
  8825. */
  8826. height: number;
  8827. }
  8828. /**
  8829. * Size containing widht and height
  8830. */
  8831. export class Size implements ISize {
  8832. /**
  8833. * Width
  8834. */
  8835. width: number;
  8836. /**
  8837. * Height
  8838. */
  8839. height: number;
  8840. /**
  8841. * Creates a Size object from the given width and height (floats).
  8842. * @param width width of the new size
  8843. * @param height height of the new size
  8844. */
  8845. constructor(width: number, height: number);
  8846. /**
  8847. * Returns a string with the Size width and height
  8848. * @returns a string with the Size width and height
  8849. */
  8850. toString(): string;
  8851. /**
  8852. * "Size"
  8853. * @returns the string "Size"
  8854. */
  8855. getClassName(): string;
  8856. /**
  8857. * Returns the Size hash code.
  8858. * @returns a hash code for a unique width and height
  8859. */
  8860. getHashCode(): number;
  8861. /**
  8862. * Updates the current size from the given one.
  8863. * @param src the given size
  8864. */
  8865. copyFrom(src: Size): void;
  8866. /**
  8867. * Updates in place the current Size from the given floats.
  8868. * @param width width of the new size
  8869. * @param height height of the new size
  8870. * @returns the updated Size.
  8871. */
  8872. copyFromFloats(width: number, height: number): Size;
  8873. /**
  8874. * Updates in place the current Size from the given floats.
  8875. * @param width width to set
  8876. * @param height height to set
  8877. * @returns the updated Size.
  8878. */
  8879. set(width: number, height: number): Size;
  8880. /**
  8881. * Multiplies the width and height by numbers
  8882. * @param w factor to multiple the width by
  8883. * @param h factor to multiple the height by
  8884. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8885. */
  8886. multiplyByFloats(w: number, h: number): Size;
  8887. /**
  8888. * Clones the size
  8889. * @returns a new Size copied from the given one.
  8890. */
  8891. clone(): Size;
  8892. /**
  8893. * True if the current Size and the given one width and height are strictly equal.
  8894. * @param other the other size to compare against
  8895. * @returns True if the current Size and the given one width and height are strictly equal.
  8896. */
  8897. equals(other: Size): boolean;
  8898. /**
  8899. * The surface of the Size : width * height (float).
  8900. */
  8901. get surface(): number;
  8902. /**
  8903. * Create a new size of zero
  8904. * @returns a new Size set to (0.0, 0.0)
  8905. */
  8906. static Zero(): Size;
  8907. /**
  8908. * Sums the width and height of two sizes
  8909. * @param otherSize size to add to this size
  8910. * @returns a new Size set as the addition result of the current Size and the given one.
  8911. */
  8912. add(otherSize: Size): Size;
  8913. /**
  8914. * Subtracts the width and height of two
  8915. * @param otherSize size to subtract to this size
  8916. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8917. */
  8918. subtract(otherSize: Size): Size;
  8919. /**
  8920. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8921. * @param start starting size to lerp between
  8922. * @param end end size to lerp between
  8923. * @param amount amount to lerp between the start and end values
  8924. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8925. */
  8926. static Lerp(start: Size, end: Size, amount: number): Size;
  8927. }
  8928. }
  8929. declare module BABYLON {
  8930. /**
  8931. * Contains position and normal vectors for a vertex
  8932. */
  8933. export class PositionNormalVertex {
  8934. /** the position of the vertex (defaut: 0,0,0) */
  8935. position: Vector3;
  8936. /** the normal of the vertex (defaut: 0,1,0) */
  8937. normal: Vector3;
  8938. /**
  8939. * Creates a PositionNormalVertex
  8940. * @param position the position of the vertex (defaut: 0,0,0)
  8941. * @param normal the normal of the vertex (defaut: 0,1,0)
  8942. */
  8943. constructor(
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position?: Vector3,
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal?: Vector3);
  8948. /**
  8949. * Clones the PositionNormalVertex
  8950. * @returns the cloned PositionNormalVertex
  8951. */
  8952. clone(): PositionNormalVertex;
  8953. }
  8954. /**
  8955. * Contains position, normal and uv vectors for a vertex
  8956. */
  8957. export class PositionNormalTextureVertex {
  8958. /** the position of the vertex (defaut: 0,0,0) */
  8959. position: Vector3;
  8960. /** the normal of the vertex (defaut: 0,1,0) */
  8961. normal: Vector3;
  8962. /** the uv of the vertex (default: 0,0) */
  8963. uv: Vector2;
  8964. /**
  8965. * Creates a PositionNormalTextureVertex
  8966. * @param position the position of the vertex (defaut: 0,0,0)
  8967. * @param normal the normal of the vertex (defaut: 0,1,0)
  8968. * @param uv the uv of the vertex (default: 0,0)
  8969. */
  8970. constructor(
  8971. /** the position of the vertex (defaut: 0,0,0) */
  8972. position?: Vector3,
  8973. /** the normal of the vertex (defaut: 0,1,0) */
  8974. normal?: Vector3,
  8975. /** the uv of the vertex (default: 0,0) */
  8976. uv?: Vector2);
  8977. /**
  8978. * Clones the PositionNormalTextureVertex
  8979. * @returns the cloned PositionNormalTextureVertex
  8980. */
  8981. clone(): PositionNormalTextureVertex;
  8982. }
  8983. }
  8984. declare module BABYLON {
  8985. /**
  8986. * Enum defining the type of animations supported by InputBlock
  8987. */
  8988. export enum AnimatedInputBlockTypes {
  8989. /** No animation */
  8990. None = 0,
  8991. /** Time based animation. Will only work for floats */
  8992. Time = 1
  8993. }
  8994. }
  8995. declare module BABYLON {
  8996. /**
  8997. * Interface describing all the common properties and methods a shadow light needs to implement.
  8998. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8999. * as well as binding the different shadow properties to the effects.
  9000. */
  9001. export interface IShadowLight extends Light {
  9002. /**
  9003. * The light id in the scene (used in scene.findLighById for instance)
  9004. */
  9005. id: string;
  9006. /**
  9007. * The position the shdow will be casted from.
  9008. */
  9009. position: Vector3;
  9010. /**
  9011. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9012. */
  9013. direction: Vector3;
  9014. /**
  9015. * The transformed position. Position of the light in world space taking parenting in account.
  9016. */
  9017. transformedPosition: Vector3;
  9018. /**
  9019. * The transformed direction. Direction of the light in world space taking parenting in account.
  9020. */
  9021. transformedDirection: Vector3;
  9022. /**
  9023. * The friendly name of the light in the scene.
  9024. */
  9025. name: string;
  9026. /**
  9027. * Defines the shadow projection clipping minimum z value.
  9028. */
  9029. shadowMinZ: number;
  9030. /**
  9031. * Defines the shadow projection clipping maximum z value.
  9032. */
  9033. shadowMaxZ: number;
  9034. /**
  9035. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9036. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9037. */
  9038. computeTransformedInformation(): boolean;
  9039. /**
  9040. * Gets the scene the light belongs to.
  9041. * @returns The scene
  9042. */
  9043. getScene(): Scene;
  9044. /**
  9045. * Callback defining a custom Projection Matrix Builder.
  9046. * This can be used to override the default projection matrix computation.
  9047. */
  9048. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9049. /**
  9050. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9051. * @param matrix The materix to updated with the projection information
  9052. * @param viewMatrix The transform matrix of the light
  9053. * @param renderList The list of mesh to render in the map
  9054. * @returns The current light
  9055. */
  9056. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9057. /**
  9058. * Gets the current depth scale used in ESM.
  9059. * @returns The scale
  9060. */
  9061. getDepthScale(): number;
  9062. /**
  9063. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9064. * @returns true if a cube texture needs to be use
  9065. */
  9066. needCube(): boolean;
  9067. /**
  9068. * Detects if the projection matrix requires to be recomputed this frame.
  9069. * @returns true if it requires to be recomputed otherwise, false.
  9070. */
  9071. needProjectionMatrixCompute(): boolean;
  9072. /**
  9073. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9074. */
  9075. forceProjectionMatrixCompute(): void;
  9076. /**
  9077. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9078. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9079. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9080. */
  9081. getShadowDirection(faceIndex?: number): Vector3;
  9082. /**
  9083. * Gets the minZ used for shadow according to both the scene and the light.
  9084. * @param activeCamera The camera we are returning the min for
  9085. * @returns the depth min z
  9086. */
  9087. getDepthMinZ(activeCamera: Camera): number;
  9088. /**
  9089. * Gets the maxZ used for shadow according to both the scene and the light.
  9090. * @param activeCamera The camera we are returning the max for
  9091. * @returns the depth max z
  9092. */
  9093. getDepthMaxZ(activeCamera: Camera): number;
  9094. }
  9095. /**
  9096. * Base implementation IShadowLight
  9097. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9098. */
  9099. export abstract class ShadowLight extends Light implements IShadowLight {
  9100. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9101. protected _position: Vector3;
  9102. protected _setPosition(value: Vector3): void;
  9103. /**
  9104. * Sets the position the shadow will be casted from. Also use as the light position for both
  9105. * point and spot lights.
  9106. */
  9107. get position(): Vector3;
  9108. /**
  9109. * Sets the position the shadow will be casted from. Also use as the light position for both
  9110. * point and spot lights.
  9111. */
  9112. set position(value: Vector3);
  9113. protected _direction: Vector3;
  9114. protected _setDirection(value: Vector3): void;
  9115. /**
  9116. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9117. * Also use as the light direction on spot and directional lights.
  9118. */
  9119. get direction(): Vector3;
  9120. /**
  9121. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9122. * Also use as the light direction on spot and directional lights.
  9123. */
  9124. set direction(value: Vector3);
  9125. protected _shadowMinZ: number;
  9126. /**
  9127. * Gets the shadow projection clipping minimum z value.
  9128. */
  9129. get shadowMinZ(): number;
  9130. /**
  9131. * Sets the shadow projection clipping minimum z value.
  9132. */
  9133. set shadowMinZ(value: number);
  9134. protected _shadowMaxZ: number;
  9135. /**
  9136. * Sets the shadow projection clipping maximum z value.
  9137. */
  9138. get shadowMaxZ(): number;
  9139. /**
  9140. * Gets the shadow projection clipping maximum z value.
  9141. */
  9142. set shadowMaxZ(value: number);
  9143. /**
  9144. * Callback defining a custom Projection Matrix Builder.
  9145. * This can be used to override the default projection matrix computation.
  9146. */
  9147. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9148. /**
  9149. * The transformed position. Position of the light in world space taking parenting in account.
  9150. */
  9151. transformedPosition: Vector3;
  9152. /**
  9153. * The transformed direction. Direction of the light in world space taking parenting in account.
  9154. */
  9155. transformedDirection: Vector3;
  9156. private _needProjectionMatrixCompute;
  9157. /**
  9158. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9159. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9160. */
  9161. computeTransformedInformation(): boolean;
  9162. /**
  9163. * Return the depth scale used for the shadow map.
  9164. * @returns the depth scale.
  9165. */
  9166. getDepthScale(): number;
  9167. /**
  9168. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9169. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9170. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9171. */
  9172. getShadowDirection(faceIndex?: number): Vector3;
  9173. /**
  9174. * Returns the ShadowLight absolute position in the World.
  9175. * @returns the position vector in world space
  9176. */
  9177. getAbsolutePosition(): Vector3;
  9178. /**
  9179. * Sets the ShadowLight direction toward the passed target.
  9180. * @param target The point to target in local space
  9181. * @returns the updated ShadowLight direction
  9182. */
  9183. setDirectionToTarget(target: Vector3): Vector3;
  9184. /**
  9185. * Returns the light rotation in euler definition.
  9186. * @returns the x y z rotation in local space.
  9187. */
  9188. getRotation(): Vector3;
  9189. /**
  9190. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9191. * @returns true if a cube texture needs to be use
  9192. */
  9193. needCube(): boolean;
  9194. /**
  9195. * Detects if the projection matrix requires to be recomputed this frame.
  9196. * @returns true if it requires to be recomputed otherwise, false.
  9197. */
  9198. needProjectionMatrixCompute(): boolean;
  9199. /**
  9200. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9201. */
  9202. forceProjectionMatrixCompute(): void;
  9203. /** @hidden */
  9204. _initCache(): void;
  9205. /** @hidden */
  9206. _isSynchronized(): boolean;
  9207. /**
  9208. * Computes the world matrix of the node
  9209. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9210. * @returns the world matrix
  9211. */
  9212. computeWorldMatrix(force?: boolean): Matrix;
  9213. /**
  9214. * Gets the minZ used for shadow according to both the scene and the light.
  9215. * @param activeCamera The camera we are returning the min for
  9216. * @returns the depth min z
  9217. */
  9218. getDepthMinZ(activeCamera: Camera): number;
  9219. /**
  9220. * Gets the maxZ used for shadow according to both the scene and the light.
  9221. * @param activeCamera The camera we are returning the max for
  9222. * @returns the depth max z
  9223. */
  9224. getDepthMaxZ(activeCamera: Camera): number;
  9225. /**
  9226. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9227. * @param matrix The materix to updated with the projection information
  9228. * @param viewMatrix The transform matrix of the light
  9229. * @param renderList The list of mesh to render in the map
  9230. * @returns The current light
  9231. */
  9232. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9233. }
  9234. }
  9235. declare module BABYLON {
  9236. /** @hidden */
  9237. export var packingFunctions: {
  9238. name: string;
  9239. shader: string;
  9240. };
  9241. }
  9242. declare module BABYLON {
  9243. /** @hidden */
  9244. export var bayerDitherFunctions: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module BABYLON {
  9250. /** @hidden */
  9251. export var shadowMapFragmentDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module BABYLON {
  9257. /** @hidden */
  9258. export var clipPlaneFragmentDeclaration: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module BABYLON {
  9264. /** @hidden */
  9265. export var clipPlaneFragment: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module BABYLON {
  9271. /** @hidden */
  9272. export var shadowMapFragment: {
  9273. name: string;
  9274. shader: string;
  9275. };
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var shadowMapPixelShader: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var bonesDeclaration: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var morphTargetsVertexGlobalDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var morphTargetsVertexDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var instancesDeclaration: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var helperFunctions: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var shadowMapVertexDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var clipPlaneVertexDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertex: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var instancesVertex: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var bonesVertex: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var shadowMapVertexNormalBias: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var shadowMapVertexMetric: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var clipPlaneVertex: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var shadowMapVertexShader: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var depthBoxBlurPixelShader: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var shadowMapFragmentSoftTransparentShadow: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /**
  9398. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9399. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9400. */
  9401. export class EffectFallbacks implements IEffectFallbacks {
  9402. private _defines;
  9403. private _currentRank;
  9404. private _maxRank;
  9405. private _mesh;
  9406. /**
  9407. * Removes the fallback from the bound mesh.
  9408. */
  9409. unBindMesh(): void;
  9410. /**
  9411. * Adds a fallback on the specified property.
  9412. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9413. * @param define The name of the define in the shader
  9414. */
  9415. addFallback(rank: number, define: string): void;
  9416. /**
  9417. * Sets the mesh to use CPU skinning when needing to fallback.
  9418. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9419. * @param mesh The mesh to use the fallbacks.
  9420. */
  9421. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9422. /**
  9423. * Checks to see if more fallbacks are still availible.
  9424. */
  9425. get hasMoreFallbacks(): boolean;
  9426. /**
  9427. * Removes the defines that should be removed when falling back.
  9428. * @param currentDefines defines the current define statements for the shader.
  9429. * @param effect defines the current effect we try to compile
  9430. * @returns The resulting defines with defines of the current rank removed.
  9431. */
  9432. reduce(currentDefines: string, effect: Effect): string;
  9433. }
  9434. }
  9435. declare module BABYLON {
  9436. /**
  9437. * Interface used to define Action
  9438. */
  9439. export interface IAction {
  9440. /**
  9441. * Trigger for the action
  9442. */
  9443. trigger: number;
  9444. /** Options of the trigger */
  9445. triggerOptions: any;
  9446. /**
  9447. * Gets the trigger parameters
  9448. * @returns the trigger parameters
  9449. */
  9450. getTriggerParameter(): any;
  9451. /**
  9452. * Internal only - executes current action event
  9453. * @hidden
  9454. */
  9455. _executeCurrent(evt?: ActionEvent): void;
  9456. /**
  9457. * Serialize placeholder for child classes
  9458. * @param parent of child
  9459. * @returns the serialized object
  9460. */
  9461. serialize(parent: any): any;
  9462. /**
  9463. * Internal only
  9464. * @hidden
  9465. */
  9466. _prepare(): void;
  9467. /**
  9468. * Internal only - manager for action
  9469. * @hidden
  9470. */
  9471. _actionManager: Nullable<AbstractActionManager>;
  9472. /**
  9473. * Adds action to chain of actions, may be a DoNothingAction
  9474. * @param action defines the next action to execute
  9475. * @returns The action passed in
  9476. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9477. */
  9478. then(action: IAction): IAction;
  9479. }
  9480. /**
  9481. * The action to be carried out following a trigger
  9482. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9483. */
  9484. export class Action implements IAction {
  9485. /** the trigger, with or without parameters, for the action */
  9486. triggerOptions: any;
  9487. /**
  9488. * Trigger for the action
  9489. */
  9490. trigger: number;
  9491. /**
  9492. * Internal only - manager for action
  9493. * @hidden
  9494. */
  9495. _actionManager: ActionManager;
  9496. private _nextActiveAction;
  9497. private _child;
  9498. private _condition?;
  9499. private _triggerParameter;
  9500. /**
  9501. * An event triggered prior to action being executed.
  9502. */
  9503. onBeforeExecuteObservable: Observable<Action>;
  9504. /**
  9505. * Creates a new Action
  9506. * @param triggerOptions the trigger, with or without parameters, for the action
  9507. * @param condition an optional determinant of action
  9508. */
  9509. constructor(
  9510. /** the trigger, with or without parameters, for the action */
  9511. triggerOptions: any, condition?: Condition);
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. _prepare(): void;
  9517. /**
  9518. * Gets the trigger parameters
  9519. * @returns the trigger parameters
  9520. */
  9521. getTriggerParameter(): any;
  9522. /**
  9523. * Internal only - executes current action event
  9524. * @hidden
  9525. */
  9526. _executeCurrent(evt?: ActionEvent): void;
  9527. /**
  9528. * Execute placeholder for child classes
  9529. * @param evt optional action event
  9530. */
  9531. execute(evt?: ActionEvent): void;
  9532. /**
  9533. * Skips to next active action
  9534. */
  9535. skipToNextActiveAction(): void;
  9536. /**
  9537. * Adds action to chain of actions, may be a DoNothingAction
  9538. * @param action defines the next action to execute
  9539. * @returns The action passed in
  9540. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9541. */
  9542. then(action: Action): Action;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. _getProperty(propertyPath: string): string;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. _getEffectiveTarget(target: any, propertyPath: string): any;
  9553. /**
  9554. * Serialize placeholder for child classes
  9555. * @param parent of child
  9556. * @returns the serialized object
  9557. */
  9558. serialize(parent: any): any;
  9559. /**
  9560. * Internal only called by serialize
  9561. * @hidden
  9562. */
  9563. protected _serialize(serializedAction: any, parent?: any): any;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. static _SerializeValueAsString: (value: any) => string;
  9569. /**
  9570. * Internal only
  9571. * @hidden
  9572. */
  9573. static _GetTargetProperty: (target: Scene | Node) => {
  9574. name: string;
  9575. targetType: string;
  9576. value: string;
  9577. };
  9578. }
  9579. }
  9580. declare module BABYLON {
  9581. /**
  9582. * A Condition applied to an Action
  9583. */
  9584. export class Condition {
  9585. /**
  9586. * Internal only - manager for action
  9587. * @hidden
  9588. */
  9589. _actionManager: ActionManager;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. _evaluationId: number;
  9595. /**
  9596. * Internal only
  9597. * @hidden
  9598. */
  9599. _currentResult: boolean;
  9600. /**
  9601. * Creates a new Condition
  9602. * @param actionManager the manager of the action the condition is applied to
  9603. */
  9604. constructor(actionManager: ActionManager);
  9605. /**
  9606. * Check if the current condition is valid
  9607. * @returns a boolean
  9608. */
  9609. isValid(): boolean;
  9610. /**
  9611. * Internal only
  9612. * @hidden
  9613. */
  9614. _getProperty(propertyPath: string): string;
  9615. /**
  9616. * Internal only
  9617. * @hidden
  9618. */
  9619. _getEffectiveTarget(target: any, propertyPath: string): any;
  9620. /**
  9621. * Serialize placeholder for child classes
  9622. * @returns the serialized object
  9623. */
  9624. serialize(): any;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. protected _serialize(serializedCondition: any): any;
  9630. }
  9631. /**
  9632. * Defines specific conditional operators as extensions of Condition
  9633. */
  9634. export class ValueCondition extends Condition {
  9635. /** path to specify the property of the target the conditional operator uses */
  9636. propertyPath: string;
  9637. /** the value compared by the conditional operator against the current value of the property */
  9638. value: any;
  9639. /** the conditional operator, default ValueCondition.IsEqual */
  9640. operator: number;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. private static _IsEqual;
  9646. /**
  9647. * Internal only
  9648. * @hidden
  9649. */
  9650. private static _IsDifferent;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. private static _IsGreater;
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. private static _IsLesser;
  9661. /**
  9662. * returns the number for IsEqual
  9663. */
  9664. static get IsEqual(): number;
  9665. /**
  9666. * Returns the number for IsDifferent
  9667. */
  9668. static get IsDifferent(): number;
  9669. /**
  9670. * Returns the number for IsGreater
  9671. */
  9672. static get IsGreater(): number;
  9673. /**
  9674. * Returns the number for IsLesser
  9675. */
  9676. static get IsLesser(): number;
  9677. /**
  9678. * Internal only The action manager for the condition
  9679. * @hidden
  9680. */
  9681. _actionManager: ActionManager;
  9682. /**
  9683. * Internal only
  9684. * @hidden
  9685. */
  9686. private _target;
  9687. /**
  9688. * Internal only
  9689. * @hidden
  9690. */
  9691. private _effectiveTarget;
  9692. /**
  9693. * Internal only
  9694. * @hidden
  9695. */
  9696. private _property;
  9697. /**
  9698. * Creates a new ValueCondition
  9699. * @param actionManager manager for the action the condition applies to
  9700. * @param target for the action
  9701. * @param propertyPath path to specify the property of the target the conditional operator uses
  9702. * @param value the value compared by the conditional operator against the current value of the property
  9703. * @param operator the conditional operator, default ValueCondition.IsEqual
  9704. */
  9705. constructor(actionManager: ActionManager, target: any,
  9706. /** path to specify the property of the target the conditional operator uses */
  9707. propertyPath: string,
  9708. /** the value compared by the conditional operator against the current value of the property */
  9709. value: any,
  9710. /** the conditional operator, default ValueCondition.IsEqual */
  9711. operator?: number);
  9712. /**
  9713. * Compares the given value with the property value for the specified conditional operator
  9714. * @returns the result of the comparison
  9715. */
  9716. isValid(): boolean;
  9717. /**
  9718. * Serialize the ValueCondition into a JSON compatible object
  9719. * @returns serialization object
  9720. */
  9721. serialize(): any;
  9722. /**
  9723. * Gets the name of the conditional operator for the ValueCondition
  9724. * @param operator the conditional operator
  9725. * @returns the name
  9726. */
  9727. static GetOperatorName(operator: number): string;
  9728. }
  9729. /**
  9730. * Defines a predicate condition as an extension of Condition
  9731. */
  9732. export class PredicateCondition extends Condition {
  9733. /** defines the predicate function used to validate the condition */
  9734. predicate: () => boolean;
  9735. /**
  9736. * Internal only - manager for action
  9737. * @hidden
  9738. */
  9739. _actionManager: ActionManager;
  9740. /**
  9741. * Creates a new PredicateCondition
  9742. * @param actionManager manager for the action the condition applies to
  9743. * @param predicate defines the predicate function used to validate the condition
  9744. */
  9745. constructor(actionManager: ActionManager,
  9746. /** defines the predicate function used to validate the condition */
  9747. predicate: () => boolean);
  9748. /**
  9749. * @returns the validity of the predicate condition
  9750. */
  9751. isValid(): boolean;
  9752. }
  9753. /**
  9754. * Defines a state condition as an extension of Condition
  9755. */
  9756. export class StateCondition extends Condition {
  9757. /** Value to compare with target state */
  9758. value: string;
  9759. /**
  9760. * Internal only - manager for action
  9761. * @hidden
  9762. */
  9763. _actionManager: ActionManager;
  9764. /**
  9765. * Internal only
  9766. * @hidden
  9767. */
  9768. private _target;
  9769. /**
  9770. * Creates a new StateCondition
  9771. * @param actionManager manager for the action the condition applies to
  9772. * @param target of the condition
  9773. * @param value to compare with target state
  9774. */
  9775. constructor(actionManager: ActionManager, target: any,
  9776. /** Value to compare with target state */
  9777. value: string);
  9778. /**
  9779. * Gets a boolean indicating if the current condition is met
  9780. * @returns the validity of the state
  9781. */
  9782. isValid(): boolean;
  9783. /**
  9784. * Serialize the StateCondition into a JSON compatible object
  9785. * @returns serialization object
  9786. */
  9787. serialize(): any;
  9788. }
  9789. }
  9790. declare module BABYLON {
  9791. /**
  9792. * This defines an action responsible to toggle a boolean once triggered.
  9793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9794. */
  9795. export class SwitchBooleanAction extends Action {
  9796. /**
  9797. * The path to the boolean property in the target object
  9798. */
  9799. propertyPath: string;
  9800. private _target;
  9801. private _effectiveTarget;
  9802. private _property;
  9803. /**
  9804. * Instantiate the action
  9805. * @param triggerOptions defines the trigger options
  9806. * @param target defines the object containing the boolean
  9807. * @param propertyPath defines the path to the boolean property in the target object
  9808. * @param condition defines the trigger related conditions
  9809. */
  9810. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9811. /** @hidden */
  9812. _prepare(): void;
  9813. /**
  9814. * Execute the action toggle the boolean value.
  9815. */
  9816. execute(): void;
  9817. /**
  9818. * Serializes the actions and its related information.
  9819. * @param parent defines the object to serialize in
  9820. * @returns the serialized object
  9821. */
  9822. serialize(parent: any): any;
  9823. }
  9824. /**
  9825. * This defines an action responsible to set a the state field of the target
  9826. * to a desired value once triggered.
  9827. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9828. */
  9829. export class SetStateAction extends Action {
  9830. /**
  9831. * The value to store in the state field.
  9832. */
  9833. value: string;
  9834. private _target;
  9835. /**
  9836. * Instantiate the action
  9837. * @param triggerOptions defines the trigger options
  9838. * @param target defines the object containing the state property
  9839. * @param value defines the value to store in the state field
  9840. * @param condition defines the trigger related conditions
  9841. */
  9842. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9843. /**
  9844. * Execute the action and store the value on the target state property.
  9845. */
  9846. execute(): void;
  9847. /**
  9848. * Serializes the actions and its related information.
  9849. * @param parent defines the object to serialize in
  9850. * @returns the serialized object
  9851. */
  9852. serialize(parent: any): any;
  9853. }
  9854. /**
  9855. * This defines an action responsible to set a property of the target
  9856. * to a desired value once triggered.
  9857. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9858. */
  9859. export class SetValueAction extends Action {
  9860. /**
  9861. * The path of the property to set in the target.
  9862. */
  9863. propertyPath: string;
  9864. /**
  9865. * The value to set in the property
  9866. */
  9867. value: any;
  9868. private _target;
  9869. private _effectiveTarget;
  9870. private _property;
  9871. /**
  9872. * Instantiate the action
  9873. * @param triggerOptions defines the trigger options
  9874. * @param target defines the object containing the property
  9875. * @param propertyPath defines the path of the property to set in the target
  9876. * @param value defines the value to set in the property
  9877. * @param condition defines the trigger related conditions
  9878. */
  9879. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9880. /** @hidden */
  9881. _prepare(): void;
  9882. /**
  9883. * Execute the action and set the targetted property to the desired value.
  9884. */
  9885. execute(): void;
  9886. /**
  9887. * Serializes the actions and its related information.
  9888. * @param parent defines the object to serialize in
  9889. * @returns the serialized object
  9890. */
  9891. serialize(parent: any): any;
  9892. }
  9893. /**
  9894. * This defines an action responsible to increment the target value
  9895. * to a desired value once triggered.
  9896. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9897. */
  9898. export class IncrementValueAction extends Action {
  9899. /**
  9900. * The path of the property to increment in the target.
  9901. */
  9902. propertyPath: string;
  9903. /**
  9904. * The value we should increment the property by.
  9905. */
  9906. value: any;
  9907. private _target;
  9908. private _effectiveTarget;
  9909. private _property;
  9910. /**
  9911. * Instantiate the action
  9912. * @param triggerOptions defines the trigger options
  9913. * @param target defines the object containing the property
  9914. * @param propertyPath defines the path of the property to increment in the target
  9915. * @param value defines the value value we should increment the property by
  9916. * @param condition defines the trigger related conditions
  9917. */
  9918. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9919. /** @hidden */
  9920. _prepare(): void;
  9921. /**
  9922. * Execute the action and increment the target of the value amount.
  9923. */
  9924. execute(): void;
  9925. /**
  9926. * Serializes the actions and its related information.
  9927. * @param parent defines the object to serialize in
  9928. * @returns the serialized object
  9929. */
  9930. serialize(parent: any): any;
  9931. }
  9932. /**
  9933. * This defines an action responsible to start an animation once triggered.
  9934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9935. */
  9936. export class PlayAnimationAction extends Action {
  9937. /**
  9938. * Where the animation should start (animation frame)
  9939. */
  9940. from: number;
  9941. /**
  9942. * Where the animation should stop (animation frame)
  9943. */
  9944. to: number;
  9945. /**
  9946. * Define if the animation should loop or stop after the first play.
  9947. */
  9948. loop?: boolean;
  9949. private _target;
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param target defines the target animation or animation name
  9954. * @param from defines from where the animation should start (animation frame)
  9955. * @param end defines where the animation should stop (animation frame)
  9956. * @param loop defines if the animation should loop or stop after the first play
  9957. * @param condition defines the trigger related conditions
  9958. */
  9959. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9960. /** @hidden */
  9961. _prepare(): void;
  9962. /**
  9963. * Execute the action and play the animation.
  9964. */
  9965. execute(): void;
  9966. /**
  9967. * Serializes the actions and its related information.
  9968. * @param parent defines the object to serialize in
  9969. * @returns the serialized object
  9970. */
  9971. serialize(parent: any): any;
  9972. }
  9973. /**
  9974. * This defines an action responsible to stop an animation once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class StopAnimationAction extends Action {
  9978. private _target;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the target animation or animation name
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and stop the animation.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible that does nothing once triggered.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class DoNothingAction extends Action {
  10004. /**
  10005. * Instantiate the action
  10006. * @param triggerOptions defines the trigger options
  10007. * @param condition defines the trigger related conditions
  10008. */
  10009. constructor(triggerOptions?: any, condition?: Condition);
  10010. /**
  10011. * Execute the action and do nothing.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible to trigger several actions once triggered.
  10023. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class CombineAction extends Action {
  10026. /**
  10027. * The list of aggregated animations to run.
  10028. */
  10029. children: Action[];
  10030. /**
  10031. * Instantiate the action
  10032. * @param triggerOptions defines the trigger options
  10033. * @param children defines the list of aggregated animations to run
  10034. * @param condition defines the trigger related conditions
  10035. */
  10036. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10037. /** @hidden */
  10038. _prepare(): void;
  10039. /**
  10040. * Execute the action and executes all the aggregated actions.
  10041. */
  10042. execute(evt: ActionEvent): void;
  10043. /**
  10044. * Serializes the actions and its related information.
  10045. * @param parent defines the object to serialize in
  10046. * @returns the serialized object
  10047. */
  10048. serialize(parent: any): any;
  10049. }
  10050. /**
  10051. * This defines an action responsible to run code (external event) once triggered.
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10053. */
  10054. export class ExecuteCodeAction extends Action {
  10055. /**
  10056. * The callback function to run.
  10057. */
  10058. func: (evt: ActionEvent) => void;
  10059. /**
  10060. * Instantiate the action
  10061. * @param triggerOptions defines the trigger options
  10062. * @param func defines the callback function to run
  10063. * @param condition defines the trigger related conditions
  10064. */
  10065. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10066. /**
  10067. * Execute the action and run the attached code.
  10068. */
  10069. execute(evt: ActionEvent): void;
  10070. }
  10071. /**
  10072. * This defines an action responsible to set the parent property of the target once triggered.
  10073. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10074. */
  10075. export class SetParentAction extends Action {
  10076. private _parent;
  10077. private _target;
  10078. /**
  10079. * Instantiate the action
  10080. * @param triggerOptions defines the trigger options
  10081. * @param target defines the target containing the parent property
  10082. * @param parent defines from where the animation should start (animation frame)
  10083. * @param condition defines the trigger related conditions
  10084. */
  10085. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10086. /** @hidden */
  10087. _prepare(): void;
  10088. /**
  10089. * Execute the action and set the parent property.
  10090. */
  10091. execute(): void;
  10092. /**
  10093. * Serializes the actions and its related information.
  10094. * @param parent defines the object to serialize in
  10095. * @returns the serialized object
  10096. */
  10097. serialize(parent: any): any;
  10098. }
  10099. }
  10100. declare module BABYLON {
  10101. /**
  10102. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10103. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10104. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10105. */
  10106. export class ActionManager extends AbstractActionManager {
  10107. /**
  10108. * Nothing
  10109. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10110. */
  10111. static readonly NothingTrigger: number;
  10112. /**
  10113. * On pick
  10114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10115. */
  10116. static readonly OnPickTrigger: number;
  10117. /**
  10118. * On left pick
  10119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10120. */
  10121. static readonly OnLeftPickTrigger: number;
  10122. /**
  10123. * On right pick
  10124. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10125. */
  10126. static readonly OnRightPickTrigger: number;
  10127. /**
  10128. * On center pick
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10130. */
  10131. static readonly OnCenterPickTrigger: number;
  10132. /**
  10133. * On pick down
  10134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10135. */
  10136. static readonly OnPickDownTrigger: number;
  10137. /**
  10138. * On double pick
  10139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10140. */
  10141. static readonly OnDoublePickTrigger: number;
  10142. /**
  10143. * On pick up
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10145. */
  10146. static readonly OnPickUpTrigger: number;
  10147. /**
  10148. * On pick out.
  10149. * This trigger will only be raised if you also declared a OnPickDown
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnPickOutTrigger: number;
  10153. /**
  10154. * On long press
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnLongPressTrigger: number;
  10158. /**
  10159. * On pointer over
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPointerOverTrigger: number;
  10163. /**
  10164. * On pointer out
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnPointerOutTrigger: number;
  10168. /**
  10169. * On every frame
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnEveryFrameTrigger: number;
  10173. /**
  10174. * On intersection enter
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnIntersectionEnterTrigger: number;
  10178. /**
  10179. * On intersection exit
  10180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10181. */
  10182. static readonly OnIntersectionExitTrigger: number;
  10183. /**
  10184. * On key down
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnKeyDownTrigger: number;
  10188. /**
  10189. * On key up
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnKeyUpTrigger: number;
  10193. private _scene;
  10194. /**
  10195. * Creates a new action manager
  10196. * @param scene defines the hosting scene
  10197. */
  10198. constructor(scene: Scene);
  10199. /**
  10200. * Releases all associated resources
  10201. */
  10202. dispose(): void;
  10203. /**
  10204. * Gets hosting scene
  10205. * @returns the hosting scene
  10206. */
  10207. getScene(): Scene;
  10208. /**
  10209. * Does this action manager handles actions of any of the given triggers
  10210. * @param triggers defines the triggers to be tested
  10211. * @return a boolean indicating whether one (or more) of the triggers is handled
  10212. */
  10213. hasSpecificTriggers(triggers: number[]): boolean;
  10214. /**
  10215. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10216. * speed.
  10217. * @param triggerA defines the trigger to be tested
  10218. * @param triggerB defines the trigger to be tested
  10219. * @return a boolean indicating whether one (or more) of the triggers is handled
  10220. */
  10221. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10222. /**
  10223. * Does this action manager handles actions of a given trigger
  10224. * @param trigger defines the trigger to be tested
  10225. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10226. * @return whether the trigger is handled
  10227. */
  10228. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10229. /**
  10230. * Does this action manager has pointer triggers
  10231. */
  10232. get hasPointerTriggers(): boolean;
  10233. /**
  10234. * Does this action manager has pick triggers
  10235. */
  10236. get hasPickTriggers(): boolean;
  10237. /**
  10238. * Registers an action to this action manager
  10239. * @param action defines the action to be registered
  10240. * @return the action amended (prepared) after registration
  10241. */
  10242. registerAction(action: IAction): Nullable<IAction>;
  10243. /**
  10244. * Unregisters an action to this action manager
  10245. * @param action defines the action to be unregistered
  10246. * @return a boolean indicating whether the action has been unregistered
  10247. */
  10248. unregisterAction(action: IAction): Boolean;
  10249. /**
  10250. * Process a specific trigger
  10251. * @param trigger defines the trigger to process
  10252. * @param evt defines the event details to be processed
  10253. */
  10254. processTrigger(trigger: number, evt?: IActionEvent): void;
  10255. /** @hidden */
  10256. _getEffectiveTarget(target: any, propertyPath: string): any;
  10257. /** @hidden */
  10258. _getProperty(propertyPath: string): string;
  10259. /**
  10260. * Serialize this manager to a JSON object
  10261. * @param name defines the property name to store this manager
  10262. * @returns a JSON representation of this manager
  10263. */
  10264. serialize(name: string): any;
  10265. /**
  10266. * Creates a new ActionManager from a JSON data
  10267. * @param parsedActions defines the JSON data to read from
  10268. * @param object defines the hosting mesh
  10269. * @param scene defines the hosting scene
  10270. */
  10271. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10272. /**
  10273. * Get a trigger name by index
  10274. * @param trigger defines the trigger index
  10275. * @returns a trigger name
  10276. */
  10277. static GetTriggerName(trigger: number): string;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Class used to represent a sprite
  10283. * @see https://doc.babylonjs.com/babylon101/sprites
  10284. */
  10285. export class Sprite implements IAnimatable {
  10286. /** defines the name */
  10287. name: string;
  10288. /** Gets or sets the current world position */
  10289. position: Vector3;
  10290. /** Gets or sets the main color */
  10291. color: Color4;
  10292. /** Gets or sets the width */
  10293. width: number;
  10294. /** Gets or sets the height */
  10295. height: number;
  10296. /** Gets or sets rotation angle */
  10297. angle: number;
  10298. /** Gets or sets the cell index in the sprite sheet */
  10299. cellIndex: number;
  10300. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10301. cellRef: string;
  10302. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10303. invertU: boolean;
  10304. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10305. invertV: boolean;
  10306. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10307. disposeWhenFinishedAnimating: boolean;
  10308. /** Gets the list of attached animations */
  10309. animations: Nullable<Array<Animation>>;
  10310. /** Gets or sets a boolean indicating if the sprite can be picked */
  10311. isPickable: boolean;
  10312. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10313. useAlphaForPicking: boolean;
  10314. /** @hidden */
  10315. _xOffset: number;
  10316. /** @hidden */
  10317. _yOffset: number;
  10318. /** @hidden */
  10319. _xSize: number;
  10320. /** @hidden */
  10321. _ySize: number;
  10322. /**
  10323. * Gets or sets the associated action manager
  10324. */
  10325. actionManager: Nullable<ActionManager>;
  10326. /**
  10327. * An event triggered when the control has been disposed
  10328. */
  10329. onDisposeObservable: Observable<Sprite>;
  10330. private _animationStarted;
  10331. private _loopAnimation;
  10332. private _fromIndex;
  10333. private _toIndex;
  10334. private _delay;
  10335. private _direction;
  10336. private _manager;
  10337. private _time;
  10338. private _onAnimationEnd;
  10339. /**
  10340. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10341. */
  10342. isVisible: boolean;
  10343. /**
  10344. * Gets or sets the sprite size
  10345. */
  10346. get size(): number;
  10347. set size(value: number);
  10348. /**
  10349. * Returns a boolean indicating if the animation is started
  10350. */
  10351. get animationStarted(): boolean;
  10352. /**
  10353. * Gets or sets the unique id of the sprite
  10354. */
  10355. uniqueId: number;
  10356. /**
  10357. * Gets the manager of this sprite
  10358. */
  10359. get manager(): ISpriteManager;
  10360. /**
  10361. * Creates a new Sprite
  10362. * @param name defines the name
  10363. * @param manager defines the manager
  10364. */
  10365. constructor(
  10366. /** defines the name */
  10367. name: string, manager: ISpriteManager);
  10368. /**
  10369. * Returns the string "Sprite"
  10370. * @returns "Sprite"
  10371. */
  10372. getClassName(): string;
  10373. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10374. get fromIndex(): number;
  10375. set fromIndex(value: number);
  10376. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10377. get toIndex(): number;
  10378. set toIndex(value: number);
  10379. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10380. get loopAnimation(): boolean;
  10381. set loopAnimation(value: boolean);
  10382. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10383. get delay(): number;
  10384. set delay(value: number);
  10385. /**
  10386. * Starts an animation
  10387. * @param from defines the initial key
  10388. * @param to defines the end key
  10389. * @param loop defines if the animation must loop
  10390. * @param delay defines the start delay (in ms)
  10391. * @param onAnimationEnd defines a callback to call when animation ends
  10392. */
  10393. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10394. /** Stops current animation (if any) */
  10395. stopAnimation(): void;
  10396. /** @hidden */
  10397. _animate(deltaTime: number): void;
  10398. /** Release associated resources */
  10399. dispose(): void;
  10400. /**
  10401. * Serializes the sprite to a JSON object
  10402. * @returns the JSON object
  10403. */
  10404. serialize(): any;
  10405. /**
  10406. * Parses a JSON object to create a new sprite
  10407. * @param parsedSprite The JSON object to parse
  10408. * @param manager defines the hosting manager
  10409. * @returns the new sprite
  10410. */
  10411. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10412. }
  10413. }
  10414. declare module BABYLON {
  10415. /**
  10416. * Information about the result of picking within a scene
  10417. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10418. */
  10419. export class PickingInfo {
  10420. /** @hidden */
  10421. _pickingUnavailable: boolean;
  10422. /**
  10423. * If the pick collided with an object
  10424. */
  10425. hit: boolean;
  10426. /**
  10427. * Distance away where the pick collided
  10428. */
  10429. distance: number;
  10430. /**
  10431. * The location of pick collision
  10432. */
  10433. pickedPoint: Nullable<Vector3>;
  10434. /**
  10435. * The mesh corresponding the the pick collision
  10436. */
  10437. pickedMesh: Nullable<AbstractMesh>;
  10438. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10439. bu: number;
  10440. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10441. bv: number;
  10442. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10443. faceId: number;
  10444. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10445. subMeshFaceId: number;
  10446. /** Id of the the submesh that was picked */
  10447. subMeshId: number;
  10448. /** If a sprite was picked, this will be the sprite the pick collided with */
  10449. pickedSprite: Nullable<Sprite>;
  10450. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10451. thinInstanceIndex: number;
  10452. /**
  10453. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10454. */
  10455. originMesh: Nullable<AbstractMesh>;
  10456. /**
  10457. * The ray that was used to perform the picking.
  10458. */
  10459. ray: Nullable<Ray>;
  10460. /**
  10461. * Gets the normal correspodning to the face the pick collided with
  10462. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10463. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10464. * @returns The normal correspodning to the face the pick collided with
  10465. */
  10466. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10467. /**
  10468. * Gets the texture coordinates of where the pick occured
  10469. * @returns the vector containing the coordnates of the texture
  10470. */
  10471. getTextureCoordinates(): Nullable<Vector2>;
  10472. }
  10473. }
  10474. declare module BABYLON {
  10475. /**
  10476. * Class representing a ray with position and direction
  10477. */
  10478. export class Ray {
  10479. /** origin point */
  10480. origin: Vector3;
  10481. /** direction */
  10482. direction: Vector3;
  10483. /** length of the ray */
  10484. length: number;
  10485. private static readonly _TmpVector3;
  10486. private _tmpRay;
  10487. /**
  10488. * Creates a new ray
  10489. * @param origin origin point
  10490. * @param direction direction
  10491. * @param length length of the ray
  10492. */
  10493. constructor(
  10494. /** origin point */
  10495. origin: Vector3,
  10496. /** direction */
  10497. direction: Vector3,
  10498. /** length of the ray */
  10499. length?: number);
  10500. /**
  10501. * Checks if the ray intersects a box
  10502. * This does not account for the ray lenght by design to improve perfs.
  10503. * @param minimum bound of the box
  10504. * @param maximum bound of the box
  10505. * @param intersectionTreshold extra extend to be added to the box in all direction
  10506. * @returns if the box was hit
  10507. */
  10508. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10509. /**
  10510. * Checks if the ray intersects a box
  10511. * This does not account for the ray lenght by design to improve perfs.
  10512. * @param box the bounding box to check
  10513. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10514. * @returns if the box was hit
  10515. */
  10516. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10517. /**
  10518. * If the ray hits a sphere
  10519. * @param sphere the bounding sphere to check
  10520. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10521. * @returns true if it hits the sphere
  10522. */
  10523. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10524. /**
  10525. * If the ray hits a triange
  10526. * @param vertex0 triangle vertex
  10527. * @param vertex1 triangle vertex
  10528. * @param vertex2 triangle vertex
  10529. * @returns intersection information if hit
  10530. */
  10531. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10532. /**
  10533. * Checks if ray intersects a plane
  10534. * @param plane the plane to check
  10535. * @returns the distance away it was hit
  10536. */
  10537. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10538. /**
  10539. * Calculate the intercept of a ray on a given axis
  10540. * @param axis to check 'x' | 'y' | 'z'
  10541. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10542. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10543. */
  10544. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10545. /**
  10546. * Checks if ray intersects a mesh
  10547. * @param mesh the mesh to check
  10548. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10549. * @returns picking info of the intersecton
  10550. */
  10551. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10552. /**
  10553. * Checks if ray intersects a mesh
  10554. * @param meshes the meshes to check
  10555. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10556. * @param results array to store result in
  10557. * @returns Array of picking infos
  10558. */
  10559. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10560. private _comparePickingInfo;
  10561. private static smallnum;
  10562. private static rayl;
  10563. /**
  10564. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10565. * @param sega the first point of the segment to test the intersection against
  10566. * @param segb the second point of the segment to test the intersection against
  10567. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10568. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10569. */
  10570. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10571. /**
  10572. * Update the ray from viewport position
  10573. * @param x position
  10574. * @param y y position
  10575. * @param viewportWidth viewport width
  10576. * @param viewportHeight viewport height
  10577. * @param world world matrix
  10578. * @param view view matrix
  10579. * @param projection projection matrix
  10580. * @returns this ray updated
  10581. */
  10582. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10583. /**
  10584. * Creates a ray with origin and direction of 0,0,0
  10585. * @returns the new ray
  10586. */
  10587. static Zero(): Ray;
  10588. /**
  10589. * Creates a new ray from screen space and viewport
  10590. * @param x position
  10591. * @param y y position
  10592. * @param viewportWidth viewport width
  10593. * @param viewportHeight viewport height
  10594. * @param world world matrix
  10595. * @param view view matrix
  10596. * @param projection projection matrix
  10597. * @returns new ray
  10598. */
  10599. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10600. /**
  10601. * 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
  10602. * transformed to the given world matrix.
  10603. * @param origin The origin point
  10604. * @param end The end point
  10605. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10606. * @returns the new ray
  10607. */
  10608. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10609. /**
  10610. * Transforms a ray by a matrix
  10611. * @param ray ray to transform
  10612. * @param matrix matrix to apply
  10613. * @returns the resulting new ray
  10614. */
  10615. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10616. /**
  10617. * Transforms a ray by a matrix
  10618. * @param ray ray to transform
  10619. * @param matrix matrix to apply
  10620. * @param result ray to store result in
  10621. */
  10622. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10623. /**
  10624. * Unproject a ray from screen space to object space
  10625. * @param sourceX defines the screen space x coordinate to use
  10626. * @param sourceY defines the screen space y coordinate to use
  10627. * @param viewportWidth defines the current width of the viewport
  10628. * @param viewportHeight defines the current height of the viewport
  10629. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10630. * @param view defines the view matrix to use
  10631. * @param projection defines the projection matrix to use
  10632. */
  10633. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10634. }
  10635. /**
  10636. * Type used to define predicate used to select faces when a mesh intersection is detected
  10637. */
  10638. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10639. interface Scene {
  10640. /** @hidden */
  10641. _tempPickingRay: Nullable<Ray>;
  10642. /** @hidden */
  10643. _cachedRayForTransform: Ray;
  10644. /** @hidden */
  10645. _pickWithRayInverseMatrix: Matrix;
  10646. /** @hidden */
  10647. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10648. /** @hidden */
  10649. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10650. /** @hidden */
  10651. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10652. }
  10653. }
  10654. declare module BABYLON {
  10655. /**
  10656. * Groups all the scene component constants in one place to ease maintenance.
  10657. * @hidden
  10658. */
  10659. export class SceneComponentConstants {
  10660. static readonly NAME_EFFECTLAYER: string;
  10661. static readonly NAME_LAYER: string;
  10662. static readonly NAME_LENSFLARESYSTEM: string;
  10663. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10664. static readonly NAME_PARTICLESYSTEM: string;
  10665. static readonly NAME_GAMEPAD: string;
  10666. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10667. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10668. static readonly NAME_PREPASSRENDERER: string;
  10669. static readonly NAME_DEPTHRENDERER: string;
  10670. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10671. static readonly NAME_SPRITE: string;
  10672. static readonly NAME_SUBSURFACE: string;
  10673. static readonly NAME_OUTLINERENDERER: string;
  10674. static readonly NAME_PROCEDURALTEXTURE: string;
  10675. static readonly NAME_SHADOWGENERATOR: string;
  10676. static readonly NAME_OCTREE: string;
  10677. static readonly NAME_PHYSICSENGINE: string;
  10678. static readonly NAME_AUDIO: string;
  10679. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10680. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10681. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10682. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10683. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10684. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10685. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10686. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10687. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10688. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10689. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10690. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10691. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10692. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10693. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10694. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10695. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10696. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10697. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10698. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10699. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10700. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10701. static readonly STEP_AFTERRENDER_AUDIO: number;
  10702. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10703. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10704. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10705. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10706. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10707. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10708. static readonly STEP_POINTERMOVE_SPRITE: number;
  10709. static readonly STEP_POINTERDOWN_SPRITE: number;
  10710. static readonly STEP_POINTERUP_SPRITE: number;
  10711. }
  10712. /**
  10713. * This represents a scene component.
  10714. *
  10715. * This is used to decouple the dependency the scene is having on the different workloads like
  10716. * layers, post processes...
  10717. */
  10718. export interface ISceneComponent {
  10719. /**
  10720. * The name of the component. Each component must have a unique name.
  10721. */
  10722. name: string;
  10723. /**
  10724. * The scene the component belongs to.
  10725. */
  10726. scene: Scene;
  10727. /**
  10728. * Register the component to one instance of a scene.
  10729. */
  10730. register(): void;
  10731. /**
  10732. * Rebuilds the elements related to this component in case of
  10733. * context lost for instance.
  10734. */
  10735. rebuild(): void;
  10736. /**
  10737. * Disposes the component and the associated ressources.
  10738. */
  10739. dispose(): void;
  10740. }
  10741. /**
  10742. * This represents a SERIALIZABLE scene component.
  10743. *
  10744. * This extends Scene Component to add Serialization methods on top.
  10745. */
  10746. export interface ISceneSerializableComponent extends ISceneComponent {
  10747. /**
  10748. * Adds all the elements from the container to the scene
  10749. * @param container the container holding the elements
  10750. */
  10751. addFromContainer(container: AbstractScene): void;
  10752. /**
  10753. * Removes all the elements in the container from the scene
  10754. * @param container contains the elements to remove
  10755. * @param dispose if the removed element should be disposed (default: false)
  10756. */
  10757. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10758. /**
  10759. * Serializes the component data to the specified json object
  10760. * @param serializationObject The object to serialize to
  10761. */
  10762. serialize(serializationObject: any): void;
  10763. }
  10764. /**
  10765. * Strong typing of a Mesh related stage step action
  10766. */
  10767. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10768. /**
  10769. * Strong typing of a Evaluate Sub Mesh related stage step action
  10770. */
  10771. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10772. /**
  10773. * Strong typing of a Active Mesh related stage step action
  10774. */
  10775. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10776. /**
  10777. * Strong typing of a Camera related stage step action
  10778. */
  10779. export type CameraStageAction = (camera: Camera) => void;
  10780. /**
  10781. * Strong typing of a Camera Frame buffer related stage step action
  10782. */
  10783. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10784. /**
  10785. * Strong typing of a Render Target related stage step action
  10786. */
  10787. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10788. /**
  10789. * Strong typing of a RenderingGroup related stage step action
  10790. */
  10791. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10792. /**
  10793. * Strong typing of a Mesh Render related stage step action
  10794. */
  10795. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10796. /**
  10797. * Strong typing of a simple stage step action
  10798. */
  10799. export type SimpleStageAction = () => void;
  10800. /**
  10801. * Strong typing of a render target action.
  10802. */
  10803. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10804. /**
  10805. * Strong typing of a pointer move action.
  10806. */
  10807. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10808. /**
  10809. * Strong typing of a pointer up/down action.
  10810. */
  10811. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10812. /**
  10813. * Representation of a stage in the scene (Basically a list of ordered steps)
  10814. * @hidden
  10815. */
  10816. export class Stage<T extends Function> extends Array<{
  10817. index: number;
  10818. component: ISceneComponent;
  10819. action: T;
  10820. }> {
  10821. /**
  10822. * Hide ctor from the rest of the world.
  10823. * @param items The items to add.
  10824. */
  10825. private constructor();
  10826. /**
  10827. * Creates a new Stage.
  10828. * @returns A new instance of a Stage
  10829. */
  10830. static Create<T extends Function>(): Stage<T>;
  10831. /**
  10832. * Registers a step in an ordered way in the targeted stage.
  10833. * @param index Defines the position to register the step in
  10834. * @param component Defines the component attached to the step
  10835. * @param action Defines the action to launch during the step
  10836. */
  10837. registerStep(index: number, component: ISceneComponent, action: T): void;
  10838. /**
  10839. * Clears all the steps from the stage.
  10840. */
  10841. clear(): void;
  10842. }
  10843. }
  10844. declare module BABYLON {
  10845. interface Scene {
  10846. /** @hidden */
  10847. _pointerOverSprite: Nullable<Sprite>;
  10848. /** @hidden */
  10849. _pickedDownSprite: Nullable<Sprite>;
  10850. /** @hidden */
  10851. _tempSpritePickingRay: Nullable<Ray>;
  10852. /**
  10853. * All of the sprite managers added to this scene
  10854. * @see https://doc.babylonjs.com/babylon101/sprites
  10855. */
  10856. spriteManagers: Array<ISpriteManager>;
  10857. /**
  10858. * An event triggered when sprites rendering is about to start
  10859. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10860. */
  10861. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10862. /**
  10863. * An event triggered when sprites rendering is done
  10864. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10865. */
  10866. onAfterSpritesRenderingObservable: Observable<Scene>;
  10867. /** @hidden */
  10868. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10869. /** Launch a ray to try to pick a sprite in the scene
  10870. * @param x position on screen
  10871. * @param y position on screen
  10872. * @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
  10873. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10874. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10875. * @returns a PickingInfo
  10876. */
  10877. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10878. /** Use the given ray to pick a sprite in the scene
  10879. * @param ray The ray (in world space) to use to pick meshes
  10880. * @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
  10881. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10882. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10883. * @returns a PickingInfo
  10884. */
  10885. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10886. /** @hidden */
  10887. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10888. /** Launch a ray to try to pick sprites in the scene
  10889. * @param x position on screen
  10890. * @param y position on screen
  10891. * @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
  10892. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10893. * @returns a PickingInfo array
  10894. */
  10895. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10896. /** Use the given ray to pick sprites in the scene
  10897. * @param ray The ray (in world space) to use to pick meshes
  10898. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10899. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10900. * @returns a PickingInfo array
  10901. */
  10902. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10903. /**
  10904. * Force the sprite under the pointer
  10905. * @param sprite defines the sprite to use
  10906. */
  10907. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10908. /**
  10909. * Gets the sprite under the pointer
  10910. * @returns a Sprite or null if no sprite is under the pointer
  10911. */
  10912. getPointerOverSprite(): Nullable<Sprite>;
  10913. }
  10914. /**
  10915. * Defines the sprite scene component responsible to manage sprites
  10916. * in a given scene.
  10917. */
  10918. export class SpriteSceneComponent implements ISceneComponent {
  10919. /**
  10920. * The component name helpfull to identify the component in the list of scene components.
  10921. */
  10922. readonly name: string;
  10923. /**
  10924. * The scene the component belongs to.
  10925. */
  10926. scene: Scene;
  10927. /** @hidden */
  10928. private _spritePredicate;
  10929. /**
  10930. * Creates a new instance of the component for the given scene
  10931. * @param scene Defines the scene to register the component in
  10932. */
  10933. constructor(scene: Scene);
  10934. /**
  10935. * Registers the component in a given scene
  10936. */
  10937. register(): void;
  10938. /**
  10939. * Rebuilds the elements related to this component in case of
  10940. * context lost for instance.
  10941. */
  10942. rebuild(): void;
  10943. /**
  10944. * Disposes the component and the associated ressources.
  10945. */
  10946. dispose(): void;
  10947. private _pickSpriteButKeepRay;
  10948. private _pointerMove;
  10949. private _pointerDown;
  10950. private _pointerUp;
  10951. }
  10952. }
  10953. declare module BABYLON {
  10954. /** @hidden */
  10955. export var fogFragmentDeclaration: {
  10956. name: string;
  10957. shader: string;
  10958. };
  10959. }
  10960. declare module BABYLON {
  10961. /** @hidden */
  10962. export var fogFragment: {
  10963. name: string;
  10964. shader: string;
  10965. };
  10966. }
  10967. declare module BABYLON {
  10968. /** @hidden */
  10969. export var spritesPixelShader: {
  10970. name: string;
  10971. shader: string;
  10972. };
  10973. }
  10974. declare module BABYLON {
  10975. /** @hidden */
  10976. export var fogVertexDeclaration: {
  10977. name: string;
  10978. shader: string;
  10979. };
  10980. }
  10981. declare module BABYLON {
  10982. /** @hidden */
  10983. export var spritesVertexShader: {
  10984. name: string;
  10985. shader: string;
  10986. };
  10987. }
  10988. declare module BABYLON {
  10989. /**
  10990. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10991. */
  10992. export interface ISpriteManager extends IDisposable {
  10993. /**
  10994. * Gets manager's name
  10995. */
  10996. name: string;
  10997. /**
  10998. * Restricts the camera to viewing objects with the same layerMask.
  10999. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11000. */
  11001. layerMask: number;
  11002. /**
  11003. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11004. */
  11005. isPickable: boolean;
  11006. /**
  11007. * Gets the hosting scene
  11008. */
  11009. scene: Scene;
  11010. /**
  11011. * Specifies the rendering group id for this mesh (0 by default)
  11012. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11013. */
  11014. renderingGroupId: number;
  11015. /**
  11016. * Defines the list of sprites managed by the manager.
  11017. */
  11018. sprites: Array<Sprite>;
  11019. /**
  11020. * Gets or sets the spritesheet texture
  11021. */
  11022. texture: Texture;
  11023. /** Defines the default width of a cell in the spritesheet */
  11024. cellWidth: number;
  11025. /** Defines the default height of a cell in the spritesheet */
  11026. cellHeight: number;
  11027. /**
  11028. * Tests the intersection of a sprite with a specific ray.
  11029. * @param ray The ray we are sending to test the collision
  11030. * @param camera The camera space we are sending rays in
  11031. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11032. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11033. * @returns picking info or null.
  11034. */
  11035. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11036. /**
  11037. * Intersects the sprites with a ray
  11038. * @param ray defines the ray to intersect with
  11039. * @param camera defines the current active camera
  11040. * @param predicate defines a predicate used to select candidate sprites
  11041. * @returns null if no hit or a PickingInfo array
  11042. */
  11043. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11044. /**
  11045. * Renders the list of sprites on screen.
  11046. */
  11047. render(): void;
  11048. }
  11049. /**
  11050. * Class used to manage multiple sprites on the same spritesheet
  11051. * @see https://doc.babylonjs.com/babylon101/sprites
  11052. */
  11053. export class SpriteManager implements ISpriteManager {
  11054. /** defines the manager's name */
  11055. name: string;
  11056. /** Define the Url to load snippets */
  11057. static SnippetUrl: string;
  11058. /** Snippet ID if the manager was created from the snippet server */
  11059. snippetId: string;
  11060. /** Gets the list of sprites */
  11061. sprites: Sprite[];
  11062. /** Gets or sets the rendering group id (0 by default) */
  11063. renderingGroupId: number;
  11064. /** Gets or sets camera layer mask */
  11065. layerMask: number;
  11066. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11067. fogEnabled: boolean;
  11068. /** Gets or sets a boolean indicating if the sprites are pickable */
  11069. isPickable: boolean;
  11070. /** Defines the default width of a cell in the spritesheet */
  11071. cellWidth: number;
  11072. /** Defines the default height of a cell in the spritesheet */
  11073. cellHeight: number;
  11074. /** Associative array from JSON sprite data file */
  11075. private _cellData;
  11076. /** Array of sprite names from JSON sprite data file */
  11077. private _spriteMap;
  11078. /** True when packed cell data from JSON file is ready*/
  11079. private _packedAndReady;
  11080. private _textureContent;
  11081. private _useInstancing;
  11082. /**
  11083. * An event triggered when the manager is disposed.
  11084. */
  11085. onDisposeObservable: Observable<SpriteManager>;
  11086. private _onDisposeObserver;
  11087. /**
  11088. * Callback called when the manager is disposed
  11089. */
  11090. set onDispose(callback: () => void);
  11091. private _capacity;
  11092. private _fromPacked;
  11093. private _spriteTexture;
  11094. private _epsilon;
  11095. private _scene;
  11096. private _vertexData;
  11097. private _buffer;
  11098. private _vertexBuffers;
  11099. private _spriteBuffer;
  11100. private _indexBuffer;
  11101. private _effectBase;
  11102. private _effectFog;
  11103. private _vertexBufferSize;
  11104. /**
  11105. * Gets or sets the unique id of the sprite
  11106. */
  11107. uniqueId: number;
  11108. /**
  11109. * Gets the array of sprites
  11110. */
  11111. get children(): Sprite[];
  11112. /**
  11113. * Gets the hosting scene
  11114. */
  11115. get scene(): Scene;
  11116. /**
  11117. * Gets the capacity of the manager
  11118. */
  11119. get capacity(): number;
  11120. /**
  11121. * Gets or sets the spritesheet texture
  11122. */
  11123. get texture(): Texture;
  11124. set texture(value: Texture);
  11125. private _blendMode;
  11126. /**
  11127. * Blend mode use to render the particle, it can be any of
  11128. * the static Constants.ALPHA_x properties provided in this class.
  11129. * Default value is Constants.ALPHA_COMBINE
  11130. */
  11131. get blendMode(): number;
  11132. set blendMode(blendMode: number);
  11133. /** Disables writing to the depth buffer when rendering the sprites.
  11134. * It can be handy to disable depth writing when using textures without alpha channel
  11135. * and setting some specific blend modes.
  11136. */
  11137. disableDepthWrite: boolean;
  11138. /**
  11139. * Creates a new sprite manager
  11140. * @param name defines the manager's name
  11141. * @param imgUrl defines the sprite sheet url
  11142. * @param capacity defines the maximum allowed number of sprites
  11143. * @param cellSize defines the size of a sprite cell
  11144. * @param scene defines the hosting scene
  11145. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11146. * @param samplingMode defines the smapling mode to use with spritesheet
  11147. * @param fromPacked set to false; do not alter
  11148. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11149. */
  11150. constructor(
  11151. /** defines the manager's name */
  11152. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11153. /**
  11154. * Returns the string "SpriteManager"
  11155. * @returns "SpriteManager"
  11156. */
  11157. getClassName(): string;
  11158. private _makePacked;
  11159. private _appendSpriteVertex;
  11160. private _checkTextureAlpha;
  11161. /**
  11162. * Intersects the sprites with a ray
  11163. * @param ray defines the ray to intersect with
  11164. * @param camera defines the current active camera
  11165. * @param predicate defines a predicate used to select candidate sprites
  11166. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11167. * @returns null if no hit or a PickingInfo
  11168. */
  11169. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11170. /**
  11171. * Intersects the sprites with a ray
  11172. * @param ray defines the ray to intersect with
  11173. * @param camera defines the current active camera
  11174. * @param predicate defines a predicate used to select candidate sprites
  11175. * @returns null if no hit or a PickingInfo array
  11176. */
  11177. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11178. /**
  11179. * Render all child sprites
  11180. */
  11181. render(): void;
  11182. /**
  11183. * Release associated resources
  11184. */
  11185. dispose(): void;
  11186. /**
  11187. * Serializes the sprite manager to a JSON object
  11188. * @param serializeTexture defines if the texture must be serialized as well
  11189. * @returns the JSON object
  11190. */
  11191. serialize(serializeTexture?: boolean): any;
  11192. /**
  11193. * Parses a JSON object to create a new sprite manager.
  11194. * @param parsedManager The JSON object to parse
  11195. * @param scene The scene to create the sprite managerin
  11196. * @param rootUrl The root url to use to load external dependencies like texture
  11197. * @returns the new sprite manager
  11198. */
  11199. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11200. /**
  11201. * Creates a sprite manager from a snippet saved in a remote file
  11202. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11203. * @param url defines the url to load from
  11204. * @param scene defines the hosting scene
  11205. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11206. * @returns a promise that will resolve to the new sprite manager
  11207. */
  11208. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11209. /**
  11210. * Creates a sprite manager from a snippet saved by the sprite editor
  11211. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11212. * @param scene defines the hosting scene
  11213. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11214. * @returns a promise that will resolve to the new sprite manager
  11215. */
  11216. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11217. }
  11218. }
  11219. declare module BABYLON {
  11220. /** Interface used by value gradients (color, factor, ...) */
  11221. export interface IValueGradient {
  11222. /**
  11223. * Gets or sets the gradient value (between 0 and 1)
  11224. */
  11225. gradient: number;
  11226. }
  11227. /** Class used to store color4 gradient */
  11228. export class ColorGradient implements IValueGradient {
  11229. /**
  11230. * Gets or sets the gradient value (between 0 and 1)
  11231. */
  11232. gradient: number;
  11233. /**
  11234. * Gets or sets first associated color
  11235. */
  11236. color1: Color4;
  11237. /**
  11238. * Gets or sets second associated color
  11239. */
  11240. color2?: Color4 | undefined;
  11241. /**
  11242. * Creates a new color4 gradient
  11243. * @param gradient gets or sets the gradient value (between 0 and 1)
  11244. * @param color1 gets or sets first associated color
  11245. * @param color2 gets or sets first second color
  11246. */
  11247. constructor(
  11248. /**
  11249. * Gets or sets the gradient value (between 0 and 1)
  11250. */
  11251. gradient: number,
  11252. /**
  11253. * Gets or sets first associated color
  11254. */
  11255. color1: Color4,
  11256. /**
  11257. * Gets or sets second associated color
  11258. */
  11259. color2?: Color4 | undefined);
  11260. /**
  11261. * Will get a color picked randomly between color1 and color2.
  11262. * If color2 is undefined then color1 will be used
  11263. * @param result defines the target Color4 to store the result in
  11264. */
  11265. getColorToRef(result: Color4): void;
  11266. }
  11267. /** Class used to store color 3 gradient */
  11268. export class Color3Gradient implements IValueGradient {
  11269. /**
  11270. * Gets or sets the gradient value (between 0 and 1)
  11271. */
  11272. gradient: number;
  11273. /**
  11274. * Gets or sets the associated color
  11275. */
  11276. color: Color3;
  11277. /**
  11278. * Creates a new color3 gradient
  11279. * @param gradient gets or sets the gradient value (between 0 and 1)
  11280. * @param color gets or sets associated color
  11281. */
  11282. constructor(
  11283. /**
  11284. * Gets or sets the gradient value (between 0 and 1)
  11285. */
  11286. gradient: number,
  11287. /**
  11288. * Gets or sets the associated color
  11289. */
  11290. color: Color3);
  11291. }
  11292. /** Class used to store factor gradient */
  11293. export class FactorGradient implements IValueGradient {
  11294. /**
  11295. * Gets or sets the gradient value (between 0 and 1)
  11296. */
  11297. gradient: number;
  11298. /**
  11299. * Gets or sets first associated factor
  11300. */
  11301. factor1: number;
  11302. /**
  11303. * Gets or sets second associated factor
  11304. */
  11305. factor2?: number | undefined;
  11306. /**
  11307. * Creates a new factor gradient
  11308. * @param gradient gets or sets the gradient value (between 0 and 1)
  11309. * @param factor1 gets or sets first associated factor
  11310. * @param factor2 gets or sets second associated factor
  11311. */
  11312. constructor(
  11313. /**
  11314. * Gets or sets the gradient value (between 0 and 1)
  11315. */
  11316. gradient: number,
  11317. /**
  11318. * Gets or sets first associated factor
  11319. */
  11320. factor1: number,
  11321. /**
  11322. * Gets or sets second associated factor
  11323. */
  11324. factor2?: number | undefined);
  11325. /**
  11326. * Will get a number picked randomly between factor1 and factor2.
  11327. * If factor2 is undefined then factor1 will be used
  11328. * @returns the picked number
  11329. */
  11330. getFactor(): number;
  11331. }
  11332. /**
  11333. * Helper used to simplify some generic gradient tasks
  11334. */
  11335. export class GradientHelper {
  11336. /**
  11337. * Gets the current gradient from an array of IValueGradient
  11338. * @param ratio defines the current ratio to get
  11339. * @param gradients defines the array of IValueGradient
  11340. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11341. */
  11342. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11343. }
  11344. }
  11345. declare module BABYLON {
  11346. interface ThinEngine {
  11347. /**
  11348. * Creates a raw texture
  11349. * @param data defines the data to store in the texture
  11350. * @param width defines the width of the texture
  11351. * @param height defines the height of the texture
  11352. * @param format defines the format of the data
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11356. * @param compression defines the compression used (null by default)
  11357. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11358. * @returns the raw texture inside an InternalTexture
  11359. */
  11360. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11361. /**
  11362. * Update a raw texture
  11363. * @param texture defines the texture to update
  11364. * @param data defines the data to store in the texture
  11365. * @param format defines the format of the data
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw texture
  11371. * @param texture defines the texture to update
  11372. * @param data defines the data to store in the texture
  11373. * @param format defines the format of the data
  11374. * @param invertY defines if data must be stored with Y axis inverted
  11375. * @param compression defines the compression used (null by default)
  11376. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11377. */
  11378. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11379. /**
  11380. * Creates a new raw cube texture
  11381. * @param data defines the array of data to use to create each face
  11382. * @param size defines the size of the textures
  11383. * @param format defines the format of the data
  11384. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11385. * @param generateMipMaps defines if the engine should generate the mip levels
  11386. * @param invertY defines if data must be stored with Y axis inverted
  11387. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11388. * @param compression defines the compression used (null by default)
  11389. * @returns the cube texture as an InternalTexture
  11390. */
  11391. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11392. /**
  11393. * Update a raw cube texture
  11394. * @param texture defines the texture to udpdate
  11395. * @param data defines the data to store
  11396. * @param format defines the data format
  11397. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11398. * @param invertY defines if data must be stored with Y axis inverted
  11399. */
  11400. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11401. /**
  11402. * Update a raw cube texture
  11403. * @param texture defines the texture to udpdate
  11404. * @param data defines the data to store
  11405. * @param format defines the data format
  11406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param compression defines the compression used (null by default)
  11409. */
  11410. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11411. /**
  11412. * Update a raw cube texture
  11413. * @param texture defines the texture to udpdate
  11414. * @param data defines the data to store
  11415. * @param format defines the data format
  11416. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11417. * @param invertY defines if data must be stored with Y axis inverted
  11418. * @param compression defines the compression used (null by default)
  11419. * @param level defines which level of the texture to update
  11420. */
  11421. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11422. /**
  11423. * Creates a new raw cube texture from a specified url
  11424. * @param url defines the url where the data is located
  11425. * @param scene defines the current scene
  11426. * @param size defines the size of the textures
  11427. * @param format defines the format of the data
  11428. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11429. * @param noMipmap defines if the engine should avoid generating the mip levels
  11430. * @param callback defines a callback used to extract texture data from loaded data
  11431. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11432. * @param onLoad defines a callback called when texture is loaded
  11433. * @param onError defines a callback called if there is an error
  11434. * @returns the cube texture as an InternalTexture
  11435. */
  11436. 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;
  11437. /**
  11438. * Creates a new raw cube texture from a specified url
  11439. * @param url defines the url where the data is located
  11440. * @param scene defines the current scene
  11441. * @param size defines the size of the textures
  11442. * @param format defines the format of the data
  11443. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11444. * @param noMipmap defines if the engine should avoid generating the mip levels
  11445. * @param callback defines a callback used to extract texture data from loaded data
  11446. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11447. * @param onLoad defines a callback called when texture is loaded
  11448. * @param onError defines a callback called if there is an error
  11449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @returns the cube texture as an InternalTexture
  11452. */
  11453. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11454. /**
  11455. * Creates a new raw 3D texture
  11456. * @param data defines the data used to create the texture
  11457. * @param width defines the width of the texture
  11458. * @param height defines the height of the texture
  11459. * @param depth defines the depth of the texture
  11460. * @param format defines the format of the texture
  11461. * @param generateMipMaps defines if the engine must generate mip levels
  11462. * @param invertY defines if data must be stored with Y axis inverted
  11463. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11464. * @param compression defines the compressed used (can be null)
  11465. * @param textureType defines the compressed used (can be null)
  11466. * @returns a new raw 3D texture (stored in an InternalTexture)
  11467. */
  11468. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11469. /**
  11470. * Update a raw 3D texture
  11471. * @param texture defines the texture to update
  11472. * @param data defines the data to store
  11473. * @param format defines the data format
  11474. * @param invertY defines if data must be stored with Y axis inverted
  11475. */
  11476. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11477. /**
  11478. * Update a raw 3D texture
  11479. * @param texture defines the texture to update
  11480. * @param data defines the data to store
  11481. * @param format defines the data format
  11482. * @param invertY defines if data must be stored with Y axis inverted
  11483. * @param compression defines the used compression (can be null)
  11484. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11485. */
  11486. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11487. /**
  11488. * Creates a new raw 2D array texture
  11489. * @param data defines the data used to create the texture
  11490. * @param width defines the width of the texture
  11491. * @param height defines the height of the texture
  11492. * @param depth defines the number of layers of the texture
  11493. * @param format defines the format of the texture
  11494. * @param generateMipMaps defines if the engine must generate mip levels
  11495. * @param invertY defines if data must be stored with Y axis inverted
  11496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11497. * @param compression defines the compressed used (can be null)
  11498. * @param textureType defines the compressed used (can be null)
  11499. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11500. */
  11501. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11502. /**
  11503. * Update a raw 2D array texture
  11504. * @param texture defines the texture to update
  11505. * @param data defines the data to store
  11506. * @param format defines the data format
  11507. * @param invertY defines if data must be stored with Y axis inverted
  11508. */
  11509. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11510. /**
  11511. * Update a raw 2D array texture
  11512. * @param texture defines the texture to update
  11513. * @param data defines the data to store
  11514. * @param format defines the data format
  11515. * @param invertY defines if data must be stored with Y axis inverted
  11516. * @param compression defines the used compression (can be null)
  11517. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11518. */
  11519. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11520. }
  11521. }
  11522. declare module BABYLON {
  11523. /**
  11524. * Raw texture can help creating a texture directly from an array of data.
  11525. * This can be super useful if you either get the data from an uncompressed source or
  11526. * if you wish to create your texture pixel by pixel.
  11527. */
  11528. export class RawTexture extends Texture {
  11529. /**
  11530. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11531. */
  11532. format: number;
  11533. /**
  11534. * Instantiates a new RawTexture.
  11535. * Raw texture can help creating a texture directly from an array of data.
  11536. * This can be super useful if you either get the data from an uncompressed source or
  11537. * if you wish to create your texture pixel by pixel.
  11538. * @param data define the array of data to use to create the texture
  11539. * @param width define the width of the texture
  11540. * @param height define the height of the texture
  11541. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11542. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11543. * @param generateMipMaps define whether mip maps should be generated or not
  11544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11546. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11547. */
  11548. constructor(data: ArrayBufferView, width: number, height: number,
  11549. /**
  11550. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11551. */
  11552. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11553. /**
  11554. * Updates the texture underlying data.
  11555. * @param data Define the new data of the texture
  11556. */
  11557. update(data: ArrayBufferView): void;
  11558. /**
  11559. * Creates a luminance texture from some data.
  11560. * @param data Define the texture data
  11561. * @param width Define the width of the texture
  11562. * @param height Define the height of the texture
  11563. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11567. * @returns the luminance texture
  11568. */
  11569. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11570. /**
  11571. * Creates a luminance alpha texture from some data.
  11572. * @param data Define the texture data
  11573. * @param width Define the width of the texture
  11574. * @param height Define the height of the texture
  11575. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11576. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11577. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11578. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11579. * @returns the luminance alpha texture
  11580. */
  11581. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11582. /**
  11583. * Creates an alpha texture from some data.
  11584. * @param data Define the texture data
  11585. * @param width Define the width of the texture
  11586. * @param height Define the height of the texture
  11587. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11588. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11589. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11590. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11591. * @returns the alpha texture
  11592. */
  11593. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11594. /**
  11595. * Creates a RGB texture from some data.
  11596. * @param data Define the texture data
  11597. * @param width Define the width of the texture
  11598. * @param height Define the height of the texture
  11599. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11603. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11604. * @returns the RGB alpha texture
  11605. */
  11606. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11607. /**
  11608. * Creates a RGBA texture from some data.
  11609. * @param data Define the texture data
  11610. * @param width Define the width of the texture
  11611. * @param height Define the height of the texture
  11612. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11613. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11614. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11615. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11616. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11617. * @returns the RGBA texture
  11618. */
  11619. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11620. /**
  11621. * Creates a R texture from some data.
  11622. * @param data Define the texture data
  11623. * @param width Define the width of the texture
  11624. * @param height Define the height of the texture
  11625. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11626. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11630. * @returns the R texture
  11631. */
  11632. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11633. }
  11634. }
  11635. declare module BABYLON {
  11636. interface ThinEngine {
  11637. /**
  11638. * Update a dynamic index buffer
  11639. * @param indexBuffer defines the target index buffer
  11640. * @param indices defines the data to update
  11641. * @param offset defines the offset in the target index buffer where update should start
  11642. */
  11643. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11644. /**
  11645. * Updates a dynamic vertex buffer.
  11646. * @param vertexBuffer the vertex buffer to update
  11647. * @param data the data used to update the vertex buffer
  11648. * @param byteOffset the byte offset of the data
  11649. * @param byteLength the byte length of the data
  11650. */
  11651. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11652. }
  11653. }
  11654. declare module BABYLON {
  11655. interface AbstractScene {
  11656. /**
  11657. * The list of procedural textures added to the scene
  11658. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11659. */
  11660. proceduralTextures: Array<ProceduralTexture>;
  11661. }
  11662. /**
  11663. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11664. * in a given scene.
  11665. */
  11666. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11667. /**
  11668. * The component name helpfull to identify the component in the list of scene components.
  11669. */
  11670. readonly name: string;
  11671. /**
  11672. * The scene the component belongs to.
  11673. */
  11674. scene: Scene;
  11675. /**
  11676. * Creates a new instance of the component for the given scene
  11677. * @param scene Defines the scene to register the component in
  11678. */
  11679. constructor(scene: Scene);
  11680. /**
  11681. * Registers the component in a given scene
  11682. */
  11683. register(): void;
  11684. /**
  11685. * Rebuilds the elements related to this component in case of
  11686. * context lost for instance.
  11687. */
  11688. rebuild(): void;
  11689. /**
  11690. * Disposes the component and the associated ressources.
  11691. */
  11692. dispose(): void;
  11693. private _beforeClear;
  11694. }
  11695. }
  11696. declare module BABYLON {
  11697. interface ThinEngine {
  11698. /**
  11699. * Creates a new render target cube texture
  11700. * @param size defines the size of the texture
  11701. * @param options defines the options used to create the texture
  11702. * @returns a new render target cube texture stored in an InternalTexture
  11703. */
  11704. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11705. }
  11706. }
  11707. declare module BABYLON {
  11708. /** @hidden */
  11709. export var proceduralVertexShader: {
  11710. name: string;
  11711. shader: string;
  11712. };
  11713. }
  11714. declare module BABYLON {
  11715. /**
  11716. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. */
  11720. export class ProceduralTexture extends Texture {
  11721. /**
  11722. * Define if the texture is enabled or not (disabled texture will not render)
  11723. */
  11724. isEnabled: boolean;
  11725. /**
  11726. * Define if the texture must be cleared before rendering (default is true)
  11727. */
  11728. autoClear: boolean;
  11729. /**
  11730. * Callback called when the texture is generated
  11731. */
  11732. onGenerated: () => void;
  11733. /**
  11734. * Event raised when the texture is generated
  11735. */
  11736. onGeneratedObservable: Observable<ProceduralTexture>;
  11737. /**
  11738. * Event raised before the texture is generated
  11739. */
  11740. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11741. /**
  11742. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11743. */
  11744. nodeMaterialSource: Nullable<NodeMaterial>;
  11745. /** @hidden */
  11746. _generateMipMaps: boolean;
  11747. /** @hidden **/
  11748. _effect: Effect;
  11749. /** @hidden */
  11750. _textures: {
  11751. [key: string]: Texture;
  11752. };
  11753. /** @hidden */
  11754. protected _fallbackTexture: Nullable<Texture>;
  11755. private _size;
  11756. private _currentRefreshId;
  11757. private _frameId;
  11758. private _refreshRate;
  11759. private _vertexBuffers;
  11760. private _indexBuffer;
  11761. private _uniforms;
  11762. private _samplers;
  11763. private _fragment;
  11764. private _floats;
  11765. private _ints;
  11766. private _floatsArrays;
  11767. private _colors3;
  11768. private _colors4;
  11769. private _vectors2;
  11770. private _vectors3;
  11771. private _matrices;
  11772. private _fallbackTextureUsed;
  11773. private _fullEngine;
  11774. private _cachedDefines;
  11775. private _contentUpdateId;
  11776. private _contentData;
  11777. /**
  11778. * Instantiates a new procedural texture.
  11779. * 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.
  11780. * This is the base class of any Procedural texture and contains most of the shareable code.
  11781. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11782. * @param name Define the name of the texture
  11783. * @param size Define the size of the texture to create
  11784. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11785. * @param scene Define the scene the texture belongs to
  11786. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11787. * @param generateMipMaps Define if the texture should creates mip maps or not
  11788. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11789. */
  11790. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11791. /**
  11792. * The effect that is created when initializing the post process.
  11793. * @returns The created effect corresponding the the postprocess.
  11794. */
  11795. getEffect(): Effect;
  11796. /**
  11797. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11798. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11799. */
  11800. getContent(): Nullable<ArrayBufferView>;
  11801. private _createIndexBuffer;
  11802. /** @hidden */
  11803. _rebuild(): void;
  11804. /**
  11805. * Resets the texture in order to recreate its associated resources.
  11806. * This can be called in case of context loss
  11807. */
  11808. reset(): void;
  11809. protected _getDefines(): string;
  11810. /**
  11811. * Is the texture ready to be used ? (rendered at least once)
  11812. * @returns true if ready, otherwise, false.
  11813. */
  11814. isReady(): boolean;
  11815. /**
  11816. * Resets the refresh counter of the texture and start bak from scratch.
  11817. * Could be useful to regenerate the texture if it is setup to render only once.
  11818. */
  11819. resetRefreshCounter(): void;
  11820. /**
  11821. * Set the fragment shader to use in order to render the texture.
  11822. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11823. */
  11824. setFragment(fragment: any): void;
  11825. /**
  11826. * Define the refresh rate of the texture or the rendering frequency.
  11827. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11828. */
  11829. get refreshRate(): number;
  11830. set refreshRate(value: number);
  11831. /** @hidden */
  11832. _shouldRender(): boolean;
  11833. /**
  11834. * Get the size the texture is rendering at.
  11835. * @returns the size (on cube texture it is always squared)
  11836. */
  11837. getRenderSize(): RenderTargetTextureSize;
  11838. /**
  11839. * Resize the texture to new value.
  11840. * @param size Define the new size the texture should have
  11841. * @param generateMipMaps Define whether the new texture should create mip maps
  11842. */
  11843. resize(size: number, generateMipMaps: boolean): void;
  11844. private _checkUniform;
  11845. /**
  11846. * Set a texture in the shader program used to render.
  11847. * @param name Define the name of the uniform samplers as defined in the shader
  11848. * @param texture Define the texture to bind to this sampler
  11849. * @return the texture itself allowing "fluent" like uniform updates
  11850. */
  11851. setTexture(name: string, texture: Texture): ProceduralTexture;
  11852. /**
  11853. * Set a float in the shader.
  11854. * @param name Define the name of the uniform as defined in the shader
  11855. * @param value Define the value to give to the uniform
  11856. * @return the texture itself allowing "fluent" like uniform updates
  11857. */
  11858. setFloat(name: string, value: number): ProceduralTexture;
  11859. /**
  11860. * Set a int in the shader.
  11861. * @param name Define the name of the uniform as defined in the shader
  11862. * @param value Define the value to give to the uniform
  11863. * @return the texture itself allowing "fluent" like uniform updates
  11864. */
  11865. setInt(name: string, value: number): ProceduralTexture;
  11866. /**
  11867. * Set an array of floats in the shader.
  11868. * @param name Define the name of the uniform as defined in the shader
  11869. * @param value Define the value to give to the uniform
  11870. * @return the texture itself allowing "fluent" like uniform updates
  11871. */
  11872. setFloats(name: string, value: number[]): ProceduralTexture;
  11873. /**
  11874. * Set a vec3 in the shader from a Color3.
  11875. * @param name Define the name of the uniform as defined in the shader
  11876. * @param value Define the value to give to the uniform
  11877. * @return the texture itself allowing "fluent" like uniform updates
  11878. */
  11879. setColor3(name: string, value: Color3): ProceduralTexture;
  11880. /**
  11881. * Set a vec4 in the shader from a Color4.
  11882. * @param name Define the name of the uniform as defined in the shader
  11883. * @param value Define the value to give to the uniform
  11884. * @return the texture itself allowing "fluent" like uniform updates
  11885. */
  11886. setColor4(name: string, value: Color4): ProceduralTexture;
  11887. /**
  11888. * Set a vec2 in the shader from a Vector2.
  11889. * @param name Define the name of the uniform as defined in the shader
  11890. * @param value Define the value to give to the uniform
  11891. * @return the texture itself allowing "fluent" like uniform updates
  11892. */
  11893. setVector2(name: string, value: Vector2): ProceduralTexture;
  11894. /**
  11895. * Set a vec3 in the shader from a Vector3.
  11896. * @param name Define the name of the uniform as defined in the shader
  11897. * @param value Define the value to give to the uniform
  11898. * @return the texture itself allowing "fluent" like uniform updates
  11899. */
  11900. setVector3(name: string, value: Vector3): ProceduralTexture;
  11901. /**
  11902. * Set a mat4 in the shader from a MAtrix.
  11903. * @param name Define the name of the uniform as defined in the shader
  11904. * @param value Define the value to give to the uniform
  11905. * @return the texture itself allowing "fluent" like uniform updates
  11906. */
  11907. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11908. /**
  11909. * Render the texture to its associated render target.
  11910. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11911. */
  11912. render(useCameraPostProcess?: boolean): void;
  11913. /**
  11914. * Clone the texture.
  11915. * @returns the cloned texture
  11916. */
  11917. clone(): ProceduralTexture;
  11918. /**
  11919. * Dispose the texture and release its asoociated resources.
  11920. */
  11921. dispose(): void;
  11922. }
  11923. }
  11924. declare module BABYLON {
  11925. /**
  11926. * This represents the base class for particle system in Babylon.
  11927. * 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.
  11928. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11929. * @example https://doc.babylonjs.com/babylon101/particles
  11930. */
  11931. export class BaseParticleSystem {
  11932. /**
  11933. * Source color is added to the destination color without alpha affecting the result
  11934. */
  11935. static BLENDMODE_ONEONE: number;
  11936. /**
  11937. * Blend current color and particle color using particle’s alpha
  11938. */
  11939. static BLENDMODE_STANDARD: number;
  11940. /**
  11941. * Add current color and particle color multiplied by particle’s alpha
  11942. */
  11943. static BLENDMODE_ADD: number;
  11944. /**
  11945. * Multiply current color with particle color
  11946. */
  11947. static BLENDMODE_MULTIPLY: number;
  11948. /**
  11949. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11950. */
  11951. static BLENDMODE_MULTIPLYADD: number;
  11952. /**
  11953. * List of animations used by the particle system.
  11954. */
  11955. animations: Animation[];
  11956. /**
  11957. * Gets or sets the unique id of the particle system
  11958. */
  11959. uniqueId: number;
  11960. /**
  11961. * The id of the Particle system.
  11962. */
  11963. id: string;
  11964. /**
  11965. * The friendly name of the Particle system.
  11966. */
  11967. name: string;
  11968. /**
  11969. * Snippet ID if the particle system was created from the snippet server
  11970. */
  11971. snippetId: string;
  11972. /**
  11973. * The rendering group used by the Particle system to chose when to render.
  11974. */
  11975. renderingGroupId: number;
  11976. /**
  11977. * The emitter represents the Mesh or position we are attaching the particle system to.
  11978. */
  11979. emitter: Nullable<AbstractMesh | Vector3>;
  11980. /**
  11981. * The maximum number of particles to emit per frame
  11982. */
  11983. emitRate: number;
  11984. /**
  11985. * If you want to launch only a few particles at once, that can be done, as well.
  11986. */
  11987. manualEmitCount: number;
  11988. /**
  11989. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11990. */
  11991. updateSpeed: number;
  11992. /**
  11993. * The amount of time the particle system is running (depends of the overall update speed).
  11994. */
  11995. targetStopDuration: number;
  11996. /**
  11997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11998. */
  11999. disposeOnStop: boolean;
  12000. /**
  12001. * Minimum power of emitting particles.
  12002. */
  12003. minEmitPower: number;
  12004. /**
  12005. * Maximum power of emitting particles.
  12006. */
  12007. maxEmitPower: number;
  12008. /**
  12009. * Minimum life time of emitting particles.
  12010. */
  12011. minLifeTime: number;
  12012. /**
  12013. * Maximum life time of emitting particles.
  12014. */
  12015. maxLifeTime: number;
  12016. /**
  12017. * Minimum Size of emitting particles.
  12018. */
  12019. minSize: number;
  12020. /**
  12021. * Maximum Size of emitting particles.
  12022. */
  12023. maxSize: number;
  12024. /**
  12025. * Minimum scale of emitting particles on X axis.
  12026. */
  12027. minScaleX: number;
  12028. /**
  12029. * Maximum scale of emitting particles on X axis.
  12030. */
  12031. maxScaleX: number;
  12032. /**
  12033. * Minimum scale of emitting particles on Y axis.
  12034. */
  12035. minScaleY: number;
  12036. /**
  12037. * Maximum scale of emitting particles on Y axis.
  12038. */
  12039. maxScaleY: number;
  12040. /**
  12041. * Gets or sets the minimal initial rotation in radians.
  12042. */
  12043. minInitialRotation: number;
  12044. /**
  12045. * Gets or sets the maximal initial rotation in radians.
  12046. */
  12047. maxInitialRotation: number;
  12048. /**
  12049. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12050. */
  12051. minAngularSpeed: number;
  12052. /**
  12053. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12054. */
  12055. maxAngularSpeed: number;
  12056. /**
  12057. * The texture used to render each particle. (this can be a spritesheet)
  12058. */
  12059. particleTexture: Nullable<BaseTexture>;
  12060. /**
  12061. * The layer mask we are rendering the particles through.
  12062. */
  12063. layerMask: number;
  12064. /**
  12065. * This can help using your own shader to render the particle system.
  12066. * The according effect will be created
  12067. */
  12068. customShader: any;
  12069. /**
  12070. * By default particle system starts as soon as they are created. This prevents the
  12071. * automatic start to happen and let you decide when to start emitting particles.
  12072. */
  12073. preventAutoStart: boolean;
  12074. private _noiseTexture;
  12075. /**
  12076. * Gets or sets a texture used to add random noise to particle positions
  12077. */
  12078. get noiseTexture(): Nullable<ProceduralTexture>;
  12079. set noiseTexture(value: Nullable<ProceduralTexture>);
  12080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12081. noiseStrength: Vector3;
  12082. /**
  12083. * Callback triggered when the particle animation is ending.
  12084. */
  12085. onAnimationEnd: Nullable<() => void>;
  12086. /**
  12087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12088. */
  12089. blendMode: number;
  12090. /**
  12091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12092. * to override the particles.
  12093. */
  12094. forceDepthWrite: boolean;
  12095. /** 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 */
  12096. preWarmCycles: number;
  12097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12098. preWarmStepOffset: number;
  12099. /**
  12100. * 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)
  12101. */
  12102. spriteCellChangeSpeed: number;
  12103. /**
  12104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12105. */
  12106. startSpriteCellID: number;
  12107. /**
  12108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12109. */
  12110. endSpriteCellID: number;
  12111. /**
  12112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12113. */
  12114. spriteCellWidth: number;
  12115. /**
  12116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12117. */
  12118. spriteCellHeight: number;
  12119. /**
  12120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12121. */
  12122. spriteRandomStartCell: boolean;
  12123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12124. translationPivot: Vector2;
  12125. /** @hidden */
  12126. protected _isAnimationSheetEnabled: boolean;
  12127. /**
  12128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12129. */
  12130. beginAnimationOnStart: boolean;
  12131. /**
  12132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12133. */
  12134. beginAnimationFrom: number;
  12135. /**
  12136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12137. */
  12138. beginAnimationTo: number;
  12139. /**
  12140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12141. */
  12142. beginAnimationLoop: boolean;
  12143. /**
  12144. * Gets or sets a world offset applied to all particles
  12145. */
  12146. worldOffset: Vector3;
  12147. /**
  12148. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12149. */
  12150. get isAnimationSheetEnabled(): boolean;
  12151. set isAnimationSheetEnabled(value: boolean);
  12152. /**
  12153. * Get hosting scene
  12154. * @returns the scene
  12155. */
  12156. getScene(): Nullable<Scene>;
  12157. /**
  12158. * You can use gravity if you want to give an orientation to your particles.
  12159. */
  12160. gravity: Vector3;
  12161. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12162. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12163. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12164. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12165. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12166. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12167. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12168. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12169. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12170. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12171. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12172. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12173. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12174. /**
  12175. * Defines the delay in milliseconds before starting the system (0 by default)
  12176. */
  12177. startDelay: number;
  12178. /**
  12179. * Gets the current list of drag gradients.
  12180. * You must use addDragGradient and removeDragGradient to udpate this list
  12181. * @returns the list of drag gradients
  12182. */
  12183. getDragGradients(): Nullable<Array<FactorGradient>>;
  12184. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12185. limitVelocityDamping: number;
  12186. /**
  12187. * Gets the current list of limit velocity gradients.
  12188. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12189. * @returns the list of limit velocity gradients
  12190. */
  12191. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12192. /**
  12193. * Gets the current list of color gradients.
  12194. * You must use addColorGradient and removeColorGradient to udpate this list
  12195. * @returns the list of color gradients
  12196. */
  12197. getColorGradients(): Nullable<Array<ColorGradient>>;
  12198. /**
  12199. * Gets the current list of size gradients.
  12200. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12201. * @returns the list of size gradients
  12202. */
  12203. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12204. /**
  12205. * Gets the current list of color remap gradients.
  12206. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12207. * @returns the list of color remap gradients
  12208. */
  12209. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12210. /**
  12211. * Gets the current list of alpha remap gradients.
  12212. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12213. * @returns the list of alpha remap gradients
  12214. */
  12215. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12216. /**
  12217. * Gets the current list of life time gradients.
  12218. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12219. * @returns the list of life time gradients
  12220. */
  12221. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12222. /**
  12223. * Gets the current list of angular speed gradients.
  12224. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12225. * @returns the list of angular speed gradients
  12226. */
  12227. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12228. /**
  12229. * Gets the current list of velocity gradients.
  12230. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12231. * @returns the list of velocity gradients
  12232. */
  12233. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12234. /**
  12235. * Gets the current list of start size gradients.
  12236. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12237. * @returns the list of start size gradients
  12238. */
  12239. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of emit rate gradients.
  12242. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12243. * @returns the list of emit rate gradients
  12244. */
  12245. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12246. /**
  12247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12248. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12249. */
  12250. get direction1(): Vector3;
  12251. set direction1(value: Vector3);
  12252. /**
  12253. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12254. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12255. */
  12256. get direction2(): Vector3;
  12257. set direction2(value: Vector3);
  12258. /**
  12259. * 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.
  12260. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12261. */
  12262. get minEmitBox(): Vector3;
  12263. set minEmitBox(value: Vector3);
  12264. /**
  12265. * 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.
  12266. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12267. */
  12268. get maxEmitBox(): Vector3;
  12269. set maxEmitBox(value: Vector3);
  12270. /**
  12271. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12272. */
  12273. color1: Color4;
  12274. /**
  12275. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12276. */
  12277. color2: Color4;
  12278. /**
  12279. * Color the particle will have at the end of its lifetime
  12280. */
  12281. colorDead: Color4;
  12282. /**
  12283. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12284. */
  12285. textureMask: Color4;
  12286. /**
  12287. * The particle emitter type defines the emitter used by the particle system.
  12288. * It can be for example box, sphere, or cone...
  12289. */
  12290. particleEmitterType: IParticleEmitterType;
  12291. /** @hidden */
  12292. _isSubEmitter: boolean;
  12293. /**
  12294. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12295. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12296. */
  12297. billboardMode: number;
  12298. protected _isBillboardBased: boolean;
  12299. /**
  12300. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12301. */
  12302. get isBillboardBased(): boolean;
  12303. set isBillboardBased(value: boolean);
  12304. /**
  12305. * The scene the particle system belongs to.
  12306. */
  12307. protected _scene: Nullable<Scene>;
  12308. /**
  12309. * The engine the particle system belongs to.
  12310. */
  12311. protected _engine: ThinEngine;
  12312. /**
  12313. * Local cache of defines for image processing.
  12314. */
  12315. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12316. /**
  12317. * Default configuration related to image processing available in the standard Material.
  12318. */
  12319. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12320. /**
  12321. * Gets the image processing configuration used either in this material.
  12322. */
  12323. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12324. /**
  12325. * Sets the Default image processing configuration used either in the this material.
  12326. *
  12327. * If sets to null, the scene one is in use.
  12328. */
  12329. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12330. /**
  12331. * Attaches a new image processing configuration to the Standard Material.
  12332. * @param configuration
  12333. */
  12334. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12335. /** @hidden */
  12336. protected _reset(): void;
  12337. /** @hidden */
  12338. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12339. /**
  12340. * Instantiates a particle system.
  12341. * 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.
  12342. * @param name The name of the particle system
  12343. */
  12344. constructor(name: string);
  12345. /**
  12346. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12347. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12348. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12349. * @returns the emitter
  12350. */
  12351. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12352. /**
  12353. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12354. * @param radius The radius of the hemisphere to emit from
  12355. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12356. * @returns the emitter
  12357. */
  12358. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12359. /**
  12360. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12361. * @param radius The radius of the sphere to emit from
  12362. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12363. * @returns the emitter
  12364. */
  12365. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12366. /**
  12367. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12368. * @param radius The radius of the sphere to emit from
  12369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12371. * @returns the emitter
  12372. */
  12373. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12374. /**
  12375. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12376. * @param radius The radius of the emission cylinder
  12377. * @param height The height of the emission cylinder
  12378. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12379. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12380. * @returns the emitter
  12381. */
  12382. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12383. /**
  12384. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12385. * @param radius The radius of the cylinder to emit from
  12386. * @param height The height of the emission cylinder
  12387. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12388. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12389. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12390. * @returns the emitter
  12391. */
  12392. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12393. /**
  12394. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12395. * @param radius The radius of the cone to emit from
  12396. * @param angle The base angle of the cone
  12397. * @returns the emitter
  12398. */
  12399. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12400. /**
  12401. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12404. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12405. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12406. * @returns the emitter
  12407. */
  12408. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12409. }
  12410. }
  12411. declare module BABYLON {
  12412. /**
  12413. * Type of sub emitter
  12414. */
  12415. export enum SubEmitterType {
  12416. /**
  12417. * Attached to the particle over it's lifetime
  12418. */
  12419. ATTACHED = 0,
  12420. /**
  12421. * Created when the particle dies
  12422. */
  12423. END = 1
  12424. }
  12425. /**
  12426. * Sub emitter class used to emit particles from an existing particle
  12427. */
  12428. export class SubEmitter {
  12429. /**
  12430. * the particle system to be used by the sub emitter
  12431. */
  12432. particleSystem: ParticleSystem;
  12433. /**
  12434. * Type of the submitter (Default: END)
  12435. */
  12436. type: SubEmitterType;
  12437. /**
  12438. * 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)
  12439. * Note: This only is supported when using an emitter of type Mesh
  12440. */
  12441. inheritDirection: boolean;
  12442. /**
  12443. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12444. */
  12445. inheritedVelocityAmount: number;
  12446. /**
  12447. * Creates a sub emitter
  12448. * @param particleSystem the particle system to be used by the sub emitter
  12449. */
  12450. constructor(
  12451. /**
  12452. * the particle system to be used by the sub emitter
  12453. */
  12454. particleSystem: ParticleSystem);
  12455. /**
  12456. * Clones the sub emitter
  12457. * @returns the cloned sub emitter
  12458. */
  12459. clone(): SubEmitter;
  12460. /**
  12461. * Serialize current object to a JSON object
  12462. * @returns the serialized object
  12463. */
  12464. serialize(): any;
  12465. /** @hidden */
  12466. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12467. /**
  12468. * Creates a new SubEmitter from a serialized JSON version
  12469. * @param serializationObject defines the JSON object to read from
  12470. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12471. * @param rootUrl defines the rootUrl for data loading
  12472. * @returns a new SubEmitter
  12473. */
  12474. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12475. /** Release associated resources */
  12476. dispose(): void;
  12477. }
  12478. }
  12479. declare module BABYLON {
  12480. /** @hidden */
  12481. export var imageProcessingDeclaration: {
  12482. name: string;
  12483. shader: string;
  12484. };
  12485. }
  12486. declare module BABYLON {
  12487. /** @hidden */
  12488. export var imageProcessingFunctions: {
  12489. name: string;
  12490. shader: string;
  12491. };
  12492. }
  12493. declare module BABYLON {
  12494. /** @hidden */
  12495. export var particlesPixelShader: {
  12496. name: string;
  12497. shader: string;
  12498. };
  12499. }
  12500. declare module BABYLON {
  12501. /** @hidden */
  12502. export var particlesVertexShader: {
  12503. name: string;
  12504. shader: string;
  12505. };
  12506. }
  12507. declare module BABYLON {
  12508. /**
  12509. * Interface used to define entities containing multiple clip planes
  12510. */
  12511. export interface IClipPlanesHolder {
  12512. /**
  12513. * Gets or sets the active clipplane 1
  12514. */
  12515. clipPlane: Nullable<Plane>;
  12516. /**
  12517. * Gets or sets the active clipplane 2
  12518. */
  12519. clipPlane2: Nullable<Plane>;
  12520. /**
  12521. * Gets or sets the active clipplane 3
  12522. */
  12523. clipPlane3: Nullable<Plane>;
  12524. /**
  12525. * Gets or sets the active clipplane 4
  12526. */
  12527. clipPlane4: Nullable<Plane>;
  12528. /**
  12529. * Gets or sets the active clipplane 5
  12530. */
  12531. clipPlane5: Nullable<Plane>;
  12532. /**
  12533. * Gets or sets the active clipplane 6
  12534. */
  12535. clipPlane6: Nullable<Plane>;
  12536. }
  12537. }
  12538. declare module BABYLON {
  12539. /**
  12540. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12541. *
  12542. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12543. *
  12544. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12545. */
  12546. export class ThinMaterialHelper {
  12547. /**
  12548. * Binds the clip plane information from the holder to the effect.
  12549. * @param effect The effect we are binding the data to
  12550. * @param holder The entity containing the clip plane information
  12551. */
  12552. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12553. }
  12554. }
  12555. declare module BABYLON {
  12556. interface ThinEngine {
  12557. /**
  12558. * Sets alpha constants used by some alpha blending modes
  12559. * @param r defines the red component
  12560. * @param g defines the green component
  12561. * @param b defines the blue component
  12562. * @param a defines the alpha component
  12563. */
  12564. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12565. /**
  12566. * Sets the current alpha mode
  12567. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12568. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12569. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12570. */
  12571. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12572. /**
  12573. * Gets the current alpha mode
  12574. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12575. * @returns the current alpha mode
  12576. */
  12577. getAlphaMode(): number;
  12578. /**
  12579. * Sets the current alpha equation
  12580. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12581. */
  12582. setAlphaEquation(equation: number): void;
  12583. /**
  12584. * Gets the current alpha equation.
  12585. * @returns the current alpha equation
  12586. */
  12587. getAlphaEquation(): number;
  12588. }
  12589. }
  12590. declare module BABYLON {
  12591. /**
  12592. * This represents a particle system in Babylon.
  12593. * 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.
  12594. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12595. * @example https://doc.babylonjs.com/babylon101/particles
  12596. */
  12597. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12598. /**
  12599. * Billboard mode will only apply to Y axis
  12600. */
  12601. static readonly BILLBOARDMODE_Y: number;
  12602. /**
  12603. * Billboard mode will apply to all axes
  12604. */
  12605. static readonly BILLBOARDMODE_ALL: number;
  12606. /**
  12607. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12608. */
  12609. static readonly BILLBOARDMODE_STRETCHED: number;
  12610. /**
  12611. * This function can be defined to provide custom update for active particles.
  12612. * This function will be called instead of regular update (age, position, color, etc.).
  12613. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12614. */
  12615. updateFunction: (particles: Particle[]) => void;
  12616. private _emitterWorldMatrix;
  12617. /**
  12618. * This function can be defined to specify initial direction for every new particle.
  12619. * It by default use the emitterType defined function
  12620. */
  12621. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12622. /**
  12623. * This function can be defined to specify initial position for every new particle.
  12624. * It by default use the emitterType defined function
  12625. */
  12626. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12627. /**
  12628. * @hidden
  12629. */
  12630. _inheritedVelocityOffset: Vector3;
  12631. /**
  12632. * An event triggered when the system is disposed
  12633. */
  12634. onDisposeObservable: Observable<IParticleSystem>;
  12635. private _onDisposeObserver;
  12636. /**
  12637. * Sets a callback that will be triggered when the system is disposed
  12638. */
  12639. set onDispose(callback: () => void);
  12640. private _particles;
  12641. private _epsilon;
  12642. private _capacity;
  12643. private _stockParticles;
  12644. private _newPartsExcess;
  12645. private _vertexData;
  12646. private _vertexBuffer;
  12647. private _vertexBuffers;
  12648. private _spriteBuffer;
  12649. private _indexBuffer;
  12650. private _effect;
  12651. private _customEffect;
  12652. private _cachedDefines;
  12653. private _scaledColorStep;
  12654. private _colorDiff;
  12655. private _scaledDirection;
  12656. private _scaledGravity;
  12657. private _currentRenderId;
  12658. private _alive;
  12659. private _useInstancing;
  12660. private _started;
  12661. private _stopped;
  12662. private _actualFrame;
  12663. private _scaledUpdateSpeed;
  12664. private _vertexBufferSize;
  12665. /** @hidden */
  12666. _currentEmitRateGradient: Nullable<FactorGradient>;
  12667. /** @hidden */
  12668. _currentEmitRate1: number;
  12669. /** @hidden */
  12670. _currentEmitRate2: number;
  12671. /** @hidden */
  12672. _currentStartSizeGradient: Nullable<FactorGradient>;
  12673. /** @hidden */
  12674. _currentStartSize1: number;
  12675. /** @hidden */
  12676. _currentStartSize2: number;
  12677. private readonly _rawTextureWidth;
  12678. private _rampGradientsTexture;
  12679. private _useRampGradients;
  12680. /** Gets or sets a matrix to use to compute projection */
  12681. defaultProjectionMatrix: Matrix;
  12682. /** Gets or sets a matrix to use to compute view */
  12683. defaultViewMatrix: Matrix;
  12684. /** Gets or sets a boolean indicating that ramp gradients must be used
  12685. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12686. */
  12687. get useRampGradients(): boolean;
  12688. set useRampGradients(value: boolean);
  12689. /**
  12690. * 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.
  12691. * 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: [])
  12692. */
  12693. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12694. private _subEmitters;
  12695. /**
  12696. * @hidden
  12697. * If the particle systems emitter should be disposed when the particle system is disposed
  12698. */
  12699. _disposeEmitterOnDispose: boolean;
  12700. /**
  12701. * The current active Sub-systems, this property is used by the root particle system only.
  12702. */
  12703. activeSubSystems: Array<ParticleSystem>;
  12704. /**
  12705. * Specifies if the particles are updated in emitter local space or world space
  12706. */
  12707. isLocal: boolean;
  12708. private _rootParticleSystem;
  12709. /**
  12710. * Gets the current list of active particles
  12711. */
  12712. get particles(): Particle[];
  12713. /**
  12714. * Gets the number of particles active at the same time.
  12715. * @returns The number of active particles.
  12716. */
  12717. getActiveCount(): number;
  12718. /**
  12719. * Returns the string "ParticleSystem"
  12720. * @returns a string containing the class name
  12721. */
  12722. getClassName(): string;
  12723. /**
  12724. * Gets a boolean indicating that the system is stopping
  12725. * @returns true if the system is currently stopping
  12726. */
  12727. isStopping(): boolean;
  12728. /**
  12729. * Gets the custom effect used to render the particles
  12730. * @param blendMode Blend mode for which the effect should be retrieved
  12731. * @returns The effect
  12732. */
  12733. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12734. /**
  12735. * Sets the custom effect used to render the particles
  12736. * @param effect The effect to set
  12737. * @param blendMode Blend mode for which the effect should be set
  12738. */
  12739. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12740. /** @hidden */
  12741. private _onBeforeDrawParticlesObservable;
  12742. /**
  12743. * Observable that will be called just before the particles are drawn
  12744. */
  12745. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12746. /**
  12747. * Gets the name of the particle vertex shader
  12748. */
  12749. get vertexShaderName(): string;
  12750. /**
  12751. * Instantiates a particle system.
  12752. * 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.
  12753. * @param name The name of the particle system
  12754. * @param capacity The max number of particles alive at the same time
  12755. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12756. * @param customEffect a custom effect used to change the way particles are rendered by default
  12757. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12758. * @param epsilon Offset used to render the particles
  12759. */
  12760. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12761. private _addFactorGradient;
  12762. private _removeFactorGradient;
  12763. /**
  12764. * Adds a new life time gradient
  12765. * @param gradient defines the gradient to use (between 0 and 1)
  12766. * @param factor defines the life time factor to affect to the specified gradient
  12767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12768. * @returns the current particle system
  12769. */
  12770. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12771. /**
  12772. * Remove a specific life time gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12777. /**
  12778. * Adds a new size gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param factor defines the size factor to affect to the specified gradient
  12781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12782. * @returns the current particle system
  12783. */
  12784. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12785. /**
  12786. * Remove a specific size gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns the current particle system
  12789. */
  12790. removeSizeGradient(gradient: number): IParticleSystem;
  12791. /**
  12792. * Adds a new color remap gradient
  12793. * @param gradient defines the gradient to use (between 0 and 1)
  12794. * @param min defines the color remap minimal range
  12795. * @param max defines the color remap maximal range
  12796. * @returns the current particle system
  12797. */
  12798. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12799. /**
  12800. * Remove a specific color remap gradient
  12801. * @param gradient defines the gradient to remove
  12802. * @returns the current particle system
  12803. */
  12804. removeColorRemapGradient(gradient: number): IParticleSystem;
  12805. /**
  12806. * Adds a new alpha remap gradient
  12807. * @param gradient defines the gradient to use (between 0 and 1)
  12808. * @param min defines the alpha remap minimal range
  12809. * @param max defines the alpha remap maximal range
  12810. * @returns the current particle system
  12811. */
  12812. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12813. /**
  12814. * Remove a specific alpha remap gradient
  12815. * @param gradient defines the gradient to remove
  12816. * @returns the current particle system
  12817. */
  12818. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12819. /**
  12820. * Adds a new angular speed gradient
  12821. * @param gradient defines the gradient to use (between 0 and 1)
  12822. * @param factor defines the angular speed to affect to the specified gradient
  12823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12824. * @returns the current particle system
  12825. */
  12826. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12827. /**
  12828. * Remove a specific angular speed gradient
  12829. * @param gradient defines the gradient to remove
  12830. * @returns the current particle system
  12831. */
  12832. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12833. /**
  12834. * Adds a new velocity gradient
  12835. * @param gradient defines the gradient to use (between 0 and 1)
  12836. * @param factor defines the velocity to affect to the specified gradient
  12837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12838. * @returns the current particle system
  12839. */
  12840. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12841. /**
  12842. * Remove a specific velocity gradient
  12843. * @param gradient defines the gradient to remove
  12844. * @returns the current particle system
  12845. */
  12846. removeVelocityGradient(gradient: number): IParticleSystem;
  12847. /**
  12848. * Adds a new limit velocity gradient
  12849. * @param gradient defines the gradient to use (between 0 and 1)
  12850. * @param factor defines the limit velocity value to affect to the specified gradient
  12851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12852. * @returns the current particle system
  12853. */
  12854. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12855. /**
  12856. * Remove a specific limit velocity gradient
  12857. * @param gradient defines the gradient to remove
  12858. * @returns the current particle system
  12859. */
  12860. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12861. /**
  12862. * Adds a new drag gradient
  12863. * @param gradient defines the gradient to use (between 0 and 1)
  12864. * @param factor defines the drag value to affect to the specified gradient
  12865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12866. * @returns the current particle system
  12867. */
  12868. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12869. /**
  12870. * Remove a specific drag gradient
  12871. * @param gradient defines the gradient to remove
  12872. * @returns the current particle system
  12873. */
  12874. removeDragGradient(gradient: number): IParticleSystem;
  12875. /**
  12876. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12877. * @param gradient defines the gradient to use (between 0 and 1)
  12878. * @param factor defines the emit rate value to affect to the specified gradient
  12879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12880. * @returns the current particle system
  12881. */
  12882. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12883. /**
  12884. * Remove a specific emit rate gradient
  12885. * @param gradient defines the gradient to remove
  12886. * @returns the current particle system
  12887. */
  12888. removeEmitRateGradient(gradient: number): IParticleSystem;
  12889. /**
  12890. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12891. * @param gradient defines the gradient to use (between 0 and 1)
  12892. * @param factor defines the start size value to affect to the specified gradient
  12893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12894. * @returns the current particle system
  12895. */
  12896. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12897. /**
  12898. * Remove a specific start size gradient
  12899. * @param gradient defines the gradient to remove
  12900. * @returns the current particle system
  12901. */
  12902. removeStartSizeGradient(gradient: number): IParticleSystem;
  12903. private _createRampGradientTexture;
  12904. /**
  12905. * Gets the current list of ramp gradients.
  12906. * You must use addRampGradient and removeRampGradient to udpate this list
  12907. * @returns the list of ramp gradients
  12908. */
  12909. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12910. /** Force the system to rebuild all gradients that need to be resync */
  12911. forceRefreshGradients(): void;
  12912. private _syncRampGradientTexture;
  12913. /**
  12914. * Adds a new ramp gradient used to remap particle colors
  12915. * @param gradient defines the gradient to use (between 0 and 1)
  12916. * @param color defines the color to affect to the specified gradient
  12917. * @returns the current particle system
  12918. */
  12919. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12920. /**
  12921. * Remove a specific ramp gradient
  12922. * @param gradient defines the gradient to remove
  12923. * @returns the current particle system
  12924. */
  12925. removeRampGradient(gradient: number): ParticleSystem;
  12926. /**
  12927. * Adds a new color gradient
  12928. * @param gradient defines the gradient to use (between 0 and 1)
  12929. * @param color1 defines the color to affect to the specified gradient
  12930. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12931. * @returns this particle system
  12932. */
  12933. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12934. /**
  12935. * Remove a specific color gradient
  12936. * @param gradient defines the gradient to remove
  12937. * @returns this particle system
  12938. */
  12939. removeColorGradient(gradient: number): IParticleSystem;
  12940. private _fetchR;
  12941. protected _reset(): void;
  12942. private _resetEffect;
  12943. private _createVertexBuffers;
  12944. private _createIndexBuffer;
  12945. /**
  12946. * Gets the maximum number of particles active at the same time.
  12947. * @returns The max number of active particles.
  12948. */
  12949. getCapacity(): number;
  12950. /**
  12951. * Gets whether there are still active particles in the system.
  12952. * @returns True if it is alive, otherwise false.
  12953. */
  12954. isAlive(): boolean;
  12955. /**
  12956. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12957. * @returns True if it has been started, otherwise false.
  12958. */
  12959. isStarted(): boolean;
  12960. private _prepareSubEmitterInternalArray;
  12961. /**
  12962. * Starts the particle system and begins to emit
  12963. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12964. */
  12965. start(delay?: number): void;
  12966. /**
  12967. * Stops the particle system.
  12968. * @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.
  12969. */
  12970. stop(stopSubEmitters?: boolean): void;
  12971. /**
  12972. * Remove all active particles
  12973. */
  12974. reset(): void;
  12975. /**
  12976. * @hidden (for internal use only)
  12977. */
  12978. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12979. /**
  12980. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12981. * Its lifetime will start back at 0.
  12982. */
  12983. recycleParticle: (particle: Particle) => void;
  12984. private _stopSubEmitters;
  12985. private _createParticle;
  12986. private _removeFromRoot;
  12987. private _emitFromParticle;
  12988. private _update;
  12989. /** @hidden */
  12990. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12991. /** @hidden */
  12992. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12993. /**
  12994. * Fill the defines array according to the current settings of the particle system
  12995. * @param defines Array to be updated
  12996. * @param blendMode blend mode to take into account when updating the array
  12997. */
  12998. fillDefines(defines: Array<string>, blendMode: number): void;
  12999. /**
  13000. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13001. * @param uniforms Uniforms array to fill
  13002. * @param attributes Attributes array to fill
  13003. * @param samplers Samplers array to fill
  13004. */
  13005. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13006. /** @hidden */
  13007. private _getEffect;
  13008. /**
  13009. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13010. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13011. */
  13012. animate(preWarmOnly?: boolean): void;
  13013. private _appendParticleVertices;
  13014. /**
  13015. * Rebuilds the particle system.
  13016. */
  13017. rebuild(): void;
  13018. /**
  13019. * Is this system ready to be used/rendered
  13020. * @return true if the system is ready
  13021. */
  13022. isReady(): boolean;
  13023. private _render;
  13024. /**
  13025. * Renders the particle system in its current state.
  13026. * @returns the current number of particles
  13027. */
  13028. render(): number;
  13029. /**
  13030. * Disposes the particle system and free the associated resources
  13031. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13032. */
  13033. dispose(disposeTexture?: boolean): void;
  13034. /**
  13035. * Clones the particle system.
  13036. * @param name The name of the cloned object
  13037. * @param newEmitter The new emitter to use
  13038. * @returns the cloned particle system
  13039. */
  13040. clone(name: string, newEmitter: any): ParticleSystem;
  13041. /**
  13042. * Serializes the particle system to a JSON object
  13043. * @param serializeTexture defines if the texture must be serialized as well
  13044. * @returns the JSON object
  13045. */
  13046. serialize(serializeTexture?: boolean): any;
  13047. /** @hidden */
  13048. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13049. /** @hidden */
  13050. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13051. /**
  13052. * Parses a JSON object to create a particle system.
  13053. * @param parsedParticleSystem The JSON object to parse
  13054. * @param sceneOrEngine The scene or the engine to create the particle system in
  13055. * @param rootUrl The root url to use to load external dependencies like texture
  13056. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13057. * @returns the Parsed particle system
  13058. */
  13059. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13060. }
  13061. }
  13062. declare module BABYLON {
  13063. /**
  13064. * A particle represents one of the element emitted by a particle system.
  13065. * This is mainly define by its coordinates, direction, velocity and age.
  13066. */
  13067. export class Particle {
  13068. /**
  13069. * The particle system the particle belongs to.
  13070. */
  13071. particleSystem: ParticleSystem;
  13072. private static _Count;
  13073. /**
  13074. * Unique ID of the particle
  13075. */
  13076. id: number;
  13077. /**
  13078. * The world position of the particle in the scene.
  13079. */
  13080. position: Vector3;
  13081. /**
  13082. * The world direction of the particle in the scene.
  13083. */
  13084. direction: Vector3;
  13085. /**
  13086. * The color of the particle.
  13087. */
  13088. color: Color4;
  13089. /**
  13090. * The color change of the particle per step.
  13091. */
  13092. colorStep: Color4;
  13093. /**
  13094. * Defines how long will the life of the particle be.
  13095. */
  13096. lifeTime: number;
  13097. /**
  13098. * The current age of the particle.
  13099. */
  13100. age: number;
  13101. /**
  13102. * The current size of the particle.
  13103. */
  13104. size: number;
  13105. /**
  13106. * The current scale of the particle.
  13107. */
  13108. scale: Vector2;
  13109. /**
  13110. * The current angle of the particle.
  13111. */
  13112. angle: number;
  13113. /**
  13114. * Defines how fast is the angle changing.
  13115. */
  13116. angularSpeed: number;
  13117. /**
  13118. * Defines the cell index used by the particle to be rendered from a sprite.
  13119. */
  13120. cellIndex: number;
  13121. /**
  13122. * The information required to support color remapping
  13123. */
  13124. remapData: Vector4;
  13125. /** @hidden */
  13126. _randomCellOffset?: number;
  13127. /** @hidden */
  13128. _initialDirection: Nullable<Vector3>;
  13129. /** @hidden */
  13130. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13131. /** @hidden */
  13132. _initialStartSpriteCellID: number;
  13133. /** @hidden */
  13134. _initialEndSpriteCellID: number;
  13135. /** @hidden */
  13136. _currentColorGradient: Nullable<ColorGradient>;
  13137. /** @hidden */
  13138. _currentColor1: Color4;
  13139. /** @hidden */
  13140. _currentColor2: Color4;
  13141. /** @hidden */
  13142. _currentSizeGradient: Nullable<FactorGradient>;
  13143. /** @hidden */
  13144. _currentSize1: number;
  13145. /** @hidden */
  13146. _currentSize2: number;
  13147. /** @hidden */
  13148. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13149. /** @hidden */
  13150. _currentAngularSpeed1: number;
  13151. /** @hidden */
  13152. _currentAngularSpeed2: number;
  13153. /** @hidden */
  13154. _currentVelocityGradient: Nullable<FactorGradient>;
  13155. /** @hidden */
  13156. _currentVelocity1: number;
  13157. /** @hidden */
  13158. _currentVelocity2: number;
  13159. /** @hidden */
  13160. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13161. /** @hidden */
  13162. _currentLimitVelocity1: number;
  13163. /** @hidden */
  13164. _currentLimitVelocity2: number;
  13165. /** @hidden */
  13166. _currentDragGradient: Nullable<FactorGradient>;
  13167. /** @hidden */
  13168. _currentDrag1: number;
  13169. /** @hidden */
  13170. _currentDrag2: number;
  13171. /** @hidden */
  13172. _randomNoiseCoordinates1: Vector3;
  13173. /** @hidden */
  13174. _randomNoiseCoordinates2: Vector3;
  13175. /** @hidden */
  13176. _localPosition?: Vector3;
  13177. /**
  13178. * Creates a new instance Particle
  13179. * @param particleSystem the particle system the particle belongs to
  13180. */
  13181. constructor(
  13182. /**
  13183. * The particle system the particle belongs to.
  13184. */
  13185. particleSystem: ParticleSystem);
  13186. private updateCellInfoFromSystem;
  13187. /**
  13188. * Defines how the sprite cell index is updated for the particle
  13189. */
  13190. updateCellIndex(): void;
  13191. /** @hidden */
  13192. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13193. /** @hidden */
  13194. _inheritParticleInfoToSubEmitters(): void;
  13195. /** @hidden */
  13196. _reset(): void;
  13197. /**
  13198. * Copy the properties of particle to another one.
  13199. * @param other the particle to copy the information to.
  13200. */
  13201. copyTo(other: Particle): void;
  13202. }
  13203. }
  13204. declare module BABYLON {
  13205. /**
  13206. * Particle emitter represents a volume emitting particles.
  13207. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13208. */
  13209. export interface IParticleEmitterType {
  13210. /**
  13211. * Called by the particle System when the direction is computed for the created particle.
  13212. * @param worldMatrix is the world matrix of the particle system
  13213. * @param directionToUpdate is the direction vector to update with the result
  13214. * @param particle is the particle we are computed the direction for
  13215. * @param isLocal defines if the direction should be set in local space
  13216. */
  13217. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13218. /**
  13219. * Called by the particle System when the position is computed for the created particle.
  13220. * @param worldMatrix is the world matrix of the particle system
  13221. * @param positionToUpdate is the position vector to update with the result
  13222. * @param particle is the particle we are computed the position for
  13223. * @param isLocal defines if the position should be set in local space
  13224. */
  13225. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13226. /**
  13227. * Clones the current emitter and returns a copy of it
  13228. * @returns the new emitter
  13229. */
  13230. clone(): IParticleEmitterType;
  13231. /**
  13232. * Called by the GPUParticleSystem to setup the update shader
  13233. * @param effect defines the update shader
  13234. */
  13235. applyToShader(effect: Effect): void;
  13236. /**
  13237. * Returns a string to use to update the GPU particles update shader
  13238. * @returns the effect defines string
  13239. */
  13240. getEffectDefines(): string;
  13241. /**
  13242. * Returns a string representing the class name
  13243. * @returns a string containing the class name
  13244. */
  13245. getClassName(): string;
  13246. /**
  13247. * Serializes the particle system to a JSON object.
  13248. * @returns the JSON object
  13249. */
  13250. serialize(): any;
  13251. /**
  13252. * Parse properties from a JSON object
  13253. * @param serializationObject defines the JSON object
  13254. * @param scene defines the hosting scene
  13255. */
  13256. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13257. }
  13258. }
  13259. declare module BABYLON {
  13260. /**
  13261. * Particle emitter emitting particles from the inside of a box.
  13262. * It emits the particles randomly between 2 given directions.
  13263. */
  13264. export class BoxParticleEmitter implements IParticleEmitterType {
  13265. /**
  13266. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13267. */
  13268. direction1: Vector3;
  13269. /**
  13270. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13271. */
  13272. direction2: Vector3;
  13273. /**
  13274. * 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.
  13275. */
  13276. minEmitBox: Vector3;
  13277. /**
  13278. * 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.
  13279. */
  13280. maxEmitBox: Vector3;
  13281. /**
  13282. * Creates a new instance BoxParticleEmitter
  13283. */
  13284. constructor();
  13285. /**
  13286. * Called by the particle System when the direction is computed for the created particle.
  13287. * @param worldMatrix is the world matrix of the particle system
  13288. * @param directionToUpdate is the direction vector to update with the result
  13289. * @param particle is the particle we are computed the direction for
  13290. * @param isLocal defines if the direction should be set in local space
  13291. */
  13292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13293. /**
  13294. * Called by the particle System when the position is computed for the created particle.
  13295. * @param worldMatrix is the world matrix of the particle system
  13296. * @param positionToUpdate is the position vector to update with the result
  13297. * @param particle is the particle we are computed the position for
  13298. * @param isLocal defines if the position should be set in local space
  13299. */
  13300. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13301. /**
  13302. * Clones the current emitter and returns a copy of it
  13303. * @returns the new emitter
  13304. */
  13305. clone(): BoxParticleEmitter;
  13306. /**
  13307. * Called by the GPUParticleSystem to setup the update shader
  13308. * @param effect defines the update shader
  13309. */
  13310. applyToShader(effect: Effect): void;
  13311. /**
  13312. * Returns a string to use to update the GPU particles update shader
  13313. * @returns a string containng the defines string
  13314. */
  13315. getEffectDefines(): string;
  13316. /**
  13317. * Returns the string "BoxParticleEmitter"
  13318. * @returns a string containing the class name
  13319. */
  13320. getClassName(): string;
  13321. /**
  13322. * Serializes the particle system to a JSON object.
  13323. * @returns the JSON object
  13324. */
  13325. serialize(): any;
  13326. /**
  13327. * Parse properties from a JSON object
  13328. * @param serializationObject defines the JSON object
  13329. */
  13330. parse(serializationObject: any): void;
  13331. }
  13332. }
  13333. declare module BABYLON {
  13334. /**
  13335. * Particle emitter emitting particles from the inside of a cone.
  13336. * It emits the particles alongside the cone volume from the base to the particle.
  13337. * The emission direction might be randomized.
  13338. */
  13339. export class ConeParticleEmitter implements IParticleEmitterType {
  13340. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13341. directionRandomizer: number;
  13342. private _radius;
  13343. private _angle;
  13344. private _height;
  13345. /**
  13346. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13347. */
  13348. radiusRange: number;
  13349. /**
  13350. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13351. */
  13352. heightRange: number;
  13353. /**
  13354. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13355. */
  13356. emitFromSpawnPointOnly: boolean;
  13357. /**
  13358. * Gets or sets the radius of the emission cone
  13359. */
  13360. get radius(): number;
  13361. set radius(value: number);
  13362. /**
  13363. * Gets or sets the angle of the emission cone
  13364. */
  13365. get angle(): number;
  13366. set angle(value: number);
  13367. private _buildHeight;
  13368. /**
  13369. * Creates a new instance ConeParticleEmitter
  13370. * @param radius the radius of the emission cone (1 by default)
  13371. * @param angle the cone base angle (PI by default)
  13372. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13373. */
  13374. constructor(radius?: number, angle?: number,
  13375. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13376. directionRandomizer?: number);
  13377. /**
  13378. * Called by the particle System when the direction is computed for the created particle.
  13379. * @param worldMatrix is the world matrix of the particle system
  13380. * @param directionToUpdate is the direction vector to update with the result
  13381. * @param particle is the particle we are computed the direction for
  13382. * @param isLocal defines if the direction should be set in local space
  13383. */
  13384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13385. /**
  13386. * Called by the particle System when the position is computed for the created particle.
  13387. * @param worldMatrix is the world matrix of the particle system
  13388. * @param positionToUpdate is the position vector to update with the result
  13389. * @param particle is the particle we are computed the position for
  13390. * @param isLocal defines if the position should be set in local space
  13391. */
  13392. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13393. /**
  13394. * Clones the current emitter and returns a copy of it
  13395. * @returns the new emitter
  13396. */
  13397. clone(): ConeParticleEmitter;
  13398. /**
  13399. * Called by the GPUParticleSystem to setup the update shader
  13400. * @param effect defines the update shader
  13401. */
  13402. applyToShader(effect: Effect): void;
  13403. /**
  13404. * Returns a string to use to update the GPU particles update shader
  13405. * @returns a string containng the defines string
  13406. */
  13407. getEffectDefines(): string;
  13408. /**
  13409. * Returns the string "ConeParticleEmitter"
  13410. * @returns a string containing the class name
  13411. */
  13412. getClassName(): string;
  13413. /**
  13414. * Serializes the particle system to a JSON object.
  13415. * @returns the JSON object
  13416. */
  13417. serialize(): any;
  13418. /**
  13419. * Parse properties from a JSON object
  13420. * @param serializationObject defines the JSON object
  13421. */
  13422. parse(serializationObject: any): void;
  13423. }
  13424. }
  13425. declare module BABYLON {
  13426. /**
  13427. * Particle emitter emitting particles from the inside of a cylinder.
  13428. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13429. */
  13430. export class CylinderParticleEmitter implements IParticleEmitterType {
  13431. /**
  13432. * The radius of the emission cylinder.
  13433. */
  13434. radius: number;
  13435. /**
  13436. * The height of the emission cylinder.
  13437. */
  13438. height: number;
  13439. /**
  13440. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13441. */
  13442. radiusRange: number;
  13443. /**
  13444. * How much to randomize the particle direction [0-1].
  13445. */
  13446. directionRandomizer: number;
  13447. /**
  13448. * Creates a new instance CylinderParticleEmitter
  13449. * @param radius the radius of the emission cylinder (1 by default)
  13450. * @param height the height of the emission cylinder (1 by default)
  13451. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13453. */
  13454. constructor(
  13455. /**
  13456. * The radius of the emission cylinder.
  13457. */
  13458. radius?: number,
  13459. /**
  13460. * The height of the emission cylinder.
  13461. */
  13462. height?: number,
  13463. /**
  13464. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13465. */
  13466. radiusRange?: number,
  13467. /**
  13468. * How much to randomize the particle direction [0-1].
  13469. */
  13470. directionRandomizer?: number);
  13471. /**
  13472. * Called by the particle System when the direction is computed for the created particle.
  13473. * @param worldMatrix is the world matrix of the particle system
  13474. * @param directionToUpdate is the direction vector to update with the result
  13475. * @param particle is the particle we are computed the direction for
  13476. * @param isLocal defines if the direction should be set in local space
  13477. */
  13478. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13479. /**
  13480. * Called by the particle System when the position is computed for the created particle.
  13481. * @param worldMatrix is the world matrix of the particle system
  13482. * @param positionToUpdate is the position vector to update with the result
  13483. * @param particle is the particle we are computed the position for
  13484. * @param isLocal defines if the position should be set in local space
  13485. */
  13486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13487. /**
  13488. * Clones the current emitter and returns a copy of it
  13489. * @returns the new emitter
  13490. */
  13491. clone(): CylinderParticleEmitter;
  13492. /**
  13493. * Called by the GPUParticleSystem to setup the update shader
  13494. * @param effect defines the update shader
  13495. */
  13496. applyToShader(effect: Effect): void;
  13497. /**
  13498. * Returns a string to use to update the GPU particles update shader
  13499. * @returns a string containng the defines string
  13500. */
  13501. getEffectDefines(): string;
  13502. /**
  13503. * Returns the string "CylinderParticleEmitter"
  13504. * @returns a string containing the class name
  13505. */
  13506. getClassName(): string;
  13507. /**
  13508. * Serializes the particle system to a JSON object.
  13509. * @returns the JSON object
  13510. */
  13511. serialize(): any;
  13512. /**
  13513. * Parse properties from a JSON object
  13514. * @param serializationObject defines the JSON object
  13515. */
  13516. parse(serializationObject: any): void;
  13517. }
  13518. /**
  13519. * Particle emitter emitting particles from the inside of a cylinder.
  13520. * It emits the particles randomly between two vectors.
  13521. */
  13522. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13523. /**
  13524. * The min limit of the emission direction.
  13525. */
  13526. direction1: Vector3;
  13527. /**
  13528. * The max limit of the emission direction.
  13529. */
  13530. direction2: Vector3;
  13531. /**
  13532. * Creates a new instance CylinderDirectedParticleEmitter
  13533. * @param radius the radius of the emission cylinder (1 by default)
  13534. * @param height the height of the emission cylinder (1 by default)
  13535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13536. * @param direction1 the min limit of the emission direction (up vector by default)
  13537. * @param direction2 the max limit of the emission direction (up vector by default)
  13538. */
  13539. constructor(radius?: number, height?: number, radiusRange?: number,
  13540. /**
  13541. * The min limit of the emission direction.
  13542. */
  13543. direction1?: Vector3,
  13544. /**
  13545. * The max limit of the emission direction.
  13546. */
  13547. direction2?: Vector3);
  13548. /**
  13549. * Called by the particle System when the direction is computed for the created particle.
  13550. * @param worldMatrix is the world matrix of the particle system
  13551. * @param directionToUpdate is the direction vector to update with the result
  13552. * @param particle is the particle we are computed the direction for
  13553. */
  13554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): CylinderDirectedParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "CylinderDirectedParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a hemisphere.
  13590. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13591. */
  13592. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * The radius of the emission hemisphere.
  13595. */
  13596. radius: number;
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange: number;
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer: number;
  13605. /**
  13606. * Creates a new instance HemisphericParticleEmitter
  13607. * @param radius the radius of the emission hemisphere (1 by default)
  13608. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission hemisphere.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13618. */
  13619. radiusRange?: number,
  13620. /**
  13621. * How much to randomize the particle direction [0-1].
  13622. */
  13623. directionRandomizer?: number);
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): HemisphericParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "HemisphericParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. }
  13672. declare module BABYLON {
  13673. /**
  13674. * Particle emitter emitting particles from a point.
  13675. * It emits the particles randomly between 2 given directions.
  13676. */
  13677. export class PointParticleEmitter implements IParticleEmitterType {
  13678. /**
  13679. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance PointParticleEmitter
  13688. */
  13689. constructor();
  13690. /**
  13691. * Called by the particle System when the direction is computed for the created particle.
  13692. * @param worldMatrix is the world matrix of the particle system
  13693. * @param directionToUpdate is the direction vector to update with the result
  13694. * @param particle is the particle we are computed the direction for
  13695. * @param isLocal defines if the direction should be set in local space
  13696. */
  13697. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13698. /**
  13699. * Called by the particle System when the position is computed for the created particle.
  13700. * @param worldMatrix is the world matrix of the particle system
  13701. * @param positionToUpdate is the position vector to update with the result
  13702. * @param particle is the particle we are computed the position for
  13703. * @param isLocal defines if the position should be set in local space
  13704. */
  13705. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): PointParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "PointParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module BABYLON {
  13739. /**
  13740. * Particle emitter emitting particles from the inside of a sphere.
  13741. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13742. */
  13743. export class SphereParticleEmitter implements IParticleEmitterType {
  13744. /**
  13745. * The radius of the emission sphere.
  13746. */
  13747. radius: number;
  13748. /**
  13749. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13750. */
  13751. radiusRange: number;
  13752. /**
  13753. * How much to randomize the particle direction [0-1].
  13754. */
  13755. directionRandomizer: number;
  13756. /**
  13757. * Creates a new instance SphereParticleEmitter
  13758. * @param radius the radius of the emission sphere (1 by default)
  13759. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13760. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13761. */
  13762. constructor(
  13763. /**
  13764. * The radius of the emission sphere.
  13765. */
  13766. radius?: number,
  13767. /**
  13768. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13769. */
  13770. radiusRange?: number,
  13771. /**
  13772. * How much to randomize the particle direction [0-1].
  13773. */
  13774. directionRandomizer?: number);
  13775. /**
  13776. * Called by the particle System when the direction is computed for the created particle.
  13777. * @param worldMatrix is the world matrix of the particle system
  13778. * @param directionToUpdate is the direction vector to update with the result
  13779. * @param particle is the particle we are computed the direction for
  13780. * @param isLocal defines if the direction should be set in local space
  13781. */
  13782. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13783. /**
  13784. * Called by the particle System when the position is computed for the created particle.
  13785. * @param worldMatrix is the world matrix of the particle system
  13786. * @param positionToUpdate is the position vector to update with the result
  13787. * @param particle is the particle we are computed the position for
  13788. * @param isLocal defines if the position should be set in local space
  13789. */
  13790. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13791. /**
  13792. * Clones the current emitter and returns a copy of it
  13793. * @returns the new emitter
  13794. */
  13795. clone(): SphereParticleEmitter;
  13796. /**
  13797. * Called by the GPUParticleSystem to setup the update shader
  13798. * @param effect defines the update shader
  13799. */
  13800. applyToShader(effect: Effect): void;
  13801. /**
  13802. * Returns a string to use to update the GPU particles update shader
  13803. * @returns a string containng the defines string
  13804. */
  13805. getEffectDefines(): string;
  13806. /**
  13807. * Returns the string "SphereParticleEmitter"
  13808. * @returns a string containing the class name
  13809. */
  13810. getClassName(): string;
  13811. /**
  13812. * Serializes the particle system to a JSON object.
  13813. * @returns the JSON object
  13814. */
  13815. serialize(): any;
  13816. /**
  13817. * Parse properties from a JSON object
  13818. * @param serializationObject defines the JSON object
  13819. */
  13820. parse(serializationObject: any): void;
  13821. }
  13822. /**
  13823. * Particle emitter emitting particles from the inside of a sphere.
  13824. * It emits the particles randomly between two vectors.
  13825. */
  13826. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13827. /**
  13828. * The min limit of the emission direction.
  13829. */
  13830. direction1: Vector3;
  13831. /**
  13832. * The max limit of the emission direction.
  13833. */
  13834. direction2: Vector3;
  13835. /**
  13836. * Creates a new instance SphereDirectedParticleEmitter
  13837. * @param radius the radius of the emission sphere (1 by default)
  13838. * @param direction1 the min limit of the emission direction (up vector by default)
  13839. * @param direction2 the max limit of the emission direction (up vector by default)
  13840. */
  13841. constructor(radius?: number,
  13842. /**
  13843. * The min limit of the emission direction.
  13844. */
  13845. direction1?: Vector3,
  13846. /**
  13847. * The max limit of the emission direction.
  13848. */
  13849. direction2?: Vector3);
  13850. /**
  13851. * Called by the particle System when the direction is computed for the created particle.
  13852. * @param worldMatrix is the world matrix of the particle system
  13853. * @param directionToUpdate is the direction vector to update with the result
  13854. * @param particle is the particle we are computed the direction for
  13855. */
  13856. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13857. /**
  13858. * Clones the current emitter and returns a copy of it
  13859. * @returns the new emitter
  13860. */
  13861. clone(): SphereDirectedParticleEmitter;
  13862. /**
  13863. * Called by the GPUParticleSystem to setup the update shader
  13864. * @param effect defines the update shader
  13865. */
  13866. applyToShader(effect: Effect): void;
  13867. /**
  13868. * Returns a string to use to update the GPU particles update shader
  13869. * @returns a string containng the defines string
  13870. */
  13871. getEffectDefines(): string;
  13872. /**
  13873. * Returns the string "SphereDirectedParticleEmitter"
  13874. * @returns a string containing the class name
  13875. */
  13876. getClassName(): string;
  13877. /**
  13878. * Serializes the particle system to a JSON object.
  13879. * @returns the JSON object
  13880. */
  13881. serialize(): any;
  13882. /**
  13883. * Parse properties from a JSON object
  13884. * @param serializationObject defines the JSON object
  13885. */
  13886. parse(serializationObject: any): void;
  13887. }
  13888. }
  13889. declare module BABYLON {
  13890. /**
  13891. * Particle emitter emitting particles from a custom list of positions.
  13892. */
  13893. export class CustomParticleEmitter implements IParticleEmitterType {
  13894. /**
  13895. * Gets or sets the position generator that will create the inital position of each particle.
  13896. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13897. */
  13898. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13899. /**
  13900. * Gets or sets the destination generator that will create the final destination of each particle.
  13901. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13902. */
  13903. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13904. /**
  13905. * Creates a new instance CustomParticleEmitter
  13906. */
  13907. constructor();
  13908. /**
  13909. * Called by the particle System when the direction is computed for the created particle.
  13910. * @param worldMatrix is the world matrix of the particle system
  13911. * @param directionToUpdate is the direction vector to update with the result
  13912. * @param particle is the particle we are computed the direction for
  13913. * @param isLocal defines if the direction should be set in local space
  13914. */
  13915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13916. /**
  13917. * Called by the particle System when the position is computed for the created particle.
  13918. * @param worldMatrix is the world matrix of the particle system
  13919. * @param positionToUpdate is the position vector to update with the result
  13920. * @param particle is the particle we are computed the position for
  13921. * @param isLocal defines if the position should be set in local space
  13922. */
  13923. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13924. /**
  13925. * Clones the current emitter and returns a copy of it
  13926. * @returns the new emitter
  13927. */
  13928. clone(): CustomParticleEmitter;
  13929. /**
  13930. * Called by the GPUParticleSystem to setup the update shader
  13931. * @param effect defines the update shader
  13932. */
  13933. applyToShader(effect: Effect): void;
  13934. /**
  13935. * Returns a string to use to update the GPU particles update shader
  13936. * @returns a string containng the defines string
  13937. */
  13938. getEffectDefines(): string;
  13939. /**
  13940. * Returns the string "PointParticleEmitter"
  13941. * @returns a string containing the class name
  13942. */
  13943. getClassName(): string;
  13944. /**
  13945. * Serializes the particle system to a JSON object.
  13946. * @returns the JSON object
  13947. */
  13948. serialize(): any;
  13949. /**
  13950. * Parse properties from a JSON object
  13951. * @param serializationObject defines the JSON object
  13952. */
  13953. parse(serializationObject: any): void;
  13954. }
  13955. }
  13956. declare module BABYLON {
  13957. /**
  13958. * Particle emitter emitting particles from the inside of a box.
  13959. * It emits the particles randomly between 2 given directions.
  13960. */
  13961. export class MeshParticleEmitter implements IParticleEmitterType {
  13962. private _indices;
  13963. private _positions;
  13964. private _normals;
  13965. private _storedNormal;
  13966. private _mesh;
  13967. /**
  13968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13969. */
  13970. direction1: Vector3;
  13971. /**
  13972. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13973. */
  13974. direction2: Vector3;
  13975. /**
  13976. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13977. */
  13978. useMeshNormalsForDirection: boolean;
  13979. /** Defines the mesh to use as source */
  13980. get mesh(): Nullable<AbstractMesh>;
  13981. set mesh(value: Nullable<AbstractMesh>);
  13982. /**
  13983. * Creates a new instance MeshParticleEmitter
  13984. * @param mesh defines the mesh to use as source
  13985. */
  13986. constructor(mesh?: Nullable<AbstractMesh>);
  13987. /**
  13988. * Called by the particle System when the direction is computed for the created particle.
  13989. * @param worldMatrix is the world matrix of the particle system
  13990. * @param directionToUpdate is the direction vector to update with the result
  13991. * @param particle is the particle we are computed the direction for
  13992. * @param isLocal defines if the direction should be set in local space
  13993. */
  13994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13995. /**
  13996. * Called by the particle System when the position is computed for the created particle.
  13997. * @param worldMatrix is the world matrix of the particle system
  13998. * @param positionToUpdate is the position vector to update with the result
  13999. * @param particle is the particle we are computed the position for
  14000. * @param isLocal defines if the position should be set in local space
  14001. */
  14002. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14003. /**
  14004. * Clones the current emitter and returns a copy of it
  14005. * @returns the new emitter
  14006. */
  14007. clone(): MeshParticleEmitter;
  14008. /**
  14009. * Called by the GPUParticleSystem to setup the update shader
  14010. * @param effect defines the update shader
  14011. */
  14012. applyToShader(effect: Effect): void;
  14013. /**
  14014. * Returns a string to use to update the GPU particles update shader
  14015. * @returns a string containng the defines string
  14016. */
  14017. getEffectDefines(): string;
  14018. /**
  14019. * Returns the string "BoxParticleEmitter"
  14020. * @returns a string containing the class name
  14021. */
  14022. getClassName(): string;
  14023. /**
  14024. * Serializes the particle system to a JSON object.
  14025. * @returns the JSON object
  14026. */
  14027. serialize(): any;
  14028. /**
  14029. * Parse properties from a JSON object
  14030. * @param serializationObject defines the JSON object
  14031. * @param scene defines the hosting scene
  14032. */
  14033. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14034. }
  14035. }
  14036. declare module BABYLON {
  14037. /**
  14038. * Interface representing a particle system in Babylon.js.
  14039. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14040. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14041. */
  14042. export interface IParticleSystem {
  14043. /**
  14044. * List of animations used by the particle system.
  14045. */
  14046. animations: Animation[];
  14047. /**
  14048. * The id of the Particle system.
  14049. */
  14050. id: string;
  14051. /**
  14052. * The name of the Particle system.
  14053. */
  14054. name: string;
  14055. /**
  14056. * The emitter represents the Mesh or position we are attaching the particle system to.
  14057. */
  14058. emitter: Nullable<AbstractMesh | Vector3>;
  14059. /**
  14060. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14061. */
  14062. isBillboardBased: boolean;
  14063. /**
  14064. * The rendering group used by the Particle system to chose when to render.
  14065. */
  14066. renderingGroupId: number;
  14067. /**
  14068. * The layer mask we are rendering the particles through.
  14069. */
  14070. layerMask: number;
  14071. /**
  14072. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14073. */
  14074. updateSpeed: number;
  14075. /**
  14076. * The amount of time the particle system is running (depends of the overall update speed).
  14077. */
  14078. targetStopDuration: number;
  14079. /**
  14080. * The texture used to render each particle. (this can be a spritesheet)
  14081. */
  14082. particleTexture: Nullable<BaseTexture>;
  14083. /**
  14084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14085. */
  14086. blendMode: number;
  14087. /**
  14088. * Minimum life time of emitting particles.
  14089. */
  14090. minLifeTime: number;
  14091. /**
  14092. * Maximum life time of emitting particles.
  14093. */
  14094. maxLifeTime: number;
  14095. /**
  14096. * Minimum Size of emitting particles.
  14097. */
  14098. minSize: number;
  14099. /**
  14100. * Maximum Size of emitting particles.
  14101. */
  14102. maxSize: number;
  14103. /**
  14104. * Minimum scale of emitting particles on X axis.
  14105. */
  14106. minScaleX: number;
  14107. /**
  14108. * Maximum scale of emitting particles on X axis.
  14109. */
  14110. maxScaleX: number;
  14111. /**
  14112. * Minimum scale of emitting particles on Y axis.
  14113. */
  14114. minScaleY: number;
  14115. /**
  14116. * Maximum scale of emitting particles on Y axis.
  14117. */
  14118. maxScaleY: number;
  14119. /**
  14120. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14121. */
  14122. color1: Color4;
  14123. /**
  14124. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14125. */
  14126. color2: Color4;
  14127. /**
  14128. * Color the particle will have at the end of its lifetime.
  14129. */
  14130. colorDead: Color4;
  14131. /**
  14132. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14133. */
  14134. emitRate: number;
  14135. /**
  14136. * You can use gravity if you want to give an orientation to your particles.
  14137. */
  14138. gravity: Vector3;
  14139. /**
  14140. * Minimum power of emitting particles.
  14141. */
  14142. minEmitPower: number;
  14143. /**
  14144. * Maximum power of emitting particles.
  14145. */
  14146. maxEmitPower: number;
  14147. /**
  14148. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14149. */
  14150. minAngularSpeed: number;
  14151. /**
  14152. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14153. */
  14154. maxAngularSpeed: number;
  14155. /**
  14156. * Gets or sets the minimal initial rotation in radians.
  14157. */
  14158. minInitialRotation: number;
  14159. /**
  14160. * Gets or sets the maximal initial rotation in radians.
  14161. */
  14162. maxInitialRotation: number;
  14163. /**
  14164. * The particle emitter type defines the emitter used by the particle system.
  14165. * It can be for example box, sphere, or cone...
  14166. */
  14167. particleEmitterType: Nullable<IParticleEmitterType>;
  14168. /**
  14169. * Defines the delay in milliseconds before starting the system (0 by default)
  14170. */
  14171. startDelay: number;
  14172. /**
  14173. * 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
  14174. */
  14175. preWarmCycles: number;
  14176. /**
  14177. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14178. */
  14179. preWarmStepOffset: number;
  14180. /**
  14181. * 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)
  14182. */
  14183. spriteCellChangeSpeed: number;
  14184. /**
  14185. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14186. */
  14187. startSpriteCellID: number;
  14188. /**
  14189. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14190. */
  14191. endSpriteCellID: number;
  14192. /**
  14193. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14194. */
  14195. spriteCellWidth: number;
  14196. /**
  14197. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14198. */
  14199. spriteCellHeight: number;
  14200. /**
  14201. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14202. */
  14203. spriteRandomStartCell: boolean;
  14204. /**
  14205. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14206. */
  14207. isAnimationSheetEnabled: boolean;
  14208. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14209. translationPivot: Vector2;
  14210. /**
  14211. * Gets or sets a texture used to add random noise to particle positions
  14212. */
  14213. noiseTexture: Nullable<BaseTexture>;
  14214. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14215. noiseStrength: Vector3;
  14216. /**
  14217. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14218. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14219. */
  14220. billboardMode: number;
  14221. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14222. limitVelocityDamping: number;
  14223. /**
  14224. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14225. */
  14226. beginAnimationOnStart: boolean;
  14227. /**
  14228. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14229. */
  14230. beginAnimationFrom: number;
  14231. /**
  14232. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14233. */
  14234. beginAnimationTo: number;
  14235. /**
  14236. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14237. */
  14238. beginAnimationLoop: boolean;
  14239. /**
  14240. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14241. */
  14242. disposeOnStop: boolean;
  14243. /**
  14244. * Specifies if the particles are updated in emitter local space or world space
  14245. */
  14246. isLocal: boolean;
  14247. /** Snippet ID if the particle system was created from the snippet server */
  14248. snippetId: string;
  14249. /** Gets or sets a matrix to use to compute projection */
  14250. defaultProjectionMatrix: Matrix;
  14251. /**
  14252. * Gets the maximum number of particles active at the same time.
  14253. * @returns The max number of active particles.
  14254. */
  14255. getCapacity(): number;
  14256. /**
  14257. * Gets the number of particles active at the same time.
  14258. * @returns The number of active particles.
  14259. */
  14260. getActiveCount(): number;
  14261. /**
  14262. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14263. * @returns True if it has been started, otherwise false.
  14264. */
  14265. isStarted(): boolean;
  14266. /**
  14267. * Animates the particle system for this frame.
  14268. */
  14269. animate(): void;
  14270. /**
  14271. * Renders the particle system in its current state.
  14272. * @returns the current number of particles
  14273. */
  14274. render(): number;
  14275. /**
  14276. * Dispose the particle system and frees its associated resources.
  14277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14278. */
  14279. dispose(disposeTexture?: boolean): void;
  14280. /**
  14281. * An event triggered when the system is disposed
  14282. */
  14283. onDisposeObservable: Observable<IParticleSystem>;
  14284. /**
  14285. * Clones the particle system.
  14286. * @param name The name of the cloned object
  14287. * @param newEmitter The new emitter to use
  14288. * @returns the cloned particle system
  14289. */
  14290. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14291. /**
  14292. * Serializes the particle system to a JSON object
  14293. * @param serializeTexture defines if the texture must be serialized as well
  14294. * @returns the JSON object
  14295. */
  14296. serialize(serializeTexture: boolean): any;
  14297. /**
  14298. * Rebuild the particle system
  14299. */
  14300. rebuild(): void;
  14301. /** Force the system to rebuild all gradients that need to be resync */
  14302. forceRefreshGradients(): void;
  14303. /**
  14304. * Starts the particle system and begins to emit
  14305. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14306. */
  14307. start(delay?: number): void;
  14308. /**
  14309. * Stops the particle system.
  14310. */
  14311. stop(): void;
  14312. /**
  14313. * Remove all active particles
  14314. */
  14315. reset(): void;
  14316. /**
  14317. * Gets a boolean indicating that the system is stopping
  14318. * @returns true if the system is currently stopping
  14319. */
  14320. isStopping(): boolean;
  14321. /**
  14322. * Is this system ready to be used/rendered
  14323. * @return true if the system is ready
  14324. */
  14325. isReady(): boolean;
  14326. /**
  14327. * Returns the string "ParticleSystem"
  14328. * @returns a string containing the class name
  14329. */
  14330. getClassName(): string;
  14331. /**
  14332. * Gets the custom effect used to render the particles
  14333. * @param blendMode Blend mode for which the effect should be retrieved
  14334. * @returns The effect
  14335. */
  14336. getCustomEffect(blendMode: number): Nullable<Effect>;
  14337. /**
  14338. * Sets the custom effect used to render the particles
  14339. * @param effect The effect to set
  14340. * @param blendMode Blend mode for which the effect should be set
  14341. */
  14342. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14343. /**
  14344. * Fill the defines array according to the current settings of the particle system
  14345. * @param defines Array to be updated
  14346. * @param blendMode blend mode to take into account when updating the array
  14347. */
  14348. fillDefines(defines: Array<string>, blendMode: number): void;
  14349. /**
  14350. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14351. * @param uniforms Uniforms array to fill
  14352. * @param attributes Attributes array to fill
  14353. * @param samplers Samplers array to fill
  14354. */
  14355. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14356. /**
  14357. * Observable that will be called just before the particles are drawn
  14358. */
  14359. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14360. /**
  14361. * Gets the name of the particle vertex shader
  14362. */
  14363. vertexShaderName: string;
  14364. /**
  14365. * Adds a new color gradient
  14366. * @param gradient defines the gradient to use (between 0 and 1)
  14367. * @param color1 defines the color to affect to the specified gradient
  14368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14369. * @returns the current particle system
  14370. */
  14371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14372. /**
  14373. * Remove a specific color gradient
  14374. * @param gradient defines the gradient to remove
  14375. * @returns the current particle system
  14376. */
  14377. removeColorGradient(gradient: number): IParticleSystem;
  14378. /**
  14379. * Adds a new size gradient
  14380. * @param gradient defines the gradient to use (between 0 and 1)
  14381. * @param factor defines the size factor to affect to the specified gradient
  14382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14383. * @returns the current particle system
  14384. */
  14385. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14386. /**
  14387. * Remove a specific size gradient
  14388. * @param gradient defines the gradient to remove
  14389. * @returns the current particle system
  14390. */
  14391. removeSizeGradient(gradient: number): IParticleSystem;
  14392. /**
  14393. * Gets the current list of color gradients.
  14394. * You must use addColorGradient and removeColorGradient to udpate this list
  14395. * @returns the list of color gradients
  14396. */
  14397. getColorGradients(): Nullable<Array<ColorGradient>>;
  14398. /**
  14399. * Gets the current list of size gradients.
  14400. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14401. * @returns the list of size gradients
  14402. */
  14403. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14404. /**
  14405. * Gets the current list of angular speed gradients.
  14406. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14407. * @returns the list of angular speed gradients
  14408. */
  14409. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14410. /**
  14411. * Adds a new angular speed gradient
  14412. * @param gradient defines the gradient to use (between 0 and 1)
  14413. * @param factor defines the angular speed to affect to the specified gradient
  14414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14415. * @returns the current particle system
  14416. */
  14417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14418. /**
  14419. * Remove a specific angular speed gradient
  14420. * @param gradient defines the gradient to remove
  14421. * @returns the current particle system
  14422. */
  14423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of velocity gradients.
  14426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14427. * @returns the list of velocity gradients
  14428. */
  14429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new velocity gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param factor defines the velocity to affect to the specified gradient
  14434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14435. * @returns the current particle system
  14436. */
  14437. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14438. /**
  14439. * Remove a specific velocity gradient
  14440. * @param gradient defines the gradient to remove
  14441. * @returns the current particle system
  14442. */
  14443. removeVelocityGradient(gradient: number): IParticleSystem;
  14444. /**
  14445. * Gets the current list of limit velocity gradients.
  14446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14447. * @returns the list of limit velocity gradients
  14448. */
  14449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14450. /**
  14451. * Adds a new limit velocity gradient
  14452. * @param gradient defines the gradient to use (between 0 and 1)
  14453. * @param factor defines the limit velocity to affect to the specified gradient
  14454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14455. * @returns the current particle system
  14456. */
  14457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14458. /**
  14459. * Remove a specific limit velocity gradient
  14460. * @param gradient defines the gradient to remove
  14461. * @returns the current particle system
  14462. */
  14463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14464. /**
  14465. * Adds a new drag gradient
  14466. * @param gradient defines the gradient to use (between 0 and 1)
  14467. * @param factor defines the drag to affect to the specified gradient
  14468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14469. * @returns the current particle system
  14470. */
  14471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14472. /**
  14473. * Remove a specific drag gradient
  14474. * @param gradient defines the gradient to remove
  14475. * @returns the current particle system
  14476. */
  14477. removeDragGradient(gradient: number): IParticleSystem;
  14478. /**
  14479. * Gets the current list of drag gradients.
  14480. * You must use addDragGradient and removeDragGradient to udpate this list
  14481. * @returns the list of drag gradients
  14482. */
  14483. getDragGradients(): Nullable<Array<FactorGradient>>;
  14484. /**
  14485. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14486. * @param gradient defines the gradient to use (between 0 and 1)
  14487. * @param factor defines the emit rate to affect to the specified gradient
  14488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14489. * @returns the current particle system
  14490. */
  14491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14492. /**
  14493. * Remove a specific emit rate gradient
  14494. * @param gradient defines the gradient to remove
  14495. * @returns the current particle system
  14496. */
  14497. removeEmitRateGradient(gradient: number): IParticleSystem;
  14498. /**
  14499. * Gets the current list of emit rate gradients.
  14500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14501. * @returns the list of emit rate gradients
  14502. */
  14503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14504. /**
  14505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param factor defines the start size to affect to the specified gradient
  14508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14509. * @returns the current particle system
  14510. */
  14511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14512. /**
  14513. * Remove a specific start size gradient
  14514. * @param gradient defines the gradient to remove
  14515. * @returns the current particle system
  14516. */
  14517. removeStartSizeGradient(gradient: number): IParticleSystem;
  14518. /**
  14519. * Gets the current list of start size gradients.
  14520. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14521. * @returns the list of start size gradients
  14522. */
  14523. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14524. /**
  14525. * Adds a new life time gradient
  14526. * @param gradient defines the gradient to use (between 0 and 1)
  14527. * @param factor defines the life time factor to affect to the specified gradient
  14528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14529. * @returns the current particle system
  14530. */
  14531. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14532. /**
  14533. * Remove a specific life time gradient
  14534. * @param gradient defines the gradient to remove
  14535. * @returns the current particle system
  14536. */
  14537. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14538. /**
  14539. * Gets the current list of life time gradients.
  14540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14541. * @returns the list of life time gradients
  14542. */
  14543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Gets the current list of color gradients.
  14546. * You must use addColorGradient and removeColorGradient to udpate this list
  14547. * @returns the list of color gradients
  14548. */
  14549. getColorGradients(): Nullable<Array<ColorGradient>>;
  14550. /**
  14551. * Adds a new ramp gradient used to remap particle colors
  14552. * @param gradient defines the gradient to use (between 0 and 1)
  14553. * @param color defines the color to affect to the specified gradient
  14554. * @returns the current particle system
  14555. */
  14556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14557. /**
  14558. * Gets the current list of ramp gradients.
  14559. * You must use addRampGradient and removeRampGradient to udpate this list
  14560. * @returns the list of ramp gradients
  14561. */
  14562. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14563. /** Gets or sets a boolean indicating that ramp gradients must be used
  14564. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14565. */
  14566. useRampGradients: boolean;
  14567. /**
  14568. * Adds a new color remap gradient
  14569. * @param gradient defines the gradient to use (between 0 and 1)
  14570. * @param min defines the color remap minimal range
  14571. * @param max defines the color remap maximal range
  14572. * @returns the current particle system
  14573. */
  14574. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14575. /**
  14576. * Gets the current list of color remap gradients.
  14577. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14578. * @returns the list of color remap gradients
  14579. */
  14580. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14581. /**
  14582. * Adds a new alpha remap gradient
  14583. * @param gradient defines the gradient to use (between 0 and 1)
  14584. * @param min defines the alpha remap minimal range
  14585. * @param max defines the alpha remap maximal range
  14586. * @returns the current particle system
  14587. */
  14588. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14589. /**
  14590. * Gets the current list of alpha remap gradients.
  14591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14592. * @returns the list of alpha remap gradients
  14593. */
  14594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14595. /**
  14596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14599. * @returns the emitter
  14600. */
  14601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14602. /**
  14603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14604. * @param radius The radius of the hemisphere to emit from
  14605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14606. * @returns the emitter
  14607. */
  14608. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14609. /**
  14610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14611. * @param radius The radius of the sphere to emit from
  14612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14613. * @returns the emitter
  14614. */
  14615. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14616. /**
  14617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14618. * @param radius The radius of the sphere to emit from
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14621. * @returns the emitter
  14622. */
  14623. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14626. * @param radius The radius of the emission cylinder
  14627. * @param height The height of the emission cylinder
  14628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14630. * @returns the emitter
  14631. */
  14632. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14633. /**
  14634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14635. * @param radius The radius of the cylinder to emit from
  14636. * @param height The height of the emission cylinder
  14637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14640. * @returns the emitter
  14641. */
  14642. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14643. /**
  14644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14645. * @param radius The radius of the cone to emit from
  14646. * @param angle The base angle of the cone
  14647. * @returns the emitter
  14648. */
  14649. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14650. /**
  14651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14656. * @returns the emitter
  14657. */
  14658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14659. /**
  14660. * Get hosting scene
  14661. * @returns the scene
  14662. */
  14663. getScene(): Nullable<Scene>;
  14664. }
  14665. }
  14666. declare module BABYLON {
  14667. /**
  14668. * 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.
  14669. * @see https://doc.babylonjs.com/how_to/transformnode
  14670. */
  14671. export class TransformNode extends Node {
  14672. /**
  14673. * Object will not rotate to face the camera
  14674. */
  14675. static BILLBOARDMODE_NONE: number;
  14676. /**
  14677. * Object will rotate to face the camera but only on the x axis
  14678. */
  14679. static BILLBOARDMODE_X: number;
  14680. /**
  14681. * Object will rotate to face the camera but only on the y axis
  14682. */
  14683. static BILLBOARDMODE_Y: number;
  14684. /**
  14685. * Object will rotate to face the camera but only on the z axis
  14686. */
  14687. static BILLBOARDMODE_Z: number;
  14688. /**
  14689. * Object will rotate to face the camera
  14690. */
  14691. static BILLBOARDMODE_ALL: number;
  14692. /**
  14693. * Object will rotate to face the camera's position instead of orientation
  14694. */
  14695. static BILLBOARDMODE_USE_POSITION: number;
  14696. private static _TmpRotation;
  14697. private static _TmpScaling;
  14698. private static _TmpTranslation;
  14699. private _forward;
  14700. private _forwardInverted;
  14701. private _up;
  14702. private _right;
  14703. private _rightInverted;
  14704. private _position;
  14705. private _rotation;
  14706. private _rotationQuaternion;
  14707. protected _scaling: Vector3;
  14708. protected _isDirty: boolean;
  14709. private _transformToBoneReferal;
  14710. private _isAbsoluteSynced;
  14711. private _billboardMode;
  14712. /**
  14713. * Gets or sets the billboard mode. Default is 0.
  14714. *
  14715. * | Value | Type | Description |
  14716. * | --- | --- | --- |
  14717. * | 0 | BILLBOARDMODE_NONE | |
  14718. * | 1 | BILLBOARDMODE_X | |
  14719. * | 2 | BILLBOARDMODE_Y | |
  14720. * | 4 | BILLBOARDMODE_Z | |
  14721. * | 7 | BILLBOARDMODE_ALL | |
  14722. *
  14723. */
  14724. get billboardMode(): number;
  14725. set billboardMode(value: number);
  14726. private _preserveParentRotationForBillboard;
  14727. /**
  14728. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14729. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14730. */
  14731. get preserveParentRotationForBillboard(): boolean;
  14732. set preserveParentRotationForBillboard(value: boolean);
  14733. /**
  14734. * 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
  14735. */
  14736. scalingDeterminant: number;
  14737. private _infiniteDistance;
  14738. /**
  14739. * Gets or sets the distance of the object to max, often used by skybox
  14740. */
  14741. get infiniteDistance(): boolean;
  14742. set infiniteDistance(value: boolean);
  14743. /**
  14744. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14745. * By default the system will update normals to compensate
  14746. */
  14747. ignoreNonUniformScaling: boolean;
  14748. /**
  14749. * 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
  14750. */
  14751. reIntegrateRotationIntoRotationQuaternion: boolean;
  14752. /** @hidden */
  14753. _poseMatrix: Nullable<Matrix>;
  14754. /** @hidden */
  14755. _localMatrix: Matrix;
  14756. private _usePivotMatrix;
  14757. private _absolutePosition;
  14758. private _absoluteScaling;
  14759. private _absoluteRotationQuaternion;
  14760. private _pivotMatrix;
  14761. private _pivotMatrixInverse;
  14762. /** @hidden */
  14763. _postMultiplyPivotMatrix: boolean;
  14764. protected _isWorldMatrixFrozen: boolean;
  14765. /** @hidden */
  14766. _indexInSceneTransformNodesArray: number;
  14767. /**
  14768. * An event triggered after the world matrix is updated
  14769. */
  14770. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14771. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14772. /**
  14773. * Gets a string identifying the name of the class
  14774. * @returns "TransformNode" string
  14775. */
  14776. getClassName(): string;
  14777. /**
  14778. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14779. */
  14780. get position(): Vector3;
  14781. set position(newPosition: Vector3);
  14782. /**
  14783. * 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)).
  14784. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14785. */
  14786. get rotation(): Vector3;
  14787. set rotation(newRotation: Vector3);
  14788. /**
  14789. * 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)).
  14790. */
  14791. get scaling(): Vector3;
  14792. set scaling(newScaling: Vector3);
  14793. /**
  14794. * 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).
  14795. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14796. */
  14797. get rotationQuaternion(): Nullable<Quaternion>;
  14798. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14799. /**
  14800. * The forward direction of that transform in world space.
  14801. */
  14802. get forward(): Vector3;
  14803. /**
  14804. * The up direction of that transform in world space.
  14805. */
  14806. get up(): Vector3;
  14807. /**
  14808. * The right direction of that transform in world space.
  14809. */
  14810. get right(): Vector3;
  14811. /**
  14812. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14813. * @param matrix the matrix to copy the pose from
  14814. * @returns this TransformNode.
  14815. */
  14816. updatePoseMatrix(matrix: Matrix): TransformNode;
  14817. /**
  14818. * Returns the mesh Pose matrix.
  14819. * @returns the pose matrix
  14820. */
  14821. getPoseMatrix(): Matrix;
  14822. /** @hidden */
  14823. _isSynchronized(): boolean;
  14824. /** @hidden */
  14825. _initCache(): void;
  14826. /**
  14827. * Flag the transform node as dirty (Forcing it to update everything)
  14828. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14829. * @returns this transform node
  14830. */
  14831. markAsDirty(property: string): TransformNode;
  14832. /**
  14833. * Returns the current mesh absolute position.
  14834. * Returns a Vector3.
  14835. */
  14836. get absolutePosition(): Vector3;
  14837. /**
  14838. * Returns the current mesh absolute scaling.
  14839. * Returns a Vector3.
  14840. */
  14841. get absoluteScaling(): Vector3;
  14842. /**
  14843. * Returns the current mesh absolute rotation.
  14844. * Returns a Quaternion.
  14845. */
  14846. get absoluteRotationQuaternion(): Quaternion;
  14847. /**
  14848. * Sets a new matrix to apply before all other transformation
  14849. * @param matrix defines the transform matrix
  14850. * @returns the current TransformNode
  14851. */
  14852. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14853. /**
  14854. * Sets a new pivot matrix to the current node
  14855. * @param matrix defines the new pivot matrix to use
  14856. * @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
  14857. * @returns the current TransformNode
  14858. */
  14859. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14860. /**
  14861. * Returns the mesh pivot matrix.
  14862. * Default : Identity.
  14863. * @returns the matrix
  14864. */
  14865. getPivotMatrix(): Matrix;
  14866. /**
  14867. * Instantiate (when possible) or clone that node with its hierarchy
  14868. * @param newParent defines the new parent to use for the instance (or clone)
  14869. * @param options defines options to configure how copy is done
  14870. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14871. * @returns an instance (or a clone) of the current node with its hiearchy
  14872. */
  14873. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14874. doNotInstantiate: boolean;
  14875. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14876. /**
  14877. * Prevents the World matrix to be computed any longer
  14878. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14879. * @returns the TransformNode.
  14880. */
  14881. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14882. /**
  14883. * Allows back the World matrix computation.
  14884. * @returns the TransformNode.
  14885. */
  14886. unfreezeWorldMatrix(): this;
  14887. /**
  14888. * True if the World matrix has been frozen.
  14889. */
  14890. get isWorldMatrixFrozen(): boolean;
  14891. /**
  14892. * Retuns the mesh absolute position in the World.
  14893. * @returns a Vector3.
  14894. */
  14895. getAbsolutePosition(): Vector3;
  14896. /**
  14897. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14898. * @param absolutePosition the absolute position to set
  14899. * @returns the TransformNode.
  14900. */
  14901. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14902. /**
  14903. * Sets the mesh position in its local space.
  14904. * @param vector3 the position to set in localspace
  14905. * @returns the TransformNode.
  14906. */
  14907. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14908. /**
  14909. * Returns the mesh position in the local space from the current World matrix values.
  14910. * @returns a new Vector3.
  14911. */
  14912. getPositionExpressedInLocalSpace(): Vector3;
  14913. /**
  14914. * Translates the mesh along the passed Vector3 in its local space.
  14915. * @param vector3 the distance to translate in localspace
  14916. * @returns the TransformNode.
  14917. */
  14918. locallyTranslate(vector3: Vector3): TransformNode;
  14919. private static _lookAtVectorCache;
  14920. /**
  14921. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14922. * @param targetPoint the position (must be in same space as current mesh) to look at
  14923. * @param yawCor optional yaw (y-axis) correction in radians
  14924. * @param pitchCor optional pitch (x-axis) correction in radians
  14925. * @param rollCor optional roll (z-axis) correction in radians
  14926. * @param space the choosen space of the target
  14927. * @returns the TransformNode.
  14928. */
  14929. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14930. /**
  14931. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14932. * This Vector3 is expressed in the World space.
  14933. * @param localAxis axis to rotate
  14934. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14935. */
  14936. getDirection(localAxis: Vector3): Vector3;
  14937. /**
  14938. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14939. * localAxis is expressed in the mesh local space.
  14940. * result is computed in the Wordl space from the mesh World matrix.
  14941. * @param localAxis axis to rotate
  14942. * @param result the resulting transformnode
  14943. * @returns this TransformNode.
  14944. */
  14945. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14946. /**
  14947. * Sets this transform node rotation to the given local axis.
  14948. * @param localAxis the axis in local space
  14949. * @param yawCor optional yaw (y-axis) correction in radians
  14950. * @param pitchCor optional pitch (x-axis) correction in radians
  14951. * @param rollCor optional roll (z-axis) correction in radians
  14952. * @returns this TransformNode
  14953. */
  14954. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14955. /**
  14956. * Sets a new pivot point to the current node
  14957. * @param point defines the new pivot point to use
  14958. * @param space defines if the point is in world or local space (local by default)
  14959. * @returns the current TransformNode
  14960. */
  14961. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14962. /**
  14963. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14964. * @returns the pivot point
  14965. */
  14966. getPivotPoint(): Vector3;
  14967. /**
  14968. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14969. * @param result the vector3 to store the result
  14970. * @returns this TransformNode.
  14971. */
  14972. getPivotPointToRef(result: Vector3): TransformNode;
  14973. /**
  14974. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14975. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14976. */
  14977. getAbsolutePivotPoint(): Vector3;
  14978. /**
  14979. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14980. * @param result vector3 to store the result
  14981. * @returns this TransformNode.
  14982. */
  14983. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14984. /**
  14985. * Defines the passed node as the parent of the current node.
  14986. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14987. * @see https://doc.babylonjs.com/how_to/parenting
  14988. * @param node the node ot set as the parent
  14989. * @returns this TransformNode.
  14990. */
  14991. setParent(node: Nullable<Node>): TransformNode;
  14992. private _nonUniformScaling;
  14993. /**
  14994. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14995. */
  14996. get nonUniformScaling(): boolean;
  14997. /** @hidden */
  14998. _updateNonUniformScalingState(value: boolean): boolean;
  14999. /**
  15000. * Attach the current TransformNode to another TransformNode associated with a bone
  15001. * @param bone Bone affecting the TransformNode
  15002. * @param affectedTransformNode TransformNode associated with the bone
  15003. * @returns this object
  15004. */
  15005. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15006. /**
  15007. * Detach the transform node if its associated with a bone
  15008. * @returns this object
  15009. */
  15010. detachFromBone(): TransformNode;
  15011. private static _rotationAxisCache;
  15012. /**
  15013. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15014. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15015. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15016. * The passed axis is also normalized.
  15017. * @param axis the axis to rotate around
  15018. * @param amount the amount to rotate in radians
  15019. * @param space Space to rotate in (Default: local)
  15020. * @returns the TransformNode.
  15021. */
  15022. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15023. /**
  15024. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15025. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15026. * The passed axis is also normalized. .
  15027. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15028. * @param point the point to rotate around
  15029. * @param axis the axis to rotate around
  15030. * @param amount the amount to rotate in radians
  15031. * @returns the TransformNode
  15032. */
  15033. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15034. /**
  15035. * Translates the mesh along the axis vector for the passed distance in the given space.
  15036. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15037. * @param axis the axis to translate in
  15038. * @param distance the distance to translate
  15039. * @param space Space to rotate in (Default: local)
  15040. * @returns the TransformNode.
  15041. */
  15042. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15043. /**
  15044. * Adds a rotation step to the mesh current rotation.
  15045. * x, y, z are Euler angles expressed in radians.
  15046. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15047. * This means this rotation is made in the mesh local space only.
  15048. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15049. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15050. * ```javascript
  15051. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15052. * ```
  15053. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15054. * 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.
  15055. * @param x Rotation to add
  15056. * @param y Rotation to add
  15057. * @param z Rotation to add
  15058. * @returns the TransformNode.
  15059. */
  15060. addRotation(x: number, y: number, z: number): TransformNode;
  15061. /**
  15062. * @hidden
  15063. */
  15064. protected _getEffectiveParent(): Nullable<Node>;
  15065. /**
  15066. * Computes the world matrix of the node
  15067. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15068. * @returns the world matrix
  15069. */
  15070. computeWorldMatrix(force?: boolean): Matrix;
  15071. /**
  15072. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15073. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15074. */
  15075. resetLocalMatrix(independentOfChildren?: boolean): void;
  15076. protected _afterComputeWorldMatrix(): void;
  15077. /**
  15078. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15079. * @param func callback function to add
  15080. *
  15081. * @returns the TransformNode.
  15082. */
  15083. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15084. /**
  15085. * Removes a registered callback function.
  15086. * @param func callback function to remove
  15087. * @returns the TransformNode.
  15088. */
  15089. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15090. /**
  15091. * Gets the position of the current mesh in camera space
  15092. * @param camera defines the camera to use
  15093. * @returns a position
  15094. */
  15095. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15096. /**
  15097. * Returns the distance from the mesh to the active camera
  15098. * @param camera defines the camera to use
  15099. * @returns the distance
  15100. */
  15101. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15102. /**
  15103. * Clone the current transform node
  15104. * @param name Name of the new clone
  15105. * @param newParent New parent for the clone
  15106. * @param doNotCloneChildren Do not clone children hierarchy
  15107. * @returns the new transform node
  15108. */
  15109. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15110. /**
  15111. * Serializes the objects information.
  15112. * @param currentSerializationObject defines the object to serialize in
  15113. * @returns the serialized object
  15114. */
  15115. serialize(currentSerializationObject?: any): any;
  15116. /**
  15117. * Returns a new TransformNode object parsed from the source provided.
  15118. * @param parsedTransformNode is the source.
  15119. * @param scene the scne the object belongs to
  15120. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15121. * @returns a new TransformNode object parsed from the source provided.
  15122. */
  15123. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15124. /**
  15125. * Get all child-transformNodes of this node
  15126. * @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
  15127. * @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
  15128. * @returns an array of TransformNode
  15129. */
  15130. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15131. /**
  15132. * Releases resources associated with this transform node.
  15133. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15134. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15135. */
  15136. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15137. /**
  15138. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15139. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15140. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15141. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15142. * @returns the current mesh
  15143. */
  15144. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15145. private _syncAbsoluteScalingAndRotation;
  15146. }
  15147. }
  15148. declare module BABYLON {
  15149. /**
  15150. * Class used to override all child animations of a given target
  15151. */
  15152. export class AnimationPropertiesOverride {
  15153. /**
  15154. * Gets or sets a value indicating if animation blending must be used
  15155. */
  15156. enableBlending: boolean;
  15157. /**
  15158. * Gets or sets the blending speed to use when enableBlending is true
  15159. */
  15160. blendingSpeed: number;
  15161. /**
  15162. * Gets or sets the default loop mode to use
  15163. */
  15164. loopMode: number;
  15165. }
  15166. }
  15167. declare module BABYLON {
  15168. /**
  15169. * Class used to store bone information
  15170. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15171. */
  15172. export class Bone extends Node {
  15173. /**
  15174. * defines the bone name
  15175. */
  15176. name: string;
  15177. private static _tmpVecs;
  15178. private static _tmpQuat;
  15179. private static _tmpMats;
  15180. /**
  15181. * Gets the list of child bones
  15182. */
  15183. children: Bone[];
  15184. /** Gets the animations associated with this bone */
  15185. animations: Animation[];
  15186. /**
  15187. * Gets or sets bone length
  15188. */
  15189. length: number;
  15190. /**
  15191. * @hidden Internal only
  15192. * Set this value to map this bone to a different index in the transform matrices
  15193. * Set this value to -1 to exclude the bone from the transform matrices
  15194. */
  15195. _index: Nullable<number>;
  15196. private _skeleton;
  15197. private _localMatrix;
  15198. private _restPose;
  15199. private _bindPose;
  15200. private _baseMatrix;
  15201. private _absoluteTransform;
  15202. private _invertedAbsoluteTransform;
  15203. private _parent;
  15204. private _scalingDeterminant;
  15205. private _worldTransform;
  15206. private _localScaling;
  15207. private _localRotation;
  15208. private _localPosition;
  15209. private _needToDecompose;
  15210. private _needToCompose;
  15211. /** @hidden */
  15212. _linkedTransformNode: Nullable<TransformNode>;
  15213. /** @hidden */
  15214. _waitingTransformNodeId: Nullable<string>;
  15215. /** @hidden */
  15216. get _matrix(): Matrix;
  15217. /** @hidden */
  15218. set _matrix(value: Matrix);
  15219. /**
  15220. * Create a new bone
  15221. * @param name defines the bone name
  15222. * @param skeleton defines the parent skeleton
  15223. * @param parentBone defines the parent (can be null if the bone is the root)
  15224. * @param localMatrix defines the local matrix
  15225. * @param restPose defines the rest pose matrix
  15226. * @param baseMatrix defines the base matrix
  15227. * @param index defines index of the bone in the hiearchy
  15228. */
  15229. constructor(
  15230. /**
  15231. * defines the bone name
  15232. */
  15233. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15234. /**
  15235. * Gets the current object class name.
  15236. * @return the class name
  15237. */
  15238. getClassName(): string;
  15239. /**
  15240. * Gets the parent skeleton
  15241. * @returns a skeleton
  15242. */
  15243. getSkeleton(): Skeleton;
  15244. /**
  15245. * Gets parent bone
  15246. * @returns a bone or null if the bone is the root of the bone hierarchy
  15247. */
  15248. getParent(): Nullable<Bone>;
  15249. /**
  15250. * Returns an array containing the root bones
  15251. * @returns an array containing the root bones
  15252. */
  15253. getChildren(): Array<Bone>;
  15254. /**
  15255. * Gets the node index in matrix array generated for rendering
  15256. * @returns the node index
  15257. */
  15258. getIndex(): number;
  15259. /**
  15260. * Sets the parent bone
  15261. * @param parent defines the parent (can be null if the bone is the root)
  15262. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15263. */
  15264. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15265. /**
  15266. * Gets the local matrix
  15267. * @returns a matrix
  15268. */
  15269. getLocalMatrix(): Matrix;
  15270. /**
  15271. * Gets the base matrix (initial matrix which remains unchanged)
  15272. * @returns a matrix
  15273. */
  15274. getBaseMatrix(): Matrix;
  15275. /**
  15276. * Gets the rest pose matrix
  15277. * @returns a matrix
  15278. */
  15279. getRestPose(): Matrix;
  15280. /**
  15281. * Sets the rest pose matrix
  15282. * @param matrix the local-space rest pose to set for this bone
  15283. */
  15284. setRestPose(matrix: Matrix): void;
  15285. /**
  15286. * Gets the bind pose matrix
  15287. * @returns the bind pose matrix
  15288. */
  15289. getBindPose(): Matrix;
  15290. /**
  15291. * Sets the bind pose matrix
  15292. * @param matrix the local-space bind pose to set for this bone
  15293. */
  15294. setBindPose(matrix: Matrix): void;
  15295. /**
  15296. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15297. */
  15298. getWorldMatrix(): Matrix;
  15299. /**
  15300. * Sets the local matrix to rest pose matrix
  15301. */
  15302. returnToRest(): void;
  15303. /**
  15304. * Gets the inverse of the absolute transform matrix.
  15305. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15306. * @returns a matrix
  15307. */
  15308. getInvertedAbsoluteTransform(): Matrix;
  15309. /**
  15310. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15311. * @returns a matrix
  15312. */
  15313. getAbsoluteTransform(): Matrix;
  15314. /**
  15315. * Links with the given transform node.
  15316. * The local matrix of this bone is copied from the transform node every frame.
  15317. * @param transformNode defines the transform node to link to
  15318. */
  15319. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15320. /**
  15321. * Gets the node used to drive the bone's transformation
  15322. * @returns a transform node or null
  15323. */
  15324. getTransformNode(): Nullable<TransformNode>;
  15325. /** Gets or sets current position (in local space) */
  15326. get position(): Vector3;
  15327. set position(newPosition: Vector3);
  15328. /** Gets or sets current rotation (in local space) */
  15329. get rotation(): Vector3;
  15330. set rotation(newRotation: Vector3);
  15331. /** Gets or sets current rotation quaternion (in local space) */
  15332. get rotationQuaternion(): Quaternion;
  15333. set rotationQuaternion(newRotation: Quaternion);
  15334. /** Gets or sets current scaling (in local space) */
  15335. get scaling(): Vector3;
  15336. set scaling(newScaling: Vector3);
  15337. /**
  15338. * Gets the animation properties override
  15339. */
  15340. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15341. private _decompose;
  15342. private _compose;
  15343. /**
  15344. * Update the base and local matrices
  15345. * @param matrix defines the new base or local matrix
  15346. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15347. * @param updateLocalMatrix defines if the local matrix should be updated
  15348. */
  15349. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15350. /** @hidden */
  15351. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15352. /**
  15353. * Flag the bone as dirty (Forcing it to update everything)
  15354. */
  15355. markAsDirty(): void;
  15356. /** @hidden */
  15357. _markAsDirtyAndCompose(): void;
  15358. private _markAsDirtyAndDecompose;
  15359. /**
  15360. * Translate the bone in local or world space
  15361. * @param vec The amount to translate the bone
  15362. * @param space The space that the translation is in
  15363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15364. */
  15365. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15366. /**
  15367. * Set the postion of the bone in local or world space
  15368. * @param position The position to set the bone
  15369. * @param space The space that the position is in
  15370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15371. */
  15372. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15373. /**
  15374. * Set the absolute position of the bone (world space)
  15375. * @param position The position to set the bone
  15376. * @param mesh The mesh that this bone is attached to
  15377. */
  15378. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15379. /**
  15380. * Scale the bone on the x, y and z axes (in local space)
  15381. * @param x The amount to scale the bone on the x axis
  15382. * @param y The amount to scale the bone on the y axis
  15383. * @param z The amount to scale the bone on the z axis
  15384. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15385. */
  15386. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15387. /**
  15388. * Set the bone scaling in local space
  15389. * @param scale defines the scaling vector
  15390. */
  15391. setScale(scale: Vector3): void;
  15392. /**
  15393. * Gets the current scaling in local space
  15394. * @returns the current scaling vector
  15395. */
  15396. getScale(): Vector3;
  15397. /**
  15398. * Gets the current scaling in local space and stores it in a target vector
  15399. * @param result defines the target vector
  15400. */
  15401. getScaleToRef(result: Vector3): void;
  15402. /**
  15403. * Set the yaw, pitch, and roll of the bone in local or world space
  15404. * @param yaw The rotation of the bone on the y axis
  15405. * @param pitch The rotation of the bone on the x axis
  15406. * @param roll The rotation of the bone on the z axis
  15407. * @param space The space that the axes of rotation are in
  15408. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15409. */
  15410. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15411. /**
  15412. * Add a rotation to the bone on an axis in local or world space
  15413. * @param axis The axis to rotate the bone on
  15414. * @param amount The amount to rotate the bone
  15415. * @param space The space that the axis is in
  15416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15417. */
  15418. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15419. /**
  15420. * Set the rotation of the bone to a particular axis angle in local or world space
  15421. * @param axis The axis to rotate the bone on
  15422. * @param angle The angle that the bone should be rotated to
  15423. * @param space The space that the axis is in
  15424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15425. */
  15426. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15427. /**
  15428. * Set the euler rotation of the bone in local or world space
  15429. * @param rotation The euler rotation that the bone should be set to
  15430. * @param space The space that the rotation is in
  15431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15432. */
  15433. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15434. /**
  15435. * Set the quaternion rotation of the bone in local or world space
  15436. * @param quat The quaternion rotation that the bone should be set to
  15437. * @param space The space that the rotation is in
  15438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15439. */
  15440. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15441. /**
  15442. * Set the rotation matrix of the bone in local or world space
  15443. * @param rotMat The rotation matrix that the bone should be set to
  15444. * @param space The space that the rotation is in
  15445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15446. */
  15447. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15448. private _rotateWithMatrix;
  15449. private _getNegativeRotationToRef;
  15450. /**
  15451. * Get the position of the bone in local or world space
  15452. * @param space The space that the returned position is in
  15453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15454. * @returns The position of the bone
  15455. */
  15456. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15457. /**
  15458. * Copy the position of the bone to a vector3 in local or world space
  15459. * @param space The space that the returned position is in
  15460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15461. * @param result The vector3 to copy the position to
  15462. */
  15463. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15464. /**
  15465. * Get the absolute position of the bone (world space)
  15466. * @param mesh The mesh that this bone is attached to
  15467. * @returns The absolute position of the bone
  15468. */
  15469. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15470. /**
  15471. * Copy the absolute position of the bone (world space) to the result param
  15472. * @param mesh The mesh that this bone is attached to
  15473. * @param result The vector3 to copy the absolute position to
  15474. */
  15475. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15476. /**
  15477. * Compute the absolute transforms of this bone and its children
  15478. */
  15479. computeAbsoluteTransforms(): void;
  15480. /**
  15481. * Get the world direction from an axis that is in the local space of the bone
  15482. * @param localAxis The local direction that is used to compute the world direction
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @returns The world direction
  15485. */
  15486. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15487. /**
  15488. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15489. * @param localAxis The local direction that is used to compute the world direction
  15490. * @param mesh The mesh that this bone is attached to
  15491. * @param result The vector3 that the world direction will be copied to
  15492. */
  15493. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15494. /**
  15495. * Get the euler rotation of the bone in local or world space
  15496. * @param space The space that the rotation should be in
  15497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15498. * @returns The euler rotation
  15499. */
  15500. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15501. /**
  15502. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15503. * @param space The space that the rotation should be in
  15504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15505. * @param result The vector3 that the rotation should be copied to
  15506. */
  15507. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15508. /**
  15509. * Get the quaternion rotation of the bone in either local or world space
  15510. * @param space The space that the rotation should be in
  15511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15512. * @returns The quaternion rotation
  15513. */
  15514. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15515. /**
  15516. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15517. * @param space The space that the rotation should be in
  15518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15519. * @param result The quaternion that the rotation should be copied to
  15520. */
  15521. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15522. /**
  15523. * Get the rotation matrix of the bone in local or world space
  15524. * @param space The space that the rotation should be in
  15525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15526. * @returns The rotation matrix
  15527. */
  15528. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15529. /**
  15530. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15531. * @param space The space that the rotation should be in
  15532. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15533. * @param result The quaternion that the rotation should be copied to
  15534. */
  15535. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15536. /**
  15537. * Get the world position of a point that is in the local space of the bone
  15538. * @param position The local position
  15539. * @param mesh The mesh that this bone is attached to
  15540. * @returns The world position
  15541. */
  15542. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15543. /**
  15544. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15545. * @param position The local position
  15546. * @param mesh The mesh that this bone is attached to
  15547. * @param result The vector3 that the world position should be copied to
  15548. */
  15549. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15550. /**
  15551. * Get the local position of a point that is in world space
  15552. * @param position The world position
  15553. * @param mesh The mesh that this bone is attached to
  15554. * @returns The local position
  15555. */
  15556. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15557. /**
  15558. * Get the local position of a point that is in world space and copy it to the result param
  15559. * @param position The world position
  15560. * @param mesh The mesh that this bone is attached to
  15561. * @param result The vector3 that the local position should be copied to
  15562. */
  15563. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15564. /**
  15565. * Set the current local matrix as the restPose for this bone.
  15566. */
  15567. setCurrentPoseAsRest(): void;
  15568. }
  15569. }
  15570. declare module BABYLON {
  15571. /**
  15572. * Defines a runtime animation
  15573. */
  15574. export class RuntimeAnimation {
  15575. private _events;
  15576. /**
  15577. * The current frame of the runtime animation
  15578. */
  15579. private _currentFrame;
  15580. /**
  15581. * The animation used by the runtime animation
  15582. */
  15583. private _animation;
  15584. /**
  15585. * The target of the runtime animation
  15586. */
  15587. private _target;
  15588. /**
  15589. * The initiating animatable
  15590. */
  15591. private _host;
  15592. /**
  15593. * The original value of the runtime animation
  15594. */
  15595. private _originalValue;
  15596. /**
  15597. * The original blend value of the runtime animation
  15598. */
  15599. private _originalBlendValue;
  15600. /**
  15601. * The offsets cache of the runtime animation
  15602. */
  15603. private _offsetsCache;
  15604. /**
  15605. * The high limits cache of the runtime animation
  15606. */
  15607. private _highLimitsCache;
  15608. /**
  15609. * Specifies if the runtime animation has been stopped
  15610. */
  15611. private _stopped;
  15612. /**
  15613. * The blending factor of the runtime animation
  15614. */
  15615. private _blendingFactor;
  15616. /**
  15617. * The BabylonJS scene
  15618. */
  15619. private _scene;
  15620. /**
  15621. * The current value of the runtime animation
  15622. */
  15623. private _currentValue;
  15624. /** @hidden */
  15625. _animationState: _IAnimationState;
  15626. /**
  15627. * The active target of the runtime animation
  15628. */
  15629. private _activeTargets;
  15630. private _currentActiveTarget;
  15631. private _directTarget;
  15632. /**
  15633. * The target path of the runtime animation
  15634. */
  15635. private _targetPath;
  15636. /**
  15637. * The weight of the runtime animation
  15638. */
  15639. private _weight;
  15640. /**
  15641. * The ratio offset of the runtime animation
  15642. */
  15643. private _ratioOffset;
  15644. /**
  15645. * The previous delay of the runtime animation
  15646. */
  15647. private _previousDelay;
  15648. /**
  15649. * The previous ratio of the runtime animation
  15650. */
  15651. private _previousRatio;
  15652. private _enableBlending;
  15653. private _keys;
  15654. private _minFrame;
  15655. private _maxFrame;
  15656. private _minValue;
  15657. private _maxValue;
  15658. private _targetIsArray;
  15659. /**
  15660. * Gets the current frame of the runtime animation
  15661. */
  15662. get currentFrame(): number;
  15663. /**
  15664. * Gets the weight of the runtime animation
  15665. */
  15666. get weight(): number;
  15667. /**
  15668. * Gets the current value of the runtime animation
  15669. */
  15670. get currentValue(): any;
  15671. /**
  15672. * Gets the target path of the runtime animation
  15673. */
  15674. get targetPath(): string;
  15675. /**
  15676. * Gets the actual target of the runtime animation
  15677. */
  15678. get target(): any;
  15679. /**
  15680. * Gets the additive state of the runtime animation
  15681. */
  15682. get isAdditive(): boolean;
  15683. /** @hidden */
  15684. _onLoop: () => void;
  15685. /**
  15686. * Create a new RuntimeAnimation object
  15687. * @param target defines the target of the animation
  15688. * @param animation defines the source animation object
  15689. * @param scene defines the hosting scene
  15690. * @param host defines the initiating Animatable
  15691. */
  15692. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15693. private _preparePath;
  15694. /**
  15695. * Gets the animation from the runtime animation
  15696. */
  15697. get animation(): Animation;
  15698. /**
  15699. * Resets the runtime animation to the beginning
  15700. * @param restoreOriginal defines whether to restore the target property to the original value
  15701. */
  15702. reset(restoreOriginal?: boolean): void;
  15703. /**
  15704. * Specifies if the runtime animation is stopped
  15705. * @returns Boolean specifying if the runtime animation is stopped
  15706. */
  15707. isStopped(): boolean;
  15708. /**
  15709. * Disposes of the runtime animation
  15710. */
  15711. dispose(): void;
  15712. /**
  15713. * Apply the interpolated value to the target
  15714. * @param currentValue defines the value computed by the animation
  15715. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15716. */
  15717. setValue(currentValue: any, weight: number): void;
  15718. private _getOriginalValues;
  15719. private _setValue;
  15720. /**
  15721. * Gets the loop pmode of the runtime animation
  15722. * @returns Loop Mode
  15723. */
  15724. private _getCorrectLoopMode;
  15725. /**
  15726. * Move the current animation to a given frame
  15727. * @param frame defines the frame to move to
  15728. */
  15729. goToFrame(frame: number): void;
  15730. /**
  15731. * @hidden Internal use only
  15732. */
  15733. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15734. /**
  15735. * Execute the current animation
  15736. * @param delay defines the delay to add to the current frame
  15737. * @param from defines the lower bound of the animation range
  15738. * @param to defines the upper bound of the animation range
  15739. * @param loop defines if the current animation must loop
  15740. * @param speedRatio defines the current speed ratio
  15741. * @param weight defines the weight of the animation (default is -1 so no weight)
  15742. * @param onLoop optional callback called when animation loops
  15743. * @returns a boolean indicating if the animation is running
  15744. */
  15745. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15746. }
  15747. }
  15748. declare module BABYLON {
  15749. /**
  15750. * Class used to store an actual running animation
  15751. */
  15752. export class Animatable {
  15753. /** defines the target object */
  15754. target: any;
  15755. /** defines the starting frame number (default is 0) */
  15756. fromFrame: number;
  15757. /** defines the ending frame number (default is 100) */
  15758. toFrame: number;
  15759. /** defines if the animation must loop (default is false) */
  15760. loopAnimation: boolean;
  15761. /** defines a callback to call when animation ends if it is not looping */
  15762. onAnimationEnd?: (() => void) | null | undefined;
  15763. /** defines a callback to call when animation loops */
  15764. onAnimationLoop?: (() => void) | null | undefined;
  15765. /** defines whether the animation should be evaluated additively */
  15766. isAdditive: boolean;
  15767. private _localDelayOffset;
  15768. private _pausedDelay;
  15769. private _runtimeAnimations;
  15770. private _paused;
  15771. private _scene;
  15772. private _speedRatio;
  15773. private _weight;
  15774. private _syncRoot;
  15775. /**
  15776. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15777. * This will only apply for non looping animation (default is true)
  15778. */
  15779. disposeOnEnd: boolean;
  15780. /**
  15781. * Gets a boolean indicating if the animation has started
  15782. */
  15783. animationStarted: boolean;
  15784. /**
  15785. * Observer raised when the animation ends
  15786. */
  15787. onAnimationEndObservable: Observable<Animatable>;
  15788. /**
  15789. * Observer raised when the animation loops
  15790. */
  15791. onAnimationLoopObservable: Observable<Animatable>;
  15792. /**
  15793. * Gets the root Animatable used to synchronize and normalize animations
  15794. */
  15795. get syncRoot(): Nullable<Animatable>;
  15796. /**
  15797. * Gets the current frame of the first RuntimeAnimation
  15798. * Used to synchronize Animatables
  15799. */
  15800. get masterFrame(): number;
  15801. /**
  15802. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15803. */
  15804. get weight(): number;
  15805. set weight(value: number);
  15806. /**
  15807. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15808. */
  15809. get speedRatio(): number;
  15810. set speedRatio(value: number);
  15811. /**
  15812. * Creates a new Animatable
  15813. * @param scene defines the hosting scene
  15814. * @param target defines the target object
  15815. * @param fromFrame defines the starting frame number (default is 0)
  15816. * @param toFrame defines the ending frame number (default is 100)
  15817. * @param loopAnimation defines if the animation must loop (default is false)
  15818. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15819. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15820. * @param animations defines a group of animation to add to the new Animatable
  15821. * @param onAnimationLoop defines a callback to call when animation loops
  15822. * @param isAdditive defines whether the animation should be evaluated additively
  15823. */
  15824. constructor(scene: Scene,
  15825. /** defines the target object */
  15826. target: any,
  15827. /** defines the starting frame number (default is 0) */
  15828. fromFrame?: number,
  15829. /** defines the ending frame number (default is 100) */
  15830. toFrame?: number,
  15831. /** defines if the animation must loop (default is false) */
  15832. loopAnimation?: boolean, speedRatio?: number,
  15833. /** defines a callback to call when animation ends if it is not looping */
  15834. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15835. /** defines a callback to call when animation loops */
  15836. onAnimationLoop?: (() => void) | null | undefined,
  15837. /** defines whether the animation should be evaluated additively */
  15838. isAdditive?: boolean);
  15839. /**
  15840. * Synchronize and normalize current Animatable with a source Animatable
  15841. * This is useful when using animation weights and when animations are not of the same length
  15842. * @param root defines the root Animatable to synchronize with
  15843. * @returns the current Animatable
  15844. */
  15845. syncWith(root: Animatable): Animatable;
  15846. /**
  15847. * Gets the list of runtime animations
  15848. * @returns an array of RuntimeAnimation
  15849. */
  15850. getAnimations(): RuntimeAnimation[];
  15851. /**
  15852. * Adds more animations to the current animatable
  15853. * @param target defines the target of the animations
  15854. * @param animations defines the new animations to add
  15855. */
  15856. appendAnimations(target: any, animations: Animation[]): void;
  15857. /**
  15858. * Gets the source animation for a specific property
  15859. * @param property defines the propertyu to look for
  15860. * @returns null or the source animation for the given property
  15861. */
  15862. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15863. /**
  15864. * Gets the runtime animation for a specific property
  15865. * @param property defines the propertyu to look for
  15866. * @returns null or the runtime animation for the given property
  15867. */
  15868. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15869. /**
  15870. * Resets the animatable to its original state
  15871. */
  15872. reset(): void;
  15873. /**
  15874. * Allows the animatable to blend with current running animations
  15875. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15876. * @param blendingSpeed defines the blending speed to use
  15877. */
  15878. enableBlending(blendingSpeed: number): void;
  15879. /**
  15880. * Disable animation blending
  15881. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15882. */
  15883. disableBlending(): void;
  15884. /**
  15885. * Jump directly to a given frame
  15886. * @param frame defines the frame to jump to
  15887. */
  15888. goToFrame(frame: number): void;
  15889. /**
  15890. * Pause the animation
  15891. */
  15892. pause(): void;
  15893. /**
  15894. * Restart the animation
  15895. */
  15896. restart(): void;
  15897. private _raiseOnAnimationEnd;
  15898. /**
  15899. * Stop and delete the current animation
  15900. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15901. * @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)
  15902. */
  15903. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15904. /**
  15905. * Wait asynchronously for the animation to end
  15906. * @returns a promise which will be fullfilled when the animation ends
  15907. */
  15908. waitAsync(): Promise<Animatable>;
  15909. /** @hidden */
  15910. _animate(delay: number): boolean;
  15911. }
  15912. interface Scene {
  15913. /** @hidden */
  15914. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15915. /** @hidden */
  15916. _processLateAnimationBindingsForMatrices(holder: {
  15917. totalWeight: number;
  15918. totalAdditiveWeight: number;
  15919. animations: RuntimeAnimation[];
  15920. additiveAnimations: RuntimeAnimation[];
  15921. originalValue: Matrix;
  15922. }): any;
  15923. /** @hidden */
  15924. _processLateAnimationBindingsForQuaternions(holder: {
  15925. totalWeight: number;
  15926. totalAdditiveWeight: number;
  15927. animations: RuntimeAnimation[];
  15928. additiveAnimations: RuntimeAnimation[];
  15929. originalValue: Quaternion;
  15930. }, refQuaternion: Quaternion): Quaternion;
  15931. /** @hidden */
  15932. _processLateAnimationBindings(): void;
  15933. /**
  15934. * Will start the animation sequence of a given target
  15935. * @param target defines the target
  15936. * @param from defines from which frame should animation start
  15937. * @param to defines until which frame should animation run.
  15938. * @param weight defines the weight to apply to the animation (1.0 by default)
  15939. * @param loop defines if the animation loops
  15940. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15941. * @param onAnimationEnd defines the function to be executed when the animation ends
  15942. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15943. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15944. * @param onAnimationLoop defines the callback to call when an animation loops
  15945. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15946. * @returns the animatable object created for this animation
  15947. */
  15948. 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;
  15949. /**
  15950. * Will start the animation sequence of a given target
  15951. * @param target defines the target
  15952. * @param from defines from which frame should animation start
  15953. * @param to defines until which frame should animation run.
  15954. * @param loop defines if the animation loops
  15955. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15956. * @param onAnimationEnd defines the function to be executed when the animation ends
  15957. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15958. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15959. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15960. * @param onAnimationLoop defines the callback to call when an animation loops
  15961. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15962. * @returns the animatable object created for this animation
  15963. */
  15964. 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;
  15965. /**
  15966. * Will start the animation sequence of a given target and its hierarchy
  15967. * @param target defines the target
  15968. * @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.
  15969. * @param from defines from which frame should animation start
  15970. * @param to defines until which frame should animation run.
  15971. * @param loop defines if the animation loops
  15972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15973. * @param onAnimationEnd defines the function to be executed when the animation ends
  15974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15975. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15976. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15977. * @param onAnimationLoop defines the callback to call when an animation loops
  15978. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15979. * @returns the list of created animatables
  15980. */
  15981. 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[];
  15982. /**
  15983. * Begin a new animation on a given node
  15984. * @param target defines the target where the animation will take place
  15985. * @param animations defines the list of animations to start
  15986. * @param from defines the initial value
  15987. * @param to defines the final value
  15988. * @param loop defines if you want animation to loop (off by default)
  15989. * @param speedRatio defines the speed ratio to apply to all animations
  15990. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15991. * @param onAnimationLoop defines the callback to call when an animation loops
  15992. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15993. * @returns the list of created animatables
  15994. */
  15995. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15996. /**
  15997. * Begin a new animation on a given node and its hierarchy
  15998. * @param target defines the root node where the animation will take place
  15999. * @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.
  16000. * @param animations defines the list of animations to start
  16001. * @param from defines the initial value
  16002. * @param to defines the final value
  16003. * @param loop defines if you want animation to loop (off by default)
  16004. * @param speedRatio defines the speed ratio to apply to all animations
  16005. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16006. * @param onAnimationLoop defines the callback to call when an animation loops
  16007. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16008. * @returns the list of animatables created for all nodes
  16009. */
  16010. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16011. /**
  16012. * Gets the animatable associated with a specific target
  16013. * @param target defines the target of the animatable
  16014. * @returns the required animatable if found
  16015. */
  16016. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16017. /**
  16018. * Gets all animatables associated with a given target
  16019. * @param target defines the target to look animatables for
  16020. * @returns an array of Animatables
  16021. */
  16022. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16023. /**
  16024. * Stops and removes all animations that have been applied to the scene
  16025. */
  16026. stopAllAnimations(): void;
  16027. /**
  16028. * Gets the current delta time used by animation engine
  16029. */
  16030. deltaTime: number;
  16031. }
  16032. interface Bone {
  16033. /**
  16034. * Copy an animation range from another bone
  16035. * @param source defines the source bone
  16036. * @param rangeName defines the range name to copy
  16037. * @param frameOffset defines the frame offset
  16038. * @param rescaleAsRequired defines if rescaling must be applied if required
  16039. * @param skelDimensionsRatio defines the scaling ratio
  16040. * @returns true if operation was successful
  16041. */
  16042. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16043. }
  16044. }
  16045. declare module BABYLON {
  16046. /**
  16047. * Class used to handle skinning animations
  16048. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16049. */
  16050. export class Skeleton implements IAnimatable {
  16051. /** defines the skeleton name */
  16052. name: string;
  16053. /** defines the skeleton Id */
  16054. id: string;
  16055. /**
  16056. * Defines the list of child bones
  16057. */
  16058. bones: Bone[];
  16059. /**
  16060. * Defines an estimate of the dimension of the skeleton at rest
  16061. */
  16062. dimensionsAtRest: Vector3;
  16063. /**
  16064. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16065. */
  16066. needInitialSkinMatrix: boolean;
  16067. /**
  16068. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16069. */
  16070. overrideMesh: Nullable<AbstractMesh>;
  16071. /**
  16072. * Gets the list of animations attached to this skeleton
  16073. */
  16074. animations: Array<Animation>;
  16075. private _scene;
  16076. private _isDirty;
  16077. private _transformMatrices;
  16078. private _transformMatrixTexture;
  16079. private _meshesWithPoseMatrix;
  16080. private _animatables;
  16081. private _identity;
  16082. private _synchronizedWithMesh;
  16083. private _ranges;
  16084. private _lastAbsoluteTransformsUpdateId;
  16085. private _canUseTextureForBones;
  16086. private _uniqueId;
  16087. /** @hidden */
  16088. _numBonesWithLinkedTransformNode: number;
  16089. /** @hidden */
  16090. _hasWaitingData: Nullable<boolean>;
  16091. /** @hidden */
  16092. _waitingOverrideMeshId: Nullable<string>;
  16093. /**
  16094. * Specifies if the skeleton should be serialized
  16095. */
  16096. doNotSerialize: boolean;
  16097. private _useTextureToStoreBoneMatrices;
  16098. /**
  16099. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16100. * Please note that this option is not available if the hardware does not support it
  16101. */
  16102. get useTextureToStoreBoneMatrices(): boolean;
  16103. set useTextureToStoreBoneMatrices(value: boolean);
  16104. private _animationPropertiesOverride;
  16105. /**
  16106. * Gets or sets the animation properties override
  16107. */
  16108. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16109. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16110. /**
  16111. * List of inspectable custom properties (used by the Inspector)
  16112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16113. */
  16114. inspectableCustomProperties: IInspectable[];
  16115. /**
  16116. * An observable triggered before computing the skeleton's matrices
  16117. */
  16118. onBeforeComputeObservable: Observable<Skeleton>;
  16119. /**
  16120. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16121. */
  16122. get isUsingTextureForMatrices(): boolean;
  16123. /**
  16124. * Gets the unique ID of this skeleton
  16125. */
  16126. get uniqueId(): number;
  16127. /**
  16128. * Creates a new skeleton
  16129. * @param name defines the skeleton name
  16130. * @param id defines the skeleton Id
  16131. * @param scene defines the hosting scene
  16132. */
  16133. constructor(
  16134. /** defines the skeleton name */
  16135. name: string,
  16136. /** defines the skeleton Id */
  16137. id: string, scene: Scene);
  16138. /**
  16139. * Gets the current object class name.
  16140. * @return the class name
  16141. */
  16142. getClassName(): string;
  16143. /**
  16144. * Returns an array containing the root bones
  16145. * @returns an array containing the root bones
  16146. */
  16147. getChildren(): Array<Bone>;
  16148. /**
  16149. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16150. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16151. * @returns a Float32Array containing matrices data
  16152. */
  16153. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16154. /**
  16155. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16156. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16157. * @returns a raw texture containing the data
  16158. */
  16159. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16160. /**
  16161. * Gets the current hosting scene
  16162. * @returns a scene object
  16163. */
  16164. getScene(): Scene;
  16165. /**
  16166. * Gets a string representing the current skeleton data
  16167. * @param fullDetails defines a boolean indicating if we want a verbose version
  16168. * @returns a string representing the current skeleton data
  16169. */
  16170. toString(fullDetails?: boolean): string;
  16171. /**
  16172. * Get bone's index searching by name
  16173. * @param name defines bone's name to search for
  16174. * @return the indice of the bone. Returns -1 if not found
  16175. */
  16176. getBoneIndexByName(name: string): number;
  16177. /**
  16178. * Creater a new animation range
  16179. * @param name defines the name of the range
  16180. * @param from defines the start key
  16181. * @param to defines the end key
  16182. */
  16183. createAnimationRange(name: string, from: number, to: number): void;
  16184. /**
  16185. * Delete a specific animation range
  16186. * @param name defines the name of the range
  16187. * @param deleteFrames defines if frames must be removed as well
  16188. */
  16189. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16190. /**
  16191. * Gets a specific animation range
  16192. * @param name defines the name of the range to look for
  16193. * @returns the requested animation range or null if not found
  16194. */
  16195. getAnimationRange(name: string): Nullable<AnimationRange>;
  16196. /**
  16197. * Gets the list of all animation ranges defined on this skeleton
  16198. * @returns an array
  16199. */
  16200. getAnimationRanges(): Nullable<AnimationRange>[];
  16201. /**
  16202. * Copy animation range from a source skeleton.
  16203. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16204. * @param source defines the source skeleton
  16205. * @param name defines the name of the range to copy
  16206. * @param rescaleAsRequired defines if rescaling must be applied if required
  16207. * @returns true if operation was successful
  16208. */
  16209. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16210. /**
  16211. * Forces the skeleton to go to rest pose
  16212. */
  16213. returnToRest(): void;
  16214. private _getHighestAnimationFrame;
  16215. /**
  16216. * Begin a specific animation range
  16217. * @param name defines the name of the range to start
  16218. * @param loop defines if looping must be turned on (false by default)
  16219. * @param speedRatio defines the speed ratio to apply (1 by default)
  16220. * @param onAnimationEnd defines a callback which will be called when animation will end
  16221. * @returns a new animatable
  16222. */
  16223. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16224. /**
  16225. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16226. * @param skeleton defines the Skeleton containing the animation range to convert
  16227. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16228. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16229. * @returns the original skeleton
  16230. */
  16231. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16232. /** @hidden */
  16233. _markAsDirty(): void;
  16234. /** @hidden */
  16235. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16236. /** @hidden */
  16237. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16238. private _computeTransformMatrices;
  16239. /**
  16240. * Build all resources required to render a skeleton
  16241. */
  16242. prepare(): void;
  16243. /**
  16244. * Gets the list of animatables currently running for this skeleton
  16245. * @returns an array of animatables
  16246. */
  16247. getAnimatables(): IAnimatable[];
  16248. /**
  16249. * Clone the current skeleton
  16250. * @param name defines the name of the new skeleton
  16251. * @param id defines the id of the new skeleton
  16252. * @returns the new skeleton
  16253. */
  16254. clone(name: string, id?: string): Skeleton;
  16255. /**
  16256. * Enable animation blending for this skeleton
  16257. * @param blendingSpeed defines the blending speed to apply
  16258. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16259. */
  16260. enableBlending(blendingSpeed?: number): void;
  16261. /**
  16262. * Releases all resources associated with the current skeleton
  16263. */
  16264. dispose(): void;
  16265. /**
  16266. * Serialize the skeleton in a JSON object
  16267. * @returns a JSON object
  16268. */
  16269. serialize(): any;
  16270. /**
  16271. * Creates a new skeleton from serialized data
  16272. * @param parsedSkeleton defines the serialized data
  16273. * @param scene defines the hosting scene
  16274. * @returns a new skeleton
  16275. */
  16276. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16277. /**
  16278. * Compute all node absolute transforms
  16279. * @param forceUpdate defines if computation must be done even if cache is up to date
  16280. */
  16281. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16282. /**
  16283. * Gets the root pose matrix
  16284. * @returns a matrix
  16285. */
  16286. getPoseMatrix(): Nullable<Matrix>;
  16287. /**
  16288. * Sorts bones per internal index
  16289. */
  16290. sortBones(): void;
  16291. private _sortBones;
  16292. /**
  16293. * Set the current local matrix as the restPose for all bones in the skeleton.
  16294. */
  16295. setCurrentPoseAsRest(): void;
  16296. }
  16297. }
  16298. declare module BABYLON {
  16299. /**
  16300. * Creates an instance based on a source mesh.
  16301. */
  16302. export class InstancedMesh extends AbstractMesh {
  16303. private _sourceMesh;
  16304. private _currentLOD;
  16305. /** @hidden */
  16306. _indexInSourceMeshInstanceArray: number;
  16307. constructor(name: string, source: Mesh);
  16308. /**
  16309. * Returns the string "InstancedMesh".
  16310. */
  16311. getClassName(): string;
  16312. /** Gets the list of lights affecting that mesh */
  16313. get lightSources(): Light[];
  16314. _resyncLightSources(): void;
  16315. _resyncLightSource(light: Light): void;
  16316. _removeLightSource(light: Light, dispose: boolean): void;
  16317. /**
  16318. * If the source mesh receives shadows
  16319. */
  16320. get receiveShadows(): boolean;
  16321. /**
  16322. * The material of the source mesh
  16323. */
  16324. get material(): Nullable<Material>;
  16325. /**
  16326. * Visibility of the source mesh
  16327. */
  16328. get visibility(): number;
  16329. /**
  16330. * Skeleton of the source mesh
  16331. */
  16332. get skeleton(): Nullable<Skeleton>;
  16333. /**
  16334. * Rendering ground id of the source mesh
  16335. */
  16336. get renderingGroupId(): number;
  16337. set renderingGroupId(value: number);
  16338. /**
  16339. * Returns the total number of vertices (integer).
  16340. */
  16341. getTotalVertices(): number;
  16342. /**
  16343. * Returns a positive integer : the total number of indices in this mesh geometry.
  16344. * @returns the numner of indices or zero if the mesh has no geometry.
  16345. */
  16346. getTotalIndices(): number;
  16347. /**
  16348. * The source mesh of the instance
  16349. */
  16350. get sourceMesh(): Mesh;
  16351. /**
  16352. * Creates a new InstancedMesh object from the mesh model.
  16353. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16354. * @param name defines the name of the new instance
  16355. * @returns a new InstancedMesh
  16356. */
  16357. createInstance(name: string): InstancedMesh;
  16358. /**
  16359. * Is this node ready to be used/rendered
  16360. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16361. * @return {boolean} is it ready
  16362. */
  16363. isReady(completeCheck?: boolean): boolean;
  16364. /**
  16365. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16366. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16367. * @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.
  16368. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16369. */
  16370. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16371. /**
  16372. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16373. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16374. * The `data` are either a numeric array either a Float32Array.
  16375. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16376. * 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).
  16377. * Note that a new underlying VertexBuffer object is created each call.
  16378. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16379. *
  16380. * Possible `kind` values :
  16381. * - VertexBuffer.PositionKind
  16382. * - VertexBuffer.UVKind
  16383. * - VertexBuffer.UV2Kind
  16384. * - VertexBuffer.UV3Kind
  16385. * - VertexBuffer.UV4Kind
  16386. * - VertexBuffer.UV5Kind
  16387. * - VertexBuffer.UV6Kind
  16388. * - VertexBuffer.ColorKind
  16389. * - VertexBuffer.MatricesIndicesKind
  16390. * - VertexBuffer.MatricesIndicesExtraKind
  16391. * - VertexBuffer.MatricesWeightsKind
  16392. * - VertexBuffer.MatricesWeightsExtraKind
  16393. *
  16394. * Returns the Mesh.
  16395. */
  16396. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16397. /**
  16398. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16399. * If the mesh has no geometry, it is simply returned as it is.
  16400. * The `data` are either a numeric array either a Float32Array.
  16401. * No new underlying VertexBuffer object is created.
  16402. * 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.
  16403. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16404. *
  16405. * Possible `kind` values :
  16406. * - VertexBuffer.PositionKind
  16407. * - VertexBuffer.UVKind
  16408. * - VertexBuffer.UV2Kind
  16409. * - VertexBuffer.UV3Kind
  16410. * - VertexBuffer.UV4Kind
  16411. * - VertexBuffer.UV5Kind
  16412. * - VertexBuffer.UV6Kind
  16413. * - VertexBuffer.ColorKind
  16414. * - VertexBuffer.MatricesIndicesKind
  16415. * - VertexBuffer.MatricesIndicesExtraKind
  16416. * - VertexBuffer.MatricesWeightsKind
  16417. * - VertexBuffer.MatricesWeightsExtraKind
  16418. *
  16419. * Returns the Mesh.
  16420. */
  16421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16422. /**
  16423. * Sets the mesh indices.
  16424. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16425. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16426. * This method creates a new index buffer each call.
  16427. * Returns the Mesh.
  16428. */
  16429. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16430. /**
  16431. * Boolean : True if the mesh owns the requested kind of data.
  16432. */
  16433. isVerticesDataPresent(kind: string): boolean;
  16434. /**
  16435. * Returns an array of indices (IndicesArray).
  16436. */
  16437. getIndices(): Nullable<IndicesArray>;
  16438. get _positions(): Nullable<Vector3[]>;
  16439. /**
  16440. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16441. * This means the mesh underlying bounding box and sphere are recomputed.
  16442. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16443. * @returns the current mesh
  16444. */
  16445. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16446. /** @hidden */
  16447. _preActivate(): InstancedMesh;
  16448. /** @hidden */
  16449. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16450. /** @hidden */
  16451. _postActivate(): void;
  16452. getWorldMatrix(): Matrix;
  16453. get isAnInstance(): boolean;
  16454. /**
  16455. * Returns the current associated LOD AbstractMesh.
  16456. */
  16457. getLOD(camera: Camera): AbstractMesh;
  16458. /** @hidden */
  16459. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16460. /** @hidden */
  16461. _syncSubMeshes(): InstancedMesh;
  16462. /** @hidden */
  16463. _generatePointsArray(): boolean;
  16464. /** @hidden */
  16465. _updateBoundingInfo(): AbstractMesh;
  16466. /**
  16467. * Creates a new InstancedMesh from the current mesh.
  16468. * - name (string) : the cloned mesh name
  16469. * - newParent (optional Node) : the optional Node to parent the clone to.
  16470. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16471. *
  16472. * Returns the clone.
  16473. */
  16474. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16475. /**
  16476. * Disposes the InstancedMesh.
  16477. * Returns nothing.
  16478. */
  16479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16480. }
  16481. interface Mesh {
  16482. /**
  16483. * Register a custom buffer that will be instanced
  16484. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16485. * @param kind defines the buffer kind
  16486. * @param stride defines the stride in floats
  16487. */
  16488. registerInstancedBuffer(kind: string, stride: number): void;
  16489. /**
  16490. * true to use the edge renderer for all instances of this mesh
  16491. */
  16492. edgesShareWithInstances: boolean;
  16493. /** @hidden */
  16494. _userInstancedBuffersStorage: {
  16495. data: {
  16496. [key: string]: Float32Array;
  16497. };
  16498. sizes: {
  16499. [key: string]: number;
  16500. };
  16501. vertexBuffers: {
  16502. [key: string]: Nullable<VertexBuffer>;
  16503. };
  16504. strides: {
  16505. [key: string]: number;
  16506. };
  16507. };
  16508. }
  16509. interface AbstractMesh {
  16510. /**
  16511. * Object used to store instanced buffers defined by user
  16512. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16513. */
  16514. instancedBuffers: {
  16515. [key: string]: any;
  16516. };
  16517. }
  16518. }
  16519. declare module BABYLON {
  16520. /**
  16521. * Defines the options associated with the creation of a shader material.
  16522. */
  16523. export interface IShaderMaterialOptions {
  16524. /**
  16525. * Does the material work in alpha blend mode
  16526. */
  16527. needAlphaBlending: boolean;
  16528. /**
  16529. * Does the material work in alpha test mode
  16530. */
  16531. needAlphaTesting: boolean;
  16532. /**
  16533. * The list of attribute names used in the shader
  16534. */
  16535. attributes: string[];
  16536. /**
  16537. * The list of unifrom names used in the shader
  16538. */
  16539. uniforms: string[];
  16540. /**
  16541. * The list of UBO names used in the shader
  16542. */
  16543. uniformBuffers: string[];
  16544. /**
  16545. * The list of sampler names used in the shader
  16546. */
  16547. samplers: string[];
  16548. /**
  16549. * The list of defines used in the shader
  16550. */
  16551. defines: string[];
  16552. }
  16553. /**
  16554. * 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.
  16555. *
  16556. * This returned material effects how the mesh will look based on the code in the shaders.
  16557. *
  16558. * @see https://doc.babylonjs.com/how_to/shader_material
  16559. */
  16560. export class ShaderMaterial extends Material {
  16561. private _shaderPath;
  16562. private _options;
  16563. private _textures;
  16564. private _textureArrays;
  16565. private _floats;
  16566. private _ints;
  16567. private _floatsArrays;
  16568. private _colors3;
  16569. private _colors3Arrays;
  16570. private _colors4;
  16571. private _colors4Arrays;
  16572. private _vectors2;
  16573. private _vectors3;
  16574. private _vectors4;
  16575. private _matrices;
  16576. private _matrixArrays;
  16577. private _matrices3x3;
  16578. private _matrices2x2;
  16579. private _vectors2Arrays;
  16580. private _vectors3Arrays;
  16581. private _vectors4Arrays;
  16582. private _cachedWorldViewMatrix;
  16583. private _cachedWorldViewProjectionMatrix;
  16584. private _renderId;
  16585. private _multiview;
  16586. private _cachedDefines;
  16587. /** Define the Url to load snippets */
  16588. static SnippetUrl: string;
  16589. /** Snippet ID if the material was created from the snippet server */
  16590. snippetId: string;
  16591. /**
  16592. * Instantiate a new shader material.
  16593. * 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.
  16594. * This returned material effects how the mesh will look based on the code in the shaders.
  16595. * @see https://doc.babylonjs.com/how_to/shader_material
  16596. * @param name Define the name of the material in the scene
  16597. * @param scene Define the scene the material belongs to
  16598. * @param shaderPath Defines the route to the shader code in one of three ways:
  16599. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16600. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16601. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16602. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16603. * @param options Define the options used to create the shader
  16604. */
  16605. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16606. /**
  16607. * Gets the shader path used to define the shader code
  16608. * It can be modified to trigger a new compilation
  16609. */
  16610. get shaderPath(): any;
  16611. /**
  16612. * Sets the shader path used to define the shader code
  16613. * It can be modified to trigger a new compilation
  16614. */
  16615. set shaderPath(shaderPath: any);
  16616. /**
  16617. * Gets the options used to compile the shader.
  16618. * They can be modified to trigger a new compilation
  16619. */
  16620. get options(): IShaderMaterialOptions;
  16621. /**
  16622. * Gets the current class name of the material e.g. "ShaderMaterial"
  16623. * Mainly use in serialization.
  16624. * @returns the class name
  16625. */
  16626. getClassName(): string;
  16627. /**
  16628. * Specifies if the material will require alpha blending
  16629. * @returns a boolean specifying if alpha blending is needed
  16630. */
  16631. needAlphaBlending(): boolean;
  16632. /**
  16633. * Specifies if this material should be rendered in alpha test mode
  16634. * @returns a boolean specifying if an alpha test is needed.
  16635. */
  16636. needAlphaTesting(): boolean;
  16637. private _checkUniform;
  16638. /**
  16639. * Set a texture in the shader.
  16640. * @param name Define the name of the uniform samplers as defined in the shader
  16641. * @param texture Define the texture to bind to this sampler
  16642. * @return the material itself allowing "fluent" like uniform updates
  16643. */
  16644. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16645. /**
  16646. * Set a texture array in the shader.
  16647. * @param name Define the name of the uniform sampler array as defined in the shader
  16648. * @param textures Define the list of textures to bind to this sampler
  16649. * @return the material itself allowing "fluent" like uniform updates
  16650. */
  16651. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16652. /**
  16653. * Set a float in the shader.
  16654. * @param name Define the name of the uniform as defined in the shader
  16655. * @param value Define the value to give to the uniform
  16656. * @return the material itself allowing "fluent" like uniform updates
  16657. */
  16658. setFloat(name: string, value: number): ShaderMaterial;
  16659. /**
  16660. * Set a int in the shader.
  16661. * @param name Define the name of the uniform as defined in the shader
  16662. * @param value Define the value to give to the uniform
  16663. * @return the material itself allowing "fluent" like uniform updates
  16664. */
  16665. setInt(name: string, value: number): ShaderMaterial;
  16666. /**
  16667. * Set an array of floats in the shader.
  16668. * @param name Define the name of the uniform as defined in the shader
  16669. * @param value Define the value to give to the uniform
  16670. * @return the material itself allowing "fluent" like uniform updates
  16671. */
  16672. setFloats(name: string, value: number[]): ShaderMaterial;
  16673. /**
  16674. * Set a vec3 in the shader from a Color3.
  16675. * @param name Define the name of the uniform as defined in the shader
  16676. * @param value Define the value to give to the uniform
  16677. * @return the material itself allowing "fluent" like uniform updates
  16678. */
  16679. setColor3(name: string, value: Color3): ShaderMaterial;
  16680. /**
  16681. * Set a vec3 array in the shader from a Color3 array.
  16682. * @param name Define the name of the uniform as defined in the shader
  16683. * @param value Define the value to give to the uniform
  16684. * @return the material itself allowing "fluent" like uniform updates
  16685. */
  16686. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16687. /**
  16688. * Set a vec4 in the shader from a Color4.
  16689. * @param name Define the name of the uniform as defined in the shader
  16690. * @param value Define the value to give to the uniform
  16691. * @return the material itself allowing "fluent" like uniform updates
  16692. */
  16693. setColor4(name: string, value: Color4): ShaderMaterial;
  16694. /**
  16695. * Set a vec4 array in the shader from a Color4 array.
  16696. * @param name Define the name of the uniform as defined in the shader
  16697. * @param value Define the value to give to the uniform
  16698. * @return the material itself allowing "fluent" like uniform updates
  16699. */
  16700. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16701. /**
  16702. * Set a vec2 in the shader from a Vector2.
  16703. * @param name Define the name of the uniform as defined in the shader
  16704. * @param value Define the value to give to the uniform
  16705. * @return the material itself allowing "fluent" like uniform updates
  16706. */
  16707. setVector2(name: string, value: Vector2): ShaderMaterial;
  16708. /**
  16709. * Set a vec3 in the shader from a Vector3.
  16710. * @param name Define the name of the uniform as defined in the shader
  16711. * @param value Define the value to give to the uniform
  16712. * @return the material itself allowing "fluent" like uniform updates
  16713. */
  16714. setVector3(name: string, value: Vector3): ShaderMaterial;
  16715. /**
  16716. * Set a vec4 in the shader from a Vector4.
  16717. * @param name Define the name of the uniform as defined in the shader
  16718. * @param value Define the value to give to the uniform
  16719. * @return the material itself allowing "fluent" like uniform updates
  16720. */
  16721. setVector4(name: string, value: Vector4): ShaderMaterial;
  16722. /**
  16723. * Set a mat4 in the shader from a Matrix.
  16724. * @param name Define the name of the uniform as defined in the shader
  16725. * @param value Define the value to give to the uniform
  16726. * @return the material itself allowing "fluent" like uniform updates
  16727. */
  16728. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16729. /**
  16730. * Set a float32Array in the shader from a matrix array.
  16731. * @param name Define the name of the uniform as defined in the shader
  16732. * @param value Define the value to give to the uniform
  16733. * @return the material itself allowing "fluent" like uniform updates
  16734. */
  16735. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16736. /**
  16737. * Set a mat3 in the shader from a Float32Array.
  16738. * @param name Define the name of the uniform as defined in the shader
  16739. * @param value Define the value to give to the uniform
  16740. * @return the material itself allowing "fluent" like uniform updates
  16741. */
  16742. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16743. /**
  16744. * Set a mat2 in the shader from a Float32Array.
  16745. * @param name Define the name of the uniform as defined in the shader
  16746. * @param value Define the value to give to the uniform
  16747. * @return the material itself allowing "fluent" like uniform updates
  16748. */
  16749. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16750. /**
  16751. * Set a vec2 array in the shader from a number array.
  16752. * @param name Define the name of the uniform as defined in the shader
  16753. * @param value Define the value to give to the uniform
  16754. * @return the material itself allowing "fluent" like uniform updates
  16755. */
  16756. setArray2(name: string, value: number[]): ShaderMaterial;
  16757. /**
  16758. * Set a vec3 array in the shader from a number array.
  16759. * @param name Define the name of the uniform as defined in the shader
  16760. * @param value Define the value to give to the uniform
  16761. * @return the material itself allowing "fluent" like uniform updates
  16762. */
  16763. setArray3(name: string, value: number[]): ShaderMaterial;
  16764. /**
  16765. * Set a vec4 array in the shader from a number array.
  16766. * @param name Define the name of the uniform as defined in the shader
  16767. * @param value Define the value to give to the uniform
  16768. * @return the material itself allowing "fluent" like uniform updates
  16769. */
  16770. setArray4(name: string, value: number[]): ShaderMaterial;
  16771. private _checkCache;
  16772. /**
  16773. * Specifies that the submesh is ready to be used
  16774. * @param mesh defines the mesh to check
  16775. * @param subMesh defines which submesh to check
  16776. * @param useInstances specifies that instances should be used
  16777. * @returns a boolean indicating that the submesh is ready or not
  16778. */
  16779. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16780. /**
  16781. * Checks if the material is ready to render the requested mesh
  16782. * @param mesh Define the mesh to render
  16783. * @param useInstances Define whether or not the material is used with instances
  16784. * @returns true if ready, otherwise false
  16785. */
  16786. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16787. /**
  16788. * Binds the world matrix to the material
  16789. * @param world defines the world transformation matrix
  16790. * @param effectOverride - If provided, use this effect instead of internal effect
  16791. */
  16792. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16793. /**
  16794. * Binds the submesh to this material by preparing the effect and shader to draw
  16795. * @param world defines the world transformation matrix
  16796. * @param mesh defines the mesh containing the submesh
  16797. * @param subMesh defines the submesh to bind the material to
  16798. */
  16799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16800. /**
  16801. * Binds the material to the mesh
  16802. * @param world defines the world transformation matrix
  16803. * @param mesh defines the mesh to bind the material to
  16804. * @param effectOverride - If provided, use this effect instead of internal effect
  16805. */
  16806. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16807. protected _afterBind(mesh?: Mesh): void;
  16808. /**
  16809. * Gets the active textures from the material
  16810. * @returns an array of textures
  16811. */
  16812. getActiveTextures(): BaseTexture[];
  16813. /**
  16814. * Specifies if the material uses a texture
  16815. * @param texture defines the texture to check against the material
  16816. * @returns a boolean specifying if the material uses the texture
  16817. */
  16818. hasTexture(texture: BaseTexture): boolean;
  16819. /**
  16820. * Makes a duplicate of the material, and gives it a new name
  16821. * @param name defines the new name for the duplicated material
  16822. * @returns the cloned material
  16823. */
  16824. clone(name: string): ShaderMaterial;
  16825. /**
  16826. * Disposes the material
  16827. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16828. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16829. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16830. */
  16831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16832. /**
  16833. * Serializes this material in a JSON representation
  16834. * @returns the serialized material object
  16835. */
  16836. serialize(): any;
  16837. /**
  16838. * Creates a shader material from parsed shader material data
  16839. * @param source defines the JSON represnetation of the material
  16840. * @param scene defines the hosting scene
  16841. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16842. * @returns a new material
  16843. */
  16844. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16845. /**
  16846. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16847. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16848. * @param url defines the url to load from
  16849. * @param scene defines the hosting scene
  16850. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16851. * @returns a promise that will resolve to the new ShaderMaterial
  16852. */
  16853. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16854. /**
  16855. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16856. * @param snippetId defines the snippet to load
  16857. * @param scene defines the hosting scene
  16858. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16859. * @returns a promise that will resolve to the new ShaderMaterial
  16860. */
  16861. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16862. }
  16863. }
  16864. declare module BABYLON {
  16865. /** @hidden */
  16866. export var colorPixelShader: {
  16867. name: string;
  16868. shader: string;
  16869. };
  16870. }
  16871. declare module BABYLON {
  16872. /** @hidden */
  16873. export var colorVertexShader: {
  16874. name: string;
  16875. shader: string;
  16876. };
  16877. }
  16878. declare module BABYLON {
  16879. /**
  16880. * Line mesh
  16881. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16882. */
  16883. export class LinesMesh extends Mesh {
  16884. /**
  16885. * If vertex color should be applied to the mesh
  16886. */
  16887. readonly useVertexColor?: boolean | undefined;
  16888. /**
  16889. * If vertex alpha should be applied to the mesh
  16890. */
  16891. readonly useVertexAlpha?: boolean | undefined;
  16892. /**
  16893. * Color of the line (Default: White)
  16894. */
  16895. color: Color3;
  16896. /**
  16897. * Alpha of the line (Default: 1)
  16898. */
  16899. alpha: number;
  16900. /**
  16901. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16902. * This margin is expressed in world space coordinates, so its value may vary.
  16903. * Default value is 0.1
  16904. */
  16905. intersectionThreshold: number;
  16906. private _colorShader;
  16907. private color4;
  16908. /**
  16909. * Creates a new LinesMesh
  16910. * @param name defines the name
  16911. * @param scene defines the hosting scene
  16912. * @param parent defines the parent mesh if any
  16913. * @param source defines the optional source LinesMesh used to clone data from
  16914. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16915. * When false, achieved by calling a clone(), also passing False.
  16916. * This will make creation of children, recursive.
  16917. * @param useVertexColor defines if this LinesMesh supports vertex color
  16918. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16919. */
  16920. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16921. /**
  16922. * If vertex color should be applied to the mesh
  16923. */
  16924. useVertexColor?: boolean | undefined,
  16925. /**
  16926. * If vertex alpha should be applied to the mesh
  16927. */
  16928. useVertexAlpha?: boolean | undefined);
  16929. private _addClipPlaneDefine;
  16930. private _removeClipPlaneDefine;
  16931. isReady(): boolean;
  16932. /**
  16933. * Returns the string "LineMesh"
  16934. */
  16935. getClassName(): string;
  16936. /**
  16937. * @hidden
  16938. */
  16939. get material(): Material;
  16940. /**
  16941. * @hidden
  16942. */
  16943. set material(value: Material);
  16944. /**
  16945. * @hidden
  16946. */
  16947. get checkCollisions(): boolean;
  16948. /** @hidden */
  16949. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16950. /** @hidden */
  16951. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16952. /**
  16953. * Disposes of the line mesh
  16954. * @param doNotRecurse If children should be disposed
  16955. */
  16956. dispose(doNotRecurse?: boolean): void;
  16957. /**
  16958. * Returns a new LineMesh object cloned from the current one.
  16959. */
  16960. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16961. /**
  16962. * Creates a new InstancedLinesMesh object from the mesh model.
  16963. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16964. * @param name defines the name of the new instance
  16965. * @returns a new InstancedLinesMesh
  16966. */
  16967. createInstance(name: string): InstancedLinesMesh;
  16968. }
  16969. /**
  16970. * Creates an instance based on a source LinesMesh
  16971. */
  16972. export class InstancedLinesMesh extends InstancedMesh {
  16973. /**
  16974. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16975. * This margin is expressed in world space coordinates, so its value may vary.
  16976. * Initilized with the intersectionThreshold value of the source LinesMesh
  16977. */
  16978. intersectionThreshold: number;
  16979. constructor(name: string, source: LinesMesh);
  16980. /**
  16981. * Returns the string "InstancedLinesMesh".
  16982. */
  16983. getClassName(): string;
  16984. }
  16985. }
  16986. declare module BABYLON {
  16987. /** @hidden */
  16988. export var linePixelShader: {
  16989. name: string;
  16990. shader: string;
  16991. };
  16992. }
  16993. declare module BABYLON {
  16994. /** @hidden */
  16995. export var lineVertexShader: {
  16996. name: string;
  16997. shader: string;
  16998. };
  16999. }
  17000. declare module BABYLON {
  17001. interface Scene {
  17002. /** @hidden */
  17003. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17004. }
  17005. interface AbstractMesh {
  17006. /**
  17007. * Gets the edgesRenderer associated with the mesh
  17008. */
  17009. edgesRenderer: Nullable<EdgesRenderer>;
  17010. }
  17011. interface LinesMesh {
  17012. /**
  17013. * Enables the edge rendering mode on the mesh.
  17014. * This mode makes the mesh edges visible
  17015. * @param epsilon defines the maximal distance between two angles to detect a face
  17016. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17017. * @returns the currentAbstractMesh
  17018. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17019. */
  17020. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17021. }
  17022. interface InstancedLinesMesh {
  17023. /**
  17024. * Enables the edge rendering mode on the mesh.
  17025. * This mode makes the mesh edges visible
  17026. * @param epsilon defines the maximal distance between two angles to detect a face
  17027. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17028. * @returns the current InstancedLinesMesh
  17029. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17030. */
  17031. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17032. }
  17033. /**
  17034. * Defines the minimum contract an Edges renderer should follow.
  17035. */
  17036. export interface IEdgesRenderer extends IDisposable {
  17037. /**
  17038. * Gets or sets a boolean indicating if the edgesRenderer is active
  17039. */
  17040. isEnabled: boolean;
  17041. /**
  17042. * Renders the edges of the attached mesh,
  17043. */
  17044. render(): void;
  17045. /**
  17046. * Checks wether or not the edges renderer is ready to render.
  17047. * @return true if ready, otherwise false.
  17048. */
  17049. isReady(): boolean;
  17050. /**
  17051. * List of instances to render in case the source mesh has instances
  17052. */
  17053. customInstances: SmartArray<Matrix>;
  17054. }
  17055. /**
  17056. * Defines the additional options of the edges renderer
  17057. */
  17058. export interface IEdgesRendererOptions {
  17059. /**
  17060. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17061. * If not defined, the default value is true
  17062. */
  17063. useAlternateEdgeFinder?: boolean;
  17064. /**
  17065. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17066. * If not defined, the default value is true.
  17067. * 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)
  17068. * This option is used only if useAlternateEdgeFinder = true
  17069. */
  17070. useFastVertexMerger?: boolean;
  17071. /**
  17072. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17073. * The default value is 1e-6
  17074. * This option is used only if useAlternateEdgeFinder = true
  17075. */
  17076. epsilonVertexMerge?: number;
  17077. /**
  17078. * 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
  17079. * 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.
  17080. * This option is used only if useAlternateEdgeFinder = true
  17081. */
  17082. applyTessellation?: boolean;
  17083. /**
  17084. * 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
  17085. * The default value is 1e-6
  17086. * This option is used only if useAlternateEdgeFinder = true
  17087. */
  17088. epsilonVertexAligned?: number;
  17089. }
  17090. /**
  17091. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17092. */
  17093. export class EdgesRenderer implements IEdgesRenderer {
  17094. /**
  17095. * Define the size of the edges with an orthographic camera
  17096. */
  17097. edgesWidthScalerForOrthographic: number;
  17098. /**
  17099. * Define the size of the edges with a perspective camera
  17100. */
  17101. edgesWidthScalerForPerspective: number;
  17102. protected _source: AbstractMesh;
  17103. protected _linesPositions: number[];
  17104. protected _linesNormals: number[];
  17105. protected _linesIndices: number[];
  17106. protected _epsilon: number;
  17107. protected _indicesCount: number;
  17108. protected _lineShader: ShaderMaterial;
  17109. protected _ib: DataBuffer;
  17110. protected _buffers: {
  17111. [key: string]: Nullable<VertexBuffer>;
  17112. };
  17113. protected _buffersForInstances: {
  17114. [key: string]: Nullable<VertexBuffer>;
  17115. };
  17116. protected _checkVerticesInsteadOfIndices: boolean;
  17117. protected _options: Nullable<IEdgesRendererOptions>;
  17118. private _meshRebuildObserver;
  17119. private _meshDisposeObserver;
  17120. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17121. isEnabled: boolean;
  17122. /**
  17123. * List of instances to render in case the source mesh has instances
  17124. */
  17125. customInstances: SmartArray<Matrix>;
  17126. private static GetShader;
  17127. /**
  17128. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17129. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17130. * @param source Mesh used to create edges
  17131. * @param epsilon sum of angles in adjacency to check for edge
  17132. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17133. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17134. * @param options The options to apply when generating the edges
  17135. */
  17136. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17137. protected _prepareRessources(): void;
  17138. /** @hidden */
  17139. _rebuild(): void;
  17140. /**
  17141. * Releases the required resources for the edges renderer
  17142. */
  17143. dispose(): void;
  17144. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17145. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17146. /**
  17147. * Checks if the pair of p0 and p1 is en edge
  17148. * @param faceIndex
  17149. * @param edge
  17150. * @param faceNormals
  17151. * @param p0
  17152. * @param p1
  17153. * @private
  17154. */
  17155. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17156. /**
  17157. * push line into the position, normal and index buffer
  17158. * @protected
  17159. */
  17160. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17161. /**
  17162. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17163. */
  17164. private _tessellateTriangle;
  17165. private _generateEdgesLinesAlternate;
  17166. /**
  17167. * Generates lines edges from adjacencjes
  17168. * @private
  17169. */
  17170. _generateEdgesLines(): void;
  17171. /**
  17172. * Checks wether or not the edges renderer is ready to render.
  17173. * @return true if ready, otherwise false.
  17174. */
  17175. isReady(): boolean;
  17176. /**
  17177. * Renders the edges of the attached mesh,
  17178. */
  17179. render(): void;
  17180. }
  17181. /**
  17182. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17183. */
  17184. export class LineEdgesRenderer extends EdgesRenderer {
  17185. /**
  17186. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17187. * @param source LineMesh used to generate edges
  17188. * @param epsilon not important (specified angle for edge detection)
  17189. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17190. */
  17191. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17192. /**
  17193. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17194. */
  17195. _generateEdgesLines(): void;
  17196. }
  17197. }
  17198. declare module BABYLON {
  17199. /**
  17200. * This represents the object necessary to create a rendering group.
  17201. * This is exclusively used and created by the rendering manager.
  17202. * To modify the behavior, you use the available helpers in your scene or meshes.
  17203. * @hidden
  17204. */
  17205. export class RenderingGroup {
  17206. index: number;
  17207. private static _zeroVector;
  17208. private _scene;
  17209. private _opaqueSubMeshes;
  17210. private _transparentSubMeshes;
  17211. private _alphaTestSubMeshes;
  17212. private _depthOnlySubMeshes;
  17213. private _particleSystems;
  17214. private _spriteManagers;
  17215. private _opaqueSortCompareFn;
  17216. private _alphaTestSortCompareFn;
  17217. private _transparentSortCompareFn;
  17218. private _renderOpaque;
  17219. private _renderAlphaTest;
  17220. private _renderTransparent;
  17221. /** @hidden */
  17222. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17223. onBeforeTransparentRendering: () => void;
  17224. /**
  17225. * Set the opaque sort comparison function.
  17226. * If null the sub meshes will be render in the order they were created
  17227. */
  17228. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17229. /**
  17230. * Set the alpha test sort comparison function.
  17231. * If null the sub meshes will be render in the order they were created
  17232. */
  17233. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17234. /**
  17235. * Set the transparent sort comparison function.
  17236. * If null the sub meshes will be render in the order they were created
  17237. */
  17238. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17239. /**
  17240. * Creates a new rendering group.
  17241. * @param index The rendering group index
  17242. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17243. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17244. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17245. */
  17246. 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>);
  17247. /**
  17248. * Render all the sub meshes contained in the group.
  17249. * @param customRenderFunction Used to override the default render behaviour of the group.
  17250. * @returns true if rendered some submeshes.
  17251. */
  17252. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17253. /**
  17254. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17255. * @param subMeshes The submeshes to render
  17256. */
  17257. private renderOpaqueSorted;
  17258. /**
  17259. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17260. * @param subMeshes The submeshes to render
  17261. */
  17262. private renderAlphaTestSorted;
  17263. /**
  17264. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17265. * @param subMeshes The submeshes to render
  17266. */
  17267. private renderTransparentSorted;
  17268. /**
  17269. * Renders the submeshes in a specified order.
  17270. * @param subMeshes The submeshes to sort before render
  17271. * @param sortCompareFn The comparison function use to sort
  17272. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17273. * @param transparent Specifies to activate blending if true
  17274. */
  17275. private static renderSorted;
  17276. /**
  17277. * Renders the submeshes in the order they were dispatched (no sort applied).
  17278. * @param subMeshes The submeshes to render
  17279. */
  17280. private static renderUnsorted;
  17281. /**
  17282. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17283. * are rendered back to front if in the same alpha index.
  17284. *
  17285. * @param a The first submesh
  17286. * @param b The second submesh
  17287. * @returns The result of the comparison
  17288. */
  17289. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17290. /**
  17291. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17292. * are rendered back to front.
  17293. *
  17294. * @param a The first submesh
  17295. * @param b The second submesh
  17296. * @returns The result of the comparison
  17297. */
  17298. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17299. /**
  17300. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17301. * are rendered front to back (prevent overdraw).
  17302. *
  17303. * @param a The first submesh
  17304. * @param b The second submesh
  17305. * @returns The result of the comparison
  17306. */
  17307. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17308. /**
  17309. * Resets the different lists of submeshes to prepare a new frame.
  17310. */
  17311. prepare(): void;
  17312. dispose(): void;
  17313. /**
  17314. * Inserts the submesh in its correct queue depending on its material.
  17315. * @param subMesh The submesh to dispatch
  17316. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17317. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17318. */
  17319. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17320. dispatchSprites(spriteManager: ISpriteManager): void;
  17321. dispatchParticles(particleSystem: IParticleSystem): void;
  17322. private _renderParticles;
  17323. private _renderSprites;
  17324. }
  17325. }
  17326. declare module BABYLON {
  17327. /**
  17328. * Interface describing the different options available in the rendering manager
  17329. * regarding Auto Clear between groups.
  17330. */
  17331. export interface IRenderingManagerAutoClearSetup {
  17332. /**
  17333. * Defines whether or not autoclear is enable.
  17334. */
  17335. autoClear: boolean;
  17336. /**
  17337. * Defines whether or not to autoclear the depth buffer.
  17338. */
  17339. depth: boolean;
  17340. /**
  17341. * Defines whether or not to autoclear the stencil buffer.
  17342. */
  17343. stencil: boolean;
  17344. }
  17345. /**
  17346. * This class is used by the onRenderingGroupObservable
  17347. */
  17348. export class RenderingGroupInfo {
  17349. /**
  17350. * The Scene that being rendered
  17351. */
  17352. scene: Scene;
  17353. /**
  17354. * The camera currently used for the rendering pass
  17355. */
  17356. camera: Nullable<Camera>;
  17357. /**
  17358. * The ID of the renderingGroup being processed
  17359. */
  17360. renderingGroupId: number;
  17361. }
  17362. /**
  17363. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17364. * It is enable to manage the different groups as well as the different necessary sort functions.
  17365. * This should not be used directly aside of the few static configurations
  17366. */
  17367. export class RenderingManager {
  17368. /**
  17369. * The max id used for rendering groups (not included)
  17370. */
  17371. static MAX_RENDERINGGROUPS: number;
  17372. /**
  17373. * The min id used for rendering groups (included)
  17374. */
  17375. static MIN_RENDERINGGROUPS: number;
  17376. /**
  17377. * Used to globally prevent autoclearing scenes.
  17378. */
  17379. static AUTOCLEAR: boolean;
  17380. /**
  17381. * @hidden
  17382. */
  17383. _useSceneAutoClearSetup: boolean;
  17384. private _scene;
  17385. private _renderingGroups;
  17386. private _depthStencilBufferAlreadyCleaned;
  17387. private _autoClearDepthStencil;
  17388. private _customOpaqueSortCompareFn;
  17389. private _customAlphaTestSortCompareFn;
  17390. private _customTransparentSortCompareFn;
  17391. private _renderingGroupInfo;
  17392. /**
  17393. * Instantiates a new rendering group for a particular scene
  17394. * @param scene Defines the scene the groups belongs to
  17395. */
  17396. constructor(scene: Scene);
  17397. private _clearDepthStencilBuffer;
  17398. /**
  17399. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17400. * @hidden
  17401. */
  17402. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17403. /**
  17404. * Resets the different information of the group to prepare a new frame
  17405. * @hidden
  17406. */
  17407. reset(): void;
  17408. /**
  17409. * Dispose and release the group and its associated resources.
  17410. * @hidden
  17411. */
  17412. dispose(): void;
  17413. /**
  17414. * Clear the info related to rendering groups preventing retention points during dispose.
  17415. */
  17416. freeRenderingGroups(): void;
  17417. private _prepareRenderingGroup;
  17418. /**
  17419. * Add a sprite manager to the rendering manager in order to render it this frame.
  17420. * @param spriteManager Define the sprite manager to render
  17421. */
  17422. dispatchSprites(spriteManager: ISpriteManager): void;
  17423. /**
  17424. * Add a particle system to the rendering manager in order to render it this frame.
  17425. * @param particleSystem Define the particle system to render
  17426. */
  17427. dispatchParticles(particleSystem: IParticleSystem): void;
  17428. /**
  17429. * Add a submesh to the manager in order to render it this frame
  17430. * @param subMesh The submesh to dispatch
  17431. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17432. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17433. */
  17434. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17435. /**
  17436. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17437. * This allowed control for front to back rendering or reversly depending of the special needs.
  17438. *
  17439. * @param renderingGroupId The rendering group id corresponding to its index
  17440. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17441. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17442. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17443. */
  17444. 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;
  17445. /**
  17446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17447. *
  17448. * @param renderingGroupId The rendering group id corresponding to its index
  17449. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17450. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17451. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17452. */
  17453. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17454. /**
  17455. * Gets the current auto clear configuration for one rendering group of the rendering
  17456. * manager.
  17457. * @param index the rendering group index to get the information for
  17458. * @returns The auto clear setup for the requested rendering group
  17459. */
  17460. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17461. }
  17462. }
  17463. declare module BABYLON {
  17464. /**
  17465. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17466. */
  17467. export interface ICustomShaderOptions {
  17468. /**
  17469. * Gets or sets the custom shader name to use
  17470. */
  17471. shaderName: string;
  17472. /**
  17473. * The list of attribute names used in the shader
  17474. */
  17475. attributes?: string[];
  17476. /**
  17477. * The list of unifrom names used in the shader
  17478. */
  17479. uniforms?: string[];
  17480. /**
  17481. * The list of sampler names used in the shader
  17482. */
  17483. samplers?: string[];
  17484. /**
  17485. * The list of defines used in the shader
  17486. */
  17487. defines?: string[];
  17488. }
  17489. /**
  17490. * Interface to implement to create a shadow generator compatible with BJS.
  17491. */
  17492. export interface IShadowGenerator {
  17493. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17494. id: string;
  17495. /**
  17496. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17497. * @returns The render target texture if present otherwise, null
  17498. */
  17499. getShadowMap(): Nullable<RenderTargetTexture>;
  17500. /**
  17501. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17502. * @param subMesh The submesh we want to render in the shadow map
  17503. * @param useInstances Defines wether will draw in the map using instances
  17504. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17505. * @returns true if ready otherwise, false
  17506. */
  17507. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17508. /**
  17509. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17510. * @param defines Defines of the material we want to update
  17511. * @param lightIndex Index of the light in the enabled light list of the material
  17512. */
  17513. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17514. /**
  17515. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17516. * defined in the generator but impacting the effect).
  17517. * It implies the unifroms available on the materials are the standard BJS ones.
  17518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17519. * @param effect The effect we are binfing the information for
  17520. */
  17521. bindShadowLight(lightIndex: string, effect: Effect): void;
  17522. /**
  17523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17524. * (eq to shadow prjection matrix * light transform matrix)
  17525. * @returns The transform matrix used to create the shadow map
  17526. */
  17527. getTransformMatrix(): Matrix;
  17528. /**
  17529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17530. * Cube and 2D textures for instance.
  17531. */
  17532. recreateShadowMap(): void;
  17533. /**
  17534. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17535. * @param onCompiled Callback triggered at the and of the effects compilation
  17536. * @param options Sets of optional options forcing the compilation with different modes
  17537. */
  17538. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17539. useInstances: boolean;
  17540. }>): void;
  17541. /**
  17542. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17543. * @param options Sets of optional options forcing the compilation with different modes
  17544. * @returns A promise that resolves when the compilation completes
  17545. */
  17546. forceCompilationAsync(options?: Partial<{
  17547. useInstances: boolean;
  17548. }>): Promise<void>;
  17549. /**
  17550. * Serializes the shadow generator setup to a json object.
  17551. * @returns The serialized JSON object
  17552. */
  17553. serialize(): any;
  17554. /**
  17555. * Disposes the Shadow map and related Textures and effects.
  17556. */
  17557. dispose(): void;
  17558. }
  17559. /**
  17560. * Default implementation IShadowGenerator.
  17561. * This is the main object responsible of generating shadows in the framework.
  17562. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17563. */
  17564. export class ShadowGenerator implements IShadowGenerator {
  17565. /**
  17566. * Name of the shadow generator class
  17567. */
  17568. static CLASSNAME: string;
  17569. /**
  17570. * Shadow generator mode None: no filtering applied.
  17571. */
  17572. static readonly FILTER_NONE: number;
  17573. /**
  17574. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17575. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17576. */
  17577. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17578. /**
  17579. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17580. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17581. */
  17582. static readonly FILTER_POISSONSAMPLING: number;
  17583. /**
  17584. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17585. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17586. */
  17587. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17588. /**
  17589. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17590. * edge artifacts on steep falloff.
  17591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17592. */
  17593. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17594. /**
  17595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17596. * edge artifacts on steep falloff.
  17597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17598. */
  17599. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17600. /**
  17601. * Shadow generator mode PCF: Percentage Closer Filtering
  17602. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17603. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17604. */
  17605. static readonly FILTER_PCF: number;
  17606. /**
  17607. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17609. * Contact Hardening
  17610. */
  17611. static readonly FILTER_PCSS: number;
  17612. /**
  17613. * Reserved for PCF and PCSS
  17614. * Highest Quality.
  17615. *
  17616. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17617. *
  17618. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17619. */
  17620. static readonly QUALITY_HIGH: number;
  17621. /**
  17622. * Reserved for PCF and PCSS
  17623. * Good tradeoff for quality/perf cross devices
  17624. *
  17625. * Execute PCF on a 3*3 kernel.
  17626. *
  17627. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17628. */
  17629. static readonly QUALITY_MEDIUM: number;
  17630. /**
  17631. * Reserved for PCF and PCSS
  17632. * The lowest quality but the fastest.
  17633. *
  17634. * Execute PCF on a 1*1 kernel.
  17635. *
  17636. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17637. */
  17638. static readonly QUALITY_LOW: number;
  17639. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17640. id: string;
  17641. /** Gets or sets the custom shader name to use */
  17642. customShaderOptions: ICustomShaderOptions;
  17643. /**
  17644. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17645. */
  17646. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17647. /**
  17648. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17649. */
  17650. onAfterShadowMapRenderObservable: Observable<Effect>;
  17651. /**
  17652. * Observable triggered before a mesh is rendered in the shadow map.
  17653. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17654. */
  17655. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17656. /**
  17657. * Observable triggered after a mesh is rendered in the shadow map.
  17658. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17659. */
  17660. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17661. protected _bias: number;
  17662. /**
  17663. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17664. */
  17665. get bias(): number;
  17666. /**
  17667. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17668. */
  17669. set bias(bias: number);
  17670. protected _normalBias: number;
  17671. /**
  17672. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17673. */
  17674. get normalBias(): number;
  17675. /**
  17676. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17677. */
  17678. set normalBias(normalBias: number);
  17679. protected _blurBoxOffset: number;
  17680. /**
  17681. * Gets the blur box offset: offset applied during the blur pass.
  17682. * Only useful if useKernelBlur = false
  17683. */
  17684. get blurBoxOffset(): number;
  17685. /**
  17686. * Sets the blur box offset: offset applied during the blur pass.
  17687. * Only useful if useKernelBlur = false
  17688. */
  17689. set blurBoxOffset(value: number);
  17690. protected _blurScale: number;
  17691. /**
  17692. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17693. * 2 means half of the size.
  17694. */
  17695. get blurScale(): number;
  17696. /**
  17697. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17698. * 2 means half of the size.
  17699. */
  17700. set blurScale(value: number);
  17701. protected _blurKernel: number;
  17702. /**
  17703. * Gets the blur kernel: kernel size of the blur pass.
  17704. * Only useful if useKernelBlur = true
  17705. */
  17706. get blurKernel(): number;
  17707. /**
  17708. * Sets the blur kernel: kernel size of the blur pass.
  17709. * Only useful if useKernelBlur = true
  17710. */
  17711. set blurKernel(value: number);
  17712. protected _useKernelBlur: boolean;
  17713. /**
  17714. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17715. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17716. */
  17717. get useKernelBlur(): boolean;
  17718. /**
  17719. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17720. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17721. */
  17722. set useKernelBlur(value: boolean);
  17723. protected _depthScale: number;
  17724. /**
  17725. * Gets the depth scale used in ESM mode.
  17726. */
  17727. get depthScale(): number;
  17728. /**
  17729. * Sets the depth scale used in ESM mode.
  17730. * This can override the scale stored on the light.
  17731. */
  17732. set depthScale(value: number);
  17733. protected _validateFilter(filter: number): number;
  17734. protected _filter: number;
  17735. /**
  17736. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17737. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17738. */
  17739. get filter(): number;
  17740. /**
  17741. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17742. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17743. */
  17744. set filter(value: number);
  17745. /**
  17746. * Gets if the current filter is set to Poisson Sampling.
  17747. */
  17748. get usePoissonSampling(): boolean;
  17749. /**
  17750. * Sets the current filter to Poisson Sampling.
  17751. */
  17752. set usePoissonSampling(value: boolean);
  17753. /**
  17754. * Gets if the current filter is set to ESM.
  17755. */
  17756. get useExponentialShadowMap(): boolean;
  17757. /**
  17758. * Sets the current filter is to ESM.
  17759. */
  17760. set useExponentialShadowMap(value: boolean);
  17761. /**
  17762. * Gets if the current filter is set to filtered ESM.
  17763. */
  17764. get useBlurExponentialShadowMap(): boolean;
  17765. /**
  17766. * Gets if the current filter is set to filtered ESM.
  17767. */
  17768. set useBlurExponentialShadowMap(value: boolean);
  17769. /**
  17770. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17771. * exponential to prevent steep falloff artifacts).
  17772. */
  17773. get useCloseExponentialShadowMap(): boolean;
  17774. /**
  17775. * Sets the current filter to "close ESM" (using the inverse of the
  17776. * exponential to prevent steep falloff artifacts).
  17777. */
  17778. set useCloseExponentialShadowMap(value: boolean);
  17779. /**
  17780. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17781. * exponential to prevent steep falloff artifacts).
  17782. */
  17783. get useBlurCloseExponentialShadowMap(): boolean;
  17784. /**
  17785. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17786. * exponential to prevent steep falloff artifacts).
  17787. */
  17788. set useBlurCloseExponentialShadowMap(value: boolean);
  17789. /**
  17790. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17791. */
  17792. get usePercentageCloserFiltering(): boolean;
  17793. /**
  17794. * Sets the current filter to "PCF" (percentage closer filtering).
  17795. */
  17796. set usePercentageCloserFiltering(value: boolean);
  17797. protected _filteringQuality: number;
  17798. /**
  17799. * Gets the PCF or PCSS Quality.
  17800. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17801. */
  17802. get filteringQuality(): number;
  17803. /**
  17804. * Sets the PCF or PCSS Quality.
  17805. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17806. */
  17807. set filteringQuality(filteringQuality: number);
  17808. /**
  17809. * Gets if the current filter is set to "PCSS" (contact hardening).
  17810. */
  17811. get useContactHardeningShadow(): boolean;
  17812. /**
  17813. * Sets the current filter to "PCSS" (contact hardening).
  17814. */
  17815. set useContactHardeningShadow(value: boolean);
  17816. protected _contactHardeningLightSizeUVRatio: number;
  17817. /**
  17818. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17819. * Using a ratio helps keeping shape stability independently of the map size.
  17820. *
  17821. * It does not account for the light projection as it was having too much
  17822. * instability during the light setup or during light position changes.
  17823. *
  17824. * Only valid if useContactHardeningShadow is true.
  17825. */
  17826. get contactHardeningLightSizeUVRatio(): number;
  17827. /**
  17828. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17829. * Using a ratio helps keeping shape stability independently of the map size.
  17830. *
  17831. * It does not account for the light projection as it was having too much
  17832. * instability during the light setup or during light position changes.
  17833. *
  17834. * Only valid if useContactHardeningShadow is true.
  17835. */
  17836. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17837. protected _darkness: number;
  17838. /** Gets or sets the actual darkness of a shadow */
  17839. get darkness(): number;
  17840. set darkness(value: number);
  17841. /**
  17842. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17843. * 0 means strongest and 1 would means no shadow.
  17844. * @returns the darkness.
  17845. */
  17846. getDarkness(): number;
  17847. /**
  17848. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17849. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17850. * @returns the shadow generator allowing fluent coding.
  17851. */
  17852. setDarkness(darkness: number): ShadowGenerator;
  17853. protected _transparencyShadow: boolean;
  17854. /** Gets or sets the ability to have transparent shadow */
  17855. get transparencyShadow(): boolean;
  17856. set transparencyShadow(value: boolean);
  17857. /**
  17858. * Sets the ability to have transparent shadow (boolean).
  17859. * @param transparent True if transparent else False
  17860. * @returns the shadow generator allowing fluent coding
  17861. */
  17862. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17863. /**
  17864. * Enables or disables shadows with varying strength based on the transparency
  17865. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17866. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17867. * mesh.visibility * alphaTexture.a
  17868. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17869. */
  17870. enableSoftTransparentShadow: boolean;
  17871. protected _shadowMap: Nullable<RenderTargetTexture>;
  17872. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17873. /**
  17874. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17875. * @returns The render target texture if present otherwise, null
  17876. */
  17877. getShadowMap(): Nullable<RenderTargetTexture>;
  17878. /**
  17879. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17880. * @returns The render target texture if the shadow map is present otherwise, null
  17881. */
  17882. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17883. /**
  17884. * Gets the class name of that object
  17885. * @returns "ShadowGenerator"
  17886. */
  17887. getClassName(): string;
  17888. /**
  17889. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17890. * @param mesh Mesh to add
  17891. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17892. * @returns the Shadow Generator itself
  17893. */
  17894. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17895. /**
  17896. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17897. * @param mesh Mesh to remove
  17898. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17899. * @returns the Shadow Generator itself
  17900. */
  17901. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17902. /**
  17903. * Controls the extent to which the shadows fade out at the edge of the frustum
  17904. */
  17905. frustumEdgeFalloff: number;
  17906. protected _light: IShadowLight;
  17907. /**
  17908. * Returns the associated light object.
  17909. * @returns the light generating the shadow
  17910. */
  17911. getLight(): IShadowLight;
  17912. /**
  17913. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17914. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17915. * It might on the other hand introduce peter panning.
  17916. */
  17917. forceBackFacesOnly: boolean;
  17918. protected _scene: Scene;
  17919. protected _lightDirection: Vector3;
  17920. protected _effect: Effect;
  17921. protected _viewMatrix: Matrix;
  17922. protected _projectionMatrix: Matrix;
  17923. protected _transformMatrix: Matrix;
  17924. protected _cachedPosition: Vector3;
  17925. protected _cachedDirection: Vector3;
  17926. protected _cachedDefines: string;
  17927. protected _currentRenderID: number;
  17928. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17929. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17930. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17931. protected _blurPostProcesses: PostProcess[];
  17932. protected _mapSize: number;
  17933. protected _currentFaceIndex: number;
  17934. protected _currentFaceIndexCache: number;
  17935. protected _textureType: number;
  17936. protected _defaultTextureMatrix: Matrix;
  17937. protected _storedUniqueId: Nullable<number>;
  17938. /** @hidden */
  17939. static _SceneComponentInitialization: (scene: Scene) => void;
  17940. /**
  17941. * Creates a ShadowGenerator object.
  17942. * A ShadowGenerator is the required tool to use the shadows.
  17943. * Each light casting shadows needs to use its own ShadowGenerator.
  17944. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17945. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17946. * @param light The light object generating the shadows.
  17947. * @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.
  17948. */
  17949. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17950. protected _initializeGenerator(): void;
  17951. protected _createTargetRenderTexture(): void;
  17952. protected _initializeShadowMap(): void;
  17953. protected _initializeBlurRTTAndPostProcesses(): void;
  17954. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17955. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17956. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17957. protected _applyFilterValues(): void;
  17958. /**
  17959. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17960. * @param onCompiled Callback triggered at the and of the effects compilation
  17961. * @param options Sets of optional options forcing the compilation with different modes
  17962. */
  17963. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17964. useInstances: boolean;
  17965. }>): void;
  17966. /**
  17967. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17968. * @param options Sets of optional options forcing the compilation with different modes
  17969. * @returns A promise that resolves when the compilation completes
  17970. */
  17971. forceCompilationAsync(options?: Partial<{
  17972. useInstances: boolean;
  17973. }>): Promise<void>;
  17974. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17975. private _prepareShadowDefines;
  17976. /**
  17977. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17978. * @param subMesh The submesh we want to render in the shadow map
  17979. * @param useInstances Defines wether will draw in the map using instances
  17980. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17981. * @returns true if ready otherwise, false
  17982. */
  17983. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17984. /**
  17985. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17986. * @param defines Defines of the material we want to update
  17987. * @param lightIndex Index of the light in the enabled light list of the material
  17988. */
  17989. prepareDefines(defines: any, lightIndex: number): void;
  17990. /**
  17991. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17992. * defined in the generator but impacting the effect).
  17993. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17994. * @param effect The effect we are binfing the information for
  17995. */
  17996. bindShadowLight(lightIndex: string, effect: Effect): void;
  17997. /**
  17998. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17999. * (eq to shadow prjection matrix * light transform matrix)
  18000. * @returns The transform matrix used to create the shadow map
  18001. */
  18002. getTransformMatrix(): Matrix;
  18003. /**
  18004. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18005. * Cube and 2D textures for instance.
  18006. */
  18007. recreateShadowMap(): void;
  18008. protected _disposeBlurPostProcesses(): void;
  18009. protected _disposeRTTandPostProcesses(): void;
  18010. /**
  18011. * Disposes the ShadowGenerator.
  18012. * Returns nothing.
  18013. */
  18014. dispose(): void;
  18015. /**
  18016. * Serializes the shadow generator setup to a json object.
  18017. * @returns The serialized JSON object
  18018. */
  18019. serialize(): any;
  18020. /**
  18021. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18022. * @param parsedShadowGenerator The JSON object to parse
  18023. * @param scene The scene to create the shadow map for
  18024. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18025. * @returns The parsed shadow generator
  18026. */
  18027. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18028. }
  18029. }
  18030. declare module BABYLON {
  18031. /**
  18032. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18033. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18034. * 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.
  18035. */
  18036. export abstract class Light extends Node {
  18037. /**
  18038. * Falloff Default: light is falling off following the material specification:
  18039. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18040. */
  18041. static readonly FALLOFF_DEFAULT: number;
  18042. /**
  18043. * Falloff Physical: light is falling off following the inverse squared distance law.
  18044. */
  18045. static readonly FALLOFF_PHYSICAL: number;
  18046. /**
  18047. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18048. * to enhance interoperability with other engines.
  18049. */
  18050. static readonly FALLOFF_GLTF: number;
  18051. /**
  18052. * Falloff Standard: light is falling off like in the standard material
  18053. * to enhance interoperability with other materials.
  18054. */
  18055. static readonly FALLOFF_STANDARD: number;
  18056. /**
  18057. * If every light affecting the material is in this lightmapMode,
  18058. * material.lightmapTexture adds or multiplies
  18059. * (depends on material.useLightmapAsShadowmap)
  18060. * after every other light calculations.
  18061. */
  18062. static readonly LIGHTMAP_DEFAULT: number;
  18063. /**
  18064. * material.lightmapTexture as only diffuse lighting from this light
  18065. * adds only specular lighting from this light
  18066. * adds dynamic shadows
  18067. */
  18068. static readonly LIGHTMAP_SPECULAR: number;
  18069. /**
  18070. * material.lightmapTexture as only lighting
  18071. * no light calculation from this light
  18072. * only adds dynamic shadows from this light
  18073. */
  18074. static readonly LIGHTMAP_SHADOWSONLY: number;
  18075. /**
  18076. * Each light type uses the default quantity according to its type:
  18077. * point/spot lights use luminous intensity
  18078. * directional lights use illuminance
  18079. */
  18080. static readonly INTENSITYMODE_AUTOMATIC: number;
  18081. /**
  18082. * lumen (lm)
  18083. */
  18084. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18085. /**
  18086. * candela (lm/sr)
  18087. */
  18088. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18089. /**
  18090. * lux (lm/m^2)
  18091. */
  18092. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18093. /**
  18094. * nit (cd/m^2)
  18095. */
  18096. static readonly INTENSITYMODE_LUMINANCE: number;
  18097. /**
  18098. * Light type const id of the point light.
  18099. */
  18100. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18101. /**
  18102. * Light type const id of the directional light.
  18103. */
  18104. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18105. /**
  18106. * Light type const id of the spot light.
  18107. */
  18108. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18109. /**
  18110. * Light type const id of the hemispheric light.
  18111. */
  18112. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18113. /**
  18114. * Diffuse gives the basic color to an object.
  18115. */
  18116. diffuse: Color3;
  18117. /**
  18118. * Specular produces a highlight color on an object.
  18119. * Note: This is note affecting PBR materials.
  18120. */
  18121. specular: Color3;
  18122. /**
  18123. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18124. * falling off base on range or angle.
  18125. * This can be set to any values in Light.FALLOFF_x.
  18126. *
  18127. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18128. * other types of materials.
  18129. */
  18130. falloffType: number;
  18131. /**
  18132. * Strength of the light.
  18133. * Note: By default it is define in the framework own unit.
  18134. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18135. */
  18136. intensity: number;
  18137. private _range;
  18138. protected _inverseSquaredRange: number;
  18139. /**
  18140. * Defines how far from the source the light is impacting in scene units.
  18141. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18142. */
  18143. get range(): number;
  18144. /**
  18145. * Defines how far from the source the light is impacting in scene units.
  18146. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18147. */
  18148. set range(value: number);
  18149. /**
  18150. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18151. * of light.
  18152. */
  18153. private _photometricScale;
  18154. private _intensityMode;
  18155. /**
  18156. * Gets the photometric scale used to interpret the intensity.
  18157. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18158. */
  18159. get intensityMode(): number;
  18160. /**
  18161. * Sets the photometric scale used to interpret the intensity.
  18162. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18163. */
  18164. set intensityMode(value: number);
  18165. private _radius;
  18166. /**
  18167. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18168. */
  18169. get radius(): number;
  18170. /**
  18171. * sets the light radius used by PBR Materials to simulate soft area lights.
  18172. */
  18173. set radius(value: number);
  18174. private _renderPriority;
  18175. /**
  18176. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18177. * exceeding the number allowed of the materials.
  18178. */
  18179. renderPriority: number;
  18180. private _shadowEnabled;
  18181. /**
  18182. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18183. * the current shadow generator.
  18184. */
  18185. get shadowEnabled(): boolean;
  18186. /**
  18187. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18188. * the current shadow generator.
  18189. */
  18190. set shadowEnabled(value: boolean);
  18191. private _includedOnlyMeshes;
  18192. /**
  18193. * Gets the only meshes impacted by this light.
  18194. */
  18195. get includedOnlyMeshes(): AbstractMesh[];
  18196. /**
  18197. * Sets the only meshes impacted by this light.
  18198. */
  18199. set includedOnlyMeshes(value: AbstractMesh[]);
  18200. private _excludedMeshes;
  18201. /**
  18202. * Gets the meshes not impacted by this light.
  18203. */
  18204. get excludedMeshes(): AbstractMesh[];
  18205. /**
  18206. * Sets the meshes not impacted by this light.
  18207. */
  18208. set excludedMeshes(value: AbstractMesh[]);
  18209. private _excludeWithLayerMask;
  18210. /**
  18211. * Gets the layer id use to find what meshes are not impacted by the light.
  18212. * Inactive if 0
  18213. */
  18214. get excludeWithLayerMask(): number;
  18215. /**
  18216. * Sets the layer id use to find what meshes are not impacted by the light.
  18217. * Inactive if 0
  18218. */
  18219. set excludeWithLayerMask(value: number);
  18220. private _includeOnlyWithLayerMask;
  18221. /**
  18222. * Gets the layer id use to find what meshes are impacted by the light.
  18223. * Inactive if 0
  18224. */
  18225. get includeOnlyWithLayerMask(): number;
  18226. /**
  18227. * Sets the layer id use to find what meshes are impacted by the light.
  18228. * Inactive if 0
  18229. */
  18230. set includeOnlyWithLayerMask(value: number);
  18231. private _lightmapMode;
  18232. /**
  18233. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18234. */
  18235. get lightmapMode(): number;
  18236. /**
  18237. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18238. */
  18239. set lightmapMode(value: number);
  18240. /**
  18241. * Shadow generator associted to the light.
  18242. * @hidden Internal use only.
  18243. */
  18244. _shadowGenerator: Nullable<IShadowGenerator>;
  18245. /**
  18246. * @hidden Internal use only.
  18247. */
  18248. _excludedMeshesIds: string[];
  18249. /**
  18250. * @hidden Internal use only.
  18251. */
  18252. _includedOnlyMeshesIds: string[];
  18253. /**
  18254. * The current light unifom buffer.
  18255. * @hidden Internal use only.
  18256. */
  18257. _uniformBuffer: UniformBuffer;
  18258. /** @hidden */
  18259. _renderId: number;
  18260. /**
  18261. * Creates a Light object in the scene.
  18262. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18263. * @param name The firendly name of the light
  18264. * @param scene The scene the light belongs too
  18265. */
  18266. constructor(name: string, scene: Scene);
  18267. protected abstract _buildUniformLayout(): void;
  18268. /**
  18269. * Sets the passed Effect "effect" with the Light information.
  18270. * @param effect The effect to update
  18271. * @param lightIndex The index of the light in the effect to update
  18272. * @returns The light
  18273. */
  18274. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18275. /**
  18276. * Sets the passed Effect "effect" with the Light textures.
  18277. * @param effect The effect to update
  18278. * @param lightIndex The index of the light in the effect to update
  18279. * @returns The light
  18280. */
  18281. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18282. /**
  18283. * Binds the lights information from the scene to the effect for the given mesh.
  18284. * @param lightIndex Light index
  18285. * @param scene The scene where the light belongs to
  18286. * @param effect The effect we are binding the data to
  18287. * @param useSpecular Defines if specular is supported
  18288. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18289. */
  18290. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18291. /**
  18292. * Sets the passed Effect "effect" with the Light information.
  18293. * @param effect The effect to update
  18294. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18295. * @returns The light
  18296. */
  18297. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18298. /**
  18299. * Returns the string "Light".
  18300. * @returns the class name
  18301. */
  18302. getClassName(): string;
  18303. /** @hidden */
  18304. readonly _isLight: boolean;
  18305. /**
  18306. * Converts the light information to a readable string for debug purpose.
  18307. * @param fullDetails Supports for multiple levels of logging within scene loading
  18308. * @returns the human readable light info
  18309. */
  18310. toString(fullDetails?: boolean): string;
  18311. /** @hidden */
  18312. protected _syncParentEnabledState(): void;
  18313. /**
  18314. * Set the enabled state of this node.
  18315. * @param value - the new enabled state
  18316. */
  18317. setEnabled(value: boolean): void;
  18318. /**
  18319. * Returns the Light associated shadow generator if any.
  18320. * @return the associated shadow generator.
  18321. */
  18322. getShadowGenerator(): Nullable<IShadowGenerator>;
  18323. /**
  18324. * Returns a Vector3, the absolute light position in the World.
  18325. * @returns the world space position of the light
  18326. */
  18327. getAbsolutePosition(): Vector3;
  18328. /**
  18329. * Specifies if the light will affect the passed mesh.
  18330. * @param mesh The mesh to test against the light
  18331. * @return true the mesh is affected otherwise, false.
  18332. */
  18333. canAffectMesh(mesh: AbstractMesh): boolean;
  18334. /**
  18335. * Sort function to order lights for rendering.
  18336. * @param a First Light object to compare to second.
  18337. * @param b Second Light object to compare first.
  18338. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18339. */
  18340. static CompareLightsPriority(a: Light, b: Light): number;
  18341. /**
  18342. * Releases resources associated with this node.
  18343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18345. */
  18346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18347. /**
  18348. * Returns the light type ID (integer).
  18349. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18350. */
  18351. getTypeID(): number;
  18352. /**
  18353. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18354. * @returns the scaled intensity in intensity mode unit
  18355. */
  18356. getScaledIntensity(): number;
  18357. /**
  18358. * Returns a new Light object, named "name", from the current one.
  18359. * @param name The name of the cloned light
  18360. * @param newParent The parent of this light, if it has one
  18361. * @returns the new created light
  18362. */
  18363. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18364. /**
  18365. * Serializes the current light into a Serialization object.
  18366. * @returns the serialized object.
  18367. */
  18368. serialize(): any;
  18369. /**
  18370. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18371. * This new light is named "name" and added to the passed scene.
  18372. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18373. * @param name The friendly name of the light
  18374. * @param scene The scene the new light will belong to
  18375. * @returns the constructor function
  18376. */
  18377. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18378. /**
  18379. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18380. * @param parsedLight The JSON representation of the light
  18381. * @param scene The scene to create the parsed light in
  18382. * @returns the created light after parsing
  18383. */
  18384. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18385. private _hookArrayForExcluded;
  18386. private _hookArrayForIncludedOnly;
  18387. private _resyncMeshes;
  18388. /**
  18389. * Forces the meshes to update their light related information in their rendering used effects
  18390. * @hidden Internal Use Only
  18391. */
  18392. _markMeshesAsLightDirty(): void;
  18393. /**
  18394. * Recomputes the cached photometric scale if needed.
  18395. */
  18396. private _computePhotometricScale;
  18397. /**
  18398. * Returns the Photometric Scale according to the light type and intensity mode.
  18399. */
  18400. private _getPhotometricScale;
  18401. /**
  18402. * Reorder the light in the scene according to their defined priority.
  18403. * @hidden Internal Use Only
  18404. */
  18405. _reorderLightsInScene(): void;
  18406. /**
  18407. * Prepares the list of defines specific to the light type.
  18408. * @param defines the list of defines
  18409. * @param lightIndex defines the index of the light for the effect
  18410. */
  18411. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18412. }
  18413. }
  18414. declare module BABYLON {
  18415. /**
  18416. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18417. * This is the base of the follow, arc rotate cameras and Free camera
  18418. * @see https://doc.babylonjs.com/features/cameras
  18419. */
  18420. export class TargetCamera extends Camera {
  18421. private static _RigCamTransformMatrix;
  18422. private static _TargetTransformMatrix;
  18423. private static _TargetFocalPoint;
  18424. private _tmpUpVector;
  18425. private _tmpTargetVector;
  18426. /**
  18427. * Define the current direction the camera is moving to
  18428. */
  18429. cameraDirection: Vector3;
  18430. /**
  18431. * Define the current rotation the camera is rotating to
  18432. */
  18433. cameraRotation: Vector2;
  18434. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18435. ignoreParentScaling: boolean;
  18436. /**
  18437. * When set, the up vector of the camera will be updated by the rotation of the camera
  18438. */
  18439. updateUpVectorFromRotation: boolean;
  18440. private _tmpQuaternion;
  18441. /**
  18442. * Define the current rotation of the camera
  18443. */
  18444. rotation: Vector3;
  18445. /**
  18446. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18447. */
  18448. rotationQuaternion: Quaternion;
  18449. /**
  18450. * Define the current speed of the camera
  18451. */
  18452. speed: number;
  18453. /**
  18454. * Add constraint to the camera to prevent it to move freely in all directions and
  18455. * around all axis.
  18456. */
  18457. noRotationConstraint: boolean;
  18458. /**
  18459. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18460. * panning
  18461. */
  18462. invertRotation: boolean;
  18463. /**
  18464. * Speed multiplier for inverse camera panning
  18465. */
  18466. inverseRotationSpeed: number;
  18467. /**
  18468. * Define the current target of the camera as an object or a position.
  18469. */
  18470. lockedTarget: any;
  18471. /** @hidden */
  18472. _currentTarget: Vector3;
  18473. /** @hidden */
  18474. _initialFocalDistance: number;
  18475. /** @hidden */
  18476. _viewMatrix: Matrix;
  18477. /** @hidden */
  18478. _camMatrix: Matrix;
  18479. /** @hidden */
  18480. _cameraTransformMatrix: Matrix;
  18481. /** @hidden */
  18482. _cameraRotationMatrix: Matrix;
  18483. /** @hidden */
  18484. _referencePoint: Vector3;
  18485. /** @hidden */
  18486. _transformedReferencePoint: Vector3;
  18487. /** @hidden */
  18488. _reset: () => void;
  18489. private _defaultUp;
  18490. /**
  18491. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18492. * This is the base of the follow, arc rotate cameras and Free camera
  18493. * @see https://doc.babylonjs.com/features/cameras
  18494. * @param name Defines the name of the camera in the scene
  18495. * @param position Defines the start position of the camera in the scene
  18496. * @param scene Defines the scene the camera belongs to
  18497. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18498. */
  18499. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18500. /**
  18501. * Gets the position in front of the camera at a given distance.
  18502. * @param distance The distance from the camera we want the position to be
  18503. * @returns the position
  18504. */
  18505. getFrontPosition(distance: number): Vector3;
  18506. /** @hidden */
  18507. _getLockedTargetPosition(): Nullable<Vector3>;
  18508. private _storedPosition;
  18509. private _storedRotation;
  18510. private _storedRotationQuaternion;
  18511. /**
  18512. * Store current camera state of the camera (fov, position, rotation, etc..)
  18513. * @returns the camera
  18514. */
  18515. storeState(): Camera;
  18516. /**
  18517. * Restored camera state. You must call storeState() first
  18518. * @returns whether it was successful or not
  18519. * @hidden
  18520. */
  18521. _restoreStateValues(): boolean;
  18522. /** @hidden */
  18523. _initCache(): void;
  18524. /** @hidden */
  18525. _updateCache(ignoreParentClass?: boolean): void;
  18526. /** @hidden */
  18527. _isSynchronizedViewMatrix(): boolean;
  18528. /** @hidden */
  18529. _computeLocalCameraSpeed(): number;
  18530. /**
  18531. * Defines the target the camera should look at.
  18532. * @param target Defines the new target as a Vector or a mesh
  18533. */
  18534. setTarget(target: Vector3): void;
  18535. /**
  18536. * Defines the target point of the camera.
  18537. * The camera looks towards it form the radius distance.
  18538. */
  18539. get target(): Vector3;
  18540. set target(value: Vector3);
  18541. /**
  18542. * Return the current target position of the camera. This value is expressed in local space.
  18543. * @returns the target position
  18544. */
  18545. getTarget(): Vector3;
  18546. /** @hidden */
  18547. _decideIfNeedsToMove(): boolean;
  18548. /** @hidden */
  18549. _updatePosition(): void;
  18550. /** @hidden */
  18551. _checkInputs(): void;
  18552. protected _updateCameraRotationMatrix(): void;
  18553. /**
  18554. * 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)
  18555. * @returns the current camera
  18556. */
  18557. private _rotateUpVectorWithCameraRotationMatrix;
  18558. private _cachedRotationZ;
  18559. private _cachedQuaternionRotationZ;
  18560. /** @hidden */
  18561. _getViewMatrix(): Matrix;
  18562. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18563. /**
  18564. * @hidden
  18565. */
  18566. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18567. /**
  18568. * @hidden
  18569. */
  18570. _updateRigCameras(): void;
  18571. private _getRigCamPositionAndTarget;
  18572. /**
  18573. * Gets the current object class name.
  18574. * @return the class name
  18575. */
  18576. getClassName(): string;
  18577. }
  18578. }
  18579. declare module BABYLON {
  18580. /**
  18581. * Gather the list of keyboard event types as constants.
  18582. */
  18583. export class KeyboardEventTypes {
  18584. /**
  18585. * The keydown event is fired when a key becomes active (pressed).
  18586. */
  18587. static readonly KEYDOWN: number;
  18588. /**
  18589. * The keyup event is fired when a key has been released.
  18590. */
  18591. static readonly KEYUP: number;
  18592. }
  18593. /**
  18594. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18595. */
  18596. export class KeyboardInfo {
  18597. /**
  18598. * Defines the type of event (KeyboardEventTypes)
  18599. */
  18600. type: number;
  18601. /**
  18602. * Defines the related dom event
  18603. */
  18604. event: KeyboardEvent;
  18605. /**
  18606. * Instantiates a new keyboard info.
  18607. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18608. * @param type Defines the type of event (KeyboardEventTypes)
  18609. * @param event Defines the related dom event
  18610. */
  18611. constructor(
  18612. /**
  18613. * Defines the type of event (KeyboardEventTypes)
  18614. */
  18615. type: number,
  18616. /**
  18617. * Defines the related dom event
  18618. */
  18619. event: KeyboardEvent);
  18620. }
  18621. /**
  18622. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18623. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18624. */
  18625. export class KeyboardInfoPre extends KeyboardInfo {
  18626. /**
  18627. * Defines the type of event (KeyboardEventTypes)
  18628. */
  18629. type: number;
  18630. /**
  18631. * Defines the related dom event
  18632. */
  18633. event: KeyboardEvent;
  18634. /**
  18635. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18636. */
  18637. skipOnPointerObservable: boolean;
  18638. /**
  18639. * Instantiates a new keyboard pre info.
  18640. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18641. * @param type Defines the type of event (KeyboardEventTypes)
  18642. * @param event Defines the related dom event
  18643. */
  18644. constructor(
  18645. /**
  18646. * Defines the type of event (KeyboardEventTypes)
  18647. */
  18648. type: number,
  18649. /**
  18650. * Defines the related dom event
  18651. */
  18652. event: KeyboardEvent);
  18653. }
  18654. }
  18655. declare module BABYLON {
  18656. /**
  18657. * Manage the keyboard inputs to control the movement of a free camera.
  18658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18659. */
  18660. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18661. /**
  18662. * Defines the camera the input is attached to.
  18663. */
  18664. camera: FreeCamera;
  18665. /**
  18666. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18667. */
  18668. keysUp: number[];
  18669. /**
  18670. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18671. */
  18672. keysUpward: number[];
  18673. /**
  18674. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18675. */
  18676. keysDown: number[];
  18677. /**
  18678. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18679. */
  18680. keysDownward: number[];
  18681. /**
  18682. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18683. */
  18684. keysLeft: number[];
  18685. /**
  18686. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18687. */
  18688. keysRight: number[];
  18689. private _keys;
  18690. private _onCanvasBlurObserver;
  18691. private _onKeyboardObserver;
  18692. private _engine;
  18693. private _scene;
  18694. /**
  18695. * Attach the input controls to a specific dom element to get the input from.
  18696. * @param element Defines the element the controls should be listened from
  18697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18698. */
  18699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18700. /**
  18701. * Detach the current controls from the specified dom element.
  18702. * @param element Defines the element to stop listening the inputs from
  18703. */
  18704. detachControl(element: Nullable<HTMLElement>): void;
  18705. /**
  18706. * Update the current camera state depending on the inputs that have been used this frame.
  18707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18708. */
  18709. checkInputs(): void;
  18710. /**
  18711. * Gets the class name of the current intput.
  18712. * @returns the class name
  18713. */
  18714. getClassName(): string;
  18715. /** @hidden */
  18716. _onLostFocus(): void;
  18717. /**
  18718. * Get the friendly name associated with the input class.
  18719. * @returns the input friendly name
  18720. */
  18721. getSimpleName(): string;
  18722. }
  18723. }
  18724. declare module BABYLON {
  18725. /**
  18726. * Gather the list of pointer event types as constants.
  18727. */
  18728. export class PointerEventTypes {
  18729. /**
  18730. * 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.
  18731. */
  18732. static readonly POINTERDOWN: number;
  18733. /**
  18734. * The pointerup event is fired when a pointer is no longer active.
  18735. */
  18736. static readonly POINTERUP: number;
  18737. /**
  18738. * The pointermove event is fired when a pointer changes coordinates.
  18739. */
  18740. static readonly POINTERMOVE: number;
  18741. /**
  18742. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18743. */
  18744. static readonly POINTERWHEEL: number;
  18745. /**
  18746. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18747. */
  18748. static readonly POINTERPICK: number;
  18749. /**
  18750. * The pointertap event is fired when a the object has been touched and released without drag.
  18751. */
  18752. static readonly POINTERTAP: number;
  18753. /**
  18754. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18755. */
  18756. static readonly POINTERDOUBLETAP: number;
  18757. }
  18758. /**
  18759. * Base class of pointer info types.
  18760. */
  18761. export class PointerInfoBase {
  18762. /**
  18763. * Defines the type of event (PointerEventTypes)
  18764. */
  18765. type: number;
  18766. /**
  18767. * Defines the related dom event
  18768. */
  18769. event: PointerEvent | MouseWheelEvent;
  18770. /**
  18771. * Instantiates the base class of pointers info.
  18772. * @param type Defines the type of event (PointerEventTypes)
  18773. * @param event Defines the related dom event
  18774. */
  18775. constructor(
  18776. /**
  18777. * Defines the type of event (PointerEventTypes)
  18778. */
  18779. type: number,
  18780. /**
  18781. * Defines the related dom event
  18782. */
  18783. event: PointerEvent | MouseWheelEvent);
  18784. }
  18785. /**
  18786. * This class is used to store pointer related info for the onPrePointerObservable event.
  18787. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18788. */
  18789. export class PointerInfoPre extends PointerInfoBase {
  18790. /**
  18791. * Ray from a pointer if availible (eg. 6dof controller)
  18792. */
  18793. ray: Nullable<Ray>;
  18794. /**
  18795. * Defines the local position of the pointer on the canvas.
  18796. */
  18797. localPosition: Vector2;
  18798. /**
  18799. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18800. */
  18801. skipOnPointerObservable: boolean;
  18802. /**
  18803. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18804. * @param type Defines the type of event (PointerEventTypes)
  18805. * @param event Defines the related dom event
  18806. * @param localX Defines the local x coordinates of the pointer when the event occured
  18807. * @param localY Defines the local y coordinates of the pointer when the event occured
  18808. */
  18809. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18810. }
  18811. /**
  18812. * This type contains all the data related to a pointer event in Babylon.js.
  18813. * 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.
  18814. */
  18815. export class PointerInfo extends PointerInfoBase {
  18816. /**
  18817. * Defines the picking info associated to the info (if any)\
  18818. */
  18819. pickInfo: Nullable<PickingInfo>;
  18820. /**
  18821. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18822. * @param type Defines the type of event (PointerEventTypes)
  18823. * @param event Defines the related dom event
  18824. * @param pickInfo Defines the picking info associated to the info (if any)\
  18825. */
  18826. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18827. /**
  18828. * Defines the picking info associated to the info (if any)\
  18829. */
  18830. pickInfo: Nullable<PickingInfo>);
  18831. }
  18832. /**
  18833. * Data relating to a touch event on the screen.
  18834. */
  18835. export interface PointerTouch {
  18836. /**
  18837. * X coordinate of touch.
  18838. */
  18839. x: number;
  18840. /**
  18841. * Y coordinate of touch.
  18842. */
  18843. y: number;
  18844. /**
  18845. * Id of touch. Unique for each finger.
  18846. */
  18847. pointerId: number;
  18848. /**
  18849. * Event type passed from DOM.
  18850. */
  18851. type: any;
  18852. }
  18853. }
  18854. declare module BABYLON {
  18855. /**
  18856. * Manage the mouse inputs to control the movement of a free camera.
  18857. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18858. */
  18859. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18860. /**
  18861. * Define if touch is enabled in the mouse input
  18862. */
  18863. touchEnabled: boolean;
  18864. /**
  18865. * Defines the camera the input is attached to.
  18866. */
  18867. camera: FreeCamera;
  18868. /**
  18869. * Defines the buttons associated with the input to handle camera move.
  18870. */
  18871. buttons: number[];
  18872. /**
  18873. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18874. */
  18875. angularSensibility: number;
  18876. private _pointerInput;
  18877. private _onMouseMove;
  18878. private _observer;
  18879. private previousPosition;
  18880. /**
  18881. * Observable for when a pointer move event occurs containing the move offset
  18882. */
  18883. onPointerMovedObservable: Observable<{
  18884. offsetX: number;
  18885. offsetY: number;
  18886. }>;
  18887. /**
  18888. * @hidden
  18889. * If the camera should be rotated automatically based on pointer movement
  18890. */
  18891. _allowCameraRotation: boolean;
  18892. /**
  18893. * Manage the mouse inputs to control the movement of a free camera.
  18894. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18895. * @param touchEnabled Defines if touch is enabled or not
  18896. */
  18897. constructor(
  18898. /**
  18899. * Define if touch is enabled in the mouse input
  18900. */
  18901. touchEnabled?: boolean);
  18902. /**
  18903. * Attach the input controls to a specific dom element to get the input from.
  18904. * @param element Defines the element the controls should be listened from
  18905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18906. */
  18907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18908. /**
  18909. * Called on JS contextmenu event.
  18910. * Override this method to provide functionality.
  18911. */
  18912. protected onContextMenu(evt: PointerEvent): void;
  18913. /**
  18914. * Detach the current controls from the specified dom element.
  18915. * @param element Defines the element to stop listening the inputs from
  18916. */
  18917. detachControl(element: Nullable<HTMLElement>): void;
  18918. /**
  18919. * Gets the class name of the current intput.
  18920. * @returns the class name
  18921. */
  18922. getClassName(): string;
  18923. /**
  18924. * Get the friendly name associated with the input class.
  18925. * @returns the input friendly name
  18926. */
  18927. getSimpleName(): string;
  18928. }
  18929. }
  18930. declare module BABYLON {
  18931. /**
  18932. * Manage the touch inputs to control the movement of a free camera.
  18933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18934. */
  18935. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18936. /**
  18937. * Define if mouse events can be treated as touch events
  18938. */
  18939. allowMouse: boolean;
  18940. /**
  18941. * Defines the camera the input is attached to.
  18942. */
  18943. camera: FreeCamera;
  18944. /**
  18945. * Defines the touch sensibility for rotation.
  18946. * The higher the faster.
  18947. */
  18948. touchAngularSensibility: number;
  18949. /**
  18950. * Defines the touch sensibility for move.
  18951. * The higher the faster.
  18952. */
  18953. touchMoveSensibility: number;
  18954. private _offsetX;
  18955. private _offsetY;
  18956. private _pointerPressed;
  18957. private _pointerInput;
  18958. private _observer;
  18959. private _onLostFocus;
  18960. /**
  18961. * Manage the touch inputs to control the movement of a free camera.
  18962. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18963. * @param allowMouse Defines if mouse events can be treated as touch events
  18964. */
  18965. constructor(
  18966. /**
  18967. * Define if mouse events can be treated as touch events
  18968. */
  18969. allowMouse?: boolean);
  18970. /**
  18971. * Attach the input controls to a specific dom element to get the input from.
  18972. * @param element Defines the element the controls should be listened from
  18973. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18974. */
  18975. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18976. /**
  18977. * Detach the current controls from the specified dom element.
  18978. * @param element Defines the element to stop listening the inputs from
  18979. */
  18980. detachControl(element: Nullable<HTMLElement>): void;
  18981. /**
  18982. * Update the current camera state depending on the inputs that have been used this frame.
  18983. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18984. */
  18985. checkInputs(): void;
  18986. /**
  18987. * Gets the class name of the current intput.
  18988. * @returns the class name
  18989. */
  18990. getClassName(): string;
  18991. /**
  18992. * Get the friendly name associated with the input class.
  18993. * @returns the input friendly name
  18994. */
  18995. getSimpleName(): string;
  18996. }
  18997. }
  18998. declare module BABYLON {
  18999. /**
  19000. * Default Inputs manager for the FreeCamera.
  19001. * It groups all the default supported inputs for ease of use.
  19002. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19003. */
  19004. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19005. /**
  19006. * @hidden
  19007. */
  19008. _mouseInput: Nullable<FreeCameraMouseInput>;
  19009. /**
  19010. * Instantiates a new FreeCameraInputsManager.
  19011. * @param camera Defines the camera the inputs belong to
  19012. */
  19013. constructor(camera: FreeCamera);
  19014. /**
  19015. * Add keyboard input support to the input manager.
  19016. * @returns the current input manager
  19017. */
  19018. addKeyboard(): FreeCameraInputsManager;
  19019. /**
  19020. * Add mouse input support to the input manager.
  19021. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19022. * @returns the current input manager
  19023. */
  19024. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19025. /**
  19026. * Removes the mouse input support from the manager
  19027. * @returns the current input manager
  19028. */
  19029. removeMouse(): FreeCameraInputsManager;
  19030. /**
  19031. * Add touch input support to the input manager.
  19032. * @returns the current input manager
  19033. */
  19034. addTouch(): FreeCameraInputsManager;
  19035. /**
  19036. * Remove all attached input methods from a camera
  19037. */
  19038. clear(): void;
  19039. }
  19040. }
  19041. declare module BABYLON {
  19042. /**
  19043. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19044. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19045. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19046. */
  19047. export class FreeCamera extends TargetCamera {
  19048. /**
  19049. * Define the collision ellipsoid of the camera.
  19050. * This is helpful to simulate a camera body like the player body around the camera
  19051. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19052. */
  19053. ellipsoid: Vector3;
  19054. /**
  19055. * Define an offset for the position of the ellipsoid around the camera.
  19056. * This can be helpful to determine the center of the body near the gravity center of the body
  19057. * instead of its head.
  19058. */
  19059. ellipsoidOffset: Vector3;
  19060. /**
  19061. * Enable or disable collisions of the camera with the rest of the scene objects.
  19062. */
  19063. checkCollisions: boolean;
  19064. /**
  19065. * Enable or disable gravity on the camera.
  19066. */
  19067. applyGravity: boolean;
  19068. /**
  19069. * Define the input manager associated to the camera.
  19070. */
  19071. inputs: FreeCameraInputsManager;
  19072. /**
  19073. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19074. * Higher values reduce sensitivity.
  19075. */
  19076. get angularSensibility(): number;
  19077. /**
  19078. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19079. * Higher values reduce sensitivity.
  19080. */
  19081. set angularSensibility(value: number);
  19082. /**
  19083. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19084. */
  19085. get keysUp(): number[];
  19086. set keysUp(value: number[]);
  19087. /**
  19088. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19089. */
  19090. get keysUpward(): number[];
  19091. set keysUpward(value: number[]);
  19092. /**
  19093. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19094. */
  19095. get keysDown(): number[];
  19096. set keysDown(value: number[]);
  19097. /**
  19098. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19099. */
  19100. get keysDownward(): number[];
  19101. set keysDownward(value: number[]);
  19102. /**
  19103. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19104. */
  19105. get keysLeft(): number[];
  19106. set keysLeft(value: number[]);
  19107. /**
  19108. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19109. */
  19110. get keysRight(): number[];
  19111. set keysRight(value: number[]);
  19112. /**
  19113. * Event raised when the camera collide with a mesh in the scene.
  19114. */
  19115. onCollide: (collidedMesh: AbstractMesh) => void;
  19116. private _collider;
  19117. private _needMoveForGravity;
  19118. private _oldPosition;
  19119. private _diffPosition;
  19120. private _newPosition;
  19121. /** @hidden */
  19122. _localDirection: Vector3;
  19123. /** @hidden */
  19124. _transformedDirection: Vector3;
  19125. /**
  19126. * Instantiates a Free Camera.
  19127. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19128. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19129. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19130. * @param name Define the name of the camera in the scene
  19131. * @param position Define the start position of the camera in the scene
  19132. * @param scene Define the scene the camera belongs to
  19133. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19134. */
  19135. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19136. /**
  19137. * Attached controls to the current camera.
  19138. * @param element Defines the element the controls should be listened from
  19139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19140. */
  19141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19142. /**
  19143. * Detach the current controls from the camera.
  19144. * The camera will stop reacting to inputs.
  19145. * @param element Defines the element to stop listening the inputs from
  19146. */
  19147. detachControl(element: HTMLElement): void;
  19148. private _collisionMask;
  19149. /**
  19150. * Define a collision mask to limit the list of object the camera can collide with
  19151. */
  19152. get collisionMask(): number;
  19153. set collisionMask(mask: number);
  19154. /** @hidden */
  19155. _collideWithWorld(displacement: Vector3): void;
  19156. private _onCollisionPositionChange;
  19157. /** @hidden */
  19158. _checkInputs(): void;
  19159. /** @hidden */
  19160. _decideIfNeedsToMove(): boolean;
  19161. /** @hidden */
  19162. _updatePosition(): void;
  19163. /**
  19164. * Destroy the camera and release the current resources hold by it.
  19165. */
  19166. dispose(): void;
  19167. /**
  19168. * Gets the current object class name.
  19169. * @return the class name
  19170. */
  19171. getClassName(): string;
  19172. }
  19173. }
  19174. declare module BABYLON {
  19175. /**
  19176. * Represents a gamepad control stick position
  19177. */
  19178. export class StickValues {
  19179. /**
  19180. * The x component of the control stick
  19181. */
  19182. x: number;
  19183. /**
  19184. * The y component of the control stick
  19185. */
  19186. y: number;
  19187. /**
  19188. * Initializes the gamepad x and y control stick values
  19189. * @param x The x component of the gamepad control stick value
  19190. * @param y The y component of the gamepad control stick value
  19191. */
  19192. constructor(
  19193. /**
  19194. * The x component of the control stick
  19195. */
  19196. x: number,
  19197. /**
  19198. * The y component of the control stick
  19199. */
  19200. y: number);
  19201. }
  19202. /**
  19203. * An interface which manages callbacks for gamepad button changes
  19204. */
  19205. export interface GamepadButtonChanges {
  19206. /**
  19207. * Called when a gamepad has been changed
  19208. */
  19209. changed: boolean;
  19210. /**
  19211. * Called when a gamepad press event has been triggered
  19212. */
  19213. pressChanged: boolean;
  19214. /**
  19215. * Called when a touch event has been triggered
  19216. */
  19217. touchChanged: boolean;
  19218. /**
  19219. * Called when a value has changed
  19220. */
  19221. valueChanged: boolean;
  19222. }
  19223. /**
  19224. * Represents a gamepad
  19225. */
  19226. export class Gamepad {
  19227. /**
  19228. * The id of the gamepad
  19229. */
  19230. id: string;
  19231. /**
  19232. * The index of the gamepad
  19233. */
  19234. index: number;
  19235. /**
  19236. * The browser gamepad
  19237. */
  19238. browserGamepad: any;
  19239. /**
  19240. * Specifies what type of gamepad this represents
  19241. */
  19242. type: number;
  19243. private _leftStick;
  19244. private _rightStick;
  19245. /** @hidden */
  19246. _isConnected: boolean;
  19247. private _leftStickAxisX;
  19248. private _leftStickAxisY;
  19249. private _rightStickAxisX;
  19250. private _rightStickAxisY;
  19251. /**
  19252. * Triggered when the left control stick has been changed
  19253. */
  19254. private _onleftstickchanged;
  19255. /**
  19256. * Triggered when the right control stick has been changed
  19257. */
  19258. private _onrightstickchanged;
  19259. /**
  19260. * Represents a gamepad controller
  19261. */
  19262. static GAMEPAD: number;
  19263. /**
  19264. * Represents a generic controller
  19265. */
  19266. static GENERIC: number;
  19267. /**
  19268. * Represents an XBox controller
  19269. */
  19270. static XBOX: number;
  19271. /**
  19272. * Represents a pose-enabled controller
  19273. */
  19274. static POSE_ENABLED: number;
  19275. /**
  19276. * Represents an Dual Shock controller
  19277. */
  19278. static DUALSHOCK: number;
  19279. /**
  19280. * Specifies whether the left control stick should be Y-inverted
  19281. */
  19282. protected _invertLeftStickY: boolean;
  19283. /**
  19284. * Specifies if the gamepad has been connected
  19285. */
  19286. get isConnected(): boolean;
  19287. /**
  19288. * Initializes the gamepad
  19289. * @param id The id of the gamepad
  19290. * @param index The index of the gamepad
  19291. * @param browserGamepad The browser gamepad
  19292. * @param leftStickX The x component of the left joystick
  19293. * @param leftStickY The y component of the left joystick
  19294. * @param rightStickX The x component of the right joystick
  19295. * @param rightStickY The y component of the right joystick
  19296. */
  19297. constructor(
  19298. /**
  19299. * The id of the gamepad
  19300. */
  19301. id: string,
  19302. /**
  19303. * The index of the gamepad
  19304. */
  19305. index: number,
  19306. /**
  19307. * The browser gamepad
  19308. */
  19309. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19310. /**
  19311. * Callback triggered when the left joystick has changed
  19312. * @param callback
  19313. */
  19314. onleftstickchanged(callback: (values: StickValues) => void): void;
  19315. /**
  19316. * Callback triggered when the right joystick has changed
  19317. * @param callback
  19318. */
  19319. onrightstickchanged(callback: (values: StickValues) => void): void;
  19320. /**
  19321. * Gets the left joystick
  19322. */
  19323. get leftStick(): StickValues;
  19324. /**
  19325. * Sets the left joystick values
  19326. */
  19327. set leftStick(newValues: StickValues);
  19328. /**
  19329. * Gets the right joystick
  19330. */
  19331. get rightStick(): StickValues;
  19332. /**
  19333. * Sets the right joystick value
  19334. */
  19335. set rightStick(newValues: StickValues);
  19336. /**
  19337. * Updates the gamepad joystick positions
  19338. */
  19339. update(): void;
  19340. /**
  19341. * Disposes the gamepad
  19342. */
  19343. dispose(): void;
  19344. }
  19345. /**
  19346. * Represents a generic gamepad
  19347. */
  19348. export class GenericPad extends Gamepad {
  19349. private _buttons;
  19350. private _onbuttondown;
  19351. private _onbuttonup;
  19352. /**
  19353. * Observable triggered when a button has been pressed
  19354. */
  19355. onButtonDownObservable: Observable<number>;
  19356. /**
  19357. * Observable triggered when a button has been released
  19358. */
  19359. onButtonUpObservable: Observable<number>;
  19360. /**
  19361. * Callback triggered when a button has been pressed
  19362. * @param callback Called when a button has been pressed
  19363. */
  19364. onbuttondown(callback: (buttonPressed: number) => void): void;
  19365. /**
  19366. * Callback triggered when a button has been released
  19367. * @param callback Called when a button has been released
  19368. */
  19369. onbuttonup(callback: (buttonReleased: number) => void): void;
  19370. /**
  19371. * Initializes the generic gamepad
  19372. * @param id The id of the generic gamepad
  19373. * @param index The index of the generic gamepad
  19374. * @param browserGamepad The browser gamepad
  19375. */
  19376. constructor(id: string, index: number, browserGamepad: any);
  19377. private _setButtonValue;
  19378. /**
  19379. * Updates the generic gamepad
  19380. */
  19381. update(): void;
  19382. /**
  19383. * Disposes the generic gamepad
  19384. */
  19385. dispose(): void;
  19386. }
  19387. }
  19388. declare module BABYLON {
  19389. /**
  19390. * Defines the types of pose enabled controllers that are supported
  19391. */
  19392. export enum PoseEnabledControllerType {
  19393. /**
  19394. * HTC Vive
  19395. */
  19396. VIVE = 0,
  19397. /**
  19398. * Oculus Rift
  19399. */
  19400. OCULUS = 1,
  19401. /**
  19402. * Windows mixed reality
  19403. */
  19404. WINDOWS = 2,
  19405. /**
  19406. * Samsung gear VR
  19407. */
  19408. GEAR_VR = 3,
  19409. /**
  19410. * Google Daydream
  19411. */
  19412. DAYDREAM = 4,
  19413. /**
  19414. * Generic
  19415. */
  19416. GENERIC = 5
  19417. }
  19418. /**
  19419. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19420. */
  19421. export interface MutableGamepadButton {
  19422. /**
  19423. * Value of the button/trigger
  19424. */
  19425. value: number;
  19426. /**
  19427. * If the button/trigger is currently touched
  19428. */
  19429. touched: boolean;
  19430. /**
  19431. * If the button/trigger is currently pressed
  19432. */
  19433. pressed: boolean;
  19434. }
  19435. /**
  19436. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19437. * @hidden
  19438. */
  19439. export interface ExtendedGamepadButton extends GamepadButton {
  19440. /**
  19441. * If the button/trigger is currently pressed
  19442. */
  19443. readonly pressed: boolean;
  19444. /**
  19445. * If the button/trigger is currently touched
  19446. */
  19447. readonly touched: boolean;
  19448. /**
  19449. * Value of the button/trigger
  19450. */
  19451. readonly value: number;
  19452. }
  19453. /** @hidden */
  19454. export interface _GamePadFactory {
  19455. /**
  19456. * Returns whether or not the current gamepad can be created for this type of controller.
  19457. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19458. * @returns true if it can be created, otherwise false
  19459. */
  19460. canCreate(gamepadInfo: any): boolean;
  19461. /**
  19462. * Creates a new instance of the Gamepad.
  19463. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19464. * @returns the new gamepad instance
  19465. */
  19466. create(gamepadInfo: any): Gamepad;
  19467. }
  19468. /**
  19469. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19470. */
  19471. export class PoseEnabledControllerHelper {
  19472. /** @hidden */
  19473. static _ControllerFactories: _GamePadFactory[];
  19474. /** @hidden */
  19475. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19476. /**
  19477. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19478. * @param vrGamepad the gamepad to initialized
  19479. * @returns a vr controller of the type the gamepad identified as
  19480. */
  19481. static InitiateController(vrGamepad: any): Gamepad;
  19482. }
  19483. /**
  19484. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19485. */
  19486. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19487. /**
  19488. * If the controller is used in a webXR session
  19489. */
  19490. isXR: boolean;
  19491. private _deviceRoomPosition;
  19492. private _deviceRoomRotationQuaternion;
  19493. /**
  19494. * The device position in babylon space
  19495. */
  19496. devicePosition: Vector3;
  19497. /**
  19498. * The device rotation in babylon space
  19499. */
  19500. deviceRotationQuaternion: Quaternion;
  19501. /**
  19502. * The scale factor of the device in babylon space
  19503. */
  19504. deviceScaleFactor: number;
  19505. /**
  19506. * (Likely devicePosition should be used instead) The device position in its room space
  19507. */
  19508. position: Vector3;
  19509. /**
  19510. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19511. */
  19512. rotationQuaternion: Quaternion;
  19513. /**
  19514. * The type of controller (Eg. Windows mixed reality)
  19515. */
  19516. controllerType: PoseEnabledControllerType;
  19517. protected _calculatedPosition: Vector3;
  19518. private _calculatedRotation;
  19519. /**
  19520. * The raw pose from the device
  19521. */
  19522. rawPose: DevicePose;
  19523. private _trackPosition;
  19524. private _maxRotationDistFromHeadset;
  19525. private _draggedRoomRotation;
  19526. /**
  19527. * @hidden
  19528. */
  19529. _disableTrackPosition(fixedPosition: Vector3): void;
  19530. /**
  19531. * Internal, the mesh attached to the controller
  19532. * @hidden
  19533. */
  19534. _mesh: Nullable<AbstractMesh>;
  19535. private _poseControlledCamera;
  19536. private _leftHandSystemQuaternion;
  19537. /**
  19538. * Internal, matrix used to convert room space to babylon space
  19539. * @hidden
  19540. */
  19541. _deviceToWorld: Matrix;
  19542. /**
  19543. * Node to be used when casting a ray from the controller
  19544. * @hidden
  19545. */
  19546. _pointingPoseNode: Nullable<TransformNode>;
  19547. /**
  19548. * Name of the child mesh that can be used to cast a ray from the controller
  19549. */
  19550. static readonly POINTING_POSE: string;
  19551. /**
  19552. * Creates a new PoseEnabledController from a gamepad
  19553. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19554. */
  19555. constructor(browserGamepad: any);
  19556. private _workingMatrix;
  19557. /**
  19558. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19559. */
  19560. update(): void;
  19561. /**
  19562. * Updates only the pose device and mesh without doing any button event checking
  19563. */
  19564. protected _updatePoseAndMesh(): void;
  19565. /**
  19566. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19567. * @param poseData raw pose fromthe device
  19568. */
  19569. updateFromDevice(poseData: DevicePose): void;
  19570. /**
  19571. * @hidden
  19572. */
  19573. _meshAttachedObservable: Observable<AbstractMesh>;
  19574. /**
  19575. * Attaches a mesh to the controller
  19576. * @param mesh the mesh to be attached
  19577. */
  19578. attachToMesh(mesh: AbstractMesh): void;
  19579. /**
  19580. * Attaches the controllers mesh to a camera
  19581. * @param camera the camera the mesh should be attached to
  19582. */
  19583. attachToPoseControlledCamera(camera: TargetCamera): void;
  19584. /**
  19585. * Disposes of the controller
  19586. */
  19587. dispose(): void;
  19588. /**
  19589. * The mesh that is attached to the controller
  19590. */
  19591. get mesh(): Nullable<AbstractMesh>;
  19592. /**
  19593. * Gets the ray of the controller in the direction the controller is pointing
  19594. * @param length the length the resulting ray should be
  19595. * @returns a ray in the direction the controller is pointing
  19596. */
  19597. getForwardRay(length?: number): Ray;
  19598. }
  19599. }
  19600. declare module BABYLON {
  19601. /**
  19602. * Defines the WebVRController object that represents controllers tracked in 3D space
  19603. */
  19604. export abstract class WebVRController extends PoseEnabledController {
  19605. /**
  19606. * Internal, the default controller model for the controller
  19607. */
  19608. protected _defaultModel: Nullable<AbstractMesh>;
  19609. /**
  19610. * Fired when the trigger state has changed
  19611. */
  19612. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19613. /**
  19614. * Fired when the main button state has changed
  19615. */
  19616. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19617. /**
  19618. * Fired when the secondary button state has changed
  19619. */
  19620. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19621. /**
  19622. * Fired when the pad state has changed
  19623. */
  19624. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19625. /**
  19626. * Fired when controllers stick values have changed
  19627. */
  19628. onPadValuesChangedObservable: Observable<StickValues>;
  19629. /**
  19630. * Array of button availible on the controller
  19631. */
  19632. protected _buttons: Array<MutableGamepadButton>;
  19633. private _onButtonStateChange;
  19634. /**
  19635. * Fired when a controller button's state has changed
  19636. * @param callback the callback containing the button that was modified
  19637. */
  19638. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19639. /**
  19640. * X and Y axis corresponding to the controllers joystick
  19641. */
  19642. pad: StickValues;
  19643. /**
  19644. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19645. */
  19646. hand: string;
  19647. /**
  19648. * The default controller model for the controller
  19649. */
  19650. get defaultModel(): Nullable<AbstractMesh>;
  19651. /**
  19652. * Creates a new WebVRController from a gamepad
  19653. * @param vrGamepad the gamepad that the WebVRController should be created from
  19654. */
  19655. constructor(vrGamepad: any);
  19656. /**
  19657. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19658. */
  19659. update(): void;
  19660. /**
  19661. * Function to be called when a button is modified
  19662. */
  19663. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19664. /**
  19665. * Loads a mesh and attaches it to the controller
  19666. * @param scene the scene the mesh should be added to
  19667. * @param meshLoaded callback for when the mesh has been loaded
  19668. */
  19669. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19670. private _setButtonValue;
  19671. private _changes;
  19672. private _checkChanges;
  19673. /**
  19674. * Disposes of th webVRCOntroller
  19675. */
  19676. dispose(): void;
  19677. }
  19678. }
  19679. declare module BABYLON {
  19680. /**
  19681. * The HemisphericLight simulates the ambient environment light,
  19682. * so the passed direction is the light reflection direction, not the incoming direction.
  19683. */
  19684. export class HemisphericLight extends Light {
  19685. /**
  19686. * The groundColor is the light in the opposite direction to the one specified during creation.
  19687. * 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.
  19688. */
  19689. groundColor: Color3;
  19690. /**
  19691. * The light reflection direction, not the incoming direction.
  19692. */
  19693. direction: Vector3;
  19694. /**
  19695. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19696. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19697. * The HemisphericLight can't cast shadows.
  19698. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19699. * @param name The friendly name of the light
  19700. * @param direction The direction of the light reflection
  19701. * @param scene The scene the light belongs to
  19702. */
  19703. constructor(name: string, direction: Vector3, scene: Scene);
  19704. protected _buildUniformLayout(): void;
  19705. /**
  19706. * Returns the string "HemisphericLight".
  19707. * @return The class name
  19708. */
  19709. getClassName(): string;
  19710. /**
  19711. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19712. * Returns the updated direction.
  19713. * @param target The target the direction should point to
  19714. * @return The computed direction
  19715. */
  19716. setDirectionToTarget(target: Vector3): Vector3;
  19717. /**
  19718. * Returns the shadow generator associated to the light.
  19719. * @returns Always null for hemispheric lights because it does not support shadows.
  19720. */
  19721. getShadowGenerator(): Nullable<IShadowGenerator>;
  19722. /**
  19723. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19724. * @param effect The effect to update
  19725. * @param lightIndex The index of the light in the effect to update
  19726. * @returns The hemispheric light
  19727. */
  19728. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19729. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19730. /**
  19731. * Computes the world matrix of the node
  19732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19733. * @param useWasUpdatedFlag defines a reserved property
  19734. * @returns the world matrix
  19735. */
  19736. computeWorldMatrix(): Matrix;
  19737. /**
  19738. * Returns the integer 3.
  19739. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19740. */
  19741. getTypeID(): number;
  19742. /**
  19743. * Prepares the list of defines specific to the light type.
  19744. * @param defines the list of defines
  19745. * @param lightIndex defines the index of the light for the effect
  19746. */
  19747. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19748. }
  19749. }
  19750. declare module BABYLON {
  19751. /** @hidden */
  19752. export var vrMultiviewToSingleviewPixelShader: {
  19753. name: string;
  19754. shader: string;
  19755. };
  19756. }
  19757. declare module BABYLON {
  19758. /**
  19759. * Renders to multiple views with a single draw call
  19760. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19761. */
  19762. export class MultiviewRenderTarget extends RenderTargetTexture {
  19763. /**
  19764. * Creates a multiview render target
  19765. * @param scene scene used with the render target
  19766. * @param size the size of the render target (used for each view)
  19767. */
  19768. constructor(scene: Scene, size?: number | {
  19769. width: number;
  19770. height: number;
  19771. } | {
  19772. ratio: number;
  19773. });
  19774. /**
  19775. * @hidden
  19776. * @param faceIndex the face index, if its a cube texture
  19777. */
  19778. _bindFrameBuffer(faceIndex?: number): void;
  19779. /**
  19780. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19781. * @returns the view count
  19782. */
  19783. getViewCount(): number;
  19784. }
  19785. }
  19786. declare module BABYLON {
  19787. interface Engine {
  19788. /**
  19789. * Creates a new multiview render target
  19790. * @param width defines the width of the texture
  19791. * @param height defines the height of the texture
  19792. * @returns the created multiview texture
  19793. */
  19794. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19795. /**
  19796. * Binds a multiview framebuffer to be drawn to
  19797. * @param multiviewTexture texture to bind
  19798. */
  19799. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19800. }
  19801. interface Camera {
  19802. /**
  19803. * @hidden
  19804. * 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)
  19805. */
  19806. _useMultiviewToSingleView: boolean;
  19807. /**
  19808. * @hidden
  19809. * 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)
  19810. */
  19811. _multiviewTexture: Nullable<RenderTargetTexture>;
  19812. /**
  19813. * @hidden
  19814. * ensures the multiview texture of the camera exists and has the specified width/height
  19815. * @param width height to set on the multiview texture
  19816. * @param height width to set on the multiview texture
  19817. */
  19818. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19819. }
  19820. interface Scene {
  19821. /** @hidden */
  19822. _transformMatrixR: Matrix;
  19823. /** @hidden */
  19824. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19825. /** @hidden */
  19826. _createMultiviewUbo(): void;
  19827. /** @hidden */
  19828. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19829. /** @hidden */
  19830. _renderMultiviewToSingleView(camera: Camera): void;
  19831. }
  19832. }
  19833. declare module BABYLON {
  19834. /**
  19835. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19836. * This will not be used for webXR as it supports displaying texture arrays directly
  19837. */
  19838. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19839. /**
  19840. * Gets a string identifying the name of the class
  19841. * @returns "VRMultiviewToSingleviewPostProcess" string
  19842. */
  19843. getClassName(): string;
  19844. /**
  19845. * Initializes a VRMultiviewToSingleview
  19846. * @param name name of the post process
  19847. * @param camera camera to be applied to
  19848. * @param scaleFactor scaling factor to the size of the output texture
  19849. */
  19850. constructor(name: string, camera: Camera, scaleFactor: number);
  19851. }
  19852. }
  19853. declare module BABYLON {
  19854. /**
  19855. * Interface used to define additional presentation attributes
  19856. */
  19857. export interface IVRPresentationAttributes {
  19858. /**
  19859. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19860. */
  19861. highRefreshRate: boolean;
  19862. /**
  19863. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19864. */
  19865. foveationLevel: number;
  19866. }
  19867. interface Engine {
  19868. /** @hidden */
  19869. _vrDisplay: any;
  19870. /** @hidden */
  19871. _vrSupported: boolean;
  19872. /** @hidden */
  19873. _oldSize: Size;
  19874. /** @hidden */
  19875. _oldHardwareScaleFactor: number;
  19876. /** @hidden */
  19877. _vrExclusivePointerMode: boolean;
  19878. /** @hidden */
  19879. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19880. /** @hidden */
  19881. _onVRDisplayPointerRestricted: () => void;
  19882. /** @hidden */
  19883. _onVRDisplayPointerUnrestricted: () => void;
  19884. /** @hidden */
  19885. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19886. /** @hidden */
  19887. _onVrDisplayDisconnect: Nullable<() => void>;
  19888. /** @hidden */
  19889. _onVrDisplayPresentChange: Nullable<() => void>;
  19890. /**
  19891. * Observable signaled when VR display mode changes
  19892. */
  19893. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19894. /**
  19895. * Observable signaled when VR request present is complete
  19896. */
  19897. onVRRequestPresentComplete: Observable<boolean>;
  19898. /**
  19899. * Observable signaled when VR request present starts
  19900. */
  19901. onVRRequestPresentStart: Observable<Engine>;
  19902. /**
  19903. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19904. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19905. */
  19906. isInVRExclusivePointerMode: boolean;
  19907. /**
  19908. * Gets a boolean indicating if a webVR device was detected
  19909. * @returns true if a webVR device was detected
  19910. */
  19911. isVRDevicePresent(): boolean;
  19912. /**
  19913. * Gets the current webVR device
  19914. * @returns the current webVR device (or null)
  19915. */
  19916. getVRDevice(): any;
  19917. /**
  19918. * Initializes a webVR display and starts listening to display change events
  19919. * The onVRDisplayChangedObservable will be notified upon these changes
  19920. * @returns A promise containing a VRDisplay and if vr is supported
  19921. */
  19922. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19923. /** @hidden */
  19924. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19925. /**
  19926. * Gets or sets the presentation attributes used to configure VR rendering
  19927. */
  19928. vrPresentationAttributes?: IVRPresentationAttributes;
  19929. /**
  19930. * Call this function to switch to webVR mode
  19931. * Will do nothing if webVR is not supported or if there is no webVR device
  19932. * @param options the webvr options provided to the camera. mainly used for multiview
  19933. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19934. */
  19935. enableVR(options: WebVROptions): void;
  19936. /** @hidden */
  19937. _onVRFullScreenTriggered(): void;
  19938. }
  19939. }
  19940. declare module BABYLON {
  19941. /**
  19942. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19943. * IMPORTANT!! The data is right-hand data.
  19944. * @export
  19945. * @interface DevicePose
  19946. */
  19947. export interface DevicePose {
  19948. /**
  19949. * The position of the device, values in array are [x,y,z].
  19950. */
  19951. readonly position: Nullable<Float32Array>;
  19952. /**
  19953. * The linearVelocity of the device, values in array are [x,y,z].
  19954. */
  19955. readonly linearVelocity: Nullable<Float32Array>;
  19956. /**
  19957. * The linearAcceleration of the device, values in array are [x,y,z].
  19958. */
  19959. readonly linearAcceleration: Nullable<Float32Array>;
  19960. /**
  19961. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19962. */
  19963. readonly orientation: Nullable<Float32Array>;
  19964. /**
  19965. * The angularVelocity of the device, values in array are [x,y,z].
  19966. */
  19967. readonly angularVelocity: Nullable<Float32Array>;
  19968. /**
  19969. * The angularAcceleration of the device, values in array are [x,y,z].
  19970. */
  19971. readonly angularAcceleration: Nullable<Float32Array>;
  19972. }
  19973. /**
  19974. * Interface representing a pose controlled object in Babylon.
  19975. * A pose controlled object has both regular pose values as well as pose values
  19976. * from an external device such as a VR head mounted display
  19977. */
  19978. export interface PoseControlled {
  19979. /**
  19980. * The position of the object in babylon space.
  19981. */
  19982. position: Vector3;
  19983. /**
  19984. * The rotation quaternion of the object in babylon space.
  19985. */
  19986. rotationQuaternion: Quaternion;
  19987. /**
  19988. * The position of the device in babylon space.
  19989. */
  19990. devicePosition?: Vector3;
  19991. /**
  19992. * The rotation quaternion of the device in babylon space.
  19993. */
  19994. deviceRotationQuaternion: Quaternion;
  19995. /**
  19996. * The raw pose coming from the device.
  19997. */
  19998. rawPose: Nullable<DevicePose>;
  19999. /**
  20000. * The scale of the device to be used when translating from device space to babylon space.
  20001. */
  20002. deviceScaleFactor: number;
  20003. /**
  20004. * Updates the poseControlled values based on the input device pose.
  20005. * @param poseData the pose data to update the object with
  20006. */
  20007. updateFromDevice(poseData: DevicePose): void;
  20008. }
  20009. /**
  20010. * Set of options to customize the webVRCamera
  20011. */
  20012. export interface WebVROptions {
  20013. /**
  20014. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20015. */
  20016. trackPosition?: boolean;
  20017. /**
  20018. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20019. */
  20020. positionScale?: number;
  20021. /**
  20022. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20023. */
  20024. displayName?: string;
  20025. /**
  20026. * Should the native controller meshes be initialized. (default: true)
  20027. */
  20028. controllerMeshes?: boolean;
  20029. /**
  20030. * Creating a default HemiLight only on controllers. (default: true)
  20031. */
  20032. defaultLightingOnControllers?: boolean;
  20033. /**
  20034. * If you don't want to use the default VR button of the helper. (default: false)
  20035. */
  20036. useCustomVRButton?: boolean;
  20037. /**
  20038. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20039. */
  20040. customVRButton?: HTMLButtonElement;
  20041. /**
  20042. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20043. */
  20044. rayLength?: number;
  20045. /**
  20046. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20047. */
  20048. defaultHeight?: number;
  20049. /**
  20050. * If multiview should be used if availible (default: false)
  20051. */
  20052. useMultiview?: boolean;
  20053. }
  20054. /**
  20055. * This represents a WebVR camera.
  20056. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20057. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20058. */
  20059. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20060. private webVROptions;
  20061. /**
  20062. * @hidden
  20063. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20064. */
  20065. _vrDevice: any;
  20066. /**
  20067. * The rawPose of the vrDevice.
  20068. */
  20069. rawPose: Nullable<DevicePose>;
  20070. private _onVREnabled;
  20071. private _specsVersion;
  20072. private _attached;
  20073. private _frameData;
  20074. protected _descendants: Array<Node>;
  20075. private _deviceRoomPosition;
  20076. /** @hidden */
  20077. _deviceRoomRotationQuaternion: Quaternion;
  20078. private _standingMatrix;
  20079. /**
  20080. * Represents device position in babylon space.
  20081. */
  20082. devicePosition: Vector3;
  20083. /**
  20084. * Represents device rotation in babylon space.
  20085. */
  20086. deviceRotationQuaternion: Quaternion;
  20087. /**
  20088. * The scale of the device to be used when translating from device space to babylon space.
  20089. */
  20090. deviceScaleFactor: number;
  20091. private _deviceToWorld;
  20092. private _worldToDevice;
  20093. /**
  20094. * References to the webVR controllers for the vrDevice.
  20095. */
  20096. controllers: Array<WebVRController>;
  20097. /**
  20098. * Emits an event when a controller is attached.
  20099. */
  20100. onControllersAttachedObservable: Observable<WebVRController[]>;
  20101. /**
  20102. * Emits an event when a controller's mesh has been loaded;
  20103. */
  20104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20105. /**
  20106. * Emits an event when the HMD's pose has been updated.
  20107. */
  20108. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20109. private _poseSet;
  20110. /**
  20111. * If the rig cameras be used as parent instead of this camera.
  20112. */
  20113. rigParenting: boolean;
  20114. private _lightOnControllers;
  20115. private _defaultHeight?;
  20116. /**
  20117. * Instantiates a WebVRFreeCamera.
  20118. * @param name The name of the WebVRFreeCamera
  20119. * @param position The starting anchor position for the camera
  20120. * @param scene The scene the camera belongs to
  20121. * @param webVROptions a set of customizable options for the webVRCamera
  20122. */
  20123. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20124. /**
  20125. * Gets the device distance from the ground in meters.
  20126. * @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.
  20127. */
  20128. deviceDistanceToRoomGround(): number;
  20129. /**
  20130. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20131. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20132. */
  20133. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20134. /**
  20135. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20136. * @returns A promise with a boolean set to if the standing matrix is supported.
  20137. */
  20138. useStandingMatrixAsync(): Promise<boolean>;
  20139. /**
  20140. * Disposes the camera
  20141. */
  20142. dispose(): void;
  20143. /**
  20144. * Gets a vrController by name.
  20145. * @param name The name of the controller to retreive
  20146. * @returns the controller matching the name specified or null if not found
  20147. */
  20148. getControllerByName(name: string): Nullable<WebVRController>;
  20149. private _leftController;
  20150. /**
  20151. * The controller corresponding to the users left hand.
  20152. */
  20153. get leftController(): Nullable<WebVRController>;
  20154. private _rightController;
  20155. /**
  20156. * The controller corresponding to the users right hand.
  20157. */
  20158. get rightController(): Nullable<WebVRController>;
  20159. /**
  20160. * Casts a ray forward from the vrCamera's gaze.
  20161. * @param length Length of the ray (default: 100)
  20162. * @returns the ray corresponding to the gaze
  20163. */
  20164. getForwardRay(length?: number): Ray;
  20165. /**
  20166. * @hidden
  20167. * Updates the camera based on device's frame data
  20168. */
  20169. _checkInputs(): void;
  20170. /**
  20171. * Updates the poseControlled values based on the input device pose.
  20172. * @param poseData Pose coming from the device
  20173. */
  20174. updateFromDevice(poseData: DevicePose): void;
  20175. private _htmlElementAttached;
  20176. private _detachIfAttached;
  20177. /**
  20178. * WebVR's attach control will start broadcasting frames to the device.
  20179. * Note that in certain browsers (chrome for example) this function must be called
  20180. * within a user-interaction callback. Example:
  20181. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20182. *
  20183. * @param element html element to attach the vrDevice to
  20184. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20185. */
  20186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20187. /**
  20188. * Detaches the camera from the html element and disables VR
  20189. *
  20190. * @param element html element to detach from
  20191. */
  20192. detachControl(element: HTMLElement): void;
  20193. /**
  20194. * @returns the name of this class
  20195. */
  20196. getClassName(): string;
  20197. /**
  20198. * Calls resetPose on the vrDisplay
  20199. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20200. */
  20201. resetToCurrentRotation(): void;
  20202. /**
  20203. * @hidden
  20204. * Updates the rig cameras (left and right eye)
  20205. */
  20206. _updateRigCameras(): void;
  20207. private _workingVector;
  20208. private _oneVector;
  20209. private _workingMatrix;
  20210. private updateCacheCalled;
  20211. private _correctPositionIfNotTrackPosition;
  20212. /**
  20213. * @hidden
  20214. * Updates the cached values of the camera
  20215. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20216. */
  20217. _updateCache(ignoreParentClass?: boolean): void;
  20218. /**
  20219. * @hidden
  20220. * Get current device position in babylon world
  20221. */
  20222. _computeDevicePosition(): void;
  20223. /**
  20224. * Updates the current device position and rotation in the babylon world
  20225. */
  20226. update(): void;
  20227. /**
  20228. * @hidden
  20229. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20230. * @returns an identity matrix
  20231. */
  20232. _getViewMatrix(): Matrix;
  20233. private _tmpMatrix;
  20234. /**
  20235. * This function is called by the two RIG cameras.
  20236. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20237. * @hidden
  20238. */
  20239. _getWebVRViewMatrix(): Matrix;
  20240. /** @hidden */
  20241. _getWebVRProjectionMatrix(): Matrix;
  20242. private _onGamepadConnectedObserver;
  20243. private _onGamepadDisconnectedObserver;
  20244. private _updateCacheWhenTrackingDisabledObserver;
  20245. /**
  20246. * Initializes the controllers and their meshes
  20247. */
  20248. initControllers(): void;
  20249. }
  20250. }
  20251. declare module BABYLON {
  20252. /**
  20253. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20254. *
  20255. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20256. *
  20257. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20258. */
  20259. export class MaterialHelper {
  20260. /**
  20261. * Bind the current view position to an effect.
  20262. * @param effect The effect to be bound
  20263. * @param scene The scene the eyes position is used from
  20264. * @param variableName name of the shader variable that will hold the eye position
  20265. */
  20266. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20267. /**
  20268. * Helps preparing the defines values about the UVs in used in the effect.
  20269. * UVs are shared as much as we can accross channels in the shaders.
  20270. * @param texture The texture we are preparing the UVs for
  20271. * @param defines The defines to update
  20272. * @param key The channel key "diffuse", "specular"... used in the shader
  20273. */
  20274. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20275. /**
  20276. * Binds a texture matrix value to its corrsponding uniform
  20277. * @param texture The texture to bind the matrix for
  20278. * @param uniformBuffer The uniform buffer receivin the data
  20279. * @param key The channel key "diffuse", "specular"... used in the shader
  20280. */
  20281. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20282. /**
  20283. * Gets the current status of the fog (should it be enabled?)
  20284. * @param mesh defines the mesh to evaluate for fog support
  20285. * @param scene defines the hosting scene
  20286. * @returns true if fog must be enabled
  20287. */
  20288. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20289. /**
  20290. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20291. * @param mesh defines the current mesh
  20292. * @param scene defines the current scene
  20293. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20294. * @param pointsCloud defines if point cloud rendering has to be turned on
  20295. * @param fogEnabled defines if fog has to be turned on
  20296. * @param alphaTest defines if alpha testing has to be turned on
  20297. * @param defines defines the current list of defines
  20298. */
  20299. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20300. /**
  20301. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20302. * @param scene defines the current scene
  20303. * @param engine defines the current engine
  20304. * @param defines specifies the list of active defines
  20305. * @param useInstances defines if instances have to be turned on
  20306. * @param useClipPlane defines if clip plane have to be turned on
  20307. * @param useInstances defines if instances have to be turned on
  20308. * @param useThinInstances defines if thin instances have to be turned on
  20309. */
  20310. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20311. /**
  20312. * Prepares the defines for bones
  20313. * @param mesh The mesh containing the geometry data we will draw
  20314. * @param defines The defines to update
  20315. */
  20316. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20317. /**
  20318. * Prepares the defines for morph targets
  20319. * @param mesh The mesh containing the geometry data we will draw
  20320. * @param defines The defines to update
  20321. */
  20322. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20323. /**
  20324. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20325. * @param mesh The mesh containing the geometry data we will draw
  20326. * @param defines The defines to update
  20327. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20328. * @param useBones Precise whether bones should be used or not (override mesh info)
  20329. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20330. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20331. * @returns false if defines are considered not dirty and have not been checked
  20332. */
  20333. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20334. /**
  20335. * Prepares the defines related to multiview
  20336. * @param scene The scene we are intending to draw
  20337. * @param defines The defines to update
  20338. */
  20339. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20340. /**
  20341. * Prepares the defines related to the prepass
  20342. * @param scene The scene we are intending to draw
  20343. * @param defines The defines to update
  20344. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20345. */
  20346. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20347. /**
  20348. * Prepares the defines related to the light information passed in parameter
  20349. * @param scene The scene we are intending to draw
  20350. * @param mesh The mesh the effect is compiling for
  20351. * @param light The light the effect is compiling for
  20352. * @param lightIndex The index of the light
  20353. * @param defines The defines to update
  20354. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20355. * @param state Defines the current state regarding what is needed (normals, etc...)
  20356. */
  20357. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20358. needNormals: boolean;
  20359. needRebuild: boolean;
  20360. shadowEnabled: boolean;
  20361. specularEnabled: boolean;
  20362. lightmapMode: boolean;
  20363. }): void;
  20364. /**
  20365. * Prepares the defines related to the light information passed in parameter
  20366. * @param scene The scene we are intending to draw
  20367. * @param mesh The mesh the effect is compiling for
  20368. * @param defines The defines to update
  20369. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20370. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20371. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20372. * @returns true if normals will be required for the rest of the effect
  20373. */
  20374. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20375. /**
  20376. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20377. * @param lightIndex defines the light index
  20378. * @param uniformsList The uniform list
  20379. * @param samplersList The sampler list
  20380. * @param projectedLightTexture defines if projected texture must be used
  20381. * @param uniformBuffersList defines an optional list of uniform buffers
  20382. */
  20383. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20384. /**
  20385. * Prepares the uniforms and samplers list to be used in the effect
  20386. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20387. * @param samplersList The sampler list
  20388. * @param defines The defines helping in the list generation
  20389. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20390. */
  20391. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20392. /**
  20393. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20394. * @param defines The defines to update while falling back
  20395. * @param fallbacks The authorized effect fallbacks
  20396. * @param maxSimultaneousLights The maximum number of lights allowed
  20397. * @param rank the current rank of the Effect
  20398. * @returns The newly affected rank
  20399. */
  20400. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20401. private static _TmpMorphInfluencers;
  20402. /**
  20403. * Prepares the list of attributes required for morph targets according to the effect defines.
  20404. * @param attribs The current list of supported attribs
  20405. * @param mesh The mesh to prepare the morph targets attributes for
  20406. * @param influencers The number of influencers
  20407. */
  20408. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20409. /**
  20410. * Prepares the list of attributes required for morph targets according to the effect defines.
  20411. * @param attribs The current list of supported attribs
  20412. * @param mesh The mesh to prepare the morph targets attributes for
  20413. * @param defines The current Defines of the effect
  20414. */
  20415. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20416. /**
  20417. * Prepares the list of attributes required for bones according to the effect defines.
  20418. * @param attribs The current list of supported attribs
  20419. * @param mesh The mesh to prepare the bones attributes for
  20420. * @param defines The current Defines of the effect
  20421. * @param fallbacks The current efffect fallback strategy
  20422. */
  20423. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20424. /**
  20425. * Check and prepare the list of attributes required for instances according to the effect defines.
  20426. * @param attribs The current list of supported attribs
  20427. * @param defines The current MaterialDefines of the effect
  20428. */
  20429. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20430. /**
  20431. * Add the list of attributes required for instances to the attribs array.
  20432. * @param attribs The current list of supported attribs
  20433. */
  20434. static PushAttributesForInstances(attribs: string[]): void;
  20435. /**
  20436. * Binds the light information to the effect.
  20437. * @param light The light containing the generator
  20438. * @param effect The effect we are binding the data to
  20439. * @param lightIndex The light index in the effect used to render
  20440. */
  20441. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20442. /**
  20443. * Binds the lights information from the scene to the effect for the given mesh.
  20444. * @param light Light to bind
  20445. * @param lightIndex Light index
  20446. * @param scene The scene where the light belongs to
  20447. * @param effect The effect we are binding the data to
  20448. * @param useSpecular Defines if specular is supported
  20449. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20450. */
  20451. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20452. /**
  20453. * Binds the lights information from the scene to the effect for the given mesh.
  20454. * @param scene The scene the lights belongs to
  20455. * @param mesh The mesh we are binding the information to render
  20456. * @param effect The effect we are binding the data to
  20457. * @param defines The generated defines for the effect
  20458. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20459. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20460. */
  20461. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20462. private static _tempFogColor;
  20463. /**
  20464. * Binds the fog information from the scene to the effect for the given mesh.
  20465. * @param scene The scene the lights belongs to
  20466. * @param mesh The mesh we are binding the information to render
  20467. * @param effect The effect we are binding the data to
  20468. * @param linearSpace Defines if the fog effect is applied in linear space
  20469. */
  20470. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20471. /**
  20472. * Binds the bones information from the mesh to the effect.
  20473. * @param mesh The mesh we are binding the information to render
  20474. * @param effect The effect we are binding the data to
  20475. */
  20476. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20477. /**
  20478. * Binds the morph targets information from the mesh to the effect.
  20479. * @param abstractMesh The mesh we are binding the information to render
  20480. * @param effect The effect we are binding the data to
  20481. */
  20482. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20483. /**
  20484. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20485. * @param defines The generated defines used in the effect
  20486. * @param effect The effect we are binding the data to
  20487. * @param scene The scene we are willing to render with logarithmic scale for
  20488. */
  20489. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20490. /**
  20491. * Binds the clip plane information from the scene to the effect.
  20492. * @param scene The scene the clip plane information are extracted from
  20493. * @param effect The effect we are binding the data to
  20494. */
  20495. static BindClipPlane(effect: Effect, scene: Scene): void;
  20496. }
  20497. }
  20498. declare module BABYLON {
  20499. /**
  20500. * Block used to expose an input value
  20501. */
  20502. export class InputBlock extends NodeMaterialBlock {
  20503. private _mode;
  20504. private _associatedVariableName;
  20505. private _storedValue;
  20506. private _valueCallback;
  20507. private _type;
  20508. private _animationType;
  20509. /** Gets or set a value used to limit the range of float values */
  20510. min: number;
  20511. /** Gets or set a value used to limit the range of float values */
  20512. max: number;
  20513. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20514. isBoolean: boolean;
  20515. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20516. matrixMode: number;
  20517. /** @hidden */
  20518. _systemValue: Nullable<NodeMaterialSystemValues>;
  20519. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20520. isConstant: boolean;
  20521. /** Gets or sets the group to use to display this block in the Inspector */
  20522. groupInInspector: string;
  20523. /** Gets an observable raised when the value is changed */
  20524. onValueChangedObservable: Observable<InputBlock>;
  20525. /**
  20526. * Gets or sets the connection point type (default is float)
  20527. */
  20528. get type(): NodeMaterialBlockConnectionPointTypes;
  20529. /**
  20530. * Creates a new InputBlock
  20531. * @param name defines the block name
  20532. * @param target defines the target of that block (Vertex by default)
  20533. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20534. */
  20535. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20536. /**
  20537. * Validates if a name is a reserve word.
  20538. * @param newName the new name to be given to the node.
  20539. * @returns false if the name is a reserve word, else true.
  20540. */
  20541. validateBlockName(newName: string): boolean;
  20542. /**
  20543. * Gets the output component
  20544. */
  20545. get output(): NodeMaterialConnectionPoint;
  20546. /**
  20547. * Set the source of this connection point to a vertex attribute
  20548. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20549. * @returns the current connection point
  20550. */
  20551. setAsAttribute(attributeName?: string): InputBlock;
  20552. /**
  20553. * Set the source of this connection point to a system value
  20554. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20555. * @returns the current connection point
  20556. */
  20557. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20558. /**
  20559. * Gets or sets the value of that point.
  20560. * Please note that this value will be ignored if valueCallback is defined
  20561. */
  20562. get value(): any;
  20563. set value(value: any);
  20564. /**
  20565. * Gets or sets a callback used to get the value of that point.
  20566. * Please note that setting this value will force the connection point to ignore the value property
  20567. */
  20568. get valueCallback(): () => any;
  20569. set valueCallback(value: () => any);
  20570. /**
  20571. * Gets or sets the associated variable name in the shader
  20572. */
  20573. get associatedVariableName(): string;
  20574. set associatedVariableName(value: string);
  20575. /** Gets or sets the type of animation applied to the input */
  20576. get animationType(): AnimatedInputBlockTypes;
  20577. set animationType(value: AnimatedInputBlockTypes);
  20578. /**
  20579. * Gets a boolean indicating that this connection point not defined yet
  20580. */
  20581. get isUndefined(): boolean;
  20582. /**
  20583. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20584. * In this case the connection point name must be the name of the uniform to use.
  20585. * Can only be set on inputs
  20586. */
  20587. get isUniform(): boolean;
  20588. set isUniform(value: boolean);
  20589. /**
  20590. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20591. * In this case the connection point name must be the name of the attribute to use
  20592. * Can only be set on inputs
  20593. */
  20594. get isAttribute(): boolean;
  20595. set isAttribute(value: boolean);
  20596. /**
  20597. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20598. * Can only be set on exit points
  20599. */
  20600. get isVarying(): boolean;
  20601. set isVarying(value: boolean);
  20602. /**
  20603. * Gets a boolean indicating that the current connection point is a system value
  20604. */
  20605. get isSystemValue(): boolean;
  20606. /**
  20607. * Gets or sets the current well known value or null if not defined as a system value
  20608. */
  20609. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20610. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20611. /**
  20612. * Gets the current class name
  20613. * @returns the class name
  20614. */
  20615. getClassName(): string;
  20616. /**
  20617. * Animate the input if animationType !== None
  20618. * @param scene defines the rendering scene
  20619. */
  20620. animate(scene: Scene): void;
  20621. private _emitDefine;
  20622. initialize(state: NodeMaterialBuildState): void;
  20623. /**
  20624. * Set the input block to its default value (based on its type)
  20625. */
  20626. setDefaultValue(): void;
  20627. private _emitConstant;
  20628. /** @hidden */
  20629. get _noContextSwitch(): boolean;
  20630. private _emit;
  20631. /** @hidden */
  20632. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20633. /** @hidden */
  20634. _transmit(effect: Effect, scene: Scene): void;
  20635. protected _buildBlock(state: NodeMaterialBuildState): void;
  20636. protected _dumpPropertiesCode(): string;
  20637. dispose(): void;
  20638. serialize(): any;
  20639. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20640. }
  20641. }
  20642. declare module BABYLON {
  20643. /**
  20644. * Enum used to define the compatibility state between two connection points
  20645. */
  20646. export enum NodeMaterialConnectionPointCompatibilityStates {
  20647. /** Points are compatibles */
  20648. Compatible = 0,
  20649. /** Points are incompatible because of their types */
  20650. TypeIncompatible = 1,
  20651. /** Points are incompatible because of their targets (vertex vs fragment) */
  20652. TargetIncompatible = 2
  20653. }
  20654. /**
  20655. * Defines the direction of a connection point
  20656. */
  20657. export enum NodeMaterialConnectionPointDirection {
  20658. /** Input */
  20659. Input = 0,
  20660. /** Output */
  20661. Output = 1
  20662. }
  20663. /**
  20664. * Defines a connection point for a block
  20665. */
  20666. export class NodeMaterialConnectionPoint {
  20667. /** @hidden */
  20668. _ownerBlock: NodeMaterialBlock;
  20669. /** @hidden */
  20670. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20671. private _endpoints;
  20672. private _associatedVariableName;
  20673. private _direction;
  20674. /** @hidden */
  20675. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20676. /** @hidden */
  20677. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20678. private _type;
  20679. /** @hidden */
  20680. _enforceAssociatedVariableName: boolean;
  20681. /** Gets the direction of the point */
  20682. get direction(): NodeMaterialConnectionPointDirection;
  20683. /** Indicates that this connection point needs dual validation before being connected to another point */
  20684. needDualDirectionValidation: boolean;
  20685. /**
  20686. * Gets or sets the additional types supported by this connection point
  20687. */
  20688. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20689. /**
  20690. * Gets or sets the additional types excluded by this connection point
  20691. */
  20692. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20693. /**
  20694. * Observable triggered when this point is connected
  20695. */
  20696. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20697. /**
  20698. * Gets or sets the associated variable name in the shader
  20699. */
  20700. get associatedVariableName(): string;
  20701. set associatedVariableName(value: string);
  20702. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20703. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20704. /**
  20705. * Gets or sets the connection point type (default is float)
  20706. */
  20707. get type(): NodeMaterialBlockConnectionPointTypes;
  20708. set type(value: NodeMaterialBlockConnectionPointTypes);
  20709. /**
  20710. * Gets or sets the connection point name
  20711. */
  20712. name: string;
  20713. /**
  20714. * Gets or sets the connection point name
  20715. */
  20716. displayName: string;
  20717. /**
  20718. * Gets or sets a boolean indicating that this connection point can be omitted
  20719. */
  20720. isOptional: boolean;
  20721. /**
  20722. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20723. */
  20724. isExposedOnFrame: boolean;
  20725. /**
  20726. * Gets or sets number indicating the position that the port is exposed to on a frame
  20727. */
  20728. exposedPortPosition: number;
  20729. /**
  20730. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20731. */
  20732. define: string;
  20733. /** @hidden */
  20734. _prioritizeVertex: boolean;
  20735. private _target;
  20736. /** Gets or sets the target of that connection point */
  20737. get target(): NodeMaterialBlockTargets;
  20738. set target(value: NodeMaterialBlockTargets);
  20739. /**
  20740. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20741. */
  20742. get isConnected(): boolean;
  20743. /**
  20744. * Gets a boolean indicating that the current point is connected to an input block
  20745. */
  20746. get isConnectedToInputBlock(): boolean;
  20747. /**
  20748. * Gets a the connected input block (if any)
  20749. */
  20750. get connectInputBlock(): Nullable<InputBlock>;
  20751. /** Get the other side of the connection (if any) */
  20752. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20753. /** Get the block that owns this connection point */
  20754. get ownerBlock(): NodeMaterialBlock;
  20755. /** Get the block connected on the other side of this connection (if any) */
  20756. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20757. /** Get the block connected on the endpoints of this connection (if any) */
  20758. get connectedBlocks(): Array<NodeMaterialBlock>;
  20759. /** Gets the list of connected endpoints */
  20760. get endpoints(): NodeMaterialConnectionPoint[];
  20761. /** Gets a boolean indicating if that output point is connected to at least one input */
  20762. get hasEndpoints(): boolean;
  20763. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20764. get isConnectedInVertexShader(): boolean;
  20765. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20766. get isConnectedInFragmentShader(): boolean;
  20767. /**
  20768. * Creates a block suitable to be used as an input for this input point.
  20769. * If null is returned, a block based on the point type will be created.
  20770. * @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
  20771. */
  20772. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20773. /**
  20774. * Creates a new connection point
  20775. * @param name defines the connection point name
  20776. * @param ownerBlock defines the block hosting this connection point
  20777. * @param direction defines the direction of the connection point
  20778. */
  20779. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20780. /**
  20781. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20782. * @returns the class name
  20783. */
  20784. getClassName(): string;
  20785. /**
  20786. * Gets a boolean indicating if the current point can be connected to another point
  20787. * @param connectionPoint defines the other connection point
  20788. * @returns a boolean
  20789. */
  20790. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20791. /**
  20792. * Gets a number indicating if the current point can be connected to another point
  20793. * @param connectionPoint defines the other connection point
  20794. * @returns a number defining the compatibility state
  20795. */
  20796. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20797. /**
  20798. * Connect this point to another connection point
  20799. * @param connectionPoint defines the other connection point
  20800. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20801. * @returns the current connection point
  20802. */
  20803. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20804. /**
  20805. * Disconnect this point from one of his endpoint
  20806. * @param endpoint defines the other connection point
  20807. * @returns the current connection point
  20808. */
  20809. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20810. /**
  20811. * Serializes this point in a JSON representation
  20812. * @param isInput defines if the connection point is an input (default is true)
  20813. * @returns the serialized point object
  20814. */
  20815. serialize(isInput?: boolean): any;
  20816. /**
  20817. * Release resources
  20818. */
  20819. dispose(): void;
  20820. }
  20821. }
  20822. declare module BABYLON {
  20823. /**
  20824. * Enum used to define the material modes
  20825. */
  20826. export enum NodeMaterialModes {
  20827. /** Regular material */
  20828. Material = 0,
  20829. /** For post process */
  20830. PostProcess = 1,
  20831. /** For particle system */
  20832. Particle = 2,
  20833. /** For procedural texture */
  20834. ProceduralTexture = 3
  20835. }
  20836. }
  20837. declare module BABYLON {
  20838. /**
  20839. * Block used to read a texture from a sampler
  20840. */
  20841. export class TextureBlock extends NodeMaterialBlock {
  20842. private _defineName;
  20843. private _linearDefineName;
  20844. private _gammaDefineName;
  20845. private _tempTextureRead;
  20846. private _samplerName;
  20847. private _transformedUVName;
  20848. private _textureTransformName;
  20849. private _textureInfoName;
  20850. private _mainUVName;
  20851. private _mainUVDefineName;
  20852. private _fragmentOnly;
  20853. /**
  20854. * Gets or sets the texture associated with the node
  20855. */
  20856. texture: Nullable<Texture>;
  20857. /**
  20858. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20859. */
  20860. convertToGammaSpace: boolean;
  20861. /**
  20862. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20863. */
  20864. convertToLinearSpace: boolean;
  20865. /**
  20866. * Create a new TextureBlock
  20867. * @param name defines the block name
  20868. */
  20869. constructor(name: string, fragmentOnly?: boolean);
  20870. /**
  20871. * Gets the current class name
  20872. * @returns the class name
  20873. */
  20874. getClassName(): string;
  20875. /**
  20876. * Gets the uv input component
  20877. */
  20878. get uv(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the rgba output component
  20881. */
  20882. get rgba(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the rgb output component
  20885. */
  20886. get rgb(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Gets the r output component
  20889. */
  20890. get r(): NodeMaterialConnectionPoint;
  20891. /**
  20892. * Gets the g output component
  20893. */
  20894. get g(): NodeMaterialConnectionPoint;
  20895. /**
  20896. * Gets the b output component
  20897. */
  20898. get b(): NodeMaterialConnectionPoint;
  20899. /**
  20900. * Gets the a output component
  20901. */
  20902. get a(): NodeMaterialConnectionPoint;
  20903. get target(): NodeMaterialBlockTargets;
  20904. autoConfigure(material: NodeMaterial): void;
  20905. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20907. isReady(): boolean;
  20908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20909. private get _isMixed();
  20910. private _injectVertexCode;
  20911. private _writeTextureRead;
  20912. private _writeOutput;
  20913. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20914. protected _dumpPropertiesCode(): string;
  20915. serialize(): any;
  20916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20917. }
  20918. }
  20919. declare module BABYLON {
  20920. /** @hidden */
  20921. export var reflectionFunction: {
  20922. name: string;
  20923. shader: string;
  20924. };
  20925. }
  20926. declare module BABYLON {
  20927. /**
  20928. * Base block used to read a reflection texture from a sampler
  20929. */
  20930. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20931. /** @hidden */
  20932. _define3DName: string;
  20933. /** @hidden */
  20934. _defineCubicName: string;
  20935. /** @hidden */
  20936. _defineExplicitName: string;
  20937. /** @hidden */
  20938. _defineProjectionName: string;
  20939. /** @hidden */
  20940. _defineLocalCubicName: string;
  20941. /** @hidden */
  20942. _defineSphericalName: string;
  20943. /** @hidden */
  20944. _definePlanarName: string;
  20945. /** @hidden */
  20946. _defineEquirectangularName: string;
  20947. /** @hidden */
  20948. _defineMirroredEquirectangularFixedName: string;
  20949. /** @hidden */
  20950. _defineEquirectangularFixedName: string;
  20951. /** @hidden */
  20952. _defineSkyboxName: string;
  20953. /** @hidden */
  20954. _defineOppositeZ: string;
  20955. /** @hidden */
  20956. _cubeSamplerName: string;
  20957. /** @hidden */
  20958. _2DSamplerName: string;
  20959. protected _positionUVWName: string;
  20960. protected _directionWName: string;
  20961. protected _reflectionVectorName: string;
  20962. /** @hidden */
  20963. _reflectionCoordsName: string;
  20964. /** @hidden */
  20965. _reflectionMatrixName: string;
  20966. protected _reflectionColorName: string;
  20967. /**
  20968. * Gets or sets the texture associated with the node
  20969. */
  20970. texture: Nullable<BaseTexture>;
  20971. /**
  20972. * Create a new ReflectionTextureBaseBlock
  20973. * @param name defines the block name
  20974. */
  20975. constructor(name: string);
  20976. /**
  20977. * Gets the current class name
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Gets the world position input component
  20983. */
  20984. abstract get position(): NodeMaterialConnectionPoint;
  20985. /**
  20986. * Gets the world position input component
  20987. */
  20988. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the world normal input component
  20991. */
  20992. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the world input component
  20995. */
  20996. abstract get world(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the camera (or eye) position component
  20999. */
  21000. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21001. /**
  21002. * Gets the view input component
  21003. */
  21004. abstract get view(): NodeMaterialConnectionPoint;
  21005. protected _getTexture(): Nullable<BaseTexture>;
  21006. autoConfigure(material: NodeMaterial): void;
  21007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21008. isReady(): boolean;
  21009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21010. /**
  21011. * Gets the code to inject in the vertex shader
  21012. * @param state current state of the node material building
  21013. * @returns the shader code
  21014. */
  21015. handleVertexSide(state: NodeMaterialBuildState): string;
  21016. /**
  21017. * Handles the inits for the fragment code path
  21018. * @param state node material build state
  21019. */
  21020. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21021. /**
  21022. * Generates the reflection coords code for the fragment code path
  21023. * @param worldNormalVarName name of the world normal variable
  21024. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21025. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21026. * @returns the shader code
  21027. */
  21028. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21029. /**
  21030. * Generates the reflection color code for the fragment code path
  21031. * @param lodVarName name of the lod variable
  21032. * @param swizzleLookupTexture swizzle to use for the final color variable
  21033. * @returns the shader code
  21034. */
  21035. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21036. /**
  21037. * Generates the code corresponding to the connected output points
  21038. * @param state node material build state
  21039. * @param varName name of the variable to output
  21040. * @returns the shader code
  21041. */
  21042. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21043. protected _buildBlock(state: NodeMaterialBuildState): this;
  21044. protected _dumpPropertiesCode(): string;
  21045. serialize(): any;
  21046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21047. }
  21048. }
  21049. declare module BABYLON {
  21050. /**
  21051. * Defines a connection point to be used for points with a custom object type
  21052. */
  21053. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21054. private _blockType;
  21055. private _blockName;
  21056. private _nameForCheking?;
  21057. /**
  21058. * Creates a new connection point
  21059. * @param name defines the connection point name
  21060. * @param ownerBlock defines the block hosting this connection point
  21061. * @param direction defines the direction of the connection point
  21062. */
  21063. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21064. /**
  21065. * Gets a number indicating if the current point can be connected to another point
  21066. * @param connectionPoint defines the other connection point
  21067. * @returns a number defining the compatibility state
  21068. */
  21069. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21070. /**
  21071. * Creates a block suitable to be used as an input for this input point.
  21072. * If null is returned, a block based on the point type will be created.
  21073. * @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
  21074. */
  21075. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21076. }
  21077. }
  21078. declare module BABYLON {
  21079. /**
  21080. * Enum defining the type of properties that can be edited in the property pages in the NME
  21081. */
  21082. export enum PropertyTypeForEdition {
  21083. /** property is a boolean */
  21084. Boolean = 0,
  21085. /** property is a float */
  21086. Float = 1,
  21087. /** property is a Vector2 */
  21088. Vector2 = 2,
  21089. /** property is a list of values */
  21090. List = 3
  21091. }
  21092. /**
  21093. * Interface that defines an option in a variable of type list
  21094. */
  21095. export interface IEditablePropertyListOption {
  21096. /** label of the option */
  21097. "label": string;
  21098. /** value of the option */
  21099. "value": number;
  21100. }
  21101. /**
  21102. * Interface that defines the options available for an editable property
  21103. */
  21104. export interface IEditablePropertyOption {
  21105. /** min value */
  21106. "min"?: number;
  21107. /** max value */
  21108. "max"?: number;
  21109. /** notifiers: indicates which actions to take when the property is changed */
  21110. "notifiers"?: {
  21111. /** the material should be rebuilt */
  21112. "rebuild"?: boolean;
  21113. /** the preview should be updated */
  21114. "update"?: boolean;
  21115. };
  21116. /** list of the options for a variable of type list */
  21117. "options"?: IEditablePropertyListOption[];
  21118. }
  21119. /**
  21120. * Interface that describes an editable property
  21121. */
  21122. export interface IPropertyDescriptionForEdition {
  21123. /** name of the property */
  21124. "propertyName": string;
  21125. /** display name of the property */
  21126. "displayName": string;
  21127. /** type of the property */
  21128. "type": PropertyTypeForEdition;
  21129. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21130. "groupName": string;
  21131. /** options for the property */
  21132. "options": IEditablePropertyOption;
  21133. }
  21134. /**
  21135. * Decorator that flags a property in a node material block as being editable
  21136. */
  21137. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21138. }
  21139. declare module BABYLON {
  21140. /**
  21141. * Block used to implement the refraction part of the sub surface module of the PBR material
  21142. */
  21143. export class RefractionBlock extends NodeMaterialBlock {
  21144. /** @hidden */
  21145. _define3DName: string;
  21146. /** @hidden */
  21147. _refractionMatrixName: string;
  21148. /** @hidden */
  21149. _defineLODRefractionAlpha: string;
  21150. /** @hidden */
  21151. _defineLinearSpecularRefraction: string;
  21152. /** @hidden */
  21153. _defineOppositeZ: string;
  21154. /** @hidden */
  21155. _cubeSamplerName: string;
  21156. /** @hidden */
  21157. _2DSamplerName: string;
  21158. /** @hidden */
  21159. _vRefractionMicrosurfaceInfosName: string;
  21160. /** @hidden */
  21161. _vRefractionInfosName: string;
  21162. private _scene;
  21163. /**
  21164. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21165. * Materials half opaque for instance using refraction could benefit from this control.
  21166. */
  21167. linkRefractionWithTransparency: boolean;
  21168. /**
  21169. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21170. */
  21171. invertRefractionY: boolean;
  21172. /**
  21173. * Gets or sets the texture associated with the node
  21174. */
  21175. texture: Nullable<BaseTexture>;
  21176. /**
  21177. * Create a new RefractionBlock
  21178. * @param name defines the block name
  21179. */
  21180. constructor(name: string);
  21181. /**
  21182. * Gets the current class name
  21183. * @returns the class name
  21184. */
  21185. getClassName(): string;
  21186. /**
  21187. * Gets the intensity input component
  21188. */
  21189. get intensity(): NodeMaterialConnectionPoint;
  21190. /**
  21191. * Gets the index of refraction input component
  21192. */
  21193. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21194. /**
  21195. * Gets the tint at distance input component
  21196. */
  21197. get tintAtDistance(): NodeMaterialConnectionPoint;
  21198. /**
  21199. * Gets the view input component
  21200. */
  21201. get view(): NodeMaterialConnectionPoint;
  21202. /**
  21203. * Gets the refraction object output component
  21204. */
  21205. get refraction(): NodeMaterialConnectionPoint;
  21206. /**
  21207. * Returns true if the block has a texture
  21208. */
  21209. get hasTexture(): boolean;
  21210. protected _getTexture(): Nullable<BaseTexture>;
  21211. autoConfigure(material: NodeMaterial): void;
  21212. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21213. isReady(): boolean;
  21214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21215. /**
  21216. * Gets the main code of the block (fragment side)
  21217. * @param state current state of the node material building
  21218. * @returns the shader code
  21219. */
  21220. getCode(state: NodeMaterialBuildState): string;
  21221. protected _buildBlock(state: NodeMaterialBuildState): this;
  21222. protected _dumpPropertiesCode(): string;
  21223. serialize(): any;
  21224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21225. }
  21226. }
  21227. declare module BABYLON {
  21228. /**
  21229. * Base block used as input for post process
  21230. */
  21231. export class CurrentScreenBlock extends NodeMaterialBlock {
  21232. private _samplerName;
  21233. private _linearDefineName;
  21234. private _gammaDefineName;
  21235. private _mainUVName;
  21236. private _tempTextureRead;
  21237. /**
  21238. * Gets or sets the texture associated with the node
  21239. */
  21240. texture: Nullable<BaseTexture>;
  21241. /**
  21242. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21243. */
  21244. convertToGammaSpace: boolean;
  21245. /**
  21246. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21247. */
  21248. convertToLinearSpace: boolean;
  21249. /**
  21250. * Create a new CurrentScreenBlock
  21251. * @param name defines the block name
  21252. */
  21253. constructor(name: string);
  21254. /**
  21255. * Gets the current class name
  21256. * @returns the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Gets the uv input component
  21261. */
  21262. get uv(): NodeMaterialConnectionPoint;
  21263. /**
  21264. * Gets the rgba output component
  21265. */
  21266. get rgba(): NodeMaterialConnectionPoint;
  21267. /**
  21268. * Gets the rgb output component
  21269. */
  21270. get rgb(): NodeMaterialConnectionPoint;
  21271. /**
  21272. * Gets the r output component
  21273. */
  21274. get r(): NodeMaterialConnectionPoint;
  21275. /**
  21276. * Gets the g output component
  21277. */
  21278. get g(): NodeMaterialConnectionPoint;
  21279. /**
  21280. * Gets the b output component
  21281. */
  21282. get b(): NodeMaterialConnectionPoint;
  21283. /**
  21284. * Gets the a output component
  21285. */
  21286. get a(): NodeMaterialConnectionPoint;
  21287. /**
  21288. * Initialize the block and prepare the context for build
  21289. * @param state defines the state that will be used for the build
  21290. */
  21291. initialize(state: NodeMaterialBuildState): void;
  21292. get target(): NodeMaterialBlockTargets;
  21293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21294. isReady(): boolean;
  21295. private _injectVertexCode;
  21296. private _writeTextureRead;
  21297. private _writeOutput;
  21298. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21299. serialize(): any;
  21300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21301. }
  21302. }
  21303. declare module BABYLON {
  21304. /**
  21305. * Base block used for the particle texture
  21306. */
  21307. export class ParticleTextureBlock extends NodeMaterialBlock {
  21308. private _samplerName;
  21309. private _linearDefineName;
  21310. private _gammaDefineName;
  21311. private _tempTextureRead;
  21312. /**
  21313. * Gets or sets the texture associated with the node
  21314. */
  21315. texture: Nullable<BaseTexture>;
  21316. /**
  21317. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21318. */
  21319. convertToGammaSpace: boolean;
  21320. /**
  21321. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21322. */
  21323. convertToLinearSpace: boolean;
  21324. /**
  21325. * Create a new ParticleTextureBlock
  21326. * @param name defines the block name
  21327. */
  21328. constructor(name: string);
  21329. /**
  21330. * Gets the current class name
  21331. * @returns the class name
  21332. */
  21333. getClassName(): string;
  21334. /**
  21335. * Gets the uv input component
  21336. */
  21337. get uv(): NodeMaterialConnectionPoint;
  21338. /**
  21339. * Gets the rgba output component
  21340. */
  21341. get rgba(): NodeMaterialConnectionPoint;
  21342. /**
  21343. * Gets the rgb output component
  21344. */
  21345. get rgb(): NodeMaterialConnectionPoint;
  21346. /**
  21347. * Gets the r output component
  21348. */
  21349. get r(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the g output component
  21352. */
  21353. get g(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the b output component
  21356. */
  21357. get b(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the a output component
  21360. */
  21361. get a(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Initialize the block and prepare the context for build
  21364. * @param state defines the state that will be used for the build
  21365. */
  21366. initialize(state: NodeMaterialBuildState): void;
  21367. autoConfigure(material: NodeMaterial): void;
  21368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21369. isReady(): boolean;
  21370. private _writeOutput;
  21371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21372. serialize(): any;
  21373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21374. }
  21375. }
  21376. declare module BABYLON {
  21377. /**
  21378. * Class used to store shared data between 2 NodeMaterialBuildState
  21379. */
  21380. export class NodeMaterialBuildStateSharedData {
  21381. /**
  21382. * Gets the list of emitted varyings
  21383. */
  21384. temps: string[];
  21385. /**
  21386. * Gets the list of emitted varyings
  21387. */
  21388. varyings: string[];
  21389. /**
  21390. * Gets the varying declaration string
  21391. */
  21392. varyingDeclaration: string;
  21393. /**
  21394. * Input blocks
  21395. */
  21396. inputBlocks: InputBlock[];
  21397. /**
  21398. * Input blocks
  21399. */
  21400. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21401. /**
  21402. * Bindable blocks (Blocks that need to set data to the effect)
  21403. */
  21404. bindableBlocks: NodeMaterialBlock[];
  21405. /**
  21406. * List of blocks that can provide a compilation fallback
  21407. */
  21408. blocksWithFallbacks: NodeMaterialBlock[];
  21409. /**
  21410. * List of blocks that can provide a define update
  21411. */
  21412. blocksWithDefines: NodeMaterialBlock[];
  21413. /**
  21414. * List of blocks that can provide a repeatable content
  21415. */
  21416. repeatableContentBlocks: NodeMaterialBlock[];
  21417. /**
  21418. * List of blocks that can provide a dynamic list of uniforms
  21419. */
  21420. dynamicUniformBlocks: NodeMaterialBlock[];
  21421. /**
  21422. * List of blocks that can block the isReady function for the material
  21423. */
  21424. blockingBlocks: NodeMaterialBlock[];
  21425. /**
  21426. * Gets the list of animated inputs
  21427. */
  21428. animatedInputs: InputBlock[];
  21429. /**
  21430. * Build Id used to avoid multiple recompilations
  21431. */
  21432. buildId: number;
  21433. /** List of emitted variables */
  21434. variableNames: {
  21435. [key: string]: number;
  21436. };
  21437. /** List of emitted defines */
  21438. defineNames: {
  21439. [key: string]: number;
  21440. };
  21441. /** Should emit comments? */
  21442. emitComments: boolean;
  21443. /** Emit build activity */
  21444. verbose: boolean;
  21445. /** Gets or sets the hosting scene */
  21446. scene: Scene;
  21447. /**
  21448. * Gets the compilation hints emitted at compilation time
  21449. */
  21450. hints: {
  21451. needWorldViewMatrix: boolean;
  21452. needWorldViewProjectionMatrix: boolean;
  21453. needAlphaBlending: boolean;
  21454. needAlphaTesting: boolean;
  21455. };
  21456. /**
  21457. * List of compilation checks
  21458. */
  21459. checks: {
  21460. emitVertex: boolean;
  21461. emitFragment: boolean;
  21462. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21463. };
  21464. /**
  21465. * Is vertex program allowed to be empty?
  21466. */
  21467. allowEmptyVertexProgram: boolean;
  21468. /** Creates a new shared data */
  21469. constructor();
  21470. /**
  21471. * Emits console errors and exceptions if there is a failing check
  21472. */
  21473. emitErrors(): void;
  21474. }
  21475. }
  21476. declare module BABYLON {
  21477. /**
  21478. * Class used to store node based material build state
  21479. */
  21480. export class NodeMaterialBuildState {
  21481. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21482. supportUniformBuffers: boolean;
  21483. /**
  21484. * Gets the list of emitted attributes
  21485. */
  21486. attributes: string[];
  21487. /**
  21488. * Gets the list of emitted uniforms
  21489. */
  21490. uniforms: string[];
  21491. /**
  21492. * Gets the list of emitted constants
  21493. */
  21494. constants: string[];
  21495. /**
  21496. * Gets the list of emitted samplers
  21497. */
  21498. samplers: string[];
  21499. /**
  21500. * Gets the list of emitted functions
  21501. */
  21502. functions: {
  21503. [key: string]: string;
  21504. };
  21505. /**
  21506. * Gets the list of emitted extensions
  21507. */
  21508. extensions: {
  21509. [key: string]: string;
  21510. };
  21511. /**
  21512. * Gets the target of the compilation state
  21513. */
  21514. target: NodeMaterialBlockTargets;
  21515. /**
  21516. * Gets the list of emitted counters
  21517. */
  21518. counters: {
  21519. [key: string]: number;
  21520. };
  21521. /**
  21522. * Shared data between multiple NodeMaterialBuildState instances
  21523. */
  21524. sharedData: NodeMaterialBuildStateSharedData;
  21525. /** @hidden */
  21526. _vertexState: NodeMaterialBuildState;
  21527. /** @hidden */
  21528. _attributeDeclaration: string;
  21529. /** @hidden */
  21530. _uniformDeclaration: string;
  21531. /** @hidden */
  21532. _constantDeclaration: string;
  21533. /** @hidden */
  21534. _samplerDeclaration: string;
  21535. /** @hidden */
  21536. _varyingTransfer: string;
  21537. /** @hidden */
  21538. _injectAtEnd: string;
  21539. private _repeatableContentAnchorIndex;
  21540. /** @hidden */
  21541. _builtCompilationString: string;
  21542. /**
  21543. * Gets the emitted compilation strings
  21544. */
  21545. compilationString: string;
  21546. /**
  21547. * Finalize the compilation strings
  21548. * @param state defines the current compilation state
  21549. */
  21550. finalize(state: NodeMaterialBuildState): void;
  21551. /** @hidden */
  21552. get _repeatableContentAnchor(): string;
  21553. /** @hidden */
  21554. _getFreeVariableName(prefix: string): string;
  21555. /** @hidden */
  21556. _getFreeDefineName(prefix: string): string;
  21557. /** @hidden */
  21558. _excludeVariableName(name: string): void;
  21559. /** @hidden */
  21560. _emit2DSampler(name: string): void;
  21561. /** @hidden */
  21562. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21563. /** @hidden */
  21564. _emitExtension(name: string, extension: string, define?: string): void;
  21565. /** @hidden */
  21566. _emitFunction(name: string, code: string, comments: string): void;
  21567. /** @hidden */
  21568. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21569. replaceStrings?: {
  21570. search: RegExp;
  21571. replace: string;
  21572. }[];
  21573. repeatKey?: string;
  21574. }): string;
  21575. /** @hidden */
  21576. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21577. repeatKey?: string;
  21578. removeAttributes?: boolean;
  21579. removeUniforms?: boolean;
  21580. removeVaryings?: boolean;
  21581. removeIfDef?: boolean;
  21582. replaceStrings?: {
  21583. search: RegExp;
  21584. replace: string;
  21585. }[];
  21586. }, storeKey?: string): void;
  21587. /** @hidden */
  21588. _registerTempVariable(name: string): boolean;
  21589. /** @hidden */
  21590. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21591. /** @hidden */
  21592. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21593. /** @hidden */
  21594. _emitFloat(value: number): string;
  21595. }
  21596. }
  21597. declare module BABYLON {
  21598. /**
  21599. * Helper class used to generate session unique ID
  21600. */
  21601. export class UniqueIdGenerator {
  21602. private static _UniqueIdCounter;
  21603. /**
  21604. * Gets an unique (relatively to the current scene) Id
  21605. */
  21606. static get UniqueId(): number;
  21607. }
  21608. }
  21609. declare module BABYLON {
  21610. /**
  21611. * Defines a block that can be used inside a node based material
  21612. */
  21613. export class NodeMaterialBlock {
  21614. private _buildId;
  21615. private _buildTarget;
  21616. private _target;
  21617. private _isFinalMerger;
  21618. private _isInput;
  21619. private _name;
  21620. protected _isUnique: boolean;
  21621. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21622. inputsAreExclusive: boolean;
  21623. /** @hidden */
  21624. _codeVariableName: string;
  21625. /** @hidden */
  21626. _inputs: NodeMaterialConnectionPoint[];
  21627. /** @hidden */
  21628. _outputs: NodeMaterialConnectionPoint[];
  21629. /** @hidden */
  21630. _preparationId: number;
  21631. /**
  21632. * Gets the name of the block
  21633. */
  21634. get name(): string;
  21635. /**
  21636. * Sets the name of the block. Will check if the name is valid.
  21637. */
  21638. set name(newName: string);
  21639. /**
  21640. * Gets or sets the unique id of the node
  21641. */
  21642. uniqueId: number;
  21643. /**
  21644. * Gets or sets the comments associated with this block
  21645. */
  21646. comments: string;
  21647. /**
  21648. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21649. */
  21650. get isUnique(): boolean;
  21651. /**
  21652. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21653. */
  21654. get isFinalMerger(): boolean;
  21655. /**
  21656. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21657. */
  21658. get isInput(): boolean;
  21659. /**
  21660. * Gets or sets the build Id
  21661. */
  21662. get buildId(): number;
  21663. set buildId(value: number);
  21664. /**
  21665. * Gets or sets the target of the block
  21666. */
  21667. get target(): NodeMaterialBlockTargets;
  21668. set target(value: NodeMaterialBlockTargets);
  21669. /**
  21670. * Gets the list of input points
  21671. */
  21672. get inputs(): NodeMaterialConnectionPoint[];
  21673. /** Gets the list of output points */
  21674. get outputs(): NodeMaterialConnectionPoint[];
  21675. /**
  21676. * Find an input by its name
  21677. * @param name defines the name of the input to look for
  21678. * @returns the input or null if not found
  21679. */
  21680. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21681. /**
  21682. * Find an output by its name
  21683. * @param name defines the name of the outputto look for
  21684. * @returns the output or null if not found
  21685. */
  21686. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21687. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21688. visibleInInspector: boolean;
  21689. /**
  21690. * Creates a new NodeMaterialBlock
  21691. * @param name defines the block name
  21692. * @param target defines the target of that block (Vertex by default)
  21693. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21694. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21695. */
  21696. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21697. /**
  21698. * Initialize the block and prepare the context for build
  21699. * @param state defines the state that will be used for the build
  21700. */
  21701. initialize(state: NodeMaterialBuildState): void;
  21702. /**
  21703. * Bind data to effect. Will only be called for blocks with isBindable === true
  21704. * @param effect defines the effect to bind data to
  21705. * @param nodeMaterial defines the hosting NodeMaterial
  21706. * @param mesh defines the mesh that will be rendered
  21707. * @param subMesh defines the submesh that will be rendered
  21708. */
  21709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21710. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21711. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21712. protected _writeFloat(value: number): string;
  21713. /**
  21714. * Gets the current class name e.g. "NodeMaterialBlock"
  21715. * @returns the class name
  21716. */
  21717. getClassName(): string;
  21718. /**
  21719. * Register a new input. Must be called inside a block constructor
  21720. * @param name defines the connection point name
  21721. * @param type defines the connection point type
  21722. * @param isOptional defines a boolean indicating that this input can be omitted
  21723. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21724. * @param point an already created connection point. If not provided, create a new one
  21725. * @returns the current block
  21726. */
  21727. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21728. /**
  21729. * Register a new output. Must be called inside a block constructor
  21730. * @param name defines the connection point name
  21731. * @param type defines the connection point type
  21732. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21733. * @param point an already created connection point. If not provided, create a new one
  21734. * @returns the current block
  21735. */
  21736. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21737. /**
  21738. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21739. * @param forOutput defines an optional connection point to check compatibility with
  21740. * @returns the first available input or null
  21741. */
  21742. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21743. /**
  21744. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21745. * @param forBlock defines an optional block to check compatibility with
  21746. * @returns the first available input or null
  21747. */
  21748. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21749. /**
  21750. * Gets the sibling of the given output
  21751. * @param current defines the current output
  21752. * @returns the next output in the list or null
  21753. */
  21754. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21755. /**
  21756. * Connect current block with another block
  21757. * @param other defines the block to connect with
  21758. * @param options define the various options to help pick the right connections
  21759. * @returns the current block
  21760. */
  21761. connectTo(other: NodeMaterialBlock, options?: {
  21762. input?: string;
  21763. output?: string;
  21764. outputSwizzle?: string;
  21765. }): this | undefined;
  21766. protected _buildBlock(state: NodeMaterialBuildState): void;
  21767. /**
  21768. * Add uniforms, samplers and uniform buffers at compilation time
  21769. * @param state defines the state to update
  21770. * @param nodeMaterial defines the node material requesting the update
  21771. * @param defines defines the material defines to update
  21772. * @param uniformBuffers defines the list of uniform buffer names
  21773. */
  21774. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21775. /**
  21776. * Add potential fallbacks if shader compilation fails
  21777. * @param mesh defines the mesh to be rendered
  21778. * @param fallbacks defines the current prioritized list of fallbacks
  21779. */
  21780. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21781. /**
  21782. * Initialize defines for shader compilation
  21783. * @param mesh defines the mesh to be rendered
  21784. * @param nodeMaterial defines the node material requesting the update
  21785. * @param defines defines the material defines to update
  21786. * @param useInstances specifies that instances should be used
  21787. */
  21788. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21789. /**
  21790. * Update defines for shader compilation
  21791. * @param mesh defines the mesh to be rendered
  21792. * @param nodeMaterial defines the node material requesting the update
  21793. * @param defines defines the material defines to update
  21794. * @param useInstances specifies that instances should be used
  21795. * @param subMesh defines which submesh to render
  21796. */
  21797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21798. /**
  21799. * Lets the block try to connect some inputs automatically
  21800. * @param material defines the hosting NodeMaterial
  21801. */
  21802. autoConfigure(material: NodeMaterial): void;
  21803. /**
  21804. * Function called when a block is declared as repeatable content generator
  21805. * @param vertexShaderState defines the current compilation state for the vertex shader
  21806. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21807. * @param mesh defines the mesh to be rendered
  21808. * @param defines defines the material defines to update
  21809. */
  21810. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21811. /**
  21812. * Checks if the block is ready
  21813. * @param mesh defines the mesh to be rendered
  21814. * @param nodeMaterial defines the node material requesting the update
  21815. * @param defines defines the material defines to update
  21816. * @param useInstances specifies that instances should be used
  21817. * @returns true if the block is ready
  21818. */
  21819. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21820. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21821. private _processBuild;
  21822. /**
  21823. * Validates the new name for the block node.
  21824. * @param newName the new name to be given to the node.
  21825. * @returns false if the name is a reserve word, else true.
  21826. */
  21827. validateBlockName(newName: string): boolean;
  21828. /**
  21829. * Compile the current node and generate the shader code
  21830. * @param state defines the current compilation state (uniforms, samplers, current string)
  21831. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21832. * @returns true if already built
  21833. */
  21834. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21835. protected _inputRename(name: string): string;
  21836. protected _outputRename(name: string): string;
  21837. protected _dumpPropertiesCode(): string;
  21838. /** @hidden */
  21839. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21840. /** @hidden */
  21841. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21842. /**
  21843. * Clone the current block to a new identical block
  21844. * @param scene defines the hosting scene
  21845. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21846. * @returns a copy of the current block
  21847. */
  21848. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21849. /**
  21850. * Serializes this block in a JSON representation
  21851. * @returns the serialized block object
  21852. */
  21853. serialize(): any;
  21854. /** @hidden */
  21855. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21856. private _deserializePortDisplayNamesAndExposedOnFrame;
  21857. /**
  21858. * Release resources
  21859. */
  21860. dispose(): void;
  21861. }
  21862. }
  21863. declare module BABYLON {
  21864. /**
  21865. * Base class of materials working in push mode in babylon JS
  21866. * @hidden
  21867. */
  21868. export class PushMaterial extends Material {
  21869. protected _activeEffect: Effect;
  21870. protected _normalMatrix: Matrix;
  21871. constructor(name: string, scene: Scene);
  21872. getEffect(): Effect;
  21873. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21874. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21875. /**
  21876. * Binds the given world matrix to the active effect
  21877. *
  21878. * @param world the matrix to bind
  21879. */
  21880. bindOnlyWorldMatrix(world: Matrix): void;
  21881. /**
  21882. * Binds the given normal matrix to the active effect
  21883. *
  21884. * @param normalMatrix the matrix to bind
  21885. */
  21886. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21887. bind(world: Matrix, mesh?: Mesh): void;
  21888. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21889. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21890. }
  21891. }
  21892. declare module BABYLON {
  21893. /**
  21894. * Root class for all node material optimizers
  21895. */
  21896. export class NodeMaterialOptimizer {
  21897. /**
  21898. * Function used to optimize a NodeMaterial graph
  21899. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21900. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21901. */
  21902. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21903. }
  21904. }
  21905. declare module BABYLON {
  21906. /**
  21907. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21908. */
  21909. export class TransformBlock extends NodeMaterialBlock {
  21910. /**
  21911. * Defines the value to use to complement W value to transform it to a Vector4
  21912. */
  21913. complementW: number;
  21914. /**
  21915. * Defines the value to use to complement z value to transform it to a Vector4
  21916. */
  21917. complementZ: number;
  21918. /**
  21919. * Creates a new TransformBlock
  21920. * @param name defines the block name
  21921. */
  21922. constructor(name: string);
  21923. /**
  21924. * Gets the current class name
  21925. * @returns the class name
  21926. */
  21927. getClassName(): string;
  21928. /**
  21929. * Gets the vector input
  21930. */
  21931. get vector(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the output component
  21934. */
  21935. get output(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the xyz output component
  21938. */
  21939. get xyz(): NodeMaterialConnectionPoint;
  21940. /**
  21941. * Gets the matrix transform input
  21942. */
  21943. get transform(): NodeMaterialConnectionPoint;
  21944. protected _buildBlock(state: NodeMaterialBuildState): this;
  21945. /**
  21946. * Update defines for shader compilation
  21947. * @param mesh defines the mesh to be rendered
  21948. * @param nodeMaterial defines the node material requesting the update
  21949. * @param defines defines the material defines to update
  21950. * @param useInstances specifies that instances should be used
  21951. * @param subMesh defines which submesh to render
  21952. */
  21953. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21954. serialize(): any;
  21955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21956. protected _dumpPropertiesCode(): string;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Block used to output the vertex position
  21962. */
  21963. export class VertexOutputBlock extends NodeMaterialBlock {
  21964. /**
  21965. * Creates a new VertexOutputBlock
  21966. * @param name defines the block name
  21967. */
  21968. constructor(name: string);
  21969. /**
  21970. * Gets the current class name
  21971. * @returns the class name
  21972. */
  21973. getClassName(): string;
  21974. /**
  21975. * Gets the vector input component
  21976. */
  21977. get vector(): NodeMaterialConnectionPoint;
  21978. protected _buildBlock(state: NodeMaterialBuildState): this;
  21979. }
  21980. }
  21981. declare module BABYLON {
  21982. /**
  21983. * Block used to output the final color
  21984. */
  21985. export class FragmentOutputBlock extends NodeMaterialBlock {
  21986. /**
  21987. * Create a new FragmentOutputBlock
  21988. * @param name defines the block name
  21989. */
  21990. constructor(name: string);
  21991. /**
  21992. * Gets the current class name
  21993. * @returns the class name
  21994. */
  21995. getClassName(): string;
  21996. /**
  21997. * Gets the rgba input component
  21998. */
  21999. get rgba(): NodeMaterialConnectionPoint;
  22000. /**
  22001. * Gets the rgb input component
  22002. */
  22003. get rgb(): NodeMaterialConnectionPoint;
  22004. /**
  22005. * Gets the a input component
  22006. */
  22007. get a(): NodeMaterialConnectionPoint;
  22008. protected _buildBlock(state: NodeMaterialBuildState): this;
  22009. }
  22010. }
  22011. declare module BABYLON {
  22012. /**
  22013. * Block used for the particle ramp gradient section
  22014. */
  22015. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22016. /**
  22017. * Create a new ParticleRampGradientBlock
  22018. * @param name defines the block name
  22019. */
  22020. constructor(name: string);
  22021. /**
  22022. * Gets the current class name
  22023. * @returns the class name
  22024. */
  22025. getClassName(): string;
  22026. /**
  22027. * Gets the color input component
  22028. */
  22029. get color(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the rampColor output component
  22032. */
  22033. get rampColor(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Initialize the block and prepare the context for build
  22036. * @param state defines the state that will be used for the build
  22037. */
  22038. initialize(state: NodeMaterialBuildState): void;
  22039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22040. }
  22041. }
  22042. declare module BABYLON {
  22043. /**
  22044. * Block used for the particle blend multiply section
  22045. */
  22046. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22047. /**
  22048. * Create a new ParticleBlendMultiplyBlock
  22049. * @param name defines the block name
  22050. */
  22051. constructor(name: string);
  22052. /**
  22053. * Gets the current class name
  22054. * @returns the class name
  22055. */
  22056. getClassName(): string;
  22057. /**
  22058. * Gets the color input component
  22059. */
  22060. get color(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the alphaTexture input component
  22063. */
  22064. get alphaTexture(): NodeMaterialConnectionPoint;
  22065. /**
  22066. * Gets the alphaColor input component
  22067. */
  22068. get alphaColor(): NodeMaterialConnectionPoint;
  22069. /**
  22070. * Gets the blendColor output component
  22071. */
  22072. get blendColor(): NodeMaterialConnectionPoint;
  22073. /**
  22074. * Initialize the block and prepare the context for build
  22075. * @param state defines the state that will be used for the build
  22076. */
  22077. initialize(state: NodeMaterialBuildState): void;
  22078. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22079. }
  22080. }
  22081. declare module BABYLON {
  22082. /**
  22083. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22084. */
  22085. export class VectorMergerBlock extends NodeMaterialBlock {
  22086. /**
  22087. * Create a new VectorMergerBlock
  22088. * @param name defines the block name
  22089. */
  22090. constructor(name: string);
  22091. /**
  22092. * Gets the current class name
  22093. * @returns the class name
  22094. */
  22095. getClassName(): string;
  22096. /**
  22097. * Gets the xyz component (input)
  22098. */
  22099. get xyzIn(): NodeMaterialConnectionPoint;
  22100. /**
  22101. * Gets the xy component (input)
  22102. */
  22103. get xyIn(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the x component (input)
  22106. */
  22107. get x(): NodeMaterialConnectionPoint;
  22108. /**
  22109. * Gets the y component (input)
  22110. */
  22111. get y(): NodeMaterialConnectionPoint;
  22112. /**
  22113. * Gets the z component (input)
  22114. */
  22115. get z(): NodeMaterialConnectionPoint;
  22116. /**
  22117. * Gets the w component (input)
  22118. */
  22119. get w(): NodeMaterialConnectionPoint;
  22120. /**
  22121. * Gets the xyzw component (output)
  22122. */
  22123. get xyzw(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the xyz component (output)
  22126. */
  22127. get xyzOut(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Gets the xy component (output)
  22130. */
  22131. get xyOut(): NodeMaterialConnectionPoint;
  22132. /**
  22133. * Gets the xy component (output)
  22134. * @deprecated Please use xyOut instead.
  22135. */
  22136. get xy(): NodeMaterialConnectionPoint;
  22137. /**
  22138. * Gets the xyz component (output)
  22139. * @deprecated Please use xyzOut instead.
  22140. */
  22141. get xyz(): NodeMaterialConnectionPoint;
  22142. protected _buildBlock(state: NodeMaterialBuildState): this;
  22143. }
  22144. }
  22145. declare module BABYLON {
  22146. /**
  22147. * Block used to remap a float from a range to a new one
  22148. */
  22149. export class RemapBlock extends NodeMaterialBlock {
  22150. /**
  22151. * Gets or sets the source range
  22152. */
  22153. sourceRange: Vector2;
  22154. /**
  22155. * Gets or sets the target range
  22156. */
  22157. targetRange: Vector2;
  22158. /**
  22159. * Creates a new RemapBlock
  22160. * @param name defines the block name
  22161. */
  22162. constructor(name: string);
  22163. /**
  22164. * Gets the current class name
  22165. * @returns the class name
  22166. */
  22167. getClassName(): string;
  22168. /**
  22169. * Gets the input component
  22170. */
  22171. get input(): NodeMaterialConnectionPoint;
  22172. /**
  22173. * Gets the source min input component
  22174. */
  22175. get sourceMin(): NodeMaterialConnectionPoint;
  22176. /**
  22177. * Gets the source max input component
  22178. */
  22179. get sourceMax(): NodeMaterialConnectionPoint;
  22180. /**
  22181. * Gets the target min input component
  22182. */
  22183. get targetMin(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the target max input component
  22186. */
  22187. get targetMax(): NodeMaterialConnectionPoint;
  22188. /**
  22189. * Gets the output component
  22190. */
  22191. get output(): NodeMaterialConnectionPoint;
  22192. protected _buildBlock(state: NodeMaterialBuildState): this;
  22193. protected _dumpPropertiesCode(): string;
  22194. serialize(): any;
  22195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22196. }
  22197. }
  22198. declare module BABYLON {
  22199. /**
  22200. * Block used to multiply 2 values
  22201. */
  22202. export class MultiplyBlock extends NodeMaterialBlock {
  22203. /**
  22204. * Creates a new MultiplyBlock
  22205. * @param name defines the block name
  22206. */
  22207. constructor(name: string);
  22208. /**
  22209. * Gets the current class name
  22210. * @returns the class name
  22211. */
  22212. getClassName(): string;
  22213. /**
  22214. * Gets the left operand input component
  22215. */
  22216. get left(): NodeMaterialConnectionPoint;
  22217. /**
  22218. * Gets the right operand input component
  22219. */
  22220. get right(): NodeMaterialConnectionPoint;
  22221. /**
  22222. * Gets the output component
  22223. */
  22224. get output(): NodeMaterialConnectionPoint;
  22225. protected _buildBlock(state: NodeMaterialBuildState): this;
  22226. }
  22227. }
  22228. declare module BABYLON {
  22229. /**
  22230. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22231. */
  22232. export class ColorSplitterBlock extends NodeMaterialBlock {
  22233. /**
  22234. * Create a new ColorSplitterBlock
  22235. * @param name defines the block name
  22236. */
  22237. constructor(name: string);
  22238. /**
  22239. * Gets the current class name
  22240. * @returns the class name
  22241. */
  22242. getClassName(): string;
  22243. /**
  22244. * Gets the rgba component (input)
  22245. */
  22246. get rgba(): NodeMaterialConnectionPoint;
  22247. /**
  22248. * Gets the rgb component (input)
  22249. */
  22250. get rgbIn(): NodeMaterialConnectionPoint;
  22251. /**
  22252. * Gets the rgb component (output)
  22253. */
  22254. get rgbOut(): NodeMaterialConnectionPoint;
  22255. /**
  22256. * Gets the r component (output)
  22257. */
  22258. get r(): NodeMaterialConnectionPoint;
  22259. /**
  22260. * Gets the g component (output)
  22261. */
  22262. get g(): NodeMaterialConnectionPoint;
  22263. /**
  22264. * Gets the b component (output)
  22265. */
  22266. get b(): NodeMaterialConnectionPoint;
  22267. /**
  22268. * Gets the a component (output)
  22269. */
  22270. get a(): NodeMaterialConnectionPoint;
  22271. protected _inputRename(name: string): string;
  22272. protected _outputRename(name: string): string;
  22273. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22274. }
  22275. }
  22276. declare module BABYLON {
  22277. /**
  22278. * Operations supported by the Trigonometry block
  22279. */
  22280. export enum TrigonometryBlockOperations {
  22281. /** Cos */
  22282. Cos = 0,
  22283. /** Sin */
  22284. Sin = 1,
  22285. /** Abs */
  22286. Abs = 2,
  22287. /** Exp */
  22288. Exp = 3,
  22289. /** Exp2 */
  22290. Exp2 = 4,
  22291. /** Round */
  22292. Round = 5,
  22293. /** Floor */
  22294. Floor = 6,
  22295. /** Ceiling */
  22296. Ceiling = 7,
  22297. /** Square root */
  22298. Sqrt = 8,
  22299. /** Log */
  22300. Log = 9,
  22301. /** Tangent */
  22302. Tan = 10,
  22303. /** Arc tangent */
  22304. ArcTan = 11,
  22305. /** Arc cosinus */
  22306. ArcCos = 12,
  22307. /** Arc sinus */
  22308. ArcSin = 13,
  22309. /** Fraction */
  22310. Fract = 14,
  22311. /** Sign */
  22312. Sign = 15,
  22313. /** To radians (from degrees) */
  22314. Radians = 16,
  22315. /** To degrees (from radians) */
  22316. Degrees = 17
  22317. }
  22318. /**
  22319. * Block used to apply trigonometry operation to floats
  22320. */
  22321. export class TrigonometryBlock extends NodeMaterialBlock {
  22322. /**
  22323. * Gets or sets the operation applied by the block
  22324. */
  22325. operation: TrigonometryBlockOperations;
  22326. /**
  22327. * Creates a new TrigonometryBlock
  22328. * @param name defines the block name
  22329. */
  22330. constructor(name: string);
  22331. /**
  22332. * Gets the current class name
  22333. * @returns the class name
  22334. */
  22335. getClassName(): string;
  22336. /**
  22337. * Gets the input component
  22338. */
  22339. get input(): NodeMaterialConnectionPoint;
  22340. /**
  22341. * Gets the output component
  22342. */
  22343. get output(): NodeMaterialConnectionPoint;
  22344. protected _buildBlock(state: NodeMaterialBuildState): this;
  22345. serialize(): any;
  22346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22347. protected _dumpPropertiesCode(): string;
  22348. }
  22349. }
  22350. declare module BABYLON {
  22351. /**
  22352. * Interface used to configure the node material editor
  22353. */
  22354. export interface INodeMaterialEditorOptions {
  22355. /** Define the URl to load node editor script */
  22356. editorURL?: string;
  22357. }
  22358. /** @hidden */
  22359. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22360. NORMAL: boolean;
  22361. TANGENT: boolean;
  22362. UV1: boolean;
  22363. /** BONES */
  22364. NUM_BONE_INFLUENCERS: number;
  22365. BonesPerMesh: number;
  22366. BONETEXTURE: boolean;
  22367. /** MORPH TARGETS */
  22368. MORPHTARGETS: boolean;
  22369. MORPHTARGETS_NORMAL: boolean;
  22370. MORPHTARGETS_TANGENT: boolean;
  22371. MORPHTARGETS_UV: boolean;
  22372. NUM_MORPH_INFLUENCERS: number;
  22373. /** IMAGE PROCESSING */
  22374. IMAGEPROCESSING: boolean;
  22375. VIGNETTE: boolean;
  22376. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22377. VIGNETTEBLENDMODEOPAQUE: boolean;
  22378. TONEMAPPING: boolean;
  22379. TONEMAPPING_ACES: boolean;
  22380. CONTRAST: boolean;
  22381. EXPOSURE: boolean;
  22382. COLORCURVES: boolean;
  22383. COLORGRADING: boolean;
  22384. COLORGRADING3D: boolean;
  22385. SAMPLER3DGREENDEPTH: boolean;
  22386. SAMPLER3DBGRMAP: boolean;
  22387. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22388. /** MISC. */
  22389. BUMPDIRECTUV: number;
  22390. constructor();
  22391. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22392. }
  22393. /**
  22394. * Class used to configure NodeMaterial
  22395. */
  22396. export interface INodeMaterialOptions {
  22397. /**
  22398. * Defines if blocks should emit comments
  22399. */
  22400. emitComments: boolean;
  22401. }
  22402. /**
  22403. * Class used to create a node based material built by assembling shader blocks
  22404. */
  22405. export class NodeMaterial extends PushMaterial {
  22406. private static _BuildIdGenerator;
  22407. private _options;
  22408. private _vertexCompilationState;
  22409. private _fragmentCompilationState;
  22410. private _sharedData;
  22411. private _buildId;
  22412. private _buildWasSuccessful;
  22413. private _cachedWorldViewMatrix;
  22414. private _cachedWorldViewProjectionMatrix;
  22415. private _optimizers;
  22416. private _animationFrame;
  22417. /** Define the Url to load node editor script */
  22418. static EditorURL: string;
  22419. /** Define the Url to load snippets */
  22420. static SnippetUrl: string;
  22421. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22422. static IgnoreTexturesAtLoadTime: boolean;
  22423. private BJSNODEMATERIALEDITOR;
  22424. /** Get the inspector from bundle or global */
  22425. private _getGlobalNodeMaterialEditor;
  22426. /**
  22427. * Snippet ID if the material was created from the snippet server
  22428. */
  22429. snippetId: string;
  22430. /**
  22431. * Gets or sets data used by visual editor
  22432. * @see https://nme.babylonjs.com
  22433. */
  22434. editorData: any;
  22435. /**
  22436. * 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)
  22437. */
  22438. ignoreAlpha: boolean;
  22439. /**
  22440. * Defines the maximum number of lights that can be used in the material
  22441. */
  22442. maxSimultaneousLights: number;
  22443. /**
  22444. * Observable raised when the material is built
  22445. */
  22446. onBuildObservable: Observable<NodeMaterial>;
  22447. /**
  22448. * Gets or sets the root nodes of the material vertex shader
  22449. */
  22450. _vertexOutputNodes: NodeMaterialBlock[];
  22451. /**
  22452. * Gets or sets the root nodes of the material fragment (pixel) shader
  22453. */
  22454. _fragmentOutputNodes: NodeMaterialBlock[];
  22455. /** Gets or sets options to control the node material overall behavior */
  22456. get options(): INodeMaterialOptions;
  22457. set options(options: INodeMaterialOptions);
  22458. /**
  22459. * Default configuration related to image processing available in the standard Material.
  22460. */
  22461. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22462. /**
  22463. * Gets the image processing configuration used either in this material.
  22464. */
  22465. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22466. /**
  22467. * Sets the Default image processing configuration used either in the this material.
  22468. *
  22469. * If sets to null, the scene one is in use.
  22470. */
  22471. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22472. /**
  22473. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22474. */
  22475. attachedBlocks: NodeMaterialBlock[];
  22476. /**
  22477. * Specifies the mode of the node material
  22478. * @hidden
  22479. */
  22480. _mode: NodeMaterialModes;
  22481. /**
  22482. * Gets the mode property
  22483. */
  22484. get mode(): NodeMaterialModes;
  22485. /**
  22486. * Create a new node based material
  22487. * @param name defines the material name
  22488. * @param scene defines the hosting scene
  22489. * @param options defines creation option
  22490. */
  22491. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22492. /**
  22493. * Gets the current class name of the material e.g. "NodeMaterial"
  22494. * @returns the class name
  22495. */
  22496. getClassName(): string;
  22497. /**
  22498. * Keep track of the image processing observer to allow dispose and replace.
  22499. */
  22500. private _imageProcessingObserver;
  22501. /**
  22502. * Attaches a new image processing configuration to the Standard Material.
  22503. * @param configuration
  22504. */
  22505. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22506. /**
  22507. * Get a block by its name
  22508. * @param name defines the name of the block to retrieve
  22509. * @returns the required block or null if not found
  22510. */
  22511. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22512. /**
  22513. * Get a block by its name
  22514. * @param predicate defines the predicate used to find the good candidate
  22515. * @returns the required block or null if not found
  22516. */
  22517. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22518. /**
  22519. * Get an input block by its name
  22520. * @param predicate defines the predicate used to find the good candidate
  22521. * @returns the required input block or null if not found
  22522. */
  22523. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22524. /**
  22525. * Gets the list of input blocks attached to this material
  22526. * @returns an array of InputBlocks
  22527. */
  22528. getInputBlocks(): InputBlock[];
  22529. /**
  22530. * Adds a new optimizer to the list of optimizers
  22531. * @param optimizer defines the optimizers to add
  22532. * @returns the current material
  22533. */
  22534. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22535. /**
  22536. * Remove an optimizer from the list of optimizers
  22537. * @param optimizer defines the optimizers to remove
  22538. * @returns the current material
  22539. */
  22540. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22541. /**
  22542. * Add a new block to the list of output nodes
  22543. * @param node defines the node to add
  22544. * @returns the current material
  22545. */
  22546. addOutputNode(node: NodeMaterialBlock): this;
  22547. /**
  22548. * Remove a block from the list of root nodes
  22549. * @param node defines the node to remove
  22550. * @returns the current material
  22551. */
  22552. removeOutputNode(node: NodeMaterialBlock): this;
  22553. private _addVertexOutputNode;
  22554. private _removeVertexOutputNode;
  22555. private _addFragmentOutputNode;
  22556. private _removeFragmentOutputNode;
  22557. /**
  22558. * Specifies if the material will require alpha blending
  22559. * @returns a boolean specifying if alpha blending is needed
  22560. */
  22561. needAlphaBlending(): boolean;
  22562. /**
  22563. * Specifies if this material should be rendered in alpha test mode
  22564. * @returns a boolean specifying if an alpha test is needed.
  22565. */
  22566. needAlphaTesting(): boolean;
  22567. private _initializeBlock;
  22568. private _resetDualBlocks;
  22569. /**
  22570. * Remove a block from the current node material
  22571. * @param block defines the block to remove
  22572. */
  22573. removeBlock(block: NodeMaterialBlock): void;
  22574. /**
  22575. * Build the material and generates the inner effect
  22576. * @param verbose defines if the build should log activity
  22577. */
  22578. build(verbose?: boolean): void;
  22579. /**
  22580. * Runs an otpimization phase to try to improve the shader code
  22581. */
  22582. optimize(): void;
  22583. private _prepareDefinesForAttributes;
  22584. /**
  22585. * Create a post process from the material
  22586. * @param camera The camera to apply the render pass to.
  22587. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22589. * @param engine The engine which the post process will be applied. (default: current engine)
  22590. * @param reusable If the post process can be reused on the same frame. (default: false)
  22591. * @param textureType Type of textures used when performing the post process. (default: 0)
  22592. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22593. * @returns the post process created
  22594. */
  22595. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22596. /**
  22597. * Create the post process effect from the material
  22598. * @param postProcess The post process to create the effect for
  22599. */
  22600. createEffectForPostProcess(postProcess: PostProcess): void;
  22601. private _createEffectForPostProcess;
  22602. /**
  22603. * Create a new procedural texture based on this node material
  22604. * @param size defines the size of the texture
  22605. * @param scene defines the hosting scene
  22606. * @returns the new procedural texture attached to this node material
  22607. */
  22608. createProceduralTexture(size: number | {
  22609. width: number;
  22610. height: number;
  22611. layers?: number;
  22612. }, scene: Scene): Nullable<ProceduralTexture>;
  22613. private _createEffectForParticles;
  22614. private _checkInternals;
  22615. /**
  22616. * Create the effect to be used as the custom effect for a particle system
  22617. * @param particleSystem Particle system to create the effect for
  22618. * @param onCompiled defines a function to call when the effect creation is successful
  22619. * @param onError defines a function to call when the effect creation has failed
  22620. */
  22621. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22622. private _processDefines;
  22623. /**
  22624. * Get if the submesh is ready to be used and all its information available.
  22625. * Child classes can use it to update shaders
  22626. * @param mesh defines the mesh to check
  22627. * @param subMesh defines which submesh to check
  22628. * @param useInstances specifies that instances should be used
  22629. * @returns a boolean indicating that the submesh is ready or not
  22630. */
  22631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22632. /**
  22633. * Get a string representing the shaders built by the current node graph
  22634. */
  22635. get compiledShaders(): string;
  22636. /**
  22637. * Binds the world matrix to the material
  22638. * @param world defines the world transformation matrix
  22639. */
  22640. bindOnlyWorldMatrix(world: Matrix): void;
  22641. /**
  22642. * Binds the submesh to this material by preparing the effect and shader to draw
  22643. * @param world defines the world transformation matrix
  22644. * @param mesh defines the mesh containing the submesh
  22645. * @param subMesh defines the submesh to bind the material to
  22646. */
  22647. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22648. /**
  22649. * Gets the active textures from the material
  22650. * @returns an array of textures
  22651. */
  22652. getActiveTextures(): BaseTexture[];
  22653. /**
  22654. * Gets the list of texture blocks
  22655. * @returns an array of texture blocks
  22656. */
  22657. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22658. /**
  22659. * Specifies if the material uses a texture
  22660. * @param texture defines the texture to check against the material
  22661. * @returns a boolean specifying if the material uses the texture
  22662. */
  22663. hasTexture(texture: BaseTexture): boolean;
  22664. /**
  22665. * Disposes the material
  22666. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22667. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22668. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22669. */
  22670. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22671. /** Creates the node editor window. */
  22672. private _createNodeEditor;
  22673. /**
  22674. * Launch the node material editor
  22675. * @param config Define the configuration of the editor
  22676. * @return a promise fulfilled when the node editor is visible
  22677. */
  22678. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22679. /**
  22680. * Clear the current material
  22681. */
  22682. clear(): void;
  22683. /**
  22684. * Clear the current material and set it to a default state
  22685. */
  22686. setToDefault(): void;
  22687. /**
  22688. * Clear the current material and set it to a default state for post process
  22689. */
  22690. setToDefaultPostProcess(): void;
  22691. /**
  22692. * Clear the current material and set it to a default state for procedural texture
  22693. */
  22694. setToDefaultProceduralTexture(): void;
  22695. /**
  22696. * Clear the current material and set it to a default state for particle
  22697. */
  22698. setToDefaultParticle(): void;
  22699. /**
  22700. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22701. * @param url defines the url to load from
  22702. * @returns a promise that will fullfil when the material is fully loaded
  22703. */
  22704. loadAsync(url: string): Promise<void>;
  22705. private _gatherBlocks;
  22706. /**
  22707. * Generate a string containing the code declaration required to create an equivalent of this material
  22708. * @returns a string
  22709. */
  22710. generateCode(): string;
  22711. /**
  22712. * Serializes this material in a JSON representation
  22713. * @returns the serialized material object
  22714. */
  22715. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22716. private _restoreConnections;
  22717. /**
  22718. * Clear the current graph and load a new one from a serialization object
  22719. * @param source defines the JSON representation of the material
  22720. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22721. * @param merge defines whether or not the source must be merged or replace the current content
  22722. */
  22723. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22724. /**
  22725. * Makes a duplicate of the current material.
  22726. * @param name - name to use for the new material.
  22727. */
  22728. clone(name: string): NodeMaterial;
  22729. /**
  22730. * Creates a node material from parsed material data
  22731. * @param source defines the JSON representation of the material
  22732. * @param scene defines the hosting scene
  22733. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22734. * @returns a new node material
  22735. */
  22736. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22737. /**
  22738. * Creates a node material from a snippet saved in a remote file
  22739. * @param name defines the name of the material to create
  22740. * @param url defines the url to load from
  22741. * @param scene defines the hosting scene
  22742. * @returns a promise that will resolve to the new node material
  22743. */
  22744. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22745. /**
  22746. * Creates a node material from a snippet saved by the node material editor
  22747. * @param snippetId defines the snippet to load
  22748. * @param scene defines the hosting scene
  22749. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22750. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22751. * @returns a promise that will resolve to the new node material
  22752. */
  22753. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22754. /**
  22755. * Creates a new node material set to default basic configuration
  22756. * @param name defines the name of the material
  22757. * @param scene defines the hosting scene
  22758. * @returns a new NodeMaterial
  22759. */
  22760. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22761. }
  22762. }
  22763. declare module BABYLON {
  22764. /**
  22765. * Size options for a post process
  22766. */
  22767. export type PostProcessOptions = {
  22768. width: number;
  22769. height: number;
  22770. };
  22771. /**
  22772. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22773. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22774. */
  22775. export class PostProcess {
  22776. /**
  22777. * Gets or sets the unique id of the post process
  22778. */
  22779. uniqueId: number;
  22780. /** Name of the PostProcess. */
  22781. name: string;
  22782. /**
  22783. * Width of the texture to apply the post process on
  22784. */
  22785. width: number;
  22786. /**
  22787. * Height of the texture to apply the post process on
  22788. */
  22789. height: number;
  22790. /**
  22791. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22792. */
  22793. nodeMaterialSource: Nullable<NodeMaterial>;
  22794. /**
  22795. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22796. * @hidden
  22797. */
  22798. _outputTexture: Nullable<InternalTexture>;
  22799. /**
  22800. * Sampling mode used by the shader
  22801. * See https://doc.babylonjs.com/classes/3.1/texture
  22802. */
  22803. renderTargetSamplingMode: number;
  22804. /**
  22805. * Clear color to use when screen clearing
  22806. */
  22807. clearColor: Color4;
  22808. /**
  22809. * If the buffer needs to be cleared before applying the post process. (default: true)
  22810. * Should be set to false if shader will overwrite all previous pixels.
  22811. */
  22812. autoClear: boolean;
  22813. /**
  22814. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22815. */
  22816. alphaMode: number;
  22817. /**
  22818. * Sets the setAlphaBlendConstants of the babylon engine
  22819. */
  22820. alphaConstants: Color4;
  22821. /**
  22822. * Animations to be used for the post processing
  22823. */
  22824. animations: Animation[];
  22825. /**
  22826. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22827. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22828. */
  22829. enablePixelPerfectMode: boolean;
  22830. /**
  22831. * Force the postprocess to be applied without taking in account viewport
  22832. */
  22833. forceFullscreenViewport: boolean;
  22834. /**
  22835. * List of inspectable custom properties (used by the Inspector)
  22836. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22837. */
  22838. inspectableCustomProperties: IInspectable[];
  22839. /**
  22840. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22841. *
  22842. * | Value | Type | Description |
  22843. * | ----- | ----------------------------------- | ----------- |
  22844. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22845. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22846. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22847. *
  22848. */
  22849. scaleMode: number;
  22850. /**
  22851. * Force textures to be a power of two (default: false)
  22852. */
  22853. alwaysForcePOT: boolean;
  22854. private _samples;
  22855. /**
  22856. * Number of sample textures (default: 1)
  22857. */
  22858. get samples(): number;
  22859. set samples(n: number);
  22860. /**
  22861. * Modify the scale of the post process to be the same as the viewport (default: false)
  22862. */
  22863. adaptScaleToCurrentViewport: boolean;
  22864. private _camera;
  22865. protected _scene: Scene;
  22866. private _engine;
  22867. private _options;
  22868. private _reusable;
  22869. private _textureType;
  22870. private _textureFormat;
  22871. /**
  22872. * Smart array of input and output textures for the post process.
  22873. * @hidden
  22874. */
  22875. _textures: SmartArray<InternalTexture>;
  22876. /**
  22877. * The index in _textures that corresponds to the output texture.
  22878. * @hidden
  22879. */
  22880. _currentRenderTextureInd: number;
  22881. private _effect;
  22882. private _samplers;
  22883. private _fragmentUrl;
  22884. private _vertexUrl;
  22885. private _parameters;
  22886. private _scaleRatio;
  22887. protected _indexParameters: any;
  22888. private _shareOutputWithPostProcess;
  22889. private _texelSize;
  22890. private _forcedOutputTexture;
  22891. /**
  22892. * Returns the fragment url or shader name used in the post process.
  22893. * @returns the fragment url or name in the shader store.
  22894. */
  22895. getEffectName(): string;
  22896. /**
  22897. * An event triggered when the postprocess is activated.
  22898. */
  22899. onActivateObservable: Observable<Camera>;
  22900. private _onActivateObserver;
  22901. /**
  22902. * A function that is added to the onActivateObservable
  22903. */
  22904. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22905. /**
  22906. * An event triggered when the postprocess changes its size.
  22907. */
  22908. onSizeChangedObservable: Observable<PostProcess>;
  22909. private _onSizeChangedObserver;
  22910. /**
  22911. * A function that is added to the onSizeChangedObservable
  22912. */
  22913. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22914. /**
  22915. * An event triggered when the postprocess applies its effect.
  22916. */
  22917. onApplyObservable: Observable<Effect>;
  22918. private _onApplyObserver;
  22919. /**
  22920. * A function that is added to the onApplyObservable
  22921. */
  22922. set onApply(callback: (effect: Effect) => void);
  22923. /**
  22924. * An event triggered before rendering the postprocess
  22925. */
  22926. onBeforeRenderObservable: Observable<Effect>;
  22927. private _onBeforeRenderObserver;
  22928. /**
  22929. * A function that is added to the onBeforeRenderObservable
  22930. */
  22931. set onBeforeRender(callback: (effect: Effect) => void);
  22932. /**
  22933. * An event triggered after rendering the postprocess
  22934. */
  22935. onAfterRenderObservable: Observable<Effect>;
  22936. private _onAfterRenderObserver;
  22937. /**
  22938. * A function that is added to the onAfterRenderObservable
  22939. */
  22940. set onAfterRender(callback: (efect: Effect) => void);
  22941. /**
  22942. * 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
  22943. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22944. */
  22945. get inputTexture(): InternalTexture;
  22946. set inputTexture(value: InternalTexture);
  22947. /**
  22948. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22949. * the only way to unset it is to use this function to restore its internal state
  22950. */
  22951. restoreDefaultInputTexture(): void;
  22952. /**
  22953. * Gets the camera which post process is applied to.
  22954. * @returns The camera the post process is applied to.
  22955. */
  22956. getCamera(): Camera;
  22957. /**
  22958. * Gets the texel size of the postprocess.
  22959. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22960. */
  22961. get texelSize(): Vector2;
  22962. /**
  22963. * Creates a new instance PostProcess
  22964. * @param name The name of the PostProcess.
  22965. * @param fragmentUrl The url of the fragment shader to be used.
  22966. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22967. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22968. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22969. * @param camera The camera to apply the render pass to.
  22970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22971. * @param engine The engine which the post process will be applied. (default: current engine)
  22972. * @param reusable If the post process can be reused on the same frame. (default: false)
  22973. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22974. * @param textureType Type of textures used when performing the post process. (default: 0)
  22975. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22976. * @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
  22977. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22978. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22979. */
  22980. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22981. /**
  22982. * Gets a string identifying the name of the class
  22983. * @returns "PostProcess" string
  22984. */
  22985. getClassName(): string;
  22986. /**
  22987. * Gets the engine which this post process belongs to.
  22988. * @returns The engine the post process was enabled with.
  22989. */
  22990. getEngine(): Engine;
  22991. /**
  22992. * The effect that is created when initializing the post process.
  22993. * @returns The created effect corresponding the the postprocess.
  22994. */
  22995. getEffect(): Effect;
  22996. /**
  22997. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22998. * @param postProcess The post process to share the output with.
  22999. * @returns This post process.
  23000. */
  23001. shareOutputWith(postProcess: PostProcess): PostProcess;
  23002. /**
  23003. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23004. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23005. */
  23006. useOwnOutput(): void;
  23007. /**
  23008. * Updates the effect with the current post process compile time values and recompiles the shader.
  23009. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23010. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23011. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23012. * @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
  23013. * @param onCompiled Called when the shader has been compiled.
  23014. * @param onError Called if there is an error when compiling a shader.
  23015. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23016. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23017. */
  23018. 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;
  23019. /**
  23020. * The post process is reusable if it can be used multiple times within one frame.
  23021. * @returns If the post process is reusable
  23022. */
  23023. isReusable(): boolean;
  23024. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23025. markTextureDirty(): void;
  23026. /**
  23027. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23028. * 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.
  23029. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23030. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23031. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23032. * @returns The target texture that was bound to be written to.
  23033. */
  23034. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23035. /**
  23036. * If the post process is supported.
  23037. */
  23038. get isSupported(): boolean;
  23039. /**
  23040. * The aspect ratio of the output texture.
  23041. */
  23042. get aspectRatio(): number;
  23043. /**
  23044. * Get a value indicating if the post-process is ready to be used
  23045. * @returns true if the post-process is ready (shader is compiled)
  23046. */
  23047. isReady(): boolean;
  23048. /**
  23049. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23050. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23051. */
  23052. apply(): Nullable<Effect>;
  23053. private _disposeTextures;
  23054. /**
  23055. * Disposes the post process.
  23056. * @param camera The camera to dispose the post process on.
  23057. */
  23058. dispose(camera?: Camera): void;
  23059. /**
  23060. * Serializes the particle system to a JSON object
  23061. * @returns the JSON object
  23062. */
  23063. serialize(): any;
  23064. /**
  23065. * Creates a material from parsed material data
  23066. * @param parsedPostProcess defines parsed post process data
  23067. * @param scene defines the hosting scene
  23068. * @param rootUrl defines the root URL to use to load textures
  23069. * @returns a new post process
  23070. */
  23071. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23072. }
  23073. }
  23074. declare module BABYLON {
  23075. /** @hidden */
  23076. export var kernelBlurVaryingDeclaration: {
  23077. name: string;
  23078. shader: string;
  23079. };
  23080. }
  23081. declare module BABYLON {
  23082. /** @hidden */
  23083. export var kernelBlurFragment: {
  23084. name: string;
  23085. shader: string;
  23086. };
  23087. }
  23088. declare module BABYLON {
  23089. /** @hidden */
  23090. export var kernelBlurFragment2: {
  23091. name: string;
  23092. shader: string;
  23093. };
  23094. }
  23095. declare module BABYLON {
  23096. /** @hidden */
  23097. export var kernelBlurPixelShader: {
  23098. name: string;
  23099. shader: string;
  23100. };
  23101. }
  23102. declare module BABYLON {
  23103. /** @hidden */
  23104. export var kernelBlurVertex: {
  23105. name: string;
  23106. shader: string;
  23107. };
  23108. }
  23109. declare module BABYLON {
  23110. /** @hidden */
  23111. export var kernelBlurVertexShader: {
  23112. name: string;
  23113. shader: string;
  23114. };
  23115. }
  23116. declare module BABYLON {
  23117. /**
  23118. * The Blur Post Process which blurs an image based on a kernel and direction.
  23119. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23120. */
  23121. export class BlurPostProcess extends PostProcess {
  23122. private blockCompilation;
  23123. protected _kernel: number;
  23124. protected _idealKernel: number;
  23125. protected _packedFloat: boolean;
  23126. private _staticDefines;
  23127. /** The direction in which to blur the image. */
  23128. direction: Vector2;
  23129. /**
  23130. * Sets the length in pixels of the blur sample region
  23131. */
  23132. set kernel(v: number);
  23133. /**
  23134. * Gets the length in pixels of the blur sample region
  23135. */
  23136. get kernel(): number;
  23137. /**
  23138. * Sets wether or not the blur needs to unpack/repack floats
  23139. */
  23140. set packedFloat(v: boolean);
  23141. /**
  23142. * Gets wether or not the blur is unpacking/repacking floats
  23143. */
  23144. get packedFloat(): boolean;
  23145. /**
  23146. * Gets a string identifying the name of the class
  23147. * @returns "BlurPostProcess" string
  23148. */
  23149. getClassName(): string;
  23150. /**
  23151. * Creates a new instance BlurPostProcess
  23152. * @param name The name of the effect.
  23153. * @param direction The direction in which to blur the image.
  23154. * @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.
  23155. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23156. * @param camera The camera to apply the render pass to.
  23157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23158. * @param engine The engine which the post process will be applied. (default: current engine)
  23159. * @param reusable If the post process can be reused on the same frame. (default: false)
  23160. * @param textureType Type of textures used when performing the post process. (default: 0)
  23161. * @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)
  23162. */
  23163. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23164. /**
  23165. * Updates the effect with the current post process compile time values and recompiles the shader.
  23166. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23167. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23168. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23169. * @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
  23170. * @param onCompiled Called when the shader has been compiled.
  23171. * @param onError Called if there is an error when compiling a shader.
  23172. */
  23173. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23174. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23175. /**
  23176. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23177. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23178. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23179. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23180. * The gaps between physical kernels are compensated for in the weighting of the samples
  23181. * @param idealKernel Ideal blur kernel.
  23182. * @return Nearest best kernel.
  23183. */
  23184. protected _nearestBestKernel(idealKernel: number): number;
  23185. /**
  23186. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23187. * @param x The point on the Gaussian distribution to sample.
  23188. * @return the value of the Gaussian function at x.
  23189. */
  23190. protected _gaussianWeight(x: number): number;
  23191. /**
  23192. * Generates a string that can be used as a floating point number in GLSL.
  23193. * @param x Value to print.
  23194. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23195. * @return GLSL float string.
  23196. */
  23197. protected _glslFloat(x: number, decimalFigures?: number): string;
  23198. /** @hidden */
  23199. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23200. }
  23201. }
  23202. declare module BABYLON {
  23203. /**
  23204. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23205. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23206. * You can then easily use it as a reflectionTexture on a flat surface.
  23207. * In case the surface is not a plane, please consider relying on reflection probes.
  23208. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23209. */
  23210. export class MirrorTexture extends RenderTargetTexture {
  23211. private scene;
  23212. /**
  23213. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23214. * 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.
  23215. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23216. */
  23217. mirrorPlane: Plane;
  23218. /**
  23219. * Define the blur ratio used to blur the reflection if needed.
  23220. */
  23221. set blurRatio(value: number);
  23222. get blurRatio(): number;
  23223. /**
  23224. * Define the adaptive blur kernel used to blur the reflection if needed.
  23225. * This will autocompute the closest best match for the `blurKernel`
  23226. */
  23227. set adaptiveBlurKernel(value: number);
  23228. /**
  23229. * Define the blur kernel used to blur the reflection if needed.
  23230. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23231. */
  23232. set blurKernel(value: number);
  23233. /**
  23234. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23235. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23236. */
  23237. set blurKernelX(value: number);
  23238. get blurKernelX(): number;
  23239. /**
  23240. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23241. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23242. */
  23243. set blurKernelY(value: number);
  23244. get blurKernelY(): number;
  23245. private _autoComputeBlurKernel;
  23246. protected _onRatioRescale(): void;
  23247. private _updateGammaSpace;
  23248. private _imageProcessingConfigChangeObserver;
  23249. private _transformMatrix;
  23250. private _mirrorMatrix;
  23251. private _savedViewMatrix;
  23252. private _blurX;
  23253. private _blurY;
  23254. private _adaptiveBlurKernel;
  23255. private _blurKernelX;
  23256. private _blurKernelY;
  23257. private _blurRatio;
  23258. /**
  23259. * Instantiates a Mirror Texture.
  23260. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23261. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23262. * You can then easily use it as a reflectionTexture on a flat surface.
  23263. * In case the surface is not a plane, please consider relying on reflection probes.
  23264. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23265. * @param name
  23266. * @param size
  23267. * @param scene
  23268. * @param generateMipMaps
  23269. * @param type
  23270. * @param samplingMode
  23271. * @param generateDepthBuffer
  23272. */
  23273. constructor(name: string, size: number | {
  23274. width: number;
  23275. height: number;
  23276. } | {
  23277. ratio: number;
  23278. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23279. private _preparePostProcesses;
  23280. /**
  23281. * Clone the mirror texture.
  23282. * @returns the cloned texture
  23283. */
  23284. clone(): MirrorTexture;
  23285. /**
  23286. * Serialize the texture to a JSON representation you could use in Parse later on
  23287. * @returns the serialized JSON representation
  23288. */
  23289. serialize(): any;
  23290. /**
  23291. * Dispose the texture and release its associated resources.
  23292. */
  23293. dispose(): void;
  23294. }
  23295. }
  23296. declare module BABYLON {
  23297. /**
  23298. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23299. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23300. */
  23301. export class Texture extends BaseTexture {
  23302. /**
  23303. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23304. */
  23305. static SerializeBuffers: boolean;
  23306. /** @hidden */
  23307. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23308. /** @hidden */
  23309. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23310. /** @hidden */
  23311. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23312. /** nearest is mag = nearest and min = nearest and mip = linear */
  23313. static readonly NEAREST_SAMPLINGMODE: number;
  23314. /** nearest is mag = nearest and min = nearest and mip = linear */
  23315. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23316. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23317. static readonly BILINEAR_SAMPLINGMODE: number;
  23318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23319. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23320. /** Trilinear is mag = linear and min = linear and mip = linear */
  23321. static readonly TRILINEAR_SAMPLINGMODE: number;
  23322. /** Trilinear is mag = linear and min = linear and mip = linear */
  23323. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23324. /** mag = nearest and min = nearest and mip = nearest */
  23325. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23326. /** mag = nearest and min = linear and mip = nearest */
  23327. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23328. /** mag = nearest and min = linear and mip = linear */
  23329. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23330. /** mag = nearest and min = linear and mip = none */
  23331. static readonly NEAREST_LINEAR: number;
  23332. /** mag = nearest and min = nearest and mip = none */
  23333. static readonly NEAREST_NEAREST: number;
  23334. /** mag = linear and min = nearest and mip = nearest */
  23335. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23336. /** mag = linear and min = nearest and mip = linear */
  23337. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23338. /** mag = linear and min = linear and mip = none */
  23339. static readonly LINEAR_LINEAR: number;
  23340. /** mag = linear and min = nearest and mip = none */
  23341. static readonly LINEAR_NEAREST: number;
  23342. /** Explicit coordinates mode */
  23343. static readonly EXPLICIT_MODE: number;
  23344. /** Spherical coordinates mode */
  23345. static readonly SPHERICAL_MODE: number;
  23346. /** Planar coordinates mode */
  23347. static readonly PLANAR_MODE: number;
  23348. /** Cubic coordinates mode */
  23349. static readonly CUBIC_MODE: number;
  23350. /** Projection coordinates mode */
  23351. static readonly PROJECTION_MODE: number;
  23352. /** Inverse Cubic coordinates mode */
  23353. static readonly SKYBOX_MODE: number;
  23354. /** Inverse Cubic coordinates mode */
  23355. static readonly INVCUBIC_MODE: number;
  23356. /** Equirectangular coordinates mode */
  23357. static readonly EQUIRECTANGULAR_MODE: number;
  23358. /** Equirectangular Fixed coordinates mode */
  23359. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23360. /** Equirectangular Fixed Mirrored coordinates mode */
  23361. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23362. /** Texture is not repeating outside of 0..1 UVs */
  23363. static readonly CLAMP_ADDRESSMODE: number;
  23364. /** Texture is repeating outside of 0..1 UVs */
  23365. static readonly WRAP_ADDRESSMODE: number;
  23366. /** Texture is repeating and mirrored */
  23367. static readonly MIRROR_ADDRESSMODE: number;
  23368. /**
  23369. * 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
  23370. */
  23371. static UseSerializedUrlIfAny: boolean;
  23372. /**
  23373. * Define the url of the texture.
  23374. */
  23375. url: Nullable<string>;
  23376. /**
  23377. * Define an offset on the texture to offset the u coordinates of the UVs
  23378. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23379. */
  23380. uOffset: number;
  23381. /**
  23382. * Define an offset on the texture to offset the v coordinates of the UVs
  23383. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23384. */
  23385. vOffset: number;
  23386. /**
  23387. * Define an offset on the texture to scale the u coordinates of the UVs
  23388. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23389. */
  23390. uScale: number;
  23391. /**
  23392. * Define an offset on the texture to scale the v coordinates of the UVs
  23393. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23394. */
  23395. vScale: number;
  23396. /**
  23397. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23398. * @see https://doc.babylonjs.com/how_to/more_materials
  23399. */
  23400. uAng: number;
  23401. /**
  23402. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23403. * @see https://doc.babylonjs.com/how_to/more_materials
  23404. */
  23405. vAng: number;
  23406. /**
  23407. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23408. * @see https://doc.babylonjs.com/how_to/more_materials
  23409. */
  23410. wAng: number;
  23411. /**
  23412. * Defines the center of rotation (U)
  23413. */
  23414. uRotationCenter: number;
  23415. /**
  23416. * Defines the center of rotation (V)
  23417. */
  23418. vRotationCenter: number;
  23419. /**
  23420. * Defines the center of rotation (W)
  23421. */
  23422. wRotationCenter: number;
  23423. /**
  23424. * Are mip maps generated for this texture or not.
  23425. */
  23426. get noMipmap(): boolean;
  23427. /**
  23428. * List of inspectable custom properties (used by the Inspector)
  23429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23430. */
  23431. inspectableCustomProperties: Nullable<IInspectable[]>;
  23432. private _noMipmap;
  23433. /** @hidden */
  23434. _invertY: boolean;
  23435. private _rowGenerationMatrix;
  23436. private _cachedTextureMatrix;
  23437. private _projectionModeMatrix;
  23438. private _t0;
  23439. private _t1;
  23440. private _t2;
  23441. private _cachedUOffset;
  23442. private _cachedVOffset;
  23443. private _cachedUScale;
  23444. private _cachedVScale;
  23445. private _cachedUAng;
  23446. private _cachedVAng;
  23447. private _cachedWAng;
  23448. private _cachedProjectionMatrixId;
  23449. private _cachedCoordinatesMode;
  23450. /** @hidden */
  23451. protected _initialSamplingMode: number;
  23452. /** @hidden */
  23453. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23454. private _deleteBuffer;
  23455. protected _format: Nullable<number>;
  23456. private _delayedOnLoad;
  23457. private _delayedOnError;
  23458. private _mimeType?;
  23459. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23460. get mimeType(): string | undefined;
  23461. /**
  23462. * Observable triggered once the texture has been loaded.
  23463. */
  23464. onLoadObservable: Observable<Texture>;
  23465. protected _isBlocking: boolean;
  23466. /**
  23467. * Is the texture preventing material to render while loading.
  23468. * If false, a default texture will be used instead of the loading one during the preparation step.
  23469. */
  23470. set isBlocking(value: boolean);
  23471. get isBlocking(): boolean;
  23472. /**
  23473. * Get the current sampling mode associated with the texture.
  23474. */
  23475. get samplingMode(): number;
  23476. /**
  23477. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23478. */
  23479. get invertY(): boolean;
  23480. /**
  23481. * Instantiates a new texture.
  23482. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23483. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23484. * @param url defines the url of the picture to load as a texture
  23485. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23486. * @param noMipmap defines if the texture will require mip maps or not
  23487. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23488. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23489. * @param onLoad defines a callback triggered when the texture has been loaded
  23490. * @param onError defines a callback triggered when an error occurred during the loading session
  23491. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23492. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23493. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23494. * @param mimeType defines an optional mime type information
  23495. */
  23496. 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);
  23497. /**
  23498. * Update the url (and optional buffer) of this texture if url was null during construction.
  23499. * @param url the url of the texture
  23500. * @param buffer the buffer of the texture (defaults to null)
  23501. * @param onLoad callback called when the texture is loaded (defaults to null)
  23502. */
  23503. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23504. /**
  23505. * Finish the loading sequence of a texture flagged as delayed load.
  23506. * @hidden
  23507. */
  23508. delayLoad(): void;
  23509. private _prepareRowForTextureGeneration;
  23510. /**
  23511. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23512. * @returns the transform matrix of the texture.
  23513. */
  23514. getTextureMatrix(uBase?: number): Matrix;
  23515. /**
  23516. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23517. * @returns The reflection texture transform
  23518. */
  23519. getReflectionTextureMatrix(): Matrix;
  23520. /**
  23521. * Clones the texture.
  23522. * @returns the cloned texture
  23523. */
  23524. clone(): Texture;
  23525. /**
  23526. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23527. * @returns The JSON representation of the texture
  23528. */
  23529. serialize(): any;
  23530. /**
  23531. * Get the current class name of the texture useful for serialization or dynamic coding.
  23532. * @returns "Texture"
  23533. */
  23534. getClassName(): string;
  23535. /**
  23536. * Dispose the texture and release its associated resources.
  23537. */
  23538. dispose(): void;
  23539. /**
  23540. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23541. * @param parsedTexture Define the JSON representation of the texture
  23542. * @param scene Define the scene the parsed texture should be instantiated in
  23543. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23544. * @returns The parsed texture if successful
  23545. */
  23546. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23547. /**
  23548. * Creates a texture from its base 64 representation.
  23549. * @param data Define the base64 payload without the data: prefix
  23550. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23551. * @param scene Define the scene the texture should belong to
  23552. * @param noMipmap Forces the texture to not create mip map information if true
  23553. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23554. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23555. * @param onLoad define a callback triggered when the texture has been loaded
  23556. * @param onError define a callback triggered when an error occurred during the loading session
  23557. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23558. * @returns the created texture
  23559. */
  23560. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23561. /**
  23562. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23563. * @param data Define the base64 payload without the data: prefix
  23564. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23565. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23566. * @param scene Define the scene the texture should belong to
  23567. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23568. * @param noMipmap Forces the texture to not create mip map information if true
  23569. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23570. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23571. * @param onLoad define a callback triggered when the texture has been loaded
  23572. * @param onError define a callback triggered when an error occurred during the loading session
  23573. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23574. * @returns the created texture
  23575. */
  23576. 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;
  23577. }
  23578. }
  23579. declare module BABYLON {
  23580. /**
  23581. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23582. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23583. */
  23584. export class PostProcessManager {
  23585. private _scene;
  23586. private _indexBuffer;
  23587. private _vertexBuffers;
  23588. /**
  23589. * Creates a new instance PostProcess
  23590. * @param scene The scene that the post process is associated with.
  23591. */
  23592. constructor(scene: Scene);
  23593. private _prepareBuffers;
  23594. private _buildIndexBuffer;
  23595. /**
  23596. * Rebuilds the vertex buffers of the manager.
  23597. * @hidden
  23598. */
  23599. _rebuild(): void;
  23600. /**
  23601. * Prepares a frame to be run through a post process.
  23602. * @param sourceTexture The input texture to the post procesess. (default: null)
  23603. * @param postProcesses An array of post processes to be run. (default: null)
  23604. * @returns True if the post processes were able to be run.
  23605. * @hidden
  23606. */
  23607. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23608. /**
  23609. * Manually render a set of post processes to a texture.
  23610. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23611. * @param postProcesses An array of post processes to be run.
  23612. * @param targetTexture The target texture to render to.
  23613. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23614. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23615. * @param lodLevel defines which lod of the texture to render to
  23616. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23617. */
  23618. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23619. /**
  23620. * Finalize the result of the output of the postprocesses.
  23621. * @param doNotPresent If true the result will not be displayed to the screen.
  23622. * @param targetTexture The target texture to render to.
  23623. * @param faceIndex The index of the face to bind the target texture to.
  23624. * @param postProcesses The array of post processes to render.
  23625. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23626. * @hidden
  23627. */
  23628. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23629. /**
  23630. * Disposes of the post process manager.
  23631. */
  23632. dispose(): void;
  23633. }
  23634. }
  23635. declare module BABYLON {
  23636. /**
  23637. * This Helps creating a texture that will be created from a camera in your scene.
  23638. * It is basically a dynamic texture that could be used to create special effects for instance.
  23639. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23640. */
  23641. export class RenderTargetTexture extends Texture {
  23642. /**
  23643. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23644. */
  23645. static readonly REFRESHRATE_RENDER_ONCE: number;
  23646. /**
  23647. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23648. */
  23649. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23650. /**
  23651. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23652. * the central point of your effect and can save a lot of performances.
  23653. */
  23654. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23655. /**
  23656. * Use this predicate to dynamically define the list of mesh you want to render.
  23657. * If set, the renderList property will be overwritten.
  23658. */
  23659. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23660. private _renderList;
  23661. /**
  23662. * Use this list to define the list of mesh you want to render.
  23663. */
  23664. get renderList(): Nullable<Array<AbstractMesh>>;
  23665. set renderList(value: Nullable<Array<AbstractMesh>>);
  23666. /**
  23667. * Use this function to overload the renderList array at rendering time.
  23668. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23669. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23670. * the cube (if the RTT is a cube, else layerOrFace=0).
  23671. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23672. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23673. * hold dummy elements!
  23674. */
  23675. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23676. private _hookArray;
  23677. /**
  23678. * Define if particles should be rendered in your texture.
  23679. */
  23680. renderParticles: boolean;
  23681. /**
  23682. * Define if sprites should be rendered in your texture.
  23683. */
  23684. renderSprites: boolean;
  23685. /**
  23686. * Define the camera used to render the texture.
  23687. */
  23688. activeCamera: Nullable<Camera>;
  23689. /**
  23690. * Override the mesh isReady function with your own one.
  23691. */
  23692. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23693. /**
  23694. * Override the render function of the texture with your own one.
  23695. */
  23696. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23697. /**
  23698. * Define if camera post processes should be use while rendering the texture.
  23699. */
  23700. useCameraPostProcesses: boolean;
  23701. /**
  23702. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23703. */
  23704. ignoreCameraViewport: boolean;
  23705. private _postProcessManager;
  23706. private _postProcesses;
  23707. private _resizeObserver;
  23708. /**
  23709. * An event triggered when the texture is unbind.
  23710. */
  23711. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23712. /**
  23713. * An event triggered when the texture is unbind.
  23714. */
  23715. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23716. private _onAfterUnbindObserver;
  23717. /**
  23718. * Set a after unbind callback in the texture.
  23719. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23720. */
  23721. set onAfterUnbind(callback: () => void);
  23722. /**
  23723. * An event triggered before rendering the texture
  23724. */
  23725. onBeforeRenderObservable: Observable<number>;
  23726. private _onBeforeRenderObserver;
  23727. /**
  23728. * Set a before render callback in the texture.
  23729. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23730. */
  23731. set onBeforeRender(callback: (faceIndex: number) => void);
  23732. /**
  23733. * An event triggered after rendering the texture
  23734. */
  23735. onAfterRenderObservable: Observable<number>;
  23736. private _onAfterRenderObserver;
  23737. /**
  23738. * Set a after render callback in the texture.
  23739. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23740. */
  23741. set onAfterRender(callback: (faceIndex: number) => void);
  23742. /**
  23743. * An event triggered after the texture clear
  23744. */
  23745. onClearObservable: Observable<Engine>;
  23746. private _onClearObserver;
  23747. /**
  23748. * Set a clear callback in the texture.
  23749. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23750. */
  23751. set onClear(callback: (Engine: Engine) => void);
  23752. /**
  23753. * An event triggered when the texture is resized.
  23754. */
  23755. onResizeObservable: Observable<RenderTargetTexture>;
  23756. /**
  23757. * Define the clear color of the Render Target if it should be different from the scene.
  23758. */
  23759. clearColor: Color4;
  23760. protected _size: number | {
  23761. width: number;
  23762. height: number;
  23763. layers?: number;
  23764. };
  23765. protected _initialSizeParameter: number | {
  23766. width: number;
  23767. height: number;
  23768. } | {
  23769. ratio: number;
  23770. };
  23771. protected _sizeRatio: Nullable<number>;
  23772. /** @hidden */
  23773. _generateMipMaps: boolean;
  23774. protected _renderingManager: RenderingManager;
  23775. /** @hidden */
  23776. _waitingRenderList?: string[];
  23777. protected _doNotChangeAspectRatio: boolean;
  23778. protected _currentRefreshId: number;
  23779. protected _refreshRate: number;
  23780. protected _textureMatrix: Matrix;
  23781. protected _samples: number;
  23782. protected _renderTargetOptions: RenderTargetCreationOptions;
  23783. /**
  23784. * Gets render target creation options that were used.
  23785. */
  23786. get renderTargetOptions(): RenderTargetCreationOptions;
  23787. protected _onRatioRescale(): void;
  23788. /**
  23789. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23790. * It must define where the camera used to render the texture is set
  23791. */
  23792. boundingBoxPosition: Vector3;
  23793. private _boundingBoxSize;
  23794. /**
  23795. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23796. * When defined, the cubemap will switch to local mode
  23797. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23798. * @example https://www.babylonjs-playground.com/#RNASML
  23799. */
  23800. set boundingBoxSize(value: Vector3);
  23801. get boundingBoxSize(): Vector3;
  23802. /**
  23803. * In case the RTT has been created with a depth texture, get the associated
  23804. * depth texture.
  23805. * Otherwise, return null.
  23806. */
  23807. get depthStencilTexture(): Nullable<InternalTexture>;
  23808. /**
  23809. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23810. * or used a shadow, depth texture...
  23811. * @param name The friendly name of the texture
  23812. * @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)
  23813. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23814. * @param generateMipMaps True if mip maps need to be generated after render.
  23815. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23816. * @param type The type of the buffer in the RTT (int, half float, float...)
  23817. * @param isCube True if a cube texture needs to be created
  23818. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23819. * @param generateDepthBuffer True to generate a depth buffer
  23820. * @param generateStencilBuffer True to generate a stencil buffer
  23821. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23822. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23823. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23824. */
  23825. constructor(name: string, size: number | {
  23826. width: number;
  23827. height: number;
  23828. layers?: number;
  23829. } | {
  23830. ratio: number;
  23831. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23832. /**
  23833. * Creates a depth stencil texture.
  23834. * This is only available in WebGL 2 or with the depth texture extension available.
  23835. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23836. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23837. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23838. */
  23839. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23840. private _processSizeParameter;
  23841. /**
  23842. * Define the number of samples to use in case of MSAA.
  23843. * It defaults to one meaning no MSAA has been enabled.
  23844. */
  23845. get samples(): number;
  23846. set samples(value: number);
  23847. /**
  23848. * Resets the refresh counter of the texture and start bak from scratch.
  23849. * Could be useful to regenerate the texture if it is setup to render only once.
  23850. */
  23851. resetRefreshCounter(): void;
  23852. /**
  23853. * Define the refresh rate of the texture or the rendering frequency.
  23854. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23855. */
  23856. get refreshRate(): number;
  23857. set refreshRate(value: number);
  23858. /**
  23859. * Adds a post process to the render target rendering passes.
  23860. * @param postProcess define the post process to add
  23861. */
  23862. addPostProcess(postProcess: PostProcess): void;
  23863. /**
  23864. * Clear all the post processes attached to the render target
  23865. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23866. */
  23867. clearPostProcesses(dispose?: boolean): void;
  23868. /**
  23869. * Remove one of the post process from the list of attached post processes to the texture
  23870. * @param postProcess define the post process to remove from the list
  23871. */
  23872. removePostProcess(postProcess: PostProcess): void;
  23873. /** @hidden */
  23874. _shouldRender(): boolean;
  23875. /**
  23876. * Gets the actual render size of the texture.
  23877. * @returns the width of the render size
  23878. */
  23879. getRenderSize(): number;
  23880. /**
  23881. * Gets the actual render width of the texture.
  23882. * @returns the width of the render size
  23883. */
  23884. getRenderWidth(): number;
  23885. /**
  23886. * Gets the actual render height of the texture.
  23887. * @returns the height of the render size
  23888. */
  23889. getRenderHeight(): number;
  23890. /**
  23891. * Gets the actual number of layers of the texture.
  23892. * @returns the number of layers
  23893. */
  23894. getRenderLayers(): number;
  23895. /**
  23896. * Get if the texture can be rescaled or not.
  23897. */
  23898. get canRescale(): boolean;
  23899. /**
  23900. * Resize the texture using a ratio.
  23901. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23902. */
  23903. scale(ratio: number): void;
  23904. /**
  23905. * Get the texture reflection matrix used to rotate/transform the reflection.
  23906. * @returns the reflection matrix
  23907. */
  23908. getReflectionTextureMatrix(): Matrix;
  23909. /**
  23910. * Resize the texture to a new desired size.
  23911. * Be carrefull as it will recreate all the data in the new texture.
  23912. * @param size Define the new size. It can be:
  23913. * - a number for squared texture,
  23914. * - an object containing { width: number, height: number }
  23915. * - or an object containing a ratio { ratio: number }
  23916. */
  23917. resize(size: number | {
  23918. width: number;
  23919. height: number;
  23920. } | {
  23921. ratio: number;
  23922. }): void;
  23923. private _defaultRenderListPrepared;
  23924. /**
  23925. * Renders all the objects from the render list into the texture.
  23926. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23927. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23928. */
  23929. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23930. private _bestReflectionRenderTargetDimension;
  23931. private _prepareRenderingManager;
  23932. /**
  23933. * @hidden
  23934. * @param faceIndex face index to bind to if this is a cubetexture
  23935. * @param layer defines the index of the texture to bind in the array
  23936. */
  23937. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23938. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23939. private renderToTarget;
  23940. /**
  23941. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23942. * This allowed control for front to back rendering or reversly depending of the special needs.
  23943. *
  23944. * @param renderingGroupId The rendering group id corresponding to its index
  23945. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23946. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23947. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23948. */
  23949. 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;
  23950. /**
  23951. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23952. *
  23953. * @param renderingGroupId The rendering group id corresponding to its index
  23954. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23955. */
  23956. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23957. /**
  23958. * Clones the texture.
  23959. * @returns the cloned texture
  23960. */
  23961. clone(): RenderTargetTexture;
  23962. /**
  23963. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23964. * @returns The JSON representation of the texture
  23965. */
  23966. serialize(): any;
  23967. /**
  23968. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23969. */
  23970. disposeFramebufferObjects(): void;
  23971. /**
  23972. * Dispose the texture and release its associated resources.
  23973. */
  23974. dispose(): void;
  23975. /** @hidden */
  23976. _rebuild(): void;
  23977. /**
  23978. * Clear the info related to rendering groups preventing retention point in material dispose.
  23979. */
  23980. freeRenderingGroups(): void;
  23981. /**
  23982. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23983. * @returns the view count
  23984. */
  23985. getViewCount(): number;
  23986. }
  23987. }
  23988. declare module BABYLON {
  23989. /**
  23990. * Class used to manipulate GUIDs
  23991. */
  23992. export class GUID {
  23993. /**
  23994. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23995. * Be aware Math.random() could cause collisions, but:
  23996. * "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"
  23997. * @returns a pseudo random id
  23998. */
  23999. static RandomId(): string;
  24000. }
  24001. }
  24002. declare module BABYLON {
  24003. /**
  24004. * Options to be used when creating a shadow depth material
  24005. */
  24006. export interface IIOptionShadowDepthMaterial {
  24007. /** Variables in the vertex shader code that need to have their names remapped.
  24008. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24009. * "var_name" should be either: worldPos or vNormalW
  24010. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24011. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24012. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24013. */
  24014. remappedVariables?: string[];
  24015. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24016. standalone?: boolean;
  24017. }
  24018. /**
  24019. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24020. */
  24021. export class ShadowDepthWrapper {
  24022. private _scene;
  24023. private _options?;
  24024. private _baseMaterial;
  24025. private _onEffectCreatedObserver;
  24026. private _subMeshToEffect;
  24027. private _subMeshToDepthEffect;
  24028. private _meshes;
  24029. /** @hidden */
  24030. _matriceNames: any;
  24031. /** Gets the standalone status of the wrapper */
  24032. get standalone(): boolean;
  24033. /** Gets the base material the wrapper is built upon */
  24034. get baseMaterial(): Material;
  24035. /**
  24036. * Instantiate a new shadow depth wrapper.
  24037. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24038. * generate the shadow depth map. For more information, please refer to the documentation:
  24039. * https://doc.babylonjs.com/babylon101/shadows
  24040. * @param baseMaterial Material to wrap
  24041. * @param scene Define the scene the material belongs to
  24042. * @param options Options used to create the wrapper
  24043. */
  24044. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24045. /**
  24046. * Gets the effect to use to generate the depth map
  24047. * @param subMesh subMesh to get the effect for
  24048. * @param shadowGenerator shadow generator to get the effect for
  24049. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24050. */
  24051. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24052. /**
  24053. * Specifies that the submesh is ready to be used for depth rendering
  24054. * @param subMesh submesh to check
  24055. * @param defines the list of defines to take into account when checking the effect
  24056. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24057. * @param useInstances specifies that instances should be used
  24058. * @returns a boolean indicating that the submesh is ready or not
  24059. */
  24060. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24061. /**
  24062. * Disposes the resources
  24063. */
  24064. dispose(): void;
  24065. private _makeEffect;
  24066. }
  24067. }
  24068. declare module BABYLON {
  24069. interface ThinEngine {
  24070. /**
  24071. * Unbind a list of render target textures from the webGL context
  24072. * This is used only when drawBuffer extension or webGL2 are active
  24073. * @param textures defines the render target textures to unbind
  24074. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24075. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24076. */
  24077. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24078. /**
  24079. * Create a multi render target texture
  24080. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24081. * @param size defines the size of the texture
  24082. * @param options defines the creation options
  24083. * @returns the cube texture as an InternalTexture
  24084. */
  24085. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24086. /**
  24087. * Update the sample count for a given multiple render target texture
  24088. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24089. * @param textures defines the textures to update
  24090. * @param samples defines the sample count to set
  24091. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24092. */
  24093. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24094. /**
  24095. * Select a subsets of attachments to draw to.
  24096. * @param attachments gl attachments
  24097. */
  24098. bindAttachments(attachments: number[]): void;
  24099. }
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * Creation options of the multi render target texture.
  24104. */
  24105. export interface IMultiRenderTargetOptions {
  24106. /**
  24107. * Define if the texture needs to create mip maps after render.
  24108. */
  24109. generateMipMaps?: boolean;
  24110. /**
  24111. * Define the types of all the draw buffers we want to create
  24112. */
  24113. types?: number[];
  24114. /**
  24115. * Define the sampling modes of all the draw buffers we want to create
  24116. */
  24117. samplingModes?: number[];
  24118. /**
  24119. * Define if a depth buffer is required
  24120. */
  24121. generateDepthBuffer?: boolean;
  24122. /**
  24123. * Define if a stencil buffer is required
  24124. */
  24125. generateStencilBuffer?: boolean;
  24126. /**
  24127. * Define if a depth texture is required instead of a depth buffer
  24128. */
  24129. generateDepthTexture?: boolean;
  24130. /**
  24131. * Define the number of desired draw buffers
  24132. */
  24133. textureCount?: number;
  24134. /**
  24135. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24136. */
  24137. doNotChangeAspectRatio?: boolean;
  24138. /**
  24139. * Define the default type of the buffers we are creating
  24140. */
  24141. defaultType?: number;
  24142. }
  24143. /**
  24144. * A multi render target, like a render target provides the ability to render to a texture.
  24145. * Unlike the render target, it can render to several draw buffers in one draw.
  24146. * This is specially interesting in deferred rendering or for any effects requiring more than
  24147. * just one color from a single pass.
  24148. */
  24149. export class MultiRenderTarget extends RenderTargetTexture {
  24150. private _internalTextures;
  24151. private _textures;
  24152. private _multiRenderTargetOptions;
  24153. private _count;
  24154. /**
  24155. * Get if draw buffers are currently supported by the used hardware and browser.
  24156. */
  24157. get isSupported(): boolean;
  24158. /**
  24159. * Get the list of textures generated by the multi render target.
  24160. */
  24161. get textures(): Texture[];
  24162. /**
  24163. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24164. */
  24165. get count(): number;
  24166. /**
  24167. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24168. */
  24169. get depthTexture(): Texture;
  24170. /**
  24171. * Set the wrapping mode on U of all the textures we are rendering to.
  24172. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24173. */
  24174. set wrapU(wrap: number);
  24175. /**
  24176. * Set the wrapping mode on V of all the textures we are rendering to.
  24177. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24178. */
  24179. set wrapV(wrap: number);
  24180. /**
  24181. * Instantiate a new multi render target texture.
  24182. * A multi render target, like a render target provides the ability to render to a texture.
  24183. * Unlike the render target, it can render to several draw buffers in one draw.
  24184. * This is specially interesting in deferred rendering or for any effects requiring more than
  24185. * just one color from a single pass.
  24186. * @param name Define the name of the texture
  24187. * @param size Define the size of the buffers to render to
  24188. * @param count Define the number of target we are rendering into
  24189. * @param scene Define the scene the texture belongs to
  24190. * @param options Define the options used to create the multi render target
  24191. */
  24192. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24193. private _initTypes;
  24194. /** @hidden */
  24195. _rebuild(forceFullRebuild?: boolean): void;
  24196. private _createInternalTextures;
  24197. private _createTextures;
  24198. /**
  24199. * Define the number of samples used if MSAA is enabled.
  24200. */
  24201. get samples(): number;
  24202. set samples(value: number);
  24203. /**
  24204. * Resize all the textures in the multi render target.
  24205. * Be careful as it will recreate all the data in the new texture.
  24206. * @param size Define the new size
  24207. */
  24208. resize(size: any): void;
  24209. /**
  24210. * Changes the number of render targets in this MRT
  24211. * Be careful as it will recreate all the data in the new texture.
  24212. * @param count new texture count
  24213. * @param options Specifies texture types and sampling modes for new textures
  24214. */
  24215. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24216. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24217. /**
  24218. * Dispose the render targets and their associated resources
  24219. */
  24220. dispose(): void;
  24221. /**
  24222. * Release all the underlying texture used as draw buffers.
  24223. */
  24224. releaseInternalTextures(): void;
  24225. }
  24226. }
  24227. declare module BABYLON {
  24228. /** @hidden */
  24229. export var imageProcessingPixelShader: {
  24230. name: string;
  24231. shader: string;
  24232. };
  24233. }
  24234. declare module BABYLON {
  24235. /**
  24236. * ImageProcessingPostProcess
  24237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24238. */
  24239. export class ImageProcessingPostProcess extends PostProcess {
  24240. /**
  24241. * Default configuration related to image processing available in the PBR Material.
  24242. */
  24243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24244. /**
  24245. * Gets the image processing configuration used either in this material.
  24246. */
  24247. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24248. /**
  24249. * Sets the Default image processing configuration used either in the this material.
  24250. *
  24251. * If sets to null, the scene one is in use.
  24252. */
  24253. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24254. /**
  24255. * Keep track of the image processing observer to allow dispose and replace.
  24256. */
  24257. private _imageProcessingObserver;
  24258. /**
  24259. * Attaches a new image processing configuration to the PBR Material.
  24260. * @param configuration
  24261. */
  24262. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24263. /**
  24264. * If the post process is supported.
  24265. */
  24266. get isSupported(): boolean;
  24267. /**
  24268. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24269. */
  24270. get colorCurves(): Nullable<ColorCurves>;
  24271. /**
  24272. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24273. */
  24274. set colorCurves(value: Nullable<ColorCurves>);
  24275. /**
  24276. * Gets wether the color curves effect is enabled.
  24277. */
  24278. get colorCurvesEnabled(): boolean;
  24279. /**
  24280. * Sets wether the color curves effect is enabled.
  24281. */
  24282. set colorCurvesEnabled(value: boolean);
  24283. /**
  24284. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24285. */
  24286. get colorGradingTexture(): Nullable<BaseTexture>;
  24287. /**
  24288. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24289. */
  24290. set colorGradingTexture(value: Nullable<BaseTexture>);
  24291. /**
  24292. * Gets wether the color grading effect is enabled.
  24293. */
  24294. get colorGradingEnabled(): boolean;
  24295. /**
  24296. * Gets wether the color grading effect is enabled.
  24297. */
  24298. set colorGradingEnabled(value: boolean);
  24299. /**
  24300. * Gets exposure used in the effect.
  24301. */
  24302. get exposure(): number;
  24303. /**
  24304. * Sets exposure used in the effect.
  24305. */
  24306. set exposure(value: number);
  24307. /**
  24308. * Gets wether tonemapping is enabled or not.
  24309. */
  24310. get toneMappingEnabled(): boolean;
  24311. /**
  24312. * Sets wether tonemapping is enabled or not
  24313. */
  24314. set toneMappingEnabled(value: boolean);
  24315. /**
  24316. * Gets the type of tone mapping effect.
  24317. */
  24318. get toneMappingType(): number;
  24319. /**
  24320. * Sets the type of tone mapping effect.
  24321. */
  24322. set toneMappingType(value: number);
  24323. /**
  24324. * Gets contrast used in the effect.
  24325. */
  24326. get contrast(): number;
  24327. /**
  24328. * Sets contrast used in the effect.
  24329. */
  24330. set contrast(value: number);
  24331. /**
  24332. * Gets Vignette stretch size.
  24333. */
  24334. get vignetteStretch(): number;
  24335. /**
  24336. * Sets Vignette stretch size.
  24337. */
  24338. set vignetteStretch(value: number);
  24339. /**
  24340. * Gets Vignette centre X Offset.
  24341. */
  24342. get vignetteCentreX(): number;
  24343. /**
  24344. * Sets Vignette centre X Offset.
  24345. */
  24346. set vignetteCentreX(value: number);
  24347. /**
  24348. * Gets Vignette centre Y Offset.
  24349. */
  24350. get vignetteCentreY(): number;
  24351. /**
  24352. * Sets Vignette centre Y Offset.
  24353. */
  24354. set vignetteCentreY(value: number);
  24355. /**
  24356. * Gets Vignette weight or intensity of the vignette effect.
  24357. */
  24358. get vignetteWeight(): number;
  24359. /**
  24360. * Sets Vignette weight or intensity of the vignette effect.
  24361. */
  24362. set vignetteWeight(value: number);
  24363. /**
  24364. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24365. * if vignetteEnabled is set to true.
  24366. */
  24367. get vignetteColor(): Color4;
  24368. /**
  24369. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24370. * if vignetteEnabled is set to true.
  24371. */
  24372. set vignetteColor(value: Color4);
  24373. /**
  24374. * Gets Camera field of view used by the Vignette effect.
  24375. */
  24376. get vignetteCameraFov(): number;
  24377. /**
  24378. * Sets Camera field of view used by the Vignette effect.
  24379. */
  24380. set vignetteCameraFov(value: number);
  24381. /**
  24382. * Gets the vignette blend mode allowing different kind of effect.
  24383. */
  24384. get vignetteBlendMode(): number;
  24385. /**
  24386. * Sets the vignette blend mode allowing different kind of effect.
  24387. */
  24388. set vignetteBlendMode(value: number);
  24389. /**
  24390. * Gets wether the vignette effect is enabled.
  24391. */
  24392. get vignetteEnabled(): boolean;
  24393. /**
  24394. * Sets wether the vignette effect is enabled.
  24395. */
  24396. set vignetteEnabled(value: boolean);
  24397. private _fromLinearSpace;
  24398. /**
  24399. * Gets wether the input of the processing is in Gamma or Linear Space.
  24400. */
  24401. get fromLinearSpace(): boolean;
  24402. /**
  24403. * Sets wether the input of the processing is in Gamma or Linear Space.
  24404. */
  24405. set fromLinearSpace(value: boolean);
  24406. /**
  24407. * Defines cache preventing GC.
  24408. */
  24409. private _defines;
  24410. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24411. /**
  24412. * "ImageProcessingPostProcess"
  24413. * @returns "ImageProcessingPostProcess"
  24414. */
  24415. getClassName(): string;
  24416. /**
  24417. * @hidden
  24418. */
  24419. _updateParameters(): void;
  24420. dispose(camera?: Camera): void;
  24421. }
  24422. }
  24423. declare module BABYLON {
  24424. /**
  24425. * Interface for defining prepass effects in the prepass post-process pipeline
  24426. */
  24427. export interface PrePassEffectConfiguration {
  24428. /**
  24429. * Name of the effect
  24430. */
  24431. name: string;
  24432. /**
  24433. * Post process to attach for this effect
  24434. */
  24435. postProcess?: PostProcess;
  24436. /**
  24437. * Textures required in the MRT
  24438. */
  24439. texturesRequired: number[];
  24440. /**
  24441. * Is the effect enabled
  24442. */
  24443. enabled: boolean;
  24444. /**
  24445. * Disposes the effect configuration
  24446. */
  24447. dispose(): void;
  24448. /**
  24449. * Creates the associated post process
  24450. */
  24451. createPostProcess?: () => PostProcess;
  24452. }
  24453. }
  24454. declare module BABYLON {
  24455. /**
  24456. * Renders a pre pass of the scene
  24457. * This means every mesh in the scene will be rendered to a render target texture
  24458. * And then this texture will be composited to the rendering canvas with post processes
  24459. * It is necessary for effects like subsurface scattering or deferred shading
  24460. */
  24461. export class PrePassRenderer {
  24462. /** @hidden */
  24463. static _SceneComponentInitialization: (scene: Scene) => void;
  24464. private _textureFormats;
  24465. private _textureIndices;
  24466. private _scene;
  24467. private _engine;
  24468. private _isDirty;
  24469. /**
  24470. * Number of textures in the multi render target texture where the scene is directly rendered
  24471. */
  24472. mrtCount: number;
  24473. /**
  24474. * The render target where the scene is directly rendered
  24475. */
  24476. prePassRT: MultiRenderTarget;
  24477. private _multiRenderAttachments;
  24478. private _defaultAttachments;
  24479. private _clearAttachments;
  24480. private _postProcesses;
  24481. private readonly _clearColor;
  24482. /**
  24483. * Image processing post process for composition
  24484. */
  24485. imageProcessingPostProcess: ImageProcessingPostProcess;
  24486. /**
  24487. * Configuration for prepass effects
  24488. */
  24489. private _effectConfigurations;
  24490. /**
  24491. * Should materials render their geometry on the MRT
  24492. */
  24493. materialsShouldRenderGeometry: boolean;
  24494. /**
  24495. * Should materials render the irradiance information on the MRT
  24496. */
  24497. materialsShouldRenderIrradiance: boolean;
  24498. private _mrtFormats;
  24499. private _mrtLayout;
  24500. private _enabled;
  24501. /**
  24502. * Indicates if the prepass is enabled
  24503. */
  24504. get enabled(): boolean;
  24505. /**
  24506. * How many samples are used for MSAA of the scene render target
  24507. */
  24508. get samples(): number;
  24509. set samples(n: number);
  24510. /**
  24511. * Instanciates a prepass renderer
  24512. * @param scene The scene
  24513. */
  24514. constructor(scene: Scene);
  24515. private _initializeAttachments;
  24516. private _createCompositionEffect;
  24517. /**
  24518. * Indicates if rendering a prepass is supported
  24519. */
  24520. get isSupported(): boolean;
  24521. /**
  24522. * Sets the proper output textures to draw in the engine.
  24523. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24524. */
  24525. bindAttachmentsForEffect(effect: Effect): void;
  24526. /**
  24527. * @hidden
  24528. */
  24529. _beforeCameraDraw(): void;
  24530. /**
  24531. * @hidden
  24532. */
  24533. _afterCameraDraw(): void;
  24534. private _checkRTSize;
  24535. private _bindFrameBuffer;
  24536. /**
  24537. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24538. */
  24539. clear(): void;
  24540. private _setState;
  24541. private _checkTextureType;
  24542. /**
  24543. * Adds an effect configuration to the prepass.
  24544. * If an effect has already been added, it won't add it twice and will return the configuration
  24545. * already present.
  24546. * @param cfg the effect configuration
  24547. * @return the effect configuration now used by the prepass
  24548. */
  24549. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24550. /**
  24551. * Returns the index of a texture in the multi render target texture array.
  24552. * @param type Texture type
  24553. * @return The index
  24554. */
  24555. getIndex(type: number): number;
  24556. private _enable;
  24557. private _disable;
  24558. private _resetLayout;
  24559. private _resetPostProcessChain;
  24560. private _bindPostProcessChain;
  24561. /**
  24562. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24563. */
  24564. markAsDirty(): void;
  24565. /**
  24566. * Enables a texture on the MultiRenderTarget for prepass
  24567. */
  24568. private _enableTextures;
  24569. private _update;
  24570. /**
  24571. * Disposes the prepass renderer.
  24572. */
  24573. dispose(): void;
  24574. }
  24575. }
  24576. declare module BABYLON {
  24577. /**
  24578. * Options for compiling materials.
  24579. */
  24580. export interface IMaterialCompilationOptions {
  24581. /**
  24582. * Defines whether clip planes are enabled.
  24583. */
  24584. clipPlane: boolean;
  24585. /**
  24586. * Defines whether instances are enabled.
  24587. */
  24588. useInstances: boolean;
  24589. }
  24590. /**
  24591. * Options passed when calling customShaderNameResolve
  24592. */
  24593. export interface ICustomShaderNameResolveOptions {
  24594. /**
  24595. * 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
  24596. */
  24597. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24598. }
  24599. /**
  24600. * Base class for the main features of a material in Babylon.js
  24601. */
  24602. export class Material implements IAnimatable {
  24603. /**
  24604. * Returns the triangle fill mode
  24605. */
  24606. static readonly TriangleFillMode: number;
  24607. /**
  24608. * Returns the wireframe mode
  24609. */
  24610. static readonly WireFrameFillMode: number;
  24611. /**
  24612. * Returns the point fill mode
  24613. */
  24614. static readonly PointFillMode: number;
  24615. /**
  24616. * Returns the point list draw mode
  24617. */
  24618. static readonly PointListDrawMode: number;
  24619. /**
  24620. * Returns the line list draw mode
  24621. */
  24622. static readonly LineListDrawMode: number;
  24623. /**
  24624. * Returns the line loop draw mode
  24625. */
  24626. static readonly LineLoopDrawMode: number;
  24627. /**
  24628. * Returns the line strip draw mode
  24629. */
  24630. static readonly LineStripDrawMode: number;
  24631. /**
  24632. * Returns the triangle strip draw mode
  24633. */
  24634. static readonly TriangleStripDrawMode: number;
  24635. /**
  24636. * Returns the triangle fan draw mode
  24637. */
  24638. static readonly TriangleFanDrawMode: number;
  24639. /**
  24640. * Stores the clock-wise side orientation
  24641. */
  24642. static readonly ClockWiseSideOrientation: number;
  24643. /**
  24644. * Stores the counter clock-wise side orientation
  24645. */
  24646. static readonly CounterClockWiseSideOrientation: number;
  24647. /**
  24648. * The dirty texture flag value
  24649. */
  24650. static readonly TextureDirtyFlag: number;
  24651. /**
  24652. * The dirty light flag value
  24653. */
  24654. static readonly LightDirtyFlag: number;
  24655. /**
  24656. * The dirty fresnel flag value
  24657. */
  24658. static readonly FresnelDirtyFlag: number;
  24659. /**
  24660. * The dirty attribute flag value
  24661. */
  24662. static readonly AttributesDirtyFlag: number;
  24663. /**
  24664. * The dirty misc flag value
  24665. */
  24666. static readonly MiscDirtyFlag: number;
  24667. /**
  24668. * The all dirty flag value
  24669. */
  24670. static readonly AllDirtyFlag: number;
  24671. /**
  24672. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24673. */
  24674. static readonly MATERIAL_OPAQUE: number;
  24675. /**
  24676. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24677. */
  24678. static readonly MATERIAL_ALPHATEST: number;
  24679. /**
  24680. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24681. */
  24682. static readonly MATERIAL_ALPHABLEND: number;
  24683. /**
  24684. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24685. * They are also discarded below the alpha cutoff threshold to improve performances.
  24686. */
  24687. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24688. /**
  24689. * The Whiteout method is used to blend normals.
  24690. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24691. */
  24692. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24693. /**
  24694. * The Reoriented Normal Mapping method is used to blend normals.
  24695. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24696. */
  24697. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24698. /**
  24699. * Custom callback helping to override the default shader used in the material.
  24700. */
  24701. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24702. /**
  24703. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24704. */
  24705. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24706. /**
  24707. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24708. * This means that the material can keep using a previous shader while a new one is being compiled.
  24709. * This is mostly used when shader parallel compilation is supported (true by default)
  24710. */
  24711. allowShaderHotSwapping: boolean;
  24712. /**
  24713. * The ID of the material
  24714. */
  24715. id: string;
  24716. /**
  24717. * Gets or sets the unique id of the material
  24718. */
  24719. uniqueId: number;
  24720. /**
  24721. * The name of the material
  24722. */
  24723. name: string;
  24724. /**
  24725. * Gets or sets user defined metadata
  24726. */
  24727. metadata: any;
  24728. /**
  24729. * For internal use only. Please do not use.
  24730. */
  24731. reservedDataStore: any;
  24732. /**
  24733. * Specifies if the ready state should be checked on each call
  24734. */
  24735. checkReadyOnEveryCall: boolean;
  24736. /**
  24737. * Specifies if the ready state should be checked once
  24738. */
  24739. checkReadyOnlyOnce: boolean;
  24740. /**
  24741. * The state of the material
  24742. */
  24743. state: string;
  24744. /**
  24745. * If the material can be rendered to several textures with MRT extension
  24746. */
  24747. get canRenderToMRT(): boolean;
  24748. /**
  24749. * The alpha value of the material
  24750. */
  24751. protected _alpha: number;
  24752. /**
  24753. * List of inspectable custom properties (used by the Inspector)
  24754. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24755. */
  24756. inspectableCustomProperties: IInspectable[];
  24757. /**
  24758. * Sets the alpha value of the material
  24759. */
  24760. set alpha(value: number);
  24761. /**
  24762. * Gets the alpha value of the material
  24763. */
  24764. get alpha(): number;
  24765. /**
  24766. * Specifies if back face culling is enabled
  24767. */
  24768. protected _backFaceCulling: boolean;
  24769. /**
  24770. * Sets the back-face culling state
  24771. */
  24772. set backFaceCulling(value: boolean);
  24773. /**
  24774. * Gets the back-face culling state
  24775. */
  24776. get backFaceCulling(): boolean;
  24777. /**
  24778. * Stores the value for side orientation
  24779. */
  24780. sideOrientation: number;
  24781. /**
  24782. * Callback triggered when the material is compiled
  24783. */
  24784. onCompiled: Nullable<(effect: Effect) => void>;
  24785. /**
  24786. * Callback triggered when an error occurs
  24787. */
  24788. onError: Nullable<(effect: Effect, errors: string) => void>;
  24789. /**
  24790. * Callback triggered to get the render target textures
  24791. */
  24792. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24793. /**
  24794. * Gets a boolean indicating that current material needs to register RTT
  24795. */
  24796. get hasRenderTargetTextures(): boolean;
  24797. /**
  24798. * Specifies if the material should be serialized
  24799. */
  24800. doNotSerialize: boolean;
  24801. /**
  24802. * @hidden
  24803. */
  24804. _storeEffectOnSubMeshes: boolean;
  24805. /**
  24806. * Stores the animations for the material
  24807. */
  24808. animations: Nullable<Array<Animation>>;
  24809. /**
  24810. * An event triggered when the material is disposed
  24811. */
  24812. onDisposeObservable: Observable<Material>;
  24813. /**
  24814. * An observer which watches for dispose events
  24815. */
  24816. private _onDisposeObserver;
  24817. private _onUnBindObservable;
  24818. /**
  24819. * Called during a dispose event
  24820. */
  24821. set onDispose(callback: () => void);
  24822. private _onBindObservable;
  24823. /**
  24824. * An event triggered when the material is bound
  24825. */
  24826. get onBindObservable(): Observable<AbstractMesh>;
  24827. /**
  24828. * An observer which watches for bind events
  24829. */
  24830. private _onBindObserver;
  24831. /**
  24832. * Called during a bind event
  24833. */
  24834. set onBind(callback: (Mesh: AbstractMesh) => void);
  24835. /**
  24836. * An event triggered when the material is unbound
  24837. */
  24838. get onUnBindObservable(): Observable<Material>;
  24839. protected _onEffectCreatedObservable: Nullable<Observable<{
  24840. effect: Effect;
  24841. subMesh: Nullable<SubMesh>;
  24842. }>>;
  24843. /**
  24844. * An event triggered when the effect is (re)created
  24845. */
  24846. get onEffectCreatedObservable(): Observable<{
  24847. effect: Effect;
  24848. subMesh: Nullable<SubMesh>;
  24849. }>;
  24850. /**
  24851. * Stores the value of the alpha mode
  24852. */
  24853. private _alphaMode;
  24854. /**
  24855. * Sets the value of the alpha mode.
  24856. *
  24857. * | Value | Type | Description |
  24858. * | --- | --- | --- |
  24859. * | 0 | ALPHA_DISABLE | |
  24860. * | 1 | ALPHA_ADD | |
  24861. * | 2 | ALPHA_COMBINE | |
  24862. * | 3 | ALPHA_SUBTRACT | |
  24863. * | 4 | ALPHA_MULTIPLY | |
  24864. * | 5 | ALPHA_MAXIMIZED | |
  24865. * | 6 | ALPHA_ONEONE | |
  24866. * | 7 | ALPHA_PREMULTIPLIED | |
  24867. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24868. * | 9 | ALPHA_INTERPOLATE | |
  24869. * | 10 | ALPHA_SCREENMODE | |
  24870. *
  24871. */
  24872. set alphaMode(value: number);
  24873. /**
  24874. * Gets the value of the alpha mode
  24875. */
  24876. get alphaMode(): number;
  24877. /**
  24878. * Stores the state of the need depth pre-pass value
  24879. */
  24880. private _needDepthPrePass;
  24881. /**
  24882. * Sets the need depth pre-pass value
  24883. */
  24884. set needDepthPrePass(value: boolean);
  24885. /**
  24886. * Gets the depth pre-pass value
  24887. */
  24888. get needDepthPrePass(): boolean;
  24889. /**
  24890. * Specifies if depth writing should be disabled
  24891. */
  24892. disableDepthWrite: boolean;
  24893. /**
  24894. * Specifies if color writing should be disabled
  24895. */
  24896. disableColorWrite: boolean;
  24897. /**
  24898. * Specifies if depth writing should be forced
  24899. */
  24900. forceDepthWrite: boolean;
  24901. /**
  24902. * Specifies the depth function that should be used. 0 means the default engine function
  24903. */
  24904. depthFunction: number;
  24905. /**
  24906. * Specifies if there should be a separate pass for culling
  24907. */
  24908. separateCullingPass: boolean;
  24909. /**
  24910. * Stores the state specifing if fog should be enabled
  24911. */
  24912. private _fogEnabled;
  24913. /**
  24914. * Sets the state for enabling fog
  24915. */
  24916. set fogEnabled(value: boolean);
  24917. /**
  24918. * Gets the value of the fog enabled state
  24919. */
  24920. get fogEnabled(): boolean;
  24921. /**
  24922. * Stores the size of points
  24923. */
  24924. pointSize: number;
  24925. /**
  24926. * Stores the z offset value
  24927. */
  24928. zOffset: number;
  24929. get wireframe(): boolean;
  24930. /**
  24931. * Sets the state of wireframe mode
  24932. */
  24933. set wireframe(value: boolean);
  24934. /**
  24935. * Gets the value specifying if point clouds are enabled
  24936. */
  24937. get pointsCloud(): boolean;
  24938. /**
  24939. * Sets the state of point cloud mode
  24940. */
  24941. set pointsCloud(value: boolean);
  24942. /**
  24943. * Gets the material fill mode
  24944. */
  24945. get fillMode(): number;
  24946. /**
  24947. * Sets the material fill mode
  24948. */
  24949. set fillMode(value: number);
  24950. /**
  24951. * @hidden
  24952. * Stores the effects for the material
  24953. */
  24954. _effect: Nullable<Effect>;
  24955. /**
  24956. * Specifies if uniform buffers should be used
  24957. */
  24958. private _useUBO;
  24959. /**
  24960. * Stores a reference to the scene
  24961. */
  24962. private _scene;
  24963. /**
  24964. * Stores the fill mode state
  24965. */
  24966. private _fillMode;
  24967. /**
  24968. * Specifies if the depth write state should be cached
  24969. */
  24970. private _cachedDepthWriteState;
  24971. /**
  24972. * Specifies if the color write state should be cached
  24973. */
  24974. private _cachedColorWriteState;
  24975. /**
  24976. * Specifies if the depth function state should be cached
  24977. */
  24978. private _cachedDepthFunctionState;
  24979. /**
  24980. * Stores the uniform buffer
  24981. */
  24982. protected _uniformBuffer: UniformBuffer;
  24983. /** @hidden */
  24984. _indexInSceneMaterialArray: number;
  24985. /** @hidden */
  24986. meshMap: Nullable<{
  24987. [id: string]: AbstractMesh | undefined;
  24988. }>;
  24989. /**
  24990. * Creates a material instance
  24991. * @param name defines the name of the material
  24992. * @param scene defines the scene to reference
  24993. * @param doNotAdd specifies if the material should be added to the scene
  24994. */
  24995. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24996. /**
  24997. * Returns a string representation of the current material
  24998. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24999. * @returns a string with material information
  25000. */
  25001. toString(fullDetails?: boolean): string;
  25002. /**
  25003. * Gets the class name of the material
  25004. * @returns a string with the class name of the material
  25005. */
  25006. getClassName(): string;
  25007. /**
  25008. * Specifies if updates for the material been locked
  25009. */
  25010. get isFrozen(): boolean;
  25011. /**
  25012. * Locks updates for the material
  25013. */
  25014. freeze(): void;
  25015. /**
  25016. * Unlocks updates for the material
  25017. */
  25018. unfreeze(): void;
  25019. /**
  25020. * Specifies if the material is ready to be used
  25021. * @param mesh defines the mesh to check
  25022. * @param useInstances specifies if instances should be used
  25023. * @returns a boolean indicating if the material is ready to be used
  25024. */
  25025. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25026. /**
  25027. * Specifies that the submesh is ready to be used
  25028. * @param mesh defines the mesh to check
  25029. * @param subMesh defines which submesh to check
  25030. * @param useInstances specifies that instances should be used
  25031. * @returns a boolean indicating that the submesh is ready or not
  25032. */
  25033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25034. /**
  25035. * Returns the material effect
  25036. * @returns the effect associated with the material
  25037. */
  25038. getEffect(): Nullable<Effect>;
  25039. /**
  25040. * Returns the current scene
  25041. * @returns a Scene
  25042. */
  25043. getScene(): Scene;
  25044. /**
  25045. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25046. */
  25047. protected _forceAlphaTest: boolean;
  25048. /**
  25049. * The transparency mode of the material.
  25050. */
  25051. protected _transparencyMode: Nullable<number>;
  25052. /**
  25053. * Gets the current transparency mode.
  25054. */
  25055. get transparencyMode(): Nullable<number>;
  25056. /**
  25057. * Sets the transparency mode of the material.
  25058. *
  25059. * | Value | Type | Description |
  25060. * | ----- | ----------------------------------- | ----------- |
  25061. * | 0 | OPAQUE | |
  25062. * | 1 | ALPHATEST | |
  25063. * | 2 | ALPHABLEND | |
  25064. * | 3 | ALPHATESTANDBLEND | |
  25065. *
  25066. */
  25067. set transparencyMode(value: Nullable<number>);
  25068. /**
  25069. * Returns true if alpha blending should be disabled.
  25070. */
  25071. protected get _disableAlphaBlending(): boolean;
  25072. /**
  25073. * Specifies whether or not this material should be rendered in alpha blend mode.
  25074. * @returns a boolean specifying if alpha blending is needed
  25075. */
  25076. needAlphaBlending(): boolean;
  25077. /**
  25078. * Specifies if the mesh will require alpha blending
  25079. * @param mesh defines the mesh to check
  25080. * @returns a boolean specifying if alpha blending is needed for the mesh
  25081. */
  25082. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25083. /**
  25084. * Specifies whether or not this material should be rendered in alpha test mode.
  25085. * @returns a boolean specifying if an alpha test is needed.
  25086. */
  25087. needAlphaTesting(): boolean;
  25088. /**
  25089. * Specifies if material alpha testing should be turned on for the mesh
  25090. * @param mesh defines the mesh to check
  25091. */
  25092. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25093. /**
  25094. * Gets the texture used for the alpha test
  25095. * @returns the texture to use for alpha testing
  25096. */
  25097. getAlphaTestTexture(): Nullable<BaseTexture>;
  25098. /**
  25099. * Marks the material to indicate that it needs to be re-calculated
  25100. */
  25101. markDirty(): void;
  25102. /** @hidden */
  25103. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25104. /**
  25105. * Binds the material to the mesh
  25106. * @param world defines the world transformation matrix
  25107. * @param mesh defines the mesh to bind the material to
  25108. */
  25109. bind(world: Matrix, mesh?: Mesh): void;
  25110. /**
  25111. * Binds the submesh to the material
  25112. * @param world defines the world transformation matrix
  25113. * @param mesh defines the mesh containing the submesh
  25114. * @param subMesh defines the submesh to bind the material to
  25115. */
  25116. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25117. /**
  25118. * Binds the world matrix to the material
  25119. * @param world defines the world transformation matrix
  25120. */
  25121. bindOnlyWorldMatrix(world: Matrix): void;
  25122. /**
  25123. * Binds the scene's uniform buffer to the effect.
  25124. * @param effect defines the effect to bind to the scene uniform buffer
  25125. * @param sceneUbo defines the uniform buffer storing scene data
  25126. */
  25127. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25128. /**
  25129. * Binds the view matrix to the effect
  25130. * @param effect defines the effect to bind the view matrix to
  25131. */
  25132. bindView(effect: Effect): void;
  25133. /**
  25134. * Binds the view projection matrix to the effect
  25135. * @param effect defines the effect to bind the view projection matrix to
  25136. */
  25137. bindViewProjection(effect: Effect): void;
  25138. /**
  25139. * Processes to execute after binding the material to a mesh
  25140. * @param mesh defines the rendered mesh
  25141. */
  25142. protected _afterBind(mesh?: Mesh): void;
  25143. /**
  25144. * Unbinds the material from the mesh
  25145. */
  25146. unbind(): void;
  25147. /**
  25148. * Gets the active textures from the material
  25149. * @returns an array of textures
  25150. */
  25151. getActiveTextures(): BaseTexture[];
  25152. /**
  25153. * Specifies if the material uses a texture
  25154. * @param texture defines the texture to check against the material
  25155. * @returns a boolean specifying if the material uses the texture
  25156. */
  25157. hasTexture(texture: BaseTexture): boolean;
  25158. /**
  25159. * Makes a duplicate of the material, and gives it a new name
  25160. * @param name defines the new name for the duplicated material
  25161. * @returns the cloned material
  25162. */
  25163. clone(name: string): Nullable<Material>;
  25164. /**
  25165. * Gets the meshes bound to the material
  25166. * @returns an array of meshes bound to the material
  25167. */
  25168. getBindedMeshes(): AbstractMesh[];
  25169. /**
  25170. * Force shader compilation
  25171. * @param mesh defines the mesh associated with this material
  25172. * @param onCompiled defines a function to execute once the material is compiled
  25173. * @param options defines the options to configure the compilation
  25174. * @param onError defines a function to execute if the material fails compiling
  25175. */
  25176. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25177. /**
  25178. * Force shader compilation
  25179. * @param mesh defines the mesh that will use this material
  25180. * @param options defines additional options for compiling the shaders
  25181. * @returns a promise that resolves when the compilation completes
  25182. */
  25183. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25184. private static readonly _AllDirtyCallBack;
  25185. private static readonly _ImageProcessingDirtyCallBack;
  25186. private static readonly _TextureDirtyCallBack;
  25187. private static readonly _FresnelDirtyCallBack;
  25188. private static readonly _MiscDirtyCallBack;
  25189. private static readonly _LightsDirtyCallBack;
  25190. private static readonly _AttributeDirtyCallBack;
  25191. private static _FresnelAndMiscDirtyCallBack;
  25192. private static _TextureAndMiscDirtyCallBack;
  25193. private static readonly _DirtyCallbackArray;
  25194. private static readonly _RunDirtyCallBacks;
  25195. /**
  25196. * Marks a define in the material to indicate that it needs to be re-computed
  25197. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25198. */
  25199. markAsDirty(flag: number): void;
  25200. /**
  25201. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25202. * @param func defines a function which checks material defines against the submeshes
  25203. */
  25204. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25205. /**
  25206. * Indicates that the scene should check if the rendering now needs a prepass
  25207. */
  25208. protected _markScenePrePassDirty(): void;
  25209. /**
  25210. * Indicates that we need to re-calculated for all submeshes
  25211. */
  25212. protected _markAllSubMeshesAsAllDirty(): void;
  25213. /**
  25214. * Indicates that image processing needs to be re-calculated for all submeshes
  25215. */
  25216. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25217. /**
  25218. * Indicates that textures need to be re-calculated for all submeshes
  25219. */
  25220. protected _markAllSubMeshesAsTexturesDirty(): void;
  25221. /**
  25222. * Indicates that fresnel needs to be re-calculated for all submeshes
  25223. */
  25224. protected _markAllSubMeshesAsFresnelDirty(): void;
  25225. /**
  25226. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25227. */
  25228. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25229. /**
  25230. * Indicates that lights need to be re-calculated for all submeshes
  25231. */
  25232. protected _markAllSubMeshesAsLightsDirty(): void;
  25233. /**
  25234. * Indicates that attributes need to be re-calculated for all submeshes
  25235. */
  25236. protected _markAllSubMeshesAsAttributesDirty(): void;
  25237. /**
  25238. * Indicates that misc needs to be re-calculated for all submeshes
  25239. */
  25240. protected _markAllSubMeshesAsMiscDirty(): void;
  25241. /**
  25242. * Indicates that textures and misc need to be re-calculated for all submeshes
  25243. */
  25244. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25245. /**
  25246. * Sets the required values to the prepass renderer.
  25247. * @param prePassRenderer defines the prepass renderer to setup.
  25248. * @returns true if the pre pass is needed.
  25249. */
  25250. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25251. /**
  25252. * Disposes the material
  25253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25255. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25256. */
  25257. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25258. /** @hidden */
  25259. private releaseVertexArrayObject;
  25260. /**
  25261. * Serializes this material
  25262. * @returns the serialized material object
  25263. */
  25264. serialize(): any;
  25265. /**
  25266. * Creates a material from parsed material data
  25267. * @param parsedMaterial defines parsed material data
  25268. * @param scene defines the hosting scene
  25269. * @param rootUrl defines the root URL to use to load textures
  25270. * @returns a new material
  25271. */
  25272. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25273. }
  25274. }
  25275. declare module BABYLON {
  25276. /**
  25277. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25278. * separate meshes. This can be use to improve performances.
  25279. * @see https://doc.babylonjs.com/how_to/multi_materials
  25280. */
  25281. export class MultiMaterial extends Material {
  25282. private _subMaterials;
  25283. /**
  25284. * Gets or Sets the list of Materials used within the multi material.
  25285. * They need to be ordered according to the submeshes order in the associated mesh
  25286. */
  25287. get subMaterials(): Nullable<Material>[];
  25288. set subMaterials(value: Nullable<Material>[]);
  25289. /**
  25290. * Function used to align with Node.getChildren()
  25291. * @returns the list of Materials used within the multi material
  25292. */
  25293. getChildren(): Nullable<Material>[];
  25294. /**
  25295. * Instantiates a new Multi Material
  25296. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25297. * separate meshes. This can be use to improve performances.
  25298. * @see https://doc.babylonjs.com/how_to/multi_materials
  25299. * @param name Define the name in the scene
  25300. * @param scene Define the scene the material belongs to
  25301. */
  25302. constructor(name: string, scene: Scene);
  25303. private _hookArray;
  25304. /**
  25305. * Get one of the submaterial by its index in the submaterials array
  25306. * @param index The index to look the sub material at
  25307. * @returns The Material if the index has been defined
  25308. */
  25309. getSubMaterial(index: number): Nullable<Material>;
  25310. /**
  25311. * Get the list of active textures for the whole sub materials list.
  25312. * @returns All the textures that will be used during the rendering
  25313. */
  25314. getActiveTextures(): BaseTexture[];
  25315. /**
  25316. * Gets the current class name of the material e.g. "MultiMaterial"
  25317. * Mainly use in serialization.
  25318. * @returns the class name
  25319. */
  25320. getClassName(): string;
  25321. /**
  25322. * Checks if the material is ready to render the requested sub mesh
  25323. * @param mesh Define the mesh the submesh belongs to
  25324. * @param subMesh Define the sub mesh to look readyness for
  25325. * @param useInstances Define whether or not the material is used with instances
  25326. * @returns true if ready, otherwise false
  25327. */
  25328. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25329. /**
  25330. * Clones the current material and its related sub materials
  25331. * @param name Define the name of the newly cloned material
  25332. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25333. * @returns the cloned material
  25334. */
  25335. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25336. /**
  25337. * Serializes the materials into a JSON representation.
  25338. * @returns the JSON representation
  25339. */
  25340. serialize(): any;
  25341. /**
  25342. * Dispose the material and release its associated resources
  25343. * @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)
  25344. * @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)
  25345. * @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)
  25346. */
  25347. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25348. /**
  25349. * Creates a MultiMaterial from parsed MultiMaterial data.
  25350. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25351. * @param scene defines the hosting scene
  25352. * @returns a new MultiMaterial
  25353. */
  25354. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25355. }
  25356. }
  25357. declare module BABYLON {
  25358. /**
  25359. * Defines a subdivision inside a mesh
  25360. */
  25361. export class SubMesh implements ICullable {
  25362. /** the material index to use */
  25363. materialIndex: number;
  25364. /** vertex index start */
  25365. verticesStart: number;
  25366. /** vertices count */
  25367. verticesCount: number;
  25368. /** index start */
  25369. indexStart: number;
  25370. /** indices count */
  25371. indexCount: number;
  25372. /** @hidden */
  25373. _materialDefines: Nullable<MaterialDefines>;
  25374. /** @hidden */
  25375. _materialEffect: Nullable<Effect>;
  25376. /** @hidden */
  25377. _effectOverride: Nullable<Effect>;
  25378. /**
  25379. * Gets material defines used by the effect associated to the sub mesh
  25380. */
  25381. get materialDefines(): Nullable<MaterialDefines>;
  25382. /**
  25383. * Sets material defines used by the effect associated to the sub mesh
  25384. */
  25385. set materialDefines(defines: Nullable<MaterialDefines>);
  25386. /**
  25387. * Gets associated effect
  25388. */
  25389. get effect(): Nullable<Effect>;
  25390. /**
  25391. * Sets associated effect (effect used to render this submesh)
  25392. * @param effect defines the effect to associate with
  25393. * @param defines defines the set of defines used to compile this effect
  25394. */
  25395. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25396. /** @hidden */
  25397. _linesIndexCount: number;
  25398. private _mesh;
  25399. private _renderingMesh;
  25400. private _boundingInfo;
  25401. private _linesIndexBuffer;
  25402. /** @hidden */
  25403. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25404. /** @hidden */
  25405. _trianglePlanes: Plane[];
  25406. /** @hidden */
  25407. _lastColliderTransformMatrix: Nullable<Matrix>;
  25408. /** @hidden */
  25409. _renderId: number;
  25410. /** @hidden */
  25411. _alphaIndex: number;
  25412. /** @hidden */
  25413. _distanceToCamera: number;
  25414. /** @hidden */
  25415. _id: number;
  25416. private _currentMaterial;
  25417. /**
  25418. * Add a new submesh to a mesh
  25419. * @param materialIndex defines the material index to use
  25420. * @param verticesStart defines vertex index start
  25421. * @param verticesCount defines vertices count
  25422. * @param indexStart defines index start
  25423. * @param indexCount defines indices count
  25424. * @param mesh defines the parent mesh
  25425. * @param renderingMesh defines an optional rendering mesh
  25426. * @param createBoundingBox defines if bounding box should be created for this submesh
  25427. * @returns the new submesh
  25428. */
  25429. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25430. /**
  25431. * Creates a new submesh
  25432. * @param materialIndex defines the material index to use
  25433. * @param verticesStart defines vertex index start
  25434. * @param verticesCount defines vertices count
  25435. * @param indexStart defines index start
  25436. * @param indexCount defines indices count
  25437. * @param mesh defines the parent mesh
  25438. * @param renderingMesh defines an optional rendering mesh
  25439. * @param createBoundingBox defines if bounding box should be created for this submesh
  25440. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25441. */
  25442. constructor(
  25443. /** the material index to use */
  25444. materialIndex: number,
  25445. /** vertex index start */
  25446. verticesStart: number,
  25447. /** vertices count */
  25448. verticesCount: number,
  25449. /** index start */
  25450. indexStart: number,
  25451. /** indices count */
  25452. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25453. /**
  25454. * Returns true if this submesh covers the entire parent mesh
  25455. * @ignorenaming
  25456. */
  25457. get IsGlobal(): boolean;
  25458. /**
  25459. * Returns the submesh BoudingInfo object
  25460. * @returns current bounding info (or mesh's one if the submesh is global)
  25461. */
  25462. getBoundingInfo(): BoundingInfo;
  25463. /**
  25464. * Sets the submesh BoundingInfo
  25465. * @param boundingInfo defines the new bounding info to use
  25466. * @returns the SubMesh
  25467. */
  25468. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25469. /**
  25470. * Returns the mesh of the current submesh
  25471. * @return the parent mesh
  25472. */
  25473. getMesh(): AbstractMesh;
  25474. /**
  25475. * Returns the rendering mesh of the submesh
  25476. * @returns the rendering mesh (could be different from parent mesh)
  25477. */
  25478. getRenderingMesh(): Mesh;
  25479. /**
  25480. * Returns the replacement mesh of the submesh
  25481. * @returns the replacement mesh (could be different from parent mesh)
  25482. */
  25483. getReplacementMesh(): Nullable<AbstractMesh>;
  25484. /**
  25485. * Returns the effective mesh of the submesh
  25486. * @returns the effective mesh (could be different from parent mesh)
  25487. */
  25488. getEffectiveMesh(): AbstractMesh;
  25489. /**
  25490. * Returns the submesh material
  25491. * @returns null or the current material
  25492. */
  25493. getMaterial(): Nullable<Material>;
  25494. private _IsMultiMaterial;
  25495. /**
  25496. * Sets a new updated BoundingInfo object to the submesh
  25497. * @param data defines an optional position array to use to determine the bounding info
  25498. * @returns the SubMesh
  25499. */
  25500. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25501. /** @hidden */
  25502. _checkCollision(collider: Collider): boolean;
  25503. /**
  25504. * Updates the submesh BoundingInfo
  25505. * @param world defines the world matrix to use to update the bounding info
  25506. * @returns the submesh
  25507. */
  25508. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25509. /**
  25510. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25511. * @param frustumPlanes defines the frustum planes
  25512. * @returns true if the submesh is intersecting with the frustum
  25513. */
  25514. isInFrustum(frustumPlanes: Plane[]): boolean;
  25515. /**
  25516. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25517. * @param frustumPlanes defines the frustum planes
  25518. * @returns true if the submesh is inside the frustum
  25519. */
  25520. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25521. /**
  25522. * Renders the submesh
  25523. * @param enableAlphaMode defines if alpha needs to be used
  25524. * @returns the submesh
  25525. */
  25526. render(enableAlphaMode: boolean): SubMesh;
  25527. /**
  25528. * @hidden
  25529. */
  25530. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25531. /**
  25532. * Checks if the submesh intersects with a ray
  25533. * @param ray defines the ray to test
  25534. * @returns true is the passed ray intersects the submesh bounding box
  25535. */
  25536. canIntersects(ray: Ray): boolean;
  25537. /**
  25538. * Intersects current submesh with a ray
  25539. * @param ray defines the ray to test
  25540. * @param positions defines mesh's positions array
  25541. * @param indices defines mesh's indices array
  25542. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25544. * @returns intersection info or null if no intersection
  25545. */
  25546. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25547. /** @hidden */
  25548. private _intersectLines;
  25549. /** @hidden */
  25550. private _intersectUnIndexedLines;
  25551. /** @hidden */
  25552. private _intersectTriangles;
  25553. /** @hidden */
  25554. private _intersectUnIndexedTriangles;
  25555. /** @hidden */
  25556. _rebuild(): void;
  25557. /**
  25558. * Creates a new submesh from the passed mesh
  25559. * @param newMesh defines the new hosting mesh
  25560. * @param newRenderingMesh defines an optional rendering mesh
  25561. * @returns the new submesh
  25562. */
  25563. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25564. /**
  25565. * Release associated resources
  25566. */
  25567. dispose(): void;
  25568. /**
  25569. * Gets the class name
  25570. * @returns the string "SubMesh".
  25571. */
  25572. getClassName(): string;
  25573. /**
  25574. * Creates a new submesh from indices data
  25575. * @param materialIndex the index of the main mesh material
  25576. * @param startIndex the index where to start the copy in the mesh indices array
  25577. * @param indexCount the number of indices to copy then from the startIndex
  25578. * @param mesh the main mesh to create the submesh from
  25579. * @param renderingMesh the optional rendering mesh
  25580. * @returns a new submesh
  25581. */
  25582. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25583. }
  25584. }
  25585. declare module BABYLON {
  25586. /**
  25587. * Class used to represent data loading progression
  25588. */
  25589. export class SceneLoaderFlags {
  25590. private static _ForceFullSceneLoadingForIncremental;
  25591. private static _ShowLoadingScreen;
  25592. private static _CleanBoneMatrixWeights;
  25593. private static _loggingLevel;
  25594. /**
  25595. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25596. */
  25597. static get ForceFullSceneLoadingForIncremental(): boolean;
  25598. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25599. /**
  25600. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25601. */
  25602. static get ShowLoadingScreen(): boolean;
  25603. static set ShowLoadingScreen(value: boolean);
  25604. /**
  25605. * Defines the current logging level (while loading the scene)
  25606. * @ignorenaming
  25607. */
  25608. static get loggingLevel(): number;
  25609. static set loggingLevel(value: number);
  25610. /**
  25611. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25612. */
  25613. static get CleanBoneMatrixWeights(): boolean;
  25614. static set CleanBoneMatrixWeights(value: boolean);
  25615. }
  25616. }
  25617. declare module BABYLON {
  25618. /**
  25619. * Class used to store geometry data (vertex buffers + index buffer)
  25620. */
  25621. export class Geometry implements IGetSetVerticesData {
  25622. /**
  25623. * Gets or sets the ID of the geometry
  25624. */
  25625. id: string;
  25626. /**
  25627. * Gets or sets the unique ID of the geometry
  25628. */
  25629. uniqueId: number;
  25630. /**
  25631. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25632. */
  25633. delayLoadState: number;
  25634. /**
  25635. * Gets the file containing the data to load when running in delay load state
  25636. */
  25637. delayLoadingFile: Nullable<string>;
  25638. /**
  25639. * Callback called when the geometry is updated
  25640. */
  25641. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25642. private _scene;
  25643. private _engine;
  25644. private _meshes;
  25645. private _totalVertices;
  25646. /** @hidden */
  25647. _indices: IndicesArray;
  25648. /** @hidden */
  25649. _vertexBuffers: {
  25650. [key: string]: VertexBuffer;
  25651. };
  25652. private _isDisposed;
  25653. private _extend;
  25654. private _boundingBias;
  25655. /** @hidden */
  25656. _delayInfo: Array<string>;
  25657. private _indexBuffer;
  25658. private _indexBufferIsUpdatable;
  25659. /** @hidden */
  25660. _boundingInfo: Nullable<BoundingInfo>;
  25661. /** @hidden */
  25662. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25663. /** @hidden */
  25664. _softwareSkinningFrameId: number;
  25665. private _vertexArrayObjects;
  25666. private _updatable;
  25667. /** @hidden */
  25668. _positions: Nullable<Vector3[]>;
  25669. /**
  25670. * 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
  25671. */
  25672. get boundingBias(): Vector2;
  25673. /**
  25674. * 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
  25675. */
  25676. set boundingBias(value: Vector2);
  25677. /**
  25678. * Static function used to attach a new empty geometry to a mesh
  25679. * @param mesh defines the mesh to attach the geometry to
  25680. * @returns the new Geometry
  25681. */
  25682. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25683. /** Get the list of meshes using this geometry */
  25684. get meshes(): Mesh[];
  25685. /**
  25686. * 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
  25687. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25688. */
  25689. useBoundingInfoFromGeometry: boolean;
  25690. /**
  25691. * Creates a new geometry
  25692. * @param id defines the unique ID
  25693. * @param scene defines the hosting scene
  25694. * @param vertexData defines the VertexData used to get geometry data
  25695. * @param updatable defines if geometry must be updatable (false by default)
  25696. * @param mesh defines the mesh that will be associated with the geometry
  25697. */
  25698. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25699. /**
  25700. * Gets the current extend of the geometry
  25701. */
  25702. get extend(): {
  25703. minimum: Vector3;
  25704. maximum: Vector3;
  25705. };
  25706. /**
  25707. * Gets the hosting scene
  25708. * @returns the hosting Scene
  25709. */
  25710. getScene(): Scene;
  25711. /**
  25712. * Gets the hosting engine
  25713. * @returns the hosting Engine
  25714. */
  25715. getEngine(): Engine;
  25716. /**
  25717. * Defines if the geometry is ready to use
  25718. * @returns true if the geometry is ready to be used
  25719. */
  25720. isReady(): boolean;
  25721. /**
  25722. * Gets a value indicating that the geometry should not be serialized
  25723. */
  25724. get doNotSerialize(): boolean;
  25725. /** @hidden */
  25726. _rebuild(): void;
  25727. /**
  25728. * Affects all geometry data in one call
  25729. * @param vertexData defines the geometry data
  25730. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25731. */
  25732. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25733. /**
  25734. * Set specific vertex data
  25735. * @param kind defines the data kind (Position, normal, etc...)
  25736. * @param data defines the vertex data to use
  25737. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25738. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25739. */
  25740. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25741. /**
  25742. * Removes a specific vertex data
  25743. * @param kind defines the data kind (Position, normal, etc...)
  25744. */
  25745. removeVerticesData(kind: string): void;
  25746. /**
  25747. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25748. * @param buffer defines the vertex buffer to use
  25749. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25750. */
  25751. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25752. /**
  25753. * Update a specific vertex buffer
  25754. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25755. * It will do nothing if the buffer is not updatable
  25756. * @param kind defines the data kind (Position, normal, etc...)
  25757. * @param data defines the data to use
  25758. * @param offset defines the offset in the target buffer where to store the data
  25759. * @param useBytes set to true if the offset is in bytes
  25760. */
  25761. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25762. /**
  25763. * Update a specific vertex buffer
  25764. * This function will create a new buffer if the current one is not updatable
  25765. * @param kind defines the data kind (Position, normal, etc...)
  25766. * @param data defines the data to use
  25767. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25768. */
  25769. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25770. private _updateBoundingInfo;
  25771. /** @hidden */
  25772. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25773. /**
  25774. * Gets total number of vertices
  25775. * @returns the total number of vertices
  25776. */
  25777. getTotalVertices(): number;
  25778. /**
  25779. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25780. * @param kind defines the data kind (Position, normal, etc...)
  25781. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25782. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25783. * @returns a float array containing vertex data
  25784. */
  25785. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25786. /**
  25787. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25788. * @param kind defines the data kind (Position, normal, etc...)
  25789. * @returns true if the vertex buffer with the specified kind is updatable
  25790. */
  25791. isVertexBufferUpdatable(kind: string): boolean;
  25792. /**
  25793. * Gets a specific vertex buffer
  25794. * @param kind defines the data kind (Position, normal, etc...)
  25795. * @returns a VertexBuffer
  25796. */
  25797. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25798. /**
  25799. * Returns all vertex buffers
  25800. * @return an object holding all vertex buffers indexed by kind
  25801. */
  25802. getVertexBuffers(): Nullable<{
  25803. [key: string]: VertexBuffer;
  25804. }>;
  25805. /**
  25806. * Gets a boolean indicating if specific vertex buffer is present
  25807. * @param kind defines the data kind (Position, normal, etc...)
  25808. * @returns true if data is present
  25809. */
  25810. isVerticesDataPresent(kind: string): boolean;
  25811. /**
  25812. * Gets a list of all attached data kinds (Position, normal, etc...)
  25813. * @returns a list of string containing all kinds
  25814. */
  25815. getVerticesDataKinds(): string[];
  25816. /**
  25817. * Update index buffer
  25818. * @param indices defines the indices to store in the index buffer
  25819. * @param offset defines the offset in the target buffer where to store the data
  25820. * @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)
  25821. */
  25822. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25823. /**
  25824. * Creates a new index buffer
  25825. * @param indices defines the indices to store in the index buffer
  25826. * @param totalVertices defines the total number of vertices (could be null)
  25827. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25828. */
  25829. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25830. /**
  25831. * Return the total number of indices
  25832. * @returns the total number of indices
  25833. */
  25834. getTotalIndices(): number;
  25835. /**
  25836. * Gets the index buffer array
  25837. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25839. * @returns the index buffer array
  25840. */
  25841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25842. /**
  25843. * Gets the index buffer
  25844. * @return the index buffer
  25845. */
  25846. getIndexBuffer(): Nullable<DataBuffer>;
  25847. /** @hidden */
  25848. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25849. /**
  25850. * Release the associated resources for a specific mesh
  25851. * @param mesh defines the source mesh
  25852. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25853. */
  25854. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25855. /**
  25856. * Apply current geometry to a given mesh
  25857. * @param mesh defines the mesh to apply geometry to
  25858. */
  25859. applyToMesh(mesh: Mesh): void;
  25860. private _updateExtend;
  25861. private _applyToMesh;
  25862. private notifyUpdate;
  25863. /**
  25864. * Load the geometry if it was flagged as delay loaded
  25865. * @param scene defines the hosting scene
  25866. * @param onLoaded defines a callback called when the geometry is loaded
  25867. */
  25868. load(scene: Scene, onLoaded?: () => void): void;
  25869. private _queueLoad;
  25870. /**
  25871. * Invert the geometry to move from a right handed system to a left handed one.
  25872. */
  25873. toLeftHanded(): void;
  25874. /** @hidden */
  25875. _resetPointsArrayCache(): void;
  25876. /** @hidden */
  25877. _generatePointsArray(): boolean;
  25878. /**
  25879. * Gets a value indicating if the geometry is disposed
  25880. * @returns true if the geometry was disposed
  25881. */
  25882. isDisposed(): boolean;
  25883. private _disposeVertexArrayObjects;
  25884. /**
  25885. * Free all associated resources
  25886. */
  25887. dispose(): void;
  25888. /**
  25889. * Clone the current geometry into a new geometry
  25890. * @param id defines the unique ID of the new geometry
  25891. * @returns a new geometry object
  25892. */
  25893. copy(id: string): Geometry;
  25894. /**
  25895. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25896. * @return a JSON representation of the current geometry data (without the vertices data)
  25897. */
  25898. serialize(): any;
  25899. private toNumberArray;
  25900. /**
  25901. * Serialize all vertices data into a JSON oject
  25902. * @returns a JSON representation of the current geometry data
  25903. */
  25904. serializeVerticeData(): any;
  25905. /**
  25906. * Extracts a clone of a mesh geometry
  25907. * @param mesh defines the source mesh
  25908. * @param id defines the unique ID of the new geometry object
  25909. * @returns the new geometry object
  25910. */
  25911. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25912. /**
  25913. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25914. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25915. * Be aware Math.random() could cause collisions, but:
  25916. * "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"
  25917. * @returns a string containing a new GUID
  25918. */
  25919. static RandomId(): string;
  25920. /** @hidden */
  25921. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25922. private static _CleanMatricesWeights;
  25923. /**
  25924. * Create a new geometry from persisted data (Using .babylon file format)
  25925. * @param parsedVertexData defines the persisted data
  25926. * @param scene defines the hosting scene
  25927. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25928. * @returns the new geometry object
  25929. */
  25930. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25931. }
  25932. }
  25933. declare module BABYLON {
  25934. /**
  25935. * Define an interface for all classes that will get and set the data on vertices
  25936. */
  25937. export interface IGetSetVerticesData {
  25938. /**
  25939. * Gets a boolean indicating if specific vertex data is present
  25940. * @param kind defines the vertex data kind to use
  25941. * @returns true is data kind is present
  25942. */
  25943. isVerticesDataPresent(kind: string): boolean;
  25944. /**
  25945. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25946. * @param kind defines the data kind (Position, normal, etc...)
  25947. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25948. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25949. * @returns a float array containing vertex data
  25950. */
  25951. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25952. /**
  25953. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25954. * @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.
  25955. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25956. * @returns the indices array or an empty array if the mesh has no geometry
  25957. */
  25958. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25959. /**
  25960. * Set specific vertex data
  25961. * @param kind defines the data kind (Position, normal, etc...)
  25962. * @param data defines the vertex data to use
  25963. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25964. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25965. */
  25966. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25967. /**
  25968. * Update a specific associated vertex buffer
  25969. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25970. * - VertexBuffer.PositionKind
  25971. * - VertexBuffer.UVKind
  25972. * - VertexBuffer.UV2Kind
  25973. * - VertexBuffer.UV3Kind
  25974. * - VertexBuffer.UV4Kind
  25975. * - VertexBuffer.UV5Kind
  25976. * - VertexBuffer.UV6Kind
  25977. * - VertexBuffer.ColorKind
  25978. * - VertexBuffer.MatricesIndicesKind
  25979. * - VertexBuffer.MatricesIndicesExtraKind
  25980. * - VertexBuffer.MatricesWeightsKind
  25981. * - VertexBuffer.MatricesWeightsExtraKind
  25982. * @param data defines the data source
  25983. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25984. * @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)
  25985. */
  25986. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25987. /**
  25988. * Creates a new index buffer
  25989. * @param indices defines the indices to store in the index buffer
  25990. * @param totalVertices defines the total number of vertices (could be null)
  25991. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25992. */
  25993. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25994. }
  25995. /**
  25996. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25997. */
  25998. export class VertexData {
  25999. /**
  26000. * Mesh side orientation : usually the external or front surface
  26001. */
  26002. static readonly FRONTSIDE: number;
  26003. /**
  26004. * Mesh side orientation : usually the internal or back surface
  26005. */
  26006. static readonly BACKSIDE: number;
  26007. /**
  26008. * Mesh side orientation : both internal and external or front and back surfaces
  26009. */
  26010. static readonly DOUBLESIDE: number;
  26011. /**
  26012. * Mesh side orientation : by default, `FRONTSIDE`
  26013. */
  26014. static readonly DEFAULTSIDE: number;
  26015. /**
  26016. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26017. */
  26018. positions: Nullable<FloatArray>;
  26019. /**
  26020. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26021. */
  26022. normals: Nullable<FloatArray>;
  26023. /**
  26024. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26025. */
  26026. tangents: Nullable<FloatArray>;
  26027. /**
  26028. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26029. */
  26030. uvs: Nullable<FloatArray>;
  26031. /**
  26032. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26033. */
  26034. uvs2: Nullable<FloatArray>;
  26035. /**
  26036. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26037. */
  26038. uvs3: Nullable<FloatArray>;
  26039. /**
  26040. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26041. */
  26042. uvs4: Nullable<FloatArray>;
  26043. /**
  26044. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26045. */
  26046. uvs5: Nullable<FloatArray>;
  26047. /**
  26048. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26049. */
  26050. uvs6: Nullable<FloatArray>;
  26051. /**
  26052. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26053. */
  26054. colors: Nullable<FloatArray>;
  26055. /**
  26056. * 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).
  26057. */
  26058. matricesIndices: Nullable<FloatArray>;
  26059. /**
  26060. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26061. */
  26062. matricesWeights: Nullable<FloatArray>;
  26063. /**
  26064. * An array extending the number of possible indices
  26065. */
  26066. matricesIndicesExtra: Nullable<FloatArray>;
  26067. /**
  26068. * An array extending the number of possible weights when the number of indices is extended
  26069. */
  26070. matricesWeightsExtra: Nullable<FloatArray>;
  26071. /**
  26072. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26073. */
  26074. indices: Nullable<IndicesArray>;
  26075. /**
  26076. * Uses the passed data array to set the set the values for the specified kind of data
  26077. * @param data a linear array of floating numbers
  26078. * @param kind the type of data that is being set, eg positions, colors etc
  26079. */
  26080. set(data: FloatArray, kind: string): void;
  26081. /**
  26082. * Associates the vertexData to the passed Mesh.
  26083. * Sets it as updatable or not (default `false`)
  26084. * @param mesh the mesh the vertexData is applied to
  26085. * @param updatable when used and having the value true allows new data to update the vertexData
  26086. * @returns the VertexData
  26087. */
  26088. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26089. /**
  26090. * Associates the vertexData to the passed Geometry.
  26091. * Sets it as updatable or not (default `false`)
  26092. * @param geometry the geometry the vertexData is applied to
  26093. * @param updatable when used and having the value true allows new data to update the vertexData
  26094. * @returns VertexData
  26095. */
  26096. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26097. /**
  26098. * Updates the associated mesh
  26099. * @param mesh the mesh to be updated
  26100. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26101. * @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
  26102. * @returns VertexData
  26103. */
  26104. updateMesh(mesh: Mesh): VertexData;
  26105. /**
  26106. * Updates the associated geometry
  26107. * @param geometry the geometry to be updated
  26108. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26109. * @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
  26110. * @returns VertexData.
  26111. */
  26112. updateGeometry(geometry: Geometry): VertexData;
  26113. private _applyTo;
  26114. private _update;
  26115. /**
  26116. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26117. * @param matrix the transforming matrix
  26118. * @returns the VertexData
  26119. */
  26120. transform(matrix: Matrix): VertexData;
  26121. /**
  26122. * Merges the passed VertexData into the current one
  26123. * @param other the VertexData to be merged into the current one
  26124. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26125. * @returns the modified VertexData
  26126. */
  26127. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26128. private _mergeElement;
  26129. private _validate;
  26130. /**
  26131. * Serializes the VertexData
  26132. * @returns a serialized object
  26133. */
  26134. serialize(): any;
  26135. /**
  26136. * Extracts the vertexData from a mesh
  26137. * @param mesh the mesh from which to extract the VertexData
  26138. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26139. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26140. * @returns the object VertexData associated to the passed mesh
  26141. */
  26142. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26143. /**
  26144. * Extracts the vertexData from the geometry
  26145. * @param geometry the geometry from which to extract the VertexData
  26146. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26147. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26148. * @returns the object VertexData associated to the passed mesh
  26149. */
  26150. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26151. private static _ExtractFrom;
  26152. /**
  26153. * Creates the VertexData for a Ribbon
  26154. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26155. * * pathArray array of paths, each of which an array of successive Vector3
  26156. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26157. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26158. * * 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
  26159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26160. * * 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)
  26161. * * 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)
  26162. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26163. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26164. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26165. * @returns the VertexData of the ribbon
  26166. */
  26167. static CreateRibbon(options: {
  26168. pathArray: Vector3[][];
  26169. closeArray?: boolean;
  26170. closePath?: boolean;
  26171. offset?: number;
  26172. sideOrientation?: number;
  26173. frontUVs?: Vector4;
  26174. backUVs?: Vector4;
  26175. invertUV?: boolean;
  26176. uvs?: Vector2[];
  26177. colors?: Color4[];
  26178. }): VertexData;
  26179. /**
  26180. * Creates the VertexData for a box
  26181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26182. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26183. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26184. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26185. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26186. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26187. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26189. * * 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)
  26190. * * 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)
  26191. * @returns the VertexData of the box
  26192. */
  26193. static CreateBox(options: {
  26194. size?: number;
  26195. width?: number;
  26196. height?: number;
  26197. depth?: number;
  26198. faceUV?: Vector4[];
  26199. faceColors?: Color4[];
  26200. sideOrientation?: number;
  26201. frontUVs?: Vector4;
  26202. backUVs?: Vector4;
  26203. }): VertexData;
  26204. /**
  26205. * Creates the VertexData for a tiled box
  26206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26207. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26208. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26209. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26211. * @returns the VertexData of the box
  26212. */
  26213. static CreateTiledBox(options: {
  26214. pattern?: number;
  26215. width?: number;
  26216. height?: number;
  26217. depth?: number;
  26218. tileSize?: number;
  26219. tileWidth?: number;
  26220. tileHeight?: number;
  26221. alignHorizontal?: number;
  26222. alignVertical?: number;
  26223. faceUV?: Vector4[];
  26224. faceColors?: Color4[];
  26225. sideOrientation?: number;
  26226. }): VertexData;
  26227. /**
  26228. * Creates the VertexData for a tiled plane
  26229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26230. * * pattern a limited pattern arrangement depending on the number
  26231. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26232. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26233. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26235. * * 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)
  26236. * * 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)
  26237. * @returns the VertexData of the tiled plane
  26238. */
  26239. static CreateTiledPlane(options: {
  26240. pattern?: number;
  26241. tileSize?: number;
  26242. tileWidth?: number;
  26243. tileHeight?: number;
  26244. size?: number;
  26245. width?: number;
  26246. height?: number;
  26247. alignHorizontal?: number;
  26248. alignVertical?: number;
  26249. sideOrientation?: number;
  26250. frontUVs?: Vector4;
  26251. backUVs?: Vector4;
  26252. }): VertexData;
  26253. /**
  26254. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26255. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26256. * * segments sets the number of horizontal strips optional, default 32
  26257. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26258. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26259. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26260. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26261. * * 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
  26262. * * 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
  26263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26264. * * 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)
  26265. * * 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)
  26266. * @returns the VertexData of the ellipsoid
  26267. */
  26268. static CreateSphere(options: {
  26269. segments?: number;
  26270. diameter?: number;
  26271. diameterX?: number;
  26272. diameterY?: number;
  26273. diameterZ?: number;
  26274. arc?: number;
  26275. slice?: number;
  26276. sideOrientation?: number;
  26277. frontUVs?: Vector4;
  26278. backUVs?: Vector4;
  26279. }): VertexData;
  26280. /**
  26281. * Creates the VertexData for a cylinder, cone or prism
  26282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26283. * * height sets the height (y direction) of the cylinder, optional, default 2
  26284. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26285. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26286. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26287. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26288. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26289. * * 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
  26290. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26291. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26292. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26293. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26295. * * 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)
  26296. * * 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)
  26297. * @returns the VertexData of the cylinder, cone or prism
  26298. */
  26299. static CreateCylinder(options: {
  26300. height?: number;
  26301. diameterTop?: number;
  26302. diameterBottom?: number;
  26303. diameter?: number;
  26304. tessellation?: number;
  26305. subdivisions?: number;
  26306. arc?: number;
  26307. faceColors?: Color4[];
  26308. faceUV?: Vector4[];
  26309. hasRings?: boolean;
  26310. enclose?: boolean;
  26311. sideOrientation?: number;
  26312. frontUVs?: Vector4;
  26313. backUVs?: Vector4;
  26314. }): VertexData;
  26315. /**
  26316. * Creates the VertexData for a torus
  26317. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26318. * * diameter the diameter of the torus, optional default 1
  26319. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26320. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26322. * * 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)
  26323. * * 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)
  26324. * @returns the VertexData of the torus
  26325. */
  26326. static CreateTorus(options: {
  26327. diameter?: number;
  26328. thickness?: number;
  26329. tessellation?: number;
  26330. sideOrientation?: number;
  26331. frontUVs?: Vector4;
  26332. backUVs?: Vector4;
  26333. }): VertexData;
  26334. /**
  26335. * Creates the VertexData of the LineSystem
  26336. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26337. * - lines an array of lines, each line being an array of successive Vector3
  26338. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26339. * @returns the VertexData of the LineSystem
  26340. */
  26341. static CreateLineSystem(options: {
  26342. lines: Vector3[][];
  26343. colors?: Nullable<Color4[][]>;
  26344. }): VertexData;
  26345. /**
  26346. * Create the VertexData for a DashedLines
  26347. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26348. * - points an array successive Vector3
  26349. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26350. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26351. * - dashNb the intended total number of dashes, optional, default 200
  26352. * @returns the VertexData for the DashedLines
  26353. */
  26354. static CreateDashedLines(options: {
  26355. points: Vector3[];
  26356. dashSize?: number;
  26357. gapSize?: number;
  26358. dashNb?: number;
  26359. }): VertexData;
  26360. /**
  26361. * Creates the VertexData for a Ground
  26362. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26363. * - width the width (x direction) of the ground, optional, default 1
  26364. * - height the height (z direction) of the ground, optional, default 1
  26365. * - subdivisions the number of subdivisions per side, optional, default 1
  26366. * @returns the VertexData of the Ground
  26367. */
  26368. static CreateGround(options: {
  26369. width?: number;
  26370. height?: number;
  26371. subdivisions?: number;
  26372. subdivisionsX?: number;
  26373. subdivisionsY?: number;
  26374. }): VertexData;
  26375. /**
  26376. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26377. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26378. * * xmin the ground minimum X coordinate, optional, default -1
  26379. * * zmin the ground minimum Z coordinate, optional, default -1
  26380. * * xmax the ground maximum X coordinate, optional, default 1
  26381. * * zmax the ground maximum Z coordinate, optional, default 1
  26382. * * 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}
  26383. * * 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}
  26384. * @returns the VertexData of the TiledGround
  26385. */
  26386. static CreateTiledGround(options: {
  26387. xmin: number;
  26388. zmin: number;
  26389. xmax: number;
  26390. zmax: number;
  26391. subdivisions?: {
  26392. w: number;
  26393. h: number;
  26394. };
  26395. precision?: {
  26396. w: number;
  26397. h: number;
  26398. };
  26399. }): VertexData;
  26400. /**
  26401. * Creates the VertexData of the Ground designed from a heightmap
  26402. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26403. * * width the width (x direction) of the ground
  26404. * * height the height (z direction) of the ground
  26405. * * subdivisions the number of subdivisions per side
  26406. * * minHeight the minimum altitude on the ground, optional, default 0
  26407. * * maxHeight the maximum altitude on the ground, optional default 1
  26408. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26409. * * buffer the array holding the image color data
  26410. * * bufferWidth the width of image
  26411. * * bufferHeight the height of image
  26412. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26413. * @returns the VertexData of the Ground designed from a heightmap
  26414. */
  26415. static CreateGroundFromHeightMap(options: {
  26416. width: number;
  26417. height: number;
  26418. subdivisions: number;
  26419. minHeight: number;
  26420. maxHeight: number;
  26421. colorFilter: Color3;
  26422. buffer: Uint8Array;
  26423. bufferWidth: number;
  26424. bufferHeight: number;
  26425. alphaFilter: number;
  26426. }): VertexData;
  26427. /**
  26428. * Creates the VertexData for a Plane
  26429. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26430. * * size sets the width and height of the plane to the value of size, optional default 1
  26431. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26432. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26434. * * 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)
  26435. * * 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)
  26436. * @returns the VertexData of the box
  26437. */
  26438. static CreatePlane(options: {
  26439. size?: number;
  26440. width?: number;
  26441. height?: number;
  26442. sideOrientation?: number;
  26443. frontUVs?: Vector4;
  26444. backUVs?: Vector4;
  26445. }): VertexData;
  26446. /**
  26447. * Creates the VertexData of the Disc or regular Polygon
  26448. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26449. * * radius the radius of the disc, optional default 0.5
  26450. * * tessellation the number of polygon sides, optional, default 64
  26451. * * 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
  26452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26453. * * 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)
  26454. * * 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)
  26455. * @returns the VertexData of the box
  26456. */
  26457. static CreateDisc(options: {
  26458. radius?: number;
  26459. tessellation?: number;
  26460. arc?: number;
  26461. sideOrientation?: number;
  26462. frontUVs?: Vector4;
  26463. backUVs?: Vector4;
  26464. }): VertexData;
  26465. /**
  26466. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26467. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26468. * @param polygon a mesh built from polygonTriangulation.build()
  26469. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26470. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26471. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26472. * @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)
  26473. * @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)
  26474. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26475. * @returns the VertexData of the Polygon
  26476. */
  26477. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26478. /**
  26479. * Creates the VertexData of the IcoSphere
  26480. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26481. * * radius the radius of the IcoSphere, optional default 1
  26482. * * radiusX allows stretching in the x direction, optional, default radius
  26483. * * radiusY allows stretching in the y direction, optional, default radius
  26484. * * radiusZ allows stretching in the z direction, optional, default radius
  26485. * * flat when true creates a flat shaded mesh, optional, default true
  26486. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26488. * * 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)
  26489. * * 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)
  26490. * @returns the VertexData of the IcoSphere
  26491. */
  26492. static CreateIcoSphere(options: {
  26493. radius?: number;
  26494. radiusX?: number;
  26495. radiusY?: number;
  26496. radiusZ?: number;
  26497. flat?: boolean;
  26498. subdivisions?: number;
  26499. sideOrientation?: number;
  26500. frontUVs?: Vector4;
  26501. backUVs?: Vector4;
  26502. }): VertexData;
  26503. /**
  26504. * Creates the VertexData for a Polyhedron
  26505. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26506. * * type provided types are:
  26507. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26508. * * 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)
  26509. * * size the size of the IcoSphere, optional default 1
  26510. * * sizeX allows stretching in the x direction, optional, default size
  26511. * * sizeY allows stretching in the y direction, optional, default size
  26512. * * sizeZ allows stretching in the z direction, optional, default size
  26513. * * 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
  26514. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26515. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26516. * * flat when true creates a flat shaded mesh, optional, default true
  26517. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26519. * * 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)
  26520. * * 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)
  26521. * @returns the VertexData of the Polyhedron
  26522. */
  26523. static CreatePolyhedron(options: {
  26524. type?: number;
  26525. size?: number;
  26526. sizeX?: number;
  26527. sizeY?: number;
  26528. sizeZ?: number;
  26529. custom?: any;
  26530. faceUV?: Vector4[];
  26531. faceColors?: Color4[];
  26532. flat?: boolean;
  26533. sideOrientation?: number;
  26534. frontUVs?: Vector4;
  26535. backUVs?: Vector4;
  26536. }): VertexData;
  26537. /**
  26538. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26539. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26540. * @returns the VertexData of the Capsule
  26541. */
  26542. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26543. /**
  26544. * Creates the VertexData for a TorusKnot
  26545. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26546. * * radius the radius of the torus knot, optional, default 2
  26547. * * tube the thickness of the tube, optional, default 0.5
  26548. * * radialSegments the number of sides on each tube segments, optional, default 32
  26549. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26550. * * p the number of windings around the z axis, optional, default 2
  26551. * * q the number of windings around the x axis, optional, default 3
  26552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26553. * * 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)
  26554. * * 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)
  26555. * @returns the VertexData of the Torus Knot
  26556. */
  26557. static CreateTorusKnot(options: {
  26558. radius?: number;
  26559. tube?: number;
  26560. radialSegments?: number;
  26561. tubularSegments?: number;
  26562. p?: number;
  26563. q?: number;
  26564. sideOrientation?: number;
  26565. frontUVs?: Vector4;
  26566. backUVs?: Vector4;
  26567. }): VertexData;
  26568. /**
  26569. * Compute normals for given positions and indices
  26570. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26571. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26572. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26573. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26574. * * facetNormals : optional array of facet normals (vector3)
  26575. * * facetPositions : optional array of facet positions (vector3)
  26576. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26577. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26578. * * bInfo : optional bounding info, required for facetPartitioning computation
  26579. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26580. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26581. * * useRightHandedSystem: optional boolean to for right handed system computation
  26582. * * depthSort : optional boolean to enable the facet depth sort computation
  26583. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26584. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26585. */
  26586. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26587. facetNormals?: any;
  26588. facetPositions?: any;
  26589. facetPartitioning?: any;
  26590. ratio?: number;
  26591. bInfo?: any;
  26592. bbSize?: Vector3;
  26593. subDiv?: any;
  26594. useRightHandedSystem?: boolean;
  26595. depthSort?: boolean;
  26596. distanceTo?: Vector3;
  26597. depthSortedFacets?: any;
  26598. }): void;
  26599. /** @hidden */
  26600. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26601. /**
  26602. * Applies VertexData created from the imported parameters to the geometry
  26603. * @param parsedVertexData the parsed data from an imported file
  26604. * @param geometry the geometry to apply the VertexData to
  26605. */
  26606. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26607. }
  26608. }
  26609. declare module BABYLON {
  26610. /**
  26611. * Defines a target to use with MorphTargetManager
  26612. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26613. */
  26614. export class MorphTarget implements IAnimatable {
  26615. /** defines the name of the target */
  26616. name: string;
  26617. /**
  26618. * Gets or sets the list of animations
  26619. */
  26620. animations: Animation[];
  26621. private _scene;
  26622. private _positions;
  26623. private _normals;
  26624. private _tangents;
  26625. private _uvs;
  26626. private _influence;
  26627. private _uniqueId;
  26628. /**
  26629. * Observable raised when the influence changes
  26630. */
  26631. onInfluenceChanged: Observable<boolean>;
  26632. /** @hidden */
  26633. _onDataLayoutChanged: Observable<void>;
  26634. /**
  26635. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26636. */
  26637. get influence(): number;
  26638. set influence(influence: number);
  26639. /**
  26640. * Gets or sets the id of the morph Target
  26641. */
  26642. id: string;
  26643. private _animationPropertiesOverride;
  26644. /**
  26645. * Gets or sets the animation properties override
  26646. */
  26647. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26648. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26649. /**
  26650. * Creates a new MorphTarget
  26651. * @param name defines the name of the target
  26652. * @param influence defines the influence to use
  26653. * @param scene defines the scene the morphtarget belongs to
  26654. */
  26655. constructor(
  26656. /** defines the name of the target */
  26657. name: string, influence?: number, scene?: Nullable<Scene>);
  26658. /**
  26659. * Gets the unique ID of this manager
  26660. */
  26661. get uniqueId(): number;
  26662. /**
  26663. * Gets a boolean defining if the target contains position data
  26664. */
  26665. get hasPositions(): boolean;
  26666. /**
  26667. * Gets a boolean defining if the target contains normal data
  26668. */
  26669. get hasNormals(): boolean;
  26670. /**
  26671. * Gets a boolean defining if the target contains tangent data
  26672. */
  26673. get hasTangents(): boolean;
  26674. /**
  26675. * Gets a boolean defining if the target contains texture coordinates data
  26676. */
  26677. get hasUVs(): boolean;
  26678. /**
  26679. * Affects position data to this target
  26680. * @param data defines the position data to use
  26681. */
  26682. setPositions(data: Nullable<FloatArray>): void;
  26683. /**
  26684. * Gets the position data stored in this target
  26685. * @returns a FloatArray containing the position data (or null if not present)
  26686. */
  26687. getPositions(): Nullable<FloatArray>;
  26688. /**
  26689. * Affects normal data to this target
  26690. * @param data defines the normal data to use
  26691. */
  26692. setNormals(data: Nullable<FloatArray>): void;
  26693. /**
  26694. * Gets the normal data stored in this target
  26695. * @returns a FloatArray containing the normal data (or null if not present)
  26696. */
  26697. getNormals(): Nullable<FloatArray>;
  26698. /**
  26699. * Affects tangent data to this target
  26700. * @param data defines the tangent data to use
  26701. */
  26702. setTangents(data: Nullable<FloatArray>): void;
  26703. /**
  26704. * Gets the tangent data stored in this target
  26705. * @returns a FloatArray containing the tangent data (or null if not present)
  26706. */
  26707. getTangents(): Nullable<FloatArray>;
  26708. /**
  26709. * Affects texture coordinates data to this target
  26710. * @param data defines the texture coordinates data to use
  26711. */
  26712. setUVs(data: Nullable<FloatArray>): void;
  26713. /**
  26714. * Gets the texture coordinates data stored in this target
  26715. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26716. */
  26717. getUVs(): Nullable<FloatArray>;
  26718. /**
  26719. * Clone the current target
  26720. * @returns a new MorphTarget
  26721. */
  26722. clone(): MorphTarget;
  26723. /**
  26724. * Serializes the current target into a Serialization object
  26725. * @returns the serialized object
  26726. */
  26727. serialize(): any;
  26728. /**
  26729. * Returns the string "MorphTarget"
  26730. * @returns "MorphTarget"
  26731. */
  26732. getClassName(): string;
  26733. /**
  26734. * Creates a new target from serialized data
  26735. * @param serializationObject defines the serialized data to use
  26736. * @returns a new MorphTarget
  26737. */
  26738. static Parse(serializationObject: any): MorphTarget;
  26739. /**
  26740. * Creates a MorphTarget from mesh data
  26741. * @param mesh defines the source mesh
  26742. * @param name defines the name to use for the new target
  26743. * @param influence defines the influence to attach to the target
  26744. * @returns a new MorphTarget
  26745. */
  26746. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26747. }
  26748. }
  26749. declare module BABYLON {
  26750. /**
  26751. * This class is used to deform meshes using morphing between different targets
  26752. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26753. */
  26754. export class MorphTargetManager {
  26755. private _targets;
  26756. private _targetInfluenceChangedObservers;
  26757. private _targetDataLayoutChangedObservers;
  26758. private _activeTargets;
  26759. private _scene;
  26760. private _influences;
  26761. private _supportsNormals;
  26762. private _supportsTangents;
  26763. private _supportsUVs;
  26764. private _vertexCount;
  26765. private _uniqueId;
  26766. private _tempInfluences;
  26767. /**
  26768. * Gets or sets a boolean indicating if normals must be morphed
  26769. */
  26770. enableNormalMorphing: boolean;
  26771. /**
  26772. * Gets or sets a boolean indicating if tangents must be morphed
  26773. */
  26774. enableTangentMorphing: boolean;
  26775. /**
  26776. * Gets or sets a boolean indicating if UV must be morphed
  26777. */
  26778. enableUVMorphing: boolean;
  26779. /**
  26780. * Creates a new MorphTargetManager
  26781. * @param scene defines the current scene
  26782. */
  26783. constructor(scene?: Nullable<Scene>);
  26784. /**
  26785. * Gets the unique ID of this manager
  26786. */
  26787. get uniqueId(): number;
  26788. /**
  26789. * Gets the number of vertices handled by this manager
  26790. */
  26791. get vertexCount(): number;
  26792. /**
  26793. * Gets a boolean indicating if this manager supports morphing of normals
  26794. */
  26795. get supportsNormals(): boolean;
  26796. /**
  26797. * Gets a boolean indicating if this manager supports morphing of tangents
  26798. */
  26799. get supportsTangents(): boolean;
  26800. /**
  26801. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26802. */
  26803. get supportsUVs(): boolean;
  26804. /**
  26805. * Gets the number of targets stored in this manager
  26806. */
  26807. get numTargets(): number;
  26808. /**
  26809. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26810. */
  26811. get numInfluencers(): number;
  26812. /**
  26813. * Gets the list of influences (one per target)
  26814. */
  26815. get influences(): Float32Array;
  26816. /**
  26817. * Gets the active target at specified index. An active target is a target with an influence > 0
  26818. * @param index defines the index to check
  26819. * @returns the requested target
  26820. */
  26821. getActiveTarget(index: number): MorphTarget;
  26822. /**
  26823. * Gets the target at specified index
  26824. * @param index defines the index to check
  26825. * @returns the requested target
  26826. */
  26827. getTarget(index: number): MorphTarget;
  26828. /**
  26829. * Add a new target to this manager
  26830. * @param target defines the target to add
  26831. */
  26832. addTarget(target: MorphTarget): void;
  26833. /**
  26834. * Removes a target from the manager
  26835. * @param target defines the target to remove
  26836. */
  26837. removeTarget(target: MorphTarget): void;
  26838. /**
  26839. * Clone the current manager
  26840. * @returns a new MorphTargetManager
  26841. */
  26842. clone(): MorphTargetManager;
  26843. /**
  26844. * Serializes the current manager into a Serialization object
  26845. * @returns the serialized object
  26846. */
  26847. serialize(): any;
  26848. private _syncActiveTargets;
  26849. /**
  26850. * Syncrhonize the targets with all the meshes using this morph target manager
  26851. */
  26852. synchronize(): void;
  26853. /**
  26854. * Creates a new MorphTargetManager from serialized data
  26855. * @param serializationObject defines the serialized data
  26856. * @param scene defines the hosting scene
  26857. * @returns the new MorphTargetManager
  26858. */
  26859. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26860. }
  26861. }
  26862. declare module BABYLON {
  26863. /**
  26864. * Class used to represent a specific level of detail of a mesh
  26865. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26866. */
  26867. export class MeshLODLevel {
  26868. /** Defines the distance where this level should start being displayed */
  26869. distance: number;
  26870. /** Defines the mesh to use to render this level */
  26871. mesh: Nullable<Mesh>;
  26872. /**
  26873. * Creates a new LOD level
  26874. * @param distance defines the distance where this level should star being displayed
  26875. * @param mesh defines the mesh to use to render this level
  26876. */
  26877. constructor(
  26878. /** Defines the distance where this level should start being displayed */
  26879. distance: number,
  26880. /** Defines the mesh to use to render this level */
  26881. mesh: Nullable<Mesh>);
  26882. }
  26883. }
  26884. declare module BABYLON {
  26885. /**
  26886. * Helper class used to generate a canvas to manipulate images
  26887. */
  26888. export class CanvasGenerator {
  26889. /**
  26890. * Create a new canvas (or offscreen canvas depending on the context)
  26891. * @param width defines the expected width
  26892. * @param height defines the expected height
  26893. * @return a new canvas or offscreen canvas
  26894. */
  26895. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26896. }
  26897. }
  26898. declare module BABYLON {
  26899. /**
  26900. * Mesh representing the gorund
  26901. */
  26902. export class GroundMesh extends Mesh {
  26903. /** If octree should be generated */
  26904. generateOctree: boolean;
  26905. private _heightQuads;
  26906. /** @hidden */
  26907. _subdivisionsX: number;
  26908. /** @hidden */
  26909. _subdivisionsY: number;
  26910. /** @hidden */
  26911. _width: number;
  26912. /** @hidden */
  26913. _height: number;
  26914. /** @hidden */
  26915. _minX: number;
  26916. /** @hidden */
  26917. _maxX: number;
  26918. /** @hidden */
  26919. _minZ: number;
  26920. /** @hidden */
  26921. _maxZ: number;
  26922. constructor(name: string, scene: Scene);
  26923. /**
  26924. * "GroundMesh"
  26925. * @returns "GroundMesh"
  26926. */
  26927. getClassName(): string;
  26928. /**
  26929. * The minimum of x and y subdivisions
  26930. */
  26931. get subdivisions(): number;
  26932. /**
  26933. * X subdivisions
  26934. */
  26935. get subdivisionsX(): number;
  26936. /**
  26937. * Y subdivisions
  26938. */
  26939. get subdivisionsY(): number;
  26940. /**
  26941. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26942. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26943. * @param chunksCount the number of subdivisions for x and y
  26944. * @param octreeBlocksSize (Default: 32)
  26945. */
  26946. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26947. /**
  26948. * Returns a height (y) value in the Worl system :
  26949. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26950. * @param x x coordinate
  26951. * @param z z coordinate
  26952. * @returns the ground y position if (x, z) are outside the ground surface.
  26953. */
  26954. getHeightAtCoordinates(x: number, z: number): number;
  26955. /**
  26956. * Returns a normalized vector (Vector3) orthogonal to the ground
  26957. * at the ground coordinates (x, z) expressed in the World system.
  26958. * @param x x coordinate
  26959. * @param z z coordinate
  26960. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26961. */
  26962. getNormalAtCoordinates(x: number, z: number): Vector3;
  26963. /**
  26964. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26965. * at the ground coordinates (x, z) expressed in the World system.
  26966. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26967. * @param x x coordinate
  26968. * @param z z coordinate
  26969. * @param ref vector to store the result
  26970. * @returns the GroundMesh.
  26971. */
  26972. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26973. /**
  26974. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26975. * if the ground has been updated.
  26976. * This can be used in the render loop.
  26977. * @returns the GroundMesh.
  26978. */
  26979. updateCoordinateHeights(): GroundMesh;
  26980. private _getFacetAt;
  26981. private _initHeightQuads;
  26982. private _computeHeightQuads;
  26983. /**
  26984. * Serializes this ground mesh
  26985. * @param serializationObject object to write serialization to
  26986. */
  26987. serialize(serializationObject: any): void;
  26988. /**
  26989. * Parses a serialized ground mesh
  26990. * @param parsedMesh the serialized mesh
  26991. * @param scene the scene to create the ground mesh in
  26992. * @returns the created ground mesh
  26993. */
  26994. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26995. }
  26996. }
  26997. declare module BABYLON {
  26998. /**
  26999. * Interface for Physics-Joint data
  27000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27001. */
  27002. export interface PhysicsJointData {
  27003. /**
  27004. * The main pivot of the joint
  27005. */
  27006. mainPivot?: Vector3;
  27007. /**
  27008. * The connected pivot of the joint
  27009. */
  27010. connectedPivot?: Vector3;
  27011. /**
  27012. * The main axis of the joint
  27013. */
  27014. mainAxis?: Vector3;
  27015. /**
  27016. * The connected axis of the joint
  27017. */
  27018. connectedAxis?: Vector3;
  27019. /**
  27020. * The collision of the joint
  27021. */
  27022. collision?: boolean;
  27023. /**
  27024. * Native Oimo/Cannon/Energy data
  27025. */
  27026. nativeParams?: any;
  27027. }
  27028. /**
  27029. * This is a holder class for the physics joint created by the physics plugin
  27030. * It holds a set of functions to control the underlying joint
  27031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27032. */
  27033. export class PhysicsJoint {
  27034. /**
  27035. * The type of the physics joint
  27036. */
  27037. type: number;
  27038. /**
  27039. * The data for the physics joint
  27040. */
  27041. jointData: PhysicsJointData;
  27042. private _physicsJoint;
  27043. protected _physicsPlugin: IPhysicsEnginePlugin;
  27044. /**
  27045. * Initializes the physics joint
  27046. * @param type The type of the physics joint
  27047. * @param jointData The data for the physics joint
  27048. */
  27049. constructor(
  27050. /**
  27051. * The type of the physics joint
  27052. */
  27053. type: number,
  27054. /**
  27055. * The data for the physics joint
  27056. */
  27057. jointData: PhysicsJointData);
  27058. /**
  27059. * Gets the physics joint
  27060. */
  27061. get physicsJoint(): any;
  27062. /**
  27063. * Sets the physics joint
  27064. */
  27065. set physicsJoint(newJoint: any);
  27066. /**
  27067. * Sets the physics plugin
  27068. */
  27069. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27070. /**
  27071. * Execute a function that is physics-plugin specific.
  27072. * @param {Function} func the function that will be executed.
  27073. * It accepts two parameters: the physics world and the physics joint
  27074. */
  27075. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27076. /**
  27077. * Distance-Joint type
  27078. */
  27079. static DistanceJoint: number;
  27080. /**
  27081. * Hinge-Joint type
  27082. */
  27083. static HingeJoint: number;
  27084. /**
  27085. * Ball-and-Socket joint type
  27086. */
  27087. static BallAndSocketJoint: number;
  27088. /**
  27089. * Wheel-Joint type
  27090. */
  27091. static WheelJoint: number;
  27092. /**
  27093. * Slider-Joint type
  27094. */
  27095. static SliderJoint: number;
  27096. /**
  27097. * Prismatic-Joint type
  27098. */
  27099. static PrismaticJoint: number;
  27100. /**
  27101. * Universal-Joint type
  27102. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27103. */
  27104. static UniversalJoint: number;
  27105. /**
  27106. * Hinge-Joint 2 type
  27107. */
  27108. static Hinge2Joint: number;
  27109. /**
  27110. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27111. */
  27112. static PointToPointJoint: number;
  27113. /**
  27114. * Spring-Joint type
  27115. */
  27116. static SpringJoint: number;
  27117. /**
  27118. * Lock-Joint type
  27119. */
  27120. static LockJoint: number;
  27121. }
  27122. /**
  27123. * A class representing a physics distance joint
  27124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27125. */
  27126. export class DistanceJoint extends PhysicsJoint {
  27127. /**
  27128. *
  27129. * @param jointData The data for the Distance-Joint
  27130. */
  27131. constructor(jointData: DistanceJointData);
  27132. /**
  27133. * Update the predefined distance.
  27134. * @param maxDistance The maximum preferred distance
  27135. * @param minDistance The minimum preferred distance
  27136. */
  27137. updateDistance(maxDistance: number, minDistance?: number): void;
  27138. }
  27139. /**
  27140. * Represents a Motor-Enabled Joint
  27141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27142. */
  27143. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27144. /**
  27145. * Initializes the Motor-Enabled Joint
  27146. * @param type The type of the joint
  27147. * @param jointData The physica joint data for the joint
  27148. */
  27149. constructor(type: number, jointData: PhysicsJointData);
  27150. /**
  27151. * Set the motor values.
  27152. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27153. * @param force the force to apply
  27154. * @param maxForce max force for this motor.
  27155. */
  27156. setMotor(force?: number, maxForce?: number): void;
  27157. /**
  27158. * Set the motor's limits.
  27159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27160. * @param upperLimit The upper limit of the motor
  27161. * @param lowerLimit The lower limit of the motor
  27162. */
  27163. setLimit(upperLimit: number, lowerLimit?: number): void;
  27164. }
  27165. /**
  27166. * This class represents a single physics Hinge-Joint
  27167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27168. */
  27169. export class HingeJoint extends MotorEnabledJoint {
  27170. /**
  27171. * Initializes the Hinge-Joint
  27172. * @param jointData The joint data for the Hinge-Joint
  27173. */
  27174. constructor(jointData: PhysicsJointData);
  27175. /**
  27176. * Set the motor values.
  27177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27178. * @param {number} force the force to apply
  27179. * @param {number} maxForce max force for this motor.
  27180. */
  27181. setMotor(force?: number, maxForce?: number): void;
  27182. /**
  27183. * Set the motor's limits.
  27184. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27185. * @param upperLimit The upper limit of the motor
  27186. * @param lowerLimit The lower limit of the motor
  27187. */
  27188. setLimit(upperLimit: number, lowerLimit?: number): void;
  27189. }
  27190. /**
  27191. * This class represents a dual hinge physics joint (same as wheel joint)
  27192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27193. */
  27194. export class Hinge2Joint extends MotorEnabledJoint {
  27195. /**
  27196. * Initializes the Hinge2-Joint
  27197. * @param jointData The joint data for the Hinge2-Joint
  27198. */
  27199. constructor(jointData: PhysicsJointData);
  27200. /**
  27201. * Set the motor values.
  27202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27203. * @param {number} targetSpeed the speed the motor is to reach
  27204. * @param {number} maxForce max force for this motor.
  27205. * @param {motorIndex} the motor's index, 0 or 1.
  27206. */
  27207. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27208. /**
  27209. * Set the motor limits.
  27210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27211. * @param {number} upperLimit the upper limit
  27212. * @param {number} lowerLimit lower limit
  27213. * @param {motorIndex} the motor's index, 0 or 1.
  27214. */
  27215. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27216. }
  27217. /**
  27218. * Interface for a motor enabled joint
  27219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27220. */
  27221. export interface IMotorEnabledJoint {
  27222. /**
  27223. * Physics joint
  27224. */
  27225. physicsJoint: any;
  27226. /**
  27227. * Sets the motor of the motor-enabled joint
  27228. * @param force The force of the motor
  27229. * @param maxForce The maximum force of the motor
  27230. * @param motorIndex The index of the motor
  27231. */
  27232. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27233. /**
  27234. * Sets the limit of the motor
  27235. * @param upperLimit The upper limit of the motor
  27236. * @param lowerLimit The lower limit of the motor
  27237. * @param motorIndex The index of the motor
  27238. */
  27239. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27240. }
  27241. /**
  27242. * Joint data for a Distance-Joint
  27243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27244. */
  27245. export interface DistanceJointData extends PhysicsJointData {
  27246. /**
  27247. * Max distance the 2 joint objects can be apart
  27248. */
  27249. maxDistance: number;
  27250. }
  27251. /**
  27252. * Joint data from a spring joint
  27253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27254. */
  27255. export interface SpringJointData extends PhysicsJointData {
  27256. /**
  27257. * Length of the spring
  27258. */
  27259. length: number;
  27260. /**
  27261. * Stiffness of the spring
  27262. */
  27263. stiffness: number;
  27264. /**
  27265. * Damping of the spring
  27266. */
  27267. damping: number;
  27268. /** this callback will be called when applying the force to the impostors. */
  27269. forceApplicationCallback: () => void;
  27270. }
  27271. }
  27272. declare module BABYLON {
  27273. /**
  27274. * Holds the data for the raycast result
  27275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27276. */
  27277. export class PhysicsRaycastResult {
  27278. private _hasHit;
  27279. private _hitDistance;
  27280. private _hitNormalWorld;
  27281. private _hitPointWorld;
  27282. private _rayFromWorld;
  27283. private _rayToWorld;
  27284. /**
  27285. * Gets if there was a hit
  27286. */
  27287. get hasHit(): boolean;
  27288. /**
  27289. * Gets the distance from the hit
  27290. */
  27291. get hitDistance(): number;
  27292. /**
  27293. * Gets the hit normal/direction in the world
  27294. */
  27295. get hitNormalWorld(): Vector3;
  27296. /**
  27297. * Gets the hit point in the world
  27298. */
  27299. get hitPointWorld(): Vector3;
  27300. /**
  27301. * Gets the ray "start point" of the ray in the world
  27302. */
  27303. get rayFromWorld(): Vector3;
  27304. /**
  27305. * Gets the ray "end point" of the ray in the world
  27306. */
  27307. get rayToWorld(): Vector3;
  27308. /**
  27309. * Sets the hit data (normal & point in world space)
  27310. * @param hitNormalWorld defines the normal in world space
  27311. * @param hitPointWorld defines the point in world space
  27312. */
  27313. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27314. /**
  27315. * Sets the distance from the start point to the hit point
  27316. * @param distance
  27317. */
  27318. setHitDistance(distance: number): void;
  27319. /**
  27320. * Calculates the distance manually
  27321. */
  27322. calculateHitDistance(): void;
  27323. /**
  27324. * Resets all the values to default
  27325. * @param from The from point on world space
  27326. * @param to The to point on world space
  27327. */
  27328. reset(from?: Vector3, to?: Vector3): void;
  27329. }
  27330. /**
  27331. * Interface for the size containing width and height
  27332. */
  27333. interface IXYZ {
  27334. /**
  27335. * X
  27336. */
  27337. x: number;
  27338. /**
  27339. * Y
  27340. */
  27341. y: number;
  27342. /**
  27343. * Z
  27344. */
  27345. z: number;
  27346. }
  27347. }
  27348. declare module BABYLON {
  27349. /**
  27350. * Interface used to describe a physics joint
  27351. */
  27352. export interface PhysicsImpostorJoint {
  27353. /** Defines the main impostor to which the joint is linked */
  27354. mainImpostor: PhysicsImpostor;
  27355. /** Defines the impostor that is connected to the main impostor using this joint */
  27356. connectedImpostor: PhysicsImpostor;
  27357. /** Defines the joint itself */
  27358. joint: PhysicsJoint;
  27359. }
  27360. /** @hidden */
  27361. export interface IPhysicsEnginePlugin {
  27362. world: any;
  27363. name: string;
  27364. setGravity(gravity: Vector3): void;
  27365. setTimeStep(timeStep: number): void;
  27366. getTimeStep(): number;
  27367. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27368. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27369. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27370. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27371. removePhysicsBody(impostor: PhysicsImpostor): void;
  27372. generateJoint(joint: PhysicsImpostorJoint): void;
  27373. removeJoint(joint: PhysicsImpostorJoint): void;
  27374. isSupported(): boolean;
  27375. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27376. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27377. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27378. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27380. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27381. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27382. getBodyMass(impostor: PhysicsImpostor): number;
  27383. getBodyFriction(impostor: PhysicsImpostor): number;
  27384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27385. getBodyRestitution(impostor: PhysicsImpostor): number;
  27386. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27387. getBodyPressure?(impostor: PhysicsImpostor): number;
  27388. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27389. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27390. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27391. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27392. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27393. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27394. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27395. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27396. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27397. sleepBody(impostor: PhysicsImpostor): void;
  27398. wakeUpBody(impostor: PhysicsImpostor): void;
  27399. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27400. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27401. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27402. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27403. getRadius(impostor: PhysicsImpostor): number;
  27404. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27405. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27406. dispose(): void;
  27407. }
  27408. /**
  27409. * Interface used to define a physics engine
  27410. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27411. */
  27412. export interface IPhysicsEngine {
  27413. /**
  27414. * Gets the gravity vector used by the simulation
  27415. */
  27416. gravity: Vector3;
  27417. /**
  27418. * Sets the gravity vector used by the simulation
  27419. * @param gravity defines the gravity vector to use
  27420. */
  27421. setGravity(gravity: Vector3): void;
  27422. /**
  27423. * Set the time step of the physics engine.
  27424. * Default is 1/60.
  27425. * To slow it down, enter 1/600 for example.
  27426. * To speed it up, 1/30
  27427. * @param newTimeStep the new timestep to apply to this world.
  27428. */
  27429. setTimeStep(newTimeStep: number): void;
  27430. /**
  27431. * Get the time step of the physics engine.
  27432. * @returns the current time step
  27433. */
  27434. getTimeStep(): number;
  27435. /**
  27436. * Set the sub time step of the physics engine.
  27437. * Default is 0 meaning there is no sub steps
  27438. * To increase physics resolution precision, set a small value (like 1 ms)
  27439. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27440. */
  27441. setSubTimeStep(subTimeStep: number): void;
  27442. /**
  27443. * Get the sub time step of the physics engine.
  27444. * @returns the current sub time step
  27445. */
  27446. getSubTimeStep(): number;
  27447. /**
  27448. * Release all resources
  27449. */
  27450. dispose(): void;
  27451. /**
  27452. * Gets the name of the current physics plugin
  27453. * @returns the name of the plugin
  27454. */
  27455. getPhysicsPluginName(): string;
  27456. /**
  27457. * Adding a new impostor for the impostor tracking.
  27458. * This will be done by the impostor itself.
  27459. * @param impostor the impostor to add
  27460. */
  27461. addImpostor(impostor: PhysicsImpostor): void;
  27462. /**
  27463. * Remove an impostor from the engine.
  27464. * This impostor and its mesh will not longer be updated by the physics engine.
  27465. * @param impostor the impostor to remove
  27466. */
  27467. removeImpostor(impostor: PhysicsImpostor): void;
  27468. /**
  27469. * Add a joint to the physics engine
  27470. * @param mainImpostor defines the main impostor to which the joint is added.
  27471. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27472. * @param joint defines the joint that will connect both impostors.
  27473. */
  27474. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27475. /**
  27476. * Removes a joint from the simulation
  27477. * @param mainImpostor defines the impostor used with the joint
  27478. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27479. * @param joint defines the joint to remove
  27480. */
  27481. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27482. /**
  27483. * Gets the current plugin used to run the simulation
  27484. * @returns current plugin
  27485. */
  27486. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27487. /**
  27488. * Gets the list of physic impostors
  27489. * @returns an array of PhysicsImpostor
  27490. */
  27491. getImpostors(): Array<PhysicsImpostor>;
  27492. /**
  27493. * Gets the impostor for a physics enabled object
  27494. * @param object defines the object impersonated by the impostor
  27495. * @returns the PhysicsImpostor or null if not found
  27496. */
  27497. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27498. /**
  27499. * Gets the impostor for a physics body object
  27500. * @param body defines physics body used by the impostor
  27501. * @returns the PhysicsImpostor or null if not found
  27502. */
  27503. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27504. /**
  27505. * Does a raycast in the physics world
  27506. * @param from when should the ray start?
  27507. * @param to when should the ray end?
  27508. * @returns PhysicsRaycastResult
  27509. */
  27510. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27511. /**
  27512. * Called by the scene. No need to call it.
  27513. * @param delta defines the timespam between frames
  27514. */
  27515. _step(delta: number): void;
  27516. }
  27517. }
  27518. declare module BABYLON {
  27519. /**
  27520. * The interface for the physics imposter parameters
  27521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27522. */
  27523. export interface PhysicsImpostorParameters {
  27524. /**
  27525. * The mass of the physics imposter
  27526. */
  27527. mass: number;
  27528. /**
  27529. * The friction of the physics imposter
  27530. */
  27531. friction?: number;
  27532. /**
  27533. * The coefficient of restitution of the physics imposter
  27534. */
  27535. restitution?: number;
  27536. /**
  27537. * The native options of the physics imposter
  27538. */
  27539. nativeOptions?: any;
  27540. /**
  27541. * Specifies if the parent should be ignored
  27542. */
  27543. ignoreParent?: boolean;
  27544. /**
  27545. * Specifies if bi-directional transformations should be disabled
  27546. */
  27547. disableBidirectionalTransformation?: boolean;
  27548. /**
  27549. * The pressure inside the physics imposter, soft object only
  27550. */
  27551. pressure?: number;
  27552. /**
  27553. * The stiffness the physics imposter, soft object only
  27554. */
  27555. stiffness?: number;
  27556. /**
  27557. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27558. */
  27559. velocityIterations?: number;
  27560. /**
  27561. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27562. */
  27563. positionIterations?: number;
  27564. /**
  27565. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27566. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27567. * Add to fix multiple points
  27568. */
  27569. fixedPoints?: number;
  27570. /**
  27571. * The collision margin around a soft object
  27572. */
  27573. margin?: number;
  27574. /**
  27575. * The collision margin around a soft object
  27576. */
  27577. damping?: number;
  27578. /**
  27579. * The path for a rope based on an extrusion
  27580. */
  27581. path?: any;
  27582. /**
  27583. * The shape of an extrusion used for a rope based on an extrusion
  27584. */
  27585. shape?: any;
  27586. }
  27587. /**
  27588. * Interface for a physics-enabled object
  27589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27590. */
  27591. export interface IPhysicsEnabledObject {
  27592. /**
  27593. * The position of the physics-enabled object
  27594. */
  27595. position: Vector3;
  27596. /**
  27597. * The rotation of the physics-enabled object
  27598. */
  27599. rotationQuaternion: Nullable<Quaternion>;
  27600. /**
  27601. * The scale of the physics-enabled object
  27602. */
  27603. scaling: Vector3;
  27604. /**
  27605. * The rotation of the physics-enabled object
  27606. */
  27607. rotation?: Vector3;
  27608. /**
  27609. * The parent of the physics-enabled object
  27610. */
  27611. parent?: any;
  27612. /**
  27613. * The bounding info of the physics-enabled object
  27614. * @returns The bounding info of the physics-enabled object
  27615. */
  27616. getBoundingInfo(): BoundingInfo;
  27617. /**
  27618. * Computes the world matrix
  27619. * @param force Specifies if the world matrix should be computed by force
  27620. * @returns A world matrix
  27621. */
  27622. computeWorldMatrix(force: boolean): Matrix;
  27623. /**
  27624. * Gets the world matrix
  27625. * @returns A world matrix
  27626. */
  27627. getWorldMatrix?(): Matrix;
  27628. /**
  27629. * Gets the child meshes
  27630. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27631. * @returns An array of abstract meshes
  27632. */
  27633. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27634. /**
  27635. * Gets the vertex data
  27636. * @param kind The type of vertex data
  27637. * @returns A nullable array of numbers, or a float32 array
  27638. */
  27639. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27640. /**
  27641. * Gets the indices from the mesh
  27642. * @returns A nullable array of index arrays
  27643. */
  27644. getIndices?(): Nullable<IndicesArray>;
  27645. /**
  27646. * Gets the scene from the mesh
  27647. * @returns the indices array or null
  27648. */
  27649. getScene?(): Scene;
  27650. /**
  27651. * Gets the absolute position from the mesh
  27652. * @returns the absolute position
  27653. */
  27654. getAbsolutePosition(): Vector3;
  27655. /**
  27656. * Gets the absolute pivot point from the mesh
  27657. * @returns the absolute pivot point
  27658. */
  27659. getAbsolutePivotPoint(): Vector3;
  27660. /**
  27661. * Rotates the mesh
  27662. * @param axis The axis of rotation
  27663. * @param amount The amount of rotation
  27664. * @param space The space of the rotation
  27665. * @returns The rotation transform node
  27666. */
  27667. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27668. /**
  27669. * Translates the mesh
  27670. * @param axis The axis of translation
  27671. * @param distance The distance of translation
  27672. * @param space The space of the translation
  27673. * @returns The transform node
  27674. */
  27675. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27676. /**
  27677. * Sets the absolute position of the mesh
  27678. * @param absolutePosition The absolute position of the mesh
  27679. * @returns The transform node
  27680. */
  27681. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27682. /**
  27683. * Gets the class name of the mesh
  27684. * @returns The class name
  27685. */
  27686. getClassName(): string;
  27687. }
  27688. /**
  27689. * Represents a physics imposter
  27690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27691. */
  27692. export class PhysicsImpostor {
  27693. /**
  27694. * The physics-enabled object used as the physics imposter
  27695. */
  27696. object: IPhysicsEnabledObject;
  27697. /**
  27698. * The type of the physics imposter
  27699. */
  27700. type: number;
  27701. private _options;
  27702. private _scene?;
  27703. /**
  27704. * The default object size of the imposter
  27705. */
  27706. static DEFAULT_OBJECT_SIZE: Vector3;
  27707. /**
  27708. * The identity quaternion of the imposter
  27709. */
  27710. static IDENTITY_QUATERNION: Quaternion;
  27711. /** @hidden */
  27712. _pluginData: any;
  27713. private _physicsEngine;
  27714. private _physicsBody;
  27715. private _bodyUpdateRequired;
  27716. private _onBeforePhysicsStepCallbacks;
  27717. private _onAfterPhysicsStepCallbacks;
  27718. /** @hidden */
  27719. _onPhysicsCollideCallbacks: Array<{
  27720. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27721. otherImpostors: Array<PhysicsImpostor>;
  27722. }>;
  27723. private _deltaPosition;
  27724. private _deltaRotation;
  27725. private _deltaRotationConjugated;
  27726. /** @hidden */
  27727. _isFromLine: boolean;
  27728. private _parent;
  27729. private _isDisposed;
  27730. private static _tmpVecs;
  27731. private static _tmpQuat;
  27732. /**
  27733. * Specifies if the physics imposter is disposed
  27734. */
  27735. get isDisposed(): boolean;
  27736. /**
  27737. * Gets the mass of the physics imposter
  27738. */
  27739. get mass(): number;
  27740. set mass(value: number);
  27741. /**
  27742. * Gets the coefficient of friction
  27743. */
  27744. get friction(): number;
  27745. /**
  27746. * Sets the coefficient of friction
  27747. */
  27748. set friction(value: number);
  27749. /**
  27750. * Gets the coefficient of restitution
  27751. */
  27752. get restitution(): number;
  27753. /**
  27754. * Sets the coefficient of restitution
  27755. */
  27756. set restitution(value: number);
  27757. /**
  27758. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27759. */
  27760. get pressure(): number;
  27761. /**
  27762. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27763. */
  27764. set pressure(value: number);
  27765. /**
  27766. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27767. */
  27768. get stiffness(): number;
  27769. /**
  27770. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27771. */
  27772. set stiffness(value: number);
  27773. /**
  27774. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27775. */
  27776. get velocityIterations(): number;
  27777. /**
  27778. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27779. */
  27780. set velocityIterations(value: number);
  27781. /**
  27782. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27783. */
  27784. get positionIterations(): number;
  27785. /**
  27786. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27787. */
  27788. set positionIterations(value: number);
  27789. /**
  27790. * The unique id of the physics imposter
  27791. * set by the physics engine when adding this impostor to the array
  27792. */
  27793. uniqueId: number;
  27794. /**
  27795. * @hidden
  27796. */
  27797. soft: boolean;
  27798. /**
  27799. * @hidden
  27800. */
  27801. segments: number;
  27802. private _joints;
  27803. /**
  27804. * Initializes the physics imposter
  27805. * @param object The physics-enabled object used as the physics imposter
  27806. * @param type The type of the physics imposter
  27807. * @param _options The options for the physics imposter
  27808. * @param _scene The Babylon scene
  27809. */
  27810. constructor(
  27811. /**
  27812. * The physics-enabled object used as the physics imposter
  27813. */
  27814. object: IPhysicsEnabledObject,
  27815. /**
  27816. * The type of the physics imposter
  27817. */
  27818. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27819. /**
  27820. * This function will completly initialize this impostor.
  27821. * It will create a new body - but only if this mesh has no parent.
  27822. * If it has, this impostor will not be used other than to define the impostor
  27823. * of the child mesh.
  27824. * @hidden
  27825. */
  27826. _init(): void;
  27827. private _getPhysicsParent;
  27828. /**
  27829. * Should a new body be generated.
  27830. * @returns boolean specifying if body initialization is required
  27831. */
  27832. isBodyInitRequired(): boolean;
  27833. /**
  27834. * Sets the updated scaling
  27835. * @param updated Specifies if the scaling is updated
  27836. */
  27837. setScalingUpdated(): void;
  27838. /**
  27839. * Force a regeneration of this or the parent's impostor's body.
  27840. * Use under cautious - This will remove all joints already implemented.
  27841. */
  27842. forceUpdate(): void;
  27843. /**
  27844. * Gets the body that holds this impostor. Either its own, or its parent.
  27845. */
  27846. get physicsBody(): any;
  27847. /**
  27848. * Get the parent of the physics imposter
  27849. * @returns Physics imposter or null
  27850. */
  27851. get parent(): Nullable<PhysicsImpostor>;
  27852. /**
  27853. * Sets the parent of the physics imposter
  27854. */
  27855. set parent(value: Nullable<PhysicsImpostor>);
  27856. /**
  27857. * Set the physics body. Used mainly by the physics engine/plugin
  27858. */
  27859. set physicsBody(physicsBody: any);
  27860. /**
  27861. * Resets the update flags
  27862. */
  27863. resetUpdateFlags(): void;
  27864. /**
  27865. * Gets the object extend size
  27866. * @returns the object extend size
  27867. */
  27868. getObjectExtendSize(): Vector3;
  27869. /**
  27870. * Gets the object center
  27871. * @returns The object center
  27872. */
  27873. getObjectCenter(): Vector3;
  27874. /**
  27875. * Get a specific parameter from the options parameters
  27876. * @param paramName The object parameter name
  27877. * @returns The object parameter
  27878. */
  27879. getParam(paramName: string): any;
  27880. /**
  27881. * Sets a specific parameter in the options given to the physics plugin
  27882. * @param paramName The parameter name
  27883. * @param value The value of the parameter
  27884. */
  27885. setParam(paramName: string, value: number): void;
  27886. /**
  27887. * Specifically change the body's mass option. Won't recreate the physics body object
  27888. * @param mass The mass of the physics imposter
  27889. */
  27890. setMass(mass: number): void;
  27891. /**
  27892. * Gets the linear velocity
  27893. * @returns linear velocity or null
  27894. */
  27895. getLinearVelocity(): Nullable<Vector3>;
  27896. /**
  27897. * Sets the linear velocity
  27898. * @param velocity linear velocity or null
  27899. */
  27900. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27901. /**
  27902. * Gets the angular velocity
  27903. * @returns angular velocity or null
  27904. */
  27905. getAngularVelocity(): Nullable<Vector3>;
  27906. /**
  27907. * Sets the angular velocity
  27908. * @param velocity The velocity or null
  27909. */
  27910. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27911. /**
  27912. * Execute a function with the physics plugin native code
  27913. * Provide a function the will have two variables - the world object and the physics body object
  27914. * @param func The function to execute with the physics plugin native code
  27915. */
  27916. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27917. /**
  27918. * Register a function that will be executed before the physics world is stepping forward
  27919. * @param func The function to execute before the physics world is stepped forward
  27920. */
  27921. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27922. /**
  27923. * Unregister a function that will be executed before the physics world is stepping forward
  27924. * @param func The function to execute before the physics world is stepped forward
  27925. */
  27926. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27927. /**
  27928. * Register a function that will be executed after the physics step
  27929. * @param func The function to execute after physics step
  27930. */
  27931. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27932. /**
  27933. * Unregisters a function that will be executed after the physics step
  27934. * @param func The function to execute after physics step
  27935. */
  27936. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27937. /**
  27938. * register a function that will be executed when this impostor collides against a different body
  27939. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27940. * @param func Callback that is executed on collision
  27941. */
  27942. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27943. /**
  27944. * Unregisters the physics imposter on contact
  27945. * @param collideAgainst The physics object to collide against
  27946. * @param func Callback to execute on collision
  27947. */
  27948. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27949. private _tmpQuat;
  27950. private _tmpQuat2;
  27951. /**
  27952. * Get the parent rotation
  27953. * @returns The parent rotation
  27954. */
  27955. getParentsRotation(): Quaternion;
  27956. /**
  27957. * this function is executed by the physics engine.
  27958. */
  27959. beforeStep: () => void;
  27960. /**
  27961. * this function is executed by the physics engine
  27962. */
  27963. afterStep: () => void;
  27964. /**
  27965. * Legacy collision detection event support
  27966. */
  27967. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27968. /**
  27969. * event and body object due to cannon's event-based architecture.
  27970. */
  27971. onCollide: (e: {
  27972. body: any;
  27973. }) => void;
  27974. /**
  27975. * Apply a force
  27976. * @param force The force to apply
  27977. * @param contactPoint The contact point for the force
  27978. * @returns The physics imposter
  27979. */
  27980. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27981. /**
  27982. * Apply an impulse
  27983. * @param force The impulse force
  27984. * @param contactPoint The contact point for the impulse force
  27985. * @returns The physics imposter
  27986. */
  27987. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27988. /**
  27989. * A help function to create a joint
  27990. * @param otherImpostor A physics imposter used to create a joint
  27991. * @param jointType The type of joint
  27992. * @param jointData The data for the joint
  27993. * @returns The physics imposter
  27994. */
  27995. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27996. /**
  27997. * Add a joint to this impostor with a different impostor
  27998. * @param otherImpostor A physics imposter used to add a joint
  27999. * @param joint The joint to add
  28000. * @returns The physics imposter
  28001. */
  28002. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28003. /**
  28004. * Add an anchor to a cloth impostor
  28005. * @param otherImpostor rigid impostor to anchor to
  28006. * @param width ratio across width from 0 to 1
  28007. * @param height ratio up height from 0 to 1
  28008. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28009. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28010. * @returns impostor the soft imposter
  28011. */
  28012. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28013. /**
  28014. * Add a hook to a rope impostor
  28015. * @param otherImpostor rigid impostor to anchor to
  28016. * @param length ratio across rope from 0 to 1
  28017. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28018. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28019. * @returns impostor the rope imposter
  28020. */
  28021. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28022. /**
  28023. * Will keep this body still, in a sleep mode.
  28024. * @returns the physics imposter
  28025. */
  28026. sleep(): PhysicsImpostor;
  28027. /**
  28028. * Wake the body up.
  28029. * @returns The physics imposter
  28030. */
  28031. wakeUp(): PhysicsImpostor;
  28032. /**
  28033. * Clones the physics imposter
  28034. * @param newObject The physics imposter clones to this physics-enabled object
  28035. * @returns A nullable physics imposter
  28036. */
  28037. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28038. /**
  28039. * Disposes the physics imposter
  28040. */
  28041. dispose(): void;
  28042. /**
  28043. * Sets the delta position
  28044. * @param position The delta position amount
  28045. */
  28046. setDeltaPosition(position: Vector3): void;
  28047. /**
  28048. * Sets the delta rotation
  28049. * @param rotation The delta rotation amount
  28050. */
  28051. setDeltaRotation(rotation: Quaternion): void;
  28052. /**
  28053. * Gets the box size of the physics imposter and stores the result in the input parameter
  28054. * @param result Stores the box size
  28055. * @returns The physics imposter
  28056. */
  28057. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28058. /**
  28059. * Gets the radius of the physics imposter
  28060. * @returns Radius of the physics imposter
  28061. */
  28062. getRadius(): number;
  28063. /**
  28064. * Sync a bone with this impostor
  28065. * @param bone The bone to sync to the impostor.
  28066. * @param boneMesh The mesh that the bone is influencing.
  28067. * @param jointPivot The pivot of the joint / bone in local space.
  28068. * @param distToJoint Optional distance from the impostor to the joint.
  28069. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28070. */
  28071. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28072. /**
  28073. * Sync impostor to a bone
  28074. * @param bone The bone that the impostor will be synced to.
  28075. * @param boneMesh The mesh that the bone is influencing.
  28076. * @param jointPivot The pivot of the joint / bone in local space.
  28077. * @param distToJoint Optional distance from the impostor to the joint.
  28078. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28079. * @param boneAxis Optional vector3 axis the bone is aligned with
  28080. */
  28081. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28082. /**
  28083. * No-Imposter type
  28084. */
  28085. static NoImpostor: number;
  28086. /**
  28087. * Sphere-Imposter type
  28088. */
  28089. static SphereImpostor: number;
  28090. /**
  28091. * Box-Imposter type
  28092. */
  28093. static BoxImpostor: number;
  28094. /**
  28095. * Plane-Imposter type
  28096. */
  28097. static PlaneImpostor: number;
  28098. /**
  28099. * Mesh-imposter type
  28100. */
  28101. static MeshImpostor: number;
  28102. /**
  28103. * Capsule-Impostor type (Ammo.js plugin only)
  28104. */
  28105. static CapsuleImpostor: number;
  28106. /**
  28107. * Cylinder-Imposter type
  28108. */
  28109. static CylinderImpostor: number;
  28110. /**
  28111. * Particle-Imposter type
  28112. */
  28113. static ParticleImpostor: number;
  28114. /**
  28115. * Heightmap-Imposter type
  28116. */
  28117. static HeightmapImpostor: number;
  28118. /**
  28119. * ConvexHull-Impostor type (Ammo.js plugin only)
  28120. */
  28121. static ConvexHullImpostor: number;
  28122. /**
  28123. * Custom-Imposter type (Ammo.js plugin only)
  28124. */
  28125. static CustomImpostor: number;
  28126. /**
  28127. * Rope-Imposter type
  28128. */
  28129. static RopeImpostor: number;
  28130. /**
  28131. * Cloth-Imposter type
  28132. */
  28133. static ClothImpostor: number;
  28134. /**
  28135. * Softbody-Imposter type
  28136. */
  28137. static SoftbodyImpostor: number;
  28138. }
  28139. }
  28140. declare module BABYLON {
  28141. /**
  28142. * @hidden
  28143. **/
  28144. export class _CreationDataStorage {
  28145. closePath?: boolean;
  28146. closeArray?: boolean;
  28147. idx: number[];
  28148. dashSize: number;
  28149. gapSize: number;
  28150. path3D: Path3D;
  28151. pathArray: Vector3[][];
  28152. arc: number;
  28153. radius: number;
  28154. cap: number;
  28155. tessellation: number;
  28156. }
  28157. /**
  28158. * @hidden
  28159. **/
  28160. class _InstanceDataStorage {
  28161. visibleInstances: any;
  28162. batchCache: _InstancesBatch;
  28163. instancesBufferSize: number;
  28164. instancesBuffer: Nullable<Buffer>;
  28165. instancesData: Float32Array;
  28166. overridenInstanceCount: number;
  28167. isFrozen: boolean;
  28168. previousBatch: Nullable<_InstancesBatch>;
  28169. hardwareInstancedRendering: boolean;
  28170. sideOrientation: number;
  28171. manualUpdate: boolean;
  28172. previousRenderId: number;
  28173. }
  28174. /**
  28175. * @hidden
  28176. **/
  28177. export class _InstancesBatch {
  28178. mustReturn: boolean;
  28179. visibleInstances: Nullable<InstancedMesh[]>[];
  28180. renderSelf: boolean[];
  28181. hardwareInstancedRendering: boolean[];
  28182. }
  28183. /**
  28184. * @hidden
  28185. **/
  28186. class _ThinInstanceDataStorage {
  28187. instancesCount: number;
  28188. matrixBuffer: Nullable<Buffer>;
  28189. matrixBufferSize: number;
  28190. matrixData: Nullable<Float32Array>;
  28191. boundingVectors: Array<Vector3>;
  28192. worldMatrices: Nullable<Matrix[]>;
  28193. }
  28194. /**
  28195. * Class used to represent renderable models
  28196. */
  28197. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28198. /**
  28199. * Mesh side orientation : usually the external or front surface
  28200. */
  28201. static readonly FRONTSIDE: number;
  28202. /**
  28203. * Mesh side orientation : usually the internal or back surface
  28204. */
  28205. static readonly BACKSIDE: number;
  28206. /**
  28207. * Mesh side orientation : both internal and external or front and back surfaces
  28208. */
  28209. static readonly DOUBLESIDE: number;
  28210. /**
  28211. * Mesh side orientation : by default, `FRONTSIDE`
  28212. */
  28213. static readonly DEFAULTSIDE: number;
  28214. /**
  28215. * Mesh cap setting : no cap
  28216. */
  28217. static readonly NO_CAP: number;
  28218. /**
  28219. * Mesh cap setting : one cap at the beginning of the mesh
  28220. */
  28221. static readonly CAP_START: number;
  28222. /**
  28223. * Mesh cap setting : one cap at the end of the mesh
  28224. */
  28225. static readonly CAP_END: number;
  28226. /**
  28227. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28228. */
  28229. static readonly CAP_ALL: number;
  28230. /**
  28231. * Mesh pattern setting : no flip or rotate
  28232. */
  28233. static readonly NO_FLIP: number;
  28234. /**
  28235. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28236. */
  28237. static readonly FLIP_TILE: number;
  28238. /**
  28239. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28240. */
  28241. static readonly ROTATE_TILE: number;
  28242. /**
  28243. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28244. */
  28245. static readonly FLIP_ROW: number;
  28246. /**
  28247. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28248. */
  28249. static readonly ROTATE_ROW: number;
  28250. /**
  28251. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28252. */
  28253. static readonly FLIP_N_ROTATE_TILE: number;
  28254. /**
  28255. * Mesh pattern setting : rotate pattern and rotate
  28256. */
  28257. static readonly FLIP_N_ROTATE_ROW: number;
  28258. /**
  28259. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28260. */
  28261. static readonly CENTER: number;
  28262. /**
  28263. * Mesh tile positioning : part tiles on left
  28264. */
  28265. static readonly LEFT: number;
  28266. /**
  28267. * Mesh tile positioning : part tiles on right
  28268. */
  28269. static readonly RIGHT: number;
  28270. /**
  28271. * Mesh tile positioning : part tiles on top
  28272. */
  28273. static readonly TOP: number;
  28274. /**
  28275. * Mesh tile positioning : part tiles on bottom
  28276. */
  28277. static readonly BOTTOM: number;
  28278. /**
  28279. * Gets the default side orientation.
  28280. * @param orientation the orientation to value to attempt to get
  28281. * @returns the default orientation
  28282. * @hidden
  28283. */
  28284. static _GetDefaultSideOrientation(orientation?: number): number;
  28285. private _internalMeshDataInfo;
  28286. get computeBonesUsingShaders(): boolean;
  28287. set computeBonesUsingShaders(value: boolean);
  28288. /**
  28289. * An event triggered before rendering the mesh
  28290. */
  28291. get onBeforeRenderObservable(): Observable<Mesh>;
  28292. /**
  28293. * An event triggered before binding the mesh
  28294. */
  28295. get onBeforeBindObservable(): Observable<Mesh>;
  28296. /**
  28297. * An event triggered after rendering the mesh
  28298. */
  28299. get onAfterRenderObservable(): Observable<Mesh>;
  28300. /**
  28301. * An event triggered before drawing the mesh
  28302. */
  28303. get onBeforeDrawObservable(): Observable<Mesh>;
  28304. private _onBeforeDrawObserver;
  28305. /**
  28306. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28307. */
  28308. set onBeforeDraw(callback: () => void);
  28309. get hasInstances(): boolean;
  28310. get hasThinInstances(): boolean;
  28311. /**
  28312. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28313. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28314. */
  28315. delayLoadState: number;
  28316. /**
  28317. * Gets the list of instances created from this mesh
  28318. * it is not supposed to be modified manually.
  28319. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28320. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28321. */
  28322. instances: InstancedMesh[];
  28323. /**
  28324. * Gets the file containing delay loading data for this mesh
  28325. */
  28326. delayLoadingFile: string;
  28327. /** @hidden */
  28328. _binaryInfo: any;
  28329. /**
  28330. * User defined function used to change how LOD level selection is done
  28331. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28332. */
  28333. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28334. /**
  28335. * Gets or sets the morph target manager
  28336. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28337. */
  28338. get morphTargetManager(): Nullable<MorphTargetManager>;
  28339. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28340. /** @hidden */
  28341. _creationDataStorage: Nullable<_CreationDataStorage>;
  28342. /** @hidden */
  28343. _geometry: Nullable<Geometry>;
  28344. /** @hidden */
  28345. _delayInfo: Array<string>;
  28346. /** @hidden */
  28347. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28348. /** @hidden */
  28349. _instanceDataStorage: _InstanceDataStorage;
  28350. /** @hidden */
  28351. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28352. private _effectiveMaterial;
  28353. /** @hidden */
  28354. _shouldGenerateFlatShading: boolean;
  28355. /** @hidden */
  28356. _originalBuilderSideOrientation: number;
  28357. /**
  28358. * Use this property to change the original side orientation defined at construction time
  28359. */
  28360. overrideMaterialSideOrientation: Nullable<number>;
  28361. /**
  28362. * Gets the source mesh (the one used to clone this one from)
  28363. */
  28364. get source(): Nullable<Mesh>;
  28365. /**
  28366. * Gets the list of clones of this mesh
  28367. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28368. * Note that useClonedMeshMap=true is the default setting
  28369. */
  28370. get cloneMeshMap(): Nullable<{
  28371. [id: string]: Mesh | undefined;
  28372. }>;
  28373. /**
  28374. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28375. */
  28376. get isUnIndexed(): boolean;
  28377. set isUnIndexed(value: boolean);
  28378. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28379. get worldMatrixInstancedBuffer(): Float32Array;
  28380. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28381. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28382. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28383. /**
  28384. * @constructor
  28385. * @param name The value used by scene.getMeshByName() to do a lookup.
  28386. * @param scene The scene to add this mesh to.
  28387. * @param parent The parent of this mesh, if it has one
  28388. * @param source An optional Mesh from which geometry is shared, cloned.
  28389. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28390. * When false, achieved by calling a clone(), also passing False.
  28391. * This will make creation of children, recursive.
  28392. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28393. */
  28394. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28395. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28396. doNotInstantiate: boolean;
  28397. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28398. /**
  28399. * Gets the class name
  28400. * @returns the string "Mesh".
  28401. */
  28402. getClassName(): string;
  28403. /** @hidden */
  28404. get _isMesh(): boolean;
  28405. /**
  28406. * Returns a description of this mesh
  28407. * @param fullDetails define if full details about this mesh must be used
  28408. * @returns a descriptive string representing this mesh
  28409. */
  28410. toString(fullDetails?: boolean): string;
  28411. /** @hidden */
  28412. _unBindEffect(): void;
  28413. /**
  28414. * Gets a boolean indicating if this mesh has LOD
  28415. */
  28416. get hasLODLevels(): boolean;
  28417. /**
  28418. * Gets the list of MeshLODLevel associated with the current mesh
  28419. * @returns an array of MeshLODLevel
  28420. */
  28421. getLODLevels(): MeshLODLevel[];
  28422. private _sortLODLevels;
  28423. /**
  28424. * Add a mesh as LOD level triggered at the given distance.
  28425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28426. * @param distance The distance from the center of the object to show this level
  28427. * @param mesh The mesh to be added as LOD level (can be null)
  28428. * @return This mesh (for chaining)
  28429. */
  28430. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28431. /**
  28432. * Returns the LOD level mesh at the passed distance or null if not found.
  28433. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28434. * @param distance The distance from the center of the object to show this level
  28435. * @returns a Mesh or `null`
  28436. */
  28437. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28438. /**
  28439. * Remove a mesh from the LOD array
  28440. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28441. * @param mesh defines the mesh to be removed
  28442. * @return This mesh (for chaining)
  28443. */
  28444. removeLODLevel(mesh: Mesh): Mesh;
  28445. /**
  28446. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28447. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28448. * @param camera defines the camera to use to compute distance
  28449. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28450. * @return This mesh (for chaining)
  28451. */
  28452. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28453. /**
  28454. * Gets the mesh internal Geometry object
  28455. */
  28456. get geometry(): Nullable<Geometry>;
  28457. /**
  28458. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28459. * @returns the total number of vertices
  28460. */
  28461. getTotalVertices(): number;
  28462. /**
  28463. * Returns the content of an associated vertex buffer
  28464. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28465. * - VertexBuffer.PositionKind
  28466. * - VertexBuffer.UVKind
  28467. * - VertexBuffer.UV2Kind
  28468. * - VertexBuffer.UV3Kind
  28469. * - VertexBuffer.UV4Kind
  28470. * - VertexBuffer.UV5Kind
  28471. * - VertexBuffer.UV6Kind
  28472. * - VertexBuffer.ColorKind
  28473. * - VertexBuffer.MatricesIndicesKind
  28474. * - VertexBuffer.MatricesIndicesExtraKind
  28475. * - VertexBuffer.MatricesWeightsKind
  28476. * - VertexBuffer.MatricesWeightsExtraKind
  28477. * @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
  28478. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28479. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28480. */
  28481. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28482. /**
  28483. * Returns the mesh VertexBuffer object from the requested `kind`
  28484. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28485. * - VertexBuffer.PositionKind
  28486. * - VertexBuffer.NormalKind
  28487. * - VertexBuffer.UVKind
  28488. * - VertexBuffer.UV2Kind
  28489. * - VertexBuffer.UV3Kind
  28490. * - VertexBuffer.UV4Kind
  28491. * - VertexBuffer.UV5Kind
  28492. * - VertexBuffer.UV6Kind
  28493. * - VertexBuffer.ColorKind
  28494. * - VertexBuffer.MatricesIndicesKind
  28495. * - VertexBuffer.MatricesIndicesExtraKind
  28496. * - VertexBuffer.MatricesWeightsKind
  28497. * - VertexBuffer.MatricesWeightsExtraKind
  28498. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28499. */
  28500. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28501. /**
  28502. * Tests if a specific vertex buffer is associated with this mesh
  28503. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28504. * - VertexBuffer.PositionKind
  28505. * - VertexBuffer.NormalKind
  28506. * - VertexBuffer.UVKind
  28507. * - VertexBuffer.UV2Kind
  28508. * - VertexBuffer.UV3Kind
  28509. * - VertexBuffer.UV4Kind
  28510. * - VertexBuffer.UV5Kind
  28511. * - VertexBuffer.UV6Kind
  28512. * - VertexBuffer.ColorKind
  28513. * - VertexBuffer.MatricesIndicesKind
  28514. * - VertexBuffer.MatricesIndicesExtraKind
  28515. * - VertexBuffer.MatricesWeightsKind
  28516. * - VertexBuffer.MatricesWeightsExtraKind
  28517. * @returns a boolean
  28518. */
  28519. isVerticesDataPresent(kind: string): boolean;
  28520. /**
  28521. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28522. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28523. * - VertexBuffer.PositionKind
  28524. * - VertexBuffer.UVKind
  28525. * - VertexBuffer.UV2Kind
  28526. * - VertexBuffer.UV3Kind
  28527. * - VertexBuffer.UV4Kind
  28528. * - VertexBuffer.UV5Kind
  28529. * - VertexBuffer.UV6Kind
  28530. * - VertexBuffer.ColorKind
  28531. * - VertexBuffer.MatricesIndicesKind
  28532. * - VertexBuffer.MatricesIndicesExtraKind
  28533. * - VertexBuffer.MatricesWeightsKind
  28534. * - VertexBuffer.MatricesWeightsExtraKind
  28535. * @returns a boolean
  28536. */
  28537. isVertexBufferUpdatable(kind: string): boolean;
  28538. /**
  28539. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28540. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28541. * - VertexBuffer.PositionKind
  28542. * - VertexBuffer.NormalKind
  28543. * - VertexBuffer.UVKind
  28544. * - VertexBuffer.UV2Kind
  28545. * - VertexBuffer.UV3Kind
  28546. * - VertexBuffer.UV4Kind
  28547. * - VertexBuffer.UV5Kind
  28548. * - VertexBuffer.UV6Kind
  28549. * - VertexBuffer.ColorKind
  28550. * - VertexBuffer.MatricesIndicesKind
  28551. * - VertexBuffer.MatricesIndicesExtraKind
  28552. * - VertexBuffer.MatricesWeightsKind
  28553. * - VertexBuffer.MatricesWeightsExtraKind
  28554. * @returns an array of strings
  28555. */
  28556. getVerticesDataKinds(): string[];
  28557. /**
  28558. * Returns a positive integer : the total number of indices in this mesh geometry.
  28559. * @returns the numner of indices or zero if the mesh has no geometry.
  28560. */
  28561. getTotalIndices(): number;
  28562. /**
  28563. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28564. * @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.
  28565. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28566. * @returns the indices array or an empty array if the mesh has no geometry
  28567. */
  28568. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28569. get isBlocked(): boolean;
  28570. /**
  28571. * Determine if the current mesh is ready to be rendered
  28572. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28573. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28574. * @returns true if all associated assets are ready (material, textures, shaders)
  28575. */
  28576. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28577. /**
  28578. * 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.
  28579. */
  28580. get areNormalsFrozen(): boolean;
  28581. /**
  28582. * 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.
  28583. * @returns the current mesh
  28584. */
  28585. freezeNormals(): Mesh;
  28586. /**
  28587. * 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
  28588. * @returns the current mesh
  28589. */
  28590. unfreezeNormals(): Mesh;
  28591. /**
  28592. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28593. */
  28594. set overridenInstanceCount(count: number);
  28595. /** @hidden */
  28596. _preActivate(): Mesh;
  28597. /** @hidden */
  28598. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28599. /** @hidden */
  28600. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28601. protected _afterComputeWorldMatrix(): void;
  28602. /** @hidden */
  28603. _postActivate(): void;
  28604. /**
  28605. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28606. * This means the mesh underlying bounding box and sphere are recomputed.
  28607. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28608. * @returns the current mesh
  28609. */
  28610. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28611. /** @hidden */
  28612. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28613. /**
  28614. * This function will subdivide the mesh into multiple submeshes
  28615. * @param count defines the expected number of submeshes
  28616. */
  28617. subdivide(count: number): void;
  28618. /**
  28619. * Copy a FloatArray into a specific associated vertex buffer
  28620. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28621. * - VertexBuffer.PositionKind
  28622. * - VertexBuffer.UVKind
  28623. * - VertexBuffer.UV2Kind
  28624. * - VertexBuffer.UV3Kind
  28625. * - VertexBuffer.UV4Kind
  28626. * - VertexBuffer.UV5Kind
  28627. * - VertexBuffer.UV6Kind
  28628. * - VertexBuffer.ColorKind
  28629. * - VertexBuffer.MatricesIndicesKind
  28630. * - VertexBuffer.MatricesIndicesExtraKind
  28631. * - VertexBuffer.MatricesWeightsKind
  28632. * - VertexBuffer.MatricesWeightsExtraKind
  28633. * @param data defines the data source
  28634. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28635. * @param stride defines the data stride size (can be null)
  28636. * @returns the current mesh
  28637. */
  28638. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28639. /**
  28640. * Delete a vertex buffer associated with this mesh
  28641. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28642. * - VertexBuffer.PositionKind
  28643. * - VertexBuffer.UVKind
  28644. * - VertexBuffer.UV2Kind
  28645. * - VertexBuffer.UV3Kind
  28646. * - VertexBuffer.UV4Kind
  28647. * - VertexBuffer.UV5Kind
  28648. * - VertexBuffer.UV6Kind
  28649. * - VertexBuffer.ColorKind
  28650. * - VertexBuffer.MatricesIndicesKind
  28651. * - VertexBuffer.MatricesIndicesExtraKind
  28652. * - VertexBuffer.MatricesWeightsKind
  28653. * - VertexBuffer.MatricesWeightsExtraKind
  28654. */
  28655. removeVerticesData(kind: string): void;
  28656. /**
  28657. * Flags an associated vertex buffer as updatable
  28658. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28659. * - VertexBuffer.PositionKind
  28660. * - VertexBuffer.UVKind
  28661. * - VertexBuffer.UV2Kind
  28662. * - VertexBuffer.UV3Kind
  28663. * - VertexBuffer.UV4Kind
  28664. * - VertexBuffer.UV5Kind
  28665. * - VertexBuffer.UV6Kind
  28666. * - VertexBuffer.ColorKind
  28667. * - VertexBuffer.MatricesIndicesKind
  28668. * - VertexBuffer.MatricesIndicesExtraKind
  28669. * - VertexBuffer.MatricesWeightsKind
  28670. * - VertexBuffer.MatricesWeightsExtraKind
  28671. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28672. */
  28673. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28674. /**
  28675. * Sets the mesh global Vertex Buffer
  28676. * @param buffer defines the buffer to use
  28677. * @returns the current mesh
  28678. */
  28679. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28680. /**
  28681. * Update a specific associated vertex buffer
  28682. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28683. * - VertexBuffer.PositionKind
  28684. * - VertexBuffer.UVKind
  28685. * - VertexBuffer.UV2Kind
  28686. * - VertexBuffer.UV3Kind
  28687. * - VertexBuffer.UV4Kind
  28688. * - VertexBuffer.UV5Kind
  28689. * - VertexBuffer.UV6Kind
  28690. * - VertexBuffer.ColorKind
  28691. * - VertexBuffer.MatricesIndicesKind
  28692. * - VertexBuffer.MatricesIndicesExtraKind
  28693. * - VertexBuffer.MatricesWeightsKind
  28694. * - VertexBuffer.MatricesWeightsExtraKind
  28695. * @param data defines the data source
  28696. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28697. * @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)
  28698. * @returns the current mesh
  28699. */
  28700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28701. /**
  28702. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28703. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28704. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28705. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28706. * @returns the current mesh
  28707. */
  28708. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28709. /**
  28710. * Creates a un-shared specific occurence of the geometry for the mesh.
  28711. * @returns the current mesh
  28712. */
  28713. makeGeometryUnique(): Mesh;
  28714. /**
  28715. * Set the index buffer of this mesh
  28716. * @param indices defines the source data
  28717. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28718. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28719. * @returns the current mesh
  28720. */
  28721. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28722. /**
  28723. * Update the current index buffer
  28724. * @param indices defines the source data
  28725. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28726. * @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)
  28727. * @returns the current mesh
  28728. */
  28729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28730. /**
  28731. * Invert the geometry to move from a right handed system to a left handed one.
  28732. * @returns the current mesh
  28733. */
  28734. toLeftHanded(): Mesh;
  28735. /** @hidden */
  28736. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28737. /** @hidden */
  28738. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28739. /**
  28740. * Registers for this mesh a javascript function called just before the rendering process
  28741. * @param func defines the function to call before rendering this mesh
  28742. * @returns the current mesh
  28743. */
  28744. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28745. /**
  28746. * Disposes a previously registered javascript function called before the rendering
  28747. * @param func defines the function to remove
  28748. * @returns the current mesh
  28749. */
  28750. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28751. /**
  28752. * Registers for this mesh a javascript function called just after the rendering is complete
  28753. * @param func defines the function to call after rendering this mesh
  28754. * @returns the current mesh
  28755. */
  28756. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28757. /**
  28758. * Disposes a previously registered javascript function called after the rendering.
  28759. * @param func defines the function to remove
  28760. * @returns the current mesh
  28761. */
  28762. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28763. /** @hidden */
  28764. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28765. /** @hidden */
  28766. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28767. /** @hidden */
  28768. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28769. /** @hidden */
  28770. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28771. /** @hidden */
  28772. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28773. /** @hidden */
  28774. _rebuild(): void;
  28775. /** @hidden */
  28776. _freeze(): void;
  28777. /** @hidden */
  28778. _unFreeze(): void;
  28779. /**
  28780. * 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
  28781. * @param subMesh defines the subMesh to render
  28782. * @param enableAlphaMode defines if alpha mode can be changed
  28783. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28784. * @returns the current mesh
  28785. */
  28786. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28787. private _onBeforeDraw;
  28788. /**
  28789. * Renormalize the mesh and patch it up if there are no weights
  28790. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28791. * However in the case of zero weights then we set just a single influence to 1.
  28792. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28793. */
  28794. cleanMatrixWeights(): void;
  28795. private normalizeSkinFourWeights;
  28796. private normalizeSkinWeightsAndExtra;
  28797. /**
  28798. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28799. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28800. * the user know there was an issue with importing the mesh
  28801. * @returns a validation object with skinned, valid and report string
  28802. */
  28803. validateSkinning(): {
  28804. skinned: boolean;
  28805. valid: boolean;
  28806. report: string;
  28807. };
  28808. /** @hidden */
  28809. _checkDelayState(): Mesh;
  28810. private _queueLoad;
  28811. /**
  28812. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28813. * A mesh is in the frustum if its bounding box intersects the frustum
  28814. * @param frustumPlanes defines the frustum to test
  28815. * @returns true if the mesh is in the frustum planes
  28816. */
  28817. isInFrustum(frustumPlanes: Plane[]): boolean;
  28818. /**
  28819. * Sets the mesh material by the material or multiMaterial `id` property
  28820. * @param id is a string identifying the material or the multiMaterial
  28821. * @returns the current mesh
  28822. */
  28823. setMaterialByID(id: string): Mesh;
  28824. /**
  28825. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28826. * @returns an array of IAnimatable
  28827. */
  28828. getAnimatables(): IAnimatable[];
  28829. /**
  28830. * Modifies the mesh geometry according to the passed transformation matrix.
  28831. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28832. * The mesh normals are modified using the same transformation.
  28833. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28834. * @param transform defines the transform matrix to use
  28835. * @see https://doc.babylonjs.com/resources/baking_transformations
  28836. * @returns the current mesh
  28837. */
  28838. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28839. /**
  28840. * Modifies the mesh geometry according to its own current World Matrix.
  28841. * The mesh World Matrix is then reset.
  28842. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28843. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28844. * @see https://doc.babylonjs.com/resources/baking_transformations
  28845. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28846. * @returns the current mesh
  28847. */
  28848. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28849. /** @hidden */
  28850. get _positions(): Nullable<Vector3[]>;
  28851. /** @hidden */
  28852. _resetPointsArrayCache(): Mesh;
  28853. /** @hidden */
  28854. _generatePointsArray(): boolean;
  28855. /**
  28856. * Returns a new Mesh object generated from the current mesh properties.
  28857. * This method must not get confused with createInstance()
  28858. * @param name is a string, the name given to the new mesh
  28859. * @param newParent can be any Node object (default `null`)
  28860. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28861. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28862. * @returns a new mesh
  28863. */
  28864. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28865. /**
  28866. * Releases resources associated with this mesh.
  28867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28869. */
  28870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28871. /** @hidden */
  28872. _disposeInstanceSpecificData(): void;
  28873. /** @hidden */
  28874. _disposeThinInstanceSpecificData(): void;
  28875. /**
  28876. * Modifies the mesh geometry according to a displacement map.
  28877. * 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.
  28878. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28879. * @param url is a string, the URL from the image file is to be downloaded.
  28880. * @param minHeight is the lower limit of the displacement.
  28881. * @param maxHeight is the upper limit of the displacement.
  28882. * @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.
  28883. * @param uvOffset is an optional vector2 used to offset UV.
  28884. * @param uvScale is an optional vector2 used to scale UV.
  28885. * @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.
  28886. * @returns the Mesh.
  28887. */
  28888. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28889. /**
  28890. * Modifies the mesh geometry according to a displacementMap buffer.
  28891. * 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.
  28892. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28893. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28894. * @param heightMapWidth is the width of the buffer image.
  28895. * @param heightMapHeight is the height of the buffer image.
  28896. * @param minHeight is the lower limit of the displacement.
  28897. * @param maxHeight is the upper limit of the displacement.
  28898. * @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.
  28899. * @param uvOffset is an optional vector2 used to offset UV.
  28900. * @param uvScale is an optional vector2 used to scale UV.
  28901. * @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.
  28902. * @returns the Mesh.
  28903. */
  28904. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28905. /**
  28906. * Modify the mesh to get a flat shading rendering.
  28907. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28908. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28909. * @returns current mesh
  28910. */
  28911. convertToFlatShadedMesh(): Mesh;
  28912. /**
  28913. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28914. * In other words, more vertices, no more indices and a single bigger VBO.
  28915. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28916. * @returns current mesh
  28917. */
  28918. convertToUnIndexedMesh(): Mesh;
  28919. /**
  28920. * Inverses facet orientations.
  28921. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28922. * @param flipNormals will also inverts the normals
  28923. * @returns current mesh
  28924. */
  28925. flipFaces(flipNormals?: boolean): Mesh;
  28926. /**
  28927. * Increase the number of facets and hence vertices in a mesh
  28928. * Vertex normals are interpolated from existing vertex normals
  28929. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28930. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28931. */
  28932. increaseVertices(numberPerEdge: number): void;
  28933. /**
  28934. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28935. * This will undo any application of covertToFlatShadedMesh
  28936. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28937. */
  28938. forceSharedVertices(): void;
  28939. /** @hidden */
  28940. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28941. /** @hidden */
  28942. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28943. /**
  28944. * Creates a new InstancedMesh object from the mesh model.
  28945. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28946. * @param name defines the name of the new instance
  28947. * @returns a new InstancedMesh
  28948. */
  28949. createInstance(name: string): InstancedMesh;
  28950. /**
  28951. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28952. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28953. * @returns the current mesh
  28954. */
  28955. synchronizeInstances(): Mesh;
  28956. /**
  28957. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28958. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28959. * This should be used together with the simplification to avoid disappearing triangles.
  28960. * @param successCallback an optional success callback to be called after the optimization finished.
  28961. * @returns the current mesh
  28962. */
  28963. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28964. /**
  28965. * Serialize current mesh
  28966. * @param serializationObject defines the object which will receive the serialization data
  28967. */
  28968. serialize(serializationObject: any): void;
  28969. /** @hidden */
  28970. _syncGeometryWithMorphTargetManager(): void;
  28971. /** @hidden */
  28972. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28973. /**
  28974. * Returns a new Mesh object parsed from the source provided.
  28975. * @param parsedMesh is the source
  28976. * @param scene defines the hosting scene
  28977. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28978. * @returns a new Mesh
  28979. */
  28980. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28981. /**
  28982. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28983. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28984. * @param name defines the name of the mesh to create
  28985. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28986. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28987. * @param closePath creates a seam between the first and the last points of each path of the path array
  28988. * @param offset is taken in account only if the `pathArray` is containing a single path
  28989. * @param scene defines the hosting scene
  28990. * @param updatable defines if the mesh must be flagged as updatable
  28991. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28992. * @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)
  28993. * @returns a new Mesh
  28994. */
  28995. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28996. /**
  28997. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28998. * @param name defines the name of the mesh to create
  28999. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29000. * @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
  29001. * @param scene defines the hosting scene
  29002. * @param updatable defines if the mesh must be flagged as updatable
  29003. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29004. * @returns a new Mesh
  29005. */
  29006. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29007. /**
  29008. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29009. * @param name defines the name of the mesh to create
  29010. * @param size sets the size (float) of each box side (default 1)
  29011. * @param scene defines the hosting scene
  29012. * @param updatable defines if the mesh must be flagged as updatable
  29013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29014. * @returns a new Mesh
  29015. */
  29016. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29017. /**
  29018. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29019. * @param name defines the name of the mesh to create
  29020. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29021. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29022. * @param scene defines the hosting scene
  29023. * @param updatable defines if the mesh must be flagged as updatable
  29024. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29025. * @returns a new Mesh
  29026. */
  29027. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29028. /**
  29029. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29030. * @param name defines the name of the mesh to create
  29031. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29032. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29033. * @param scene defines the hosting scene
  29034. * @returns a new Mesh
  29035. */
  29036. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29037. /**
  29038. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29039. * @param name defines the name of the mesh to create
  29040. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29041. * @param diameterTop set the top cap diameter (floats, default 1)
  29042. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29043. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29044. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29045. * @param scene defines the hosting scene
  29046. * @param updatable defines if the mesh must be flagged as updatable
  29047. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29048. * @returns a new Mesh
  29049. */
  29050. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29051. /**
  29052. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29053. * @param name defines the name of the mesh to create
  29054. * @param diameter sets the diameter size (float) of the torus (default 1)
  29055. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29056. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29057. * @param scene defines the hosting scene
  29058. * @param updatable defines if the mesh must be flagged as updatable
  29059. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29060. * @returns a new Mesh
  29061. */
  29062. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29063. /**
  29064. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29065. * @param name defines the name of the mesh to create
  29066. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29067. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29068. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29069. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29070. * @param p the number of windings on X axis (positive integers, default 2)
  29071. * @param q the number of windings on Y axis (positive integers, default 3)
  29072. * @param scene defines the hosting scene
  29073. * @param updatable defines if the mesh must be flagged as updatable
  29074. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29075. * @returns a new Mesh
  29076. */
  29077. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29078. /**
  29079. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29080. * @param name defines the name of the mesh to create
  29081. * @param points is an array successive Vector3
  29082. * @param scene defines the hosting scene
  29083. * @param updatable defines if the mesh must be flagged as updatable
  29084. * @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).
  29085. * @returns a new Mesh
  29086. */
  29087. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29088. /**
  29089. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29090. * @param name defines the name of the mesh to create
  29091. * @param points is an array successive Vector3
  29092. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29093. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29094. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29095. * @param scene defines the hosting scene
  29096. * @param updatable defines if the mesh must be flagged as updatable
  29097. * @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)
  29098. * @returns a new Mesh
  29099. */
  29100. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29101. /**
  29102. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29103. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29104. * 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.
  29105. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29106. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29107. * Remember you can only change the shape positions, not their number when updating a polygon.
  29108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29109. * @param name defines the name of the mesh to create
  29110. * @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
  29111. * @param scene defines the hosting scene
  29112. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29113. * @param updatable defines if the mesh must be flagged as updatable
  29114. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29115. * @param earcutInjection can be used to inject your own earcut reference
  29116. * @returns a new Mesh
  29117. */
  29118. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29119. /**
  29120. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29122. * @param name defines the name of the mesh to create
  29123. * @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
  29124. * @param depth defines the height of extrusion
  29125. * @param scene defines the hosting scene
  29126. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29127. * @param updatable defines if the mesh must be flagged as updatable
  29128. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29129. * @param earcutInjection can be used to inject your own earcut reference
  29130. * @returns a new Mesh
  29131. */
  29132. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29133. /**
  29134. * Creates an extruded shape mesh.
  29135. * 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
  29136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29138. * @param name defines the name of the mesh to create
  29139. * @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
  29140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29141. * @param scale is the value to scale the shape
  29142. * @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
  29143. * @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
  29144. * @param scene defines the hosting scene
  29145. * @param updatable defines if the mesh must be flagged as updatable
  29146. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29147. * @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)
  29148. * @returns a new Mesh
  29149. */
  29150. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29151. /**
  29152. * Creates an custom extruded shape mesh.
  29153. * The custom extrusion is a parametric shape.
  29154. * It has no predefined shape. Its final shape will depend on the input parameters.
  29155. * Please consider using the same method from the MeshBuilder class instead
  29156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29157. * @param name defines the name of the mesh to create
  29158. * @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
  29159. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29160. * @param scaleFunction is a custom Javascript function called on each path point
  29161. * @param rotationFunction is a custom Javascript function called on each path point
  29162. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29163. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29164. * @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
  29165. * @param scene defines the hosting scene
  29166. * @param updatable defines if the mesh must be flagged as updatable
  29167. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29168. * @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)
  29169. * @returns a new Mesh
  29170. */
  29171. 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;
  29172. /**
  29173. * Creates lathe mesh.
  29174. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29175. * Please consider using the same method from the MeshBuilder class instead
  29176. * @param name defines the name of the mesh to create
  29177. * @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
  29178. * @param radius is the radius value of the lathe
  29179. * @param tessellation is the side number of the lathe.
  29180. * @param scene defines the hosting scene
  29181. * @param updatable defines if the mesh must be flagged as updatable
  29182. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29183. * @returns a new Mesh
  29184. */
  29185. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29186. /**
  29187. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29188. * @param name defines the name of the mesh to create
  29189. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29190. * @param scene defines the hosting scene
  29191. * @param updatable defines if the mesh must be flagged as updatable
  29192. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29193. * @returns a new Mesh
  29194. */
  29195. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29196. /**
  29197. * Creates a ground mesh.
  29198. * Please consider using the same method from the MeshBuilder class instead
  29199. * @param name defines the name of the mesh to create
  29200. * @param width set the width of the ground
  29201. * @param height set the height of the ground
  29202. * @param subdivisions sets the number of subdivisions per side
  29203. * @param scene defines the hosting scene
  29204. * @param updatable defines if the mesh must be flagged as updatable
  29205. * @returns a new Mesh
  29206. */
  29207. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29208. /**
  29209. * Creates a tiled ground mesh.
  29210. * Please consider using the same method from the MeshBuilder class instead
  29211. * @param name defines the name of the mesh to create
  29212. * @param xmin set the ground minimum X coordinate
  29213. * @param zmin set the ground minimum Y coordinate
  29214. * @param xmax set the ground maximum X coordinate
  29215. * @param zmax set the ground maximum Z coordinate
  29216. * @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
  29217. * @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
  29218. * @param scene defines the hosting scene
  29219. * @param updatable defines if the mesh must be flagged as updatable
  29220. * @returns a new Mesh
  29221. */
  29222. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29223. w: number;
  29224. h: number;
  29225. }, precision: {
  29226. w: number;
  29227. h: number;
  29228. }, scene: Scene, updatable?: boolean): Mesh;
  29229. /**
  29230. * Creates a ground mesh from a height map.
  29231. * Please consider using the same method from the MeshBuilder class instead
  29232. * @see https://doc.babylonjs.com/babylon101/height_map
  29233. * @param name defines the name of the mesh to create
  29234. * @param url sets the URL of the height map image resource
  29235. * @param width set the ground width size
  29236. * @param height set the ground height size
  29237. * @param subdivisions sets the number of subdivision per side
  29238. * @param minHeight is the minimum altitude on the ground
  29239. * @param maxHeight is the maximum altitude on the ground
  29240. * @param scene defines the hosting scene
  29241. * @param updatable defines if the mesh must be flagged as updatable
  29242. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29243. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29244. * @returns a new Mesh
  29245. */
  29246. 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;
  29247. /**
  29248. * Creates a tube mesh.
  29249. * The tube is a parametric shape.
  29250. * It has no predefined shape. Its final shape will depend on the input parameters.
  29251. * Please consider using the same method from the MeshBuilder class instead
  29252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29253. * @param name defines the name of the mesh to create
  29254. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29255. * @param radius sets the tube radius size
  29256. * @param tessellation is the number of sides on the tubular surface
  29257. * @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
  29258. * @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
  29259. * @param scene defines the hosting scene
  29260. * @param updatable defines if the mesh must be flagged as updatable
  29261. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29262. * @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)
  29263. * @returns a new Mesh
  29264. */
  29265. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29266. (i: number, distance: number): number;
  29267. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29268. /**
  29269. * Creates a polyhedron mesh.
  29270. * Please consider using the same method from the MeshBuilder class instead.
  29271. * * 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
  29272. * * The parameter `size` (positive float, default 1) sets the polygon size
  29273. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29274. * * 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`
  29275. * * 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
  29276. * * 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)`)
  29277. * * 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
  29278. * * 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
  29279. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29280. * * 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
  29281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29282. * @param name defines the name of the mesh to create
  29283. * @param options defines the options used to create the mesh
  29284. * @param scene defines the hosting scene
  29285. * @returns a new Mesh
  29286. */
  29287. static CreatePolyhedron(name: string, options: {
  29288. type?: number;
  29289. size?: number;
  29290. sizeX?: number;
  29291. sizeY?: number;
  29292. sizeZ?: number;
  29293. custom?: any;
  29294. faceUV?: Vector4[];
  29295. faceColors?: Color4[];
  29296. updatable?: boolean;
  29297. sideOrientation?: number;
  29298. }, scene: Scene): Mesh;
  29299. /**
  29300. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29301. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29302. * * 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`)
  29303. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29304. * * 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
  29305. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29306. * * 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
  29307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29308. * @param name defines the name of the mesh
  29309. * @param options defines the options used to create the mesh
  29310. * @param scene defines the hosting scene
  29311. * @returns a new Mesh
  29312. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29313. */
  29314. static CreateIcoSphere(name: string, options: {
  29315. radius?: number;
  29316. flat?: boolean;
  29317. subdivisions?: number;
  29318. sideOrientation?: number;
  29319. updatable?: boolean;
  29320. }, scene: Scene): Mesh;
  29321. /**
  29322. * Creates a decal mesh.
  29323. * Please consider using the same method from the MeshBuilder class instead.
  29324. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29325. * @param name defines the name of the mesh
  29326. * @param sourceMesh defines the mesh receiving the decal
  29327. * @param position sets the position of the decal in world coordinates
  29328. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29329. * @param size sets the decal scaling
  29330. * @param angle sets the angle to rotate the decal
  29331. * @returns a new Mesh
  29332. */
  29333. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29334. /** Creates a Capsule Mesh
  29335. * @param name defines the name of the mesh.
  29336. * @param options the constructors options used to shape the mesh.
  29337. * @param scene defines the scene the mesh is scoped to.
  29338. * @returns the capsule mesh
  29339. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29340. */
  29341. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29342. /**
  29343. * Prepare internal position array for software CPU skinning
  29344. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29345. */
  29346. setPositionsForCPUSkinning(): Float32Array;
  29347. /**
  29348. * Prepare internal normal array for software CPU skinning
  29349. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29350. */
  29351. setNormalsForCPUSkinning(): Float32Array;
  29352. /**
  29353. * Updates the vertex buffer by applying transformation from the bones
  29354. * @param skeleton defines the skeleton to apply to current mesh
  29355. * @returns the current mesh
  29356. */
  29357. applySkeleton(skeleton: Skeleton): Mesh;
  29358. /**
  29359. * 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
  29360. * @param meshes defines the list of meshes to scan
  29361. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29362. */
  29363. static MinMax(meshes: AbstractMesh[]): {
  29364. min: Vector3;
  29365. max: Vector3;
  29366. };
  29367. /**
  29368. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29369. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29370. * @returns a vector3
  29371. */
  29372. static Center(meshesOrMinMaxVector: {
  29373. min: Vector3;
  29374. max: Vector3;
  29375. } | AbstractMesh[]): Vector3;
  29376. /**
  29377. * Merge the array of meshes into a single mesh for performance reasons.
  29378. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29379. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29380. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29381. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29382. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29383. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29384. * @returns a new mesh
  29385. */
  29386. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29387. /** @hidden */
  29388. addInstance(instance: InstancedMesh): void;
  29389. /** @hidden */
  29390. removeInstance(instance: InstancedMesh): void;
  29391. }
  29392. }
  29393. declare module BABYLON {
  29394. /**
  29395. * This is the base class of all the camera used in the application.
  29396. * @see https://doc.babylonjs.com/features/cameras
  29397. */
  29398. export class Camera extends Node {
  29399. /** @hidden */
  29400. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29401. /**
  29402. * This is the default projection mode used by the cameras.
  29403. * It helps recreating a feeling of perspective and better appreciate depth.
  29404. * This is the best way to simulate real life cameras.
  29405. */
  29406. static readonly PERSPECTIVE_CAMERA: number;
  29407. /**
  29408. * This helps creating camera with an orthographic mode.
  29409. * 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.
  29410. */
  29411. static readonly ORTHOGRAPHIC_CAMERA: number;
  29412. /**
  29413. * This is the default FOV mode for perspective cameras.
  29414. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29415. */
  29416. static readonly FOVMODE_VERTICAL_FIXED: number;
  29417. /**
  29418. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29419. */
  29420. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29421. /**
  29422. * This specifies ther is no need for a camera rig.
  29423. * Basically only one eye is rendered corresponding to the camera.
  29424. */
  29425. static readonly RIG_MODE_NONE: number;
  29426. /**
  29427. * Simulates a camera Rig with one blue eye and one red eye.
  29428. * This can be use with 3d blue and red glasses.
  29429. */
  29430. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29431. /**
  29432. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29433. */
  29434. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29435. /**
  29436. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29437. */
  29438. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29439. /**
  29440. * Defines that both eyes of the camera will be rendered over under each other.
  29441. */
  29442. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29443. /**
  29444. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29445. */
  29446. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29447. /**
  29448. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29449. */
  29450. static readonly RIG_MODE_VR: number;
  29451. /**
  29452. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29453. */
  29454. static readonly RIG_MODE_WEBVR: number;
  29455. /**
  29456. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29457. */
  29458. static readonly RIG_MODE_CUSTOM: number;
  29459. /**
  29460. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29461. */
  29462. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29463. /**
  29464. * Define the input manager associated with the camera.
  29465. */
  29466. inputs: CameraInputsManager<Camera>;
  29467. /** @hidden */
  29468. _position: Vector3;
  29469. /**
  29470. * Define the current local position of the camera in the scene
  29471. */
  29472. get position(): Vector3;
  29473. set position(newPosition: Vector3);
  29474. protected _upVector: Vector3;
  29475. /**
  29476. * The vector the camera should consider as up.
  29477. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29478. */
  29479. set upVector(vec: Vector3);
  29480. get upVector(): Vector3;
  29481. /**
  29482. * Define the current limit on the left side for an orthographic camera
  29483. * In scene unit
  29484. */
  29485. orthoLeft: Nullable<number>;
  29486. /**
  29487. * Define the current limit on the right side for an orthographic camera
  29488. * In scene unit
  29489. */
  29490. orthoRight: Nullable<number>;
  29491. /**
  29492. * Define the current limit on the bottom side for an orthographic camera
  29493. * In scene unit
  29494. */
  29495. orthoBottom: Nullable<number>;
  29496. /**
  29497. * Define the current limit on the top side for an orthographic camera
  29498. * In scene unit
  29499. */
  29500. orthoTop: Nullable<number>;
  29501. /**
  29502. * Field Of View is set in Radians. (default is 0.8)
  29503. */
  29504. fov: number;
  29505. /**
  29506. * Define the minimum distance the camera can see from.
  29507. * This is important to note that the depth buffer are not infinite and the closer it starts
  29508. * the more your scene might encounter depth fighting issue.
  29509. */
  29510. minZ: number;
  29511. /**
  29512. * Define the maximum distance the camera can see to.
  29513. * This is important to note that the depth buffer are not infinite and the further it end
  29514. * the more your scene might encounter depth fighting issue.
  29515. */
  29516. maxZ: number;
  29517. /**
  29518. * Define the default inertia of the camera.
  29519. * This helps giving a smooth feeling to the camera movement.
  29520. */
  29521. inertia: number;
  29522. /**
  29523. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29524. */
  29525. mode: number;
  29526. /**
  29527. * Define whether the camera is intermediate.
  29528. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29529. */
  29530. isIntermediate: boolean;
  29531. /**
  29532. * Define the viewport of the camera.
  29533. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29534. */
  29535. viewport: Viewport;
  29536. /**
  29537. * Restricts the camera to viewing objects with the same layerMask.
  29538. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29539. */
  29540. layerMask: number;
  29541. /**
  29542. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29543. */
  29544. fovMode: number;
  29545. /**
  29546. * Rig mode of the camera.
  29547. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29548. * This is normally controlled byt the camera themselves as internal use.
  29549. */
  29550. cameraRigMode: number;
  29551. /**
  29552. * Defines the distance between both "eyes" in case of a RIG
  29553. */
  29554. interaxialDistance: number;
  29555. /**
  29556. * Defines if stereoscopic rendering is done side by side or over under.
  29557. */
  29558. isStereoscopicSideBySide: boolean;
  29559. /**
  29560. * 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
  29561. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29562. * else in the scene. (Eg. security camera)
  29563. *
  29564. * 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)
  29565. */
  29566. customRenderTargets: RenderTargetTexture[];
  29567. /**
  29568. * When set, the camera will render to this render target instead of the default canvas
  29569. *
  29570. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29571. */
  29572. outputRenderTarget: Nullable<RenderTargetTexture>;
  29573. /**
  29574. * Observable triggered when the camera view matrix has changed.
  29575. */
  29576. onViewMatrixChangedObservable: Observable<Camera>;
  29577. /**
  29578. * Observable triggered when the camera Projection matrix has changed.
  29579. */
  29580. onProjectionMatrixChangedObservable: Observable<Camera>;
  29581. /**
  29582. * Observable triggered when the inputs have been processed.
  29583. */
  29584. onAfterCheckInputsObservable: Observable<Camera>;
  29585. /**
  29586. * Observable triggered when reset has been called and applied to the camera.
  29587. */
  29588. onRestoreStateObservable: Observable<Camera>;
  29589. /**
  29590. * Is this camera a part of a rig system?
  29591. */
  29592. isRigCamera: boolean;
  29593. /**
  29594. * If isRigCamera set to true this will be set with the parent camera.
  29595. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29596. */
  29597. rigParent?: Camera;
  29598. /** @hidden */
  29599. _cameraRigParams: any;
  29600. /** @hidden */
  29601. _rigCameras: Camera[];
  29602. /** @hidden */
  29603. _rigPostProcess: Nullable<PostProcess>;
  29604. protected _webvrViewMatrix: Matrix;
  29605. /** @hidden */
  29606. _skipRendering: boolean;
  29607. /** @hidden */
  29608. _projectionMatrix: Matrix;
  29609. /** @hidden */
  29610. _postProcesses: Nullable<PostProcess>[];
  29611. /** @hidden */
  29612. _activeMeshes: SmartArray<AbstractMesh>;
  29613. protected _globalPosition: Vector3;
  29614. /** @hidden */
  29615. _computedViewMatrix: Matrix;
  29616. private _doNotComputeProjectionMatrix;
  29617. private _transformMatrix;
  29618. private _frustumPlanes;
  29619. private _refreshFrustumPlanes;
  29620. private _storedFov;
  29621. private _stateStored;
  29622. /**
  29623. * Instantiates a new camera object.
  29624. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29625. * @see https://doc.babylonjs.com/features/cameras
  29626. * @param name Defines the name of the camera in the scene
  29627. * @param position Defines the position of the camera
  29628. * @param scene Defines the scene the camera belongs too
  29629. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29630. */
  29631. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29632. /**
  29633. * Store current camera state (fov, position, etc..)
  29634. * @returns the camera
  29635. */
  29636. storeState(): Camera;
  29637. /**
  29638. * Restores the camera state values if it has been stored. You must call storeState() first
  29639. */
  29640. protected _restoreStateValues(): boolean;
  29641. /**
  29642. * Restored camera state. You must call storeState() first.
  29643. * @returns true if restored and false otherwise
  29644. */
  29645. restoreState(): boolean;
  29646. /**
  29647. * Gets the class name of the camera.
  29648. * @returns the class name
  29649. */
  29650. getClassName(): string;
  29651. /** @hidden */
  29652. readonly _isCamera: boolean;
  29653. /**
  29654. * Gets a string representation of the camera useful for debug purpose.
  29655. * @param fullDetails Defines that a more verboe level of logging is required
  29656. * @returns the string representation
  29657. */
  29658. toString(fullDetails?: boolean): string;
  29659. /**
  29660. * Gets the current world space position of the camera.
  29661. */
  29662. get globalPosition(): Vector3;
  29663. /**
  29664. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29665. * @returns the active meshe list
  29666. */
  29667. getActiveMeshes(): SmartArray<AbstractMesh>;
  29668. /**
  29669. * Check whether a mesh is part of the current active mesh list of the camera
  29670. * @param mesh Defines the mesh to check
  29671. * @returns true if active, false otherwise
  29672. */
  29673. isActiveMesh(mesh: Mesh): boolean;
  29674. /**
  29675. * Is this camera ready to be used/rendered
  29676. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29677. * @return true if the camera is ready
  29678. */
  29679. isReady(completeCheck?: boolean): boolean;
  29680. /** @hidden */
  29681. _initCache(): void;
  29682. /** @hidden */
  29683. _updateCache(ignoreParentClass?: boolean): void;
  29684. /** @hidden */
  29685. _isSynchronized(): boolean;
  29686. /** @hidden */
  29687. _isSynchronizedViewMatrix(): boolean;
  29688. /** @hidden */
  29689. _isSynchronizedProjectionMatrix(): boolean;
  29690. /**
  29691. * Attach the input controls to a specific dom element to get the input from.
  29692. * @param element Defines the element the controls should be listened from
  29693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29694. */
  29695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29696. /**
  29697. * Detach the current controls from the specified dom element.
  29698. * @param element Defines the element to stop listening the inputs from
  29699. */
  29700. detachControl(element: HTMLElement): void;
  29701. /**
  29702. * Update the camera state according to the different inputs gathered during the frame.
  29703. */
  29704. update(): void;
  29705. /** @hidden */
  29706. _checkInputs(): void;
  29707. /** @hidden */
  29708. get rigCameras(): Camera[];
  29709. /**
  29710. * Gets the post process used by the rig cameras
  29711. */
  29712. get rigPostProcess(): Nullable<PostProcess>;
  29713. /**
  29714. * Internal, gets the first post proces.
  29715. * @returns the first post process to be run on this camera.
  29716. */
  29717. _getFirstPostProcess(): Nullable<PostProcess>;
  29718. private _cascadePostProcessesToRigCams;
  29719. /**
  29720. * Attach a post process to the camera.
  29721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29722. * @param postProcess The post process to attach to the camera
  29723. * @param insertAt The position of the post process in case several of them are in use in the scene
  29724. * @returns the position the post process has been inserted at
  29725. */
  29726. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29727. /**
  29728. * Detach a post process to the camera.
  29729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29730. * @param postProcess The post process to detach from the camera
  29731. */
  29732. detachPostProcess(postProcess: PostProcess): void;
  29733. /**
  29734. * Gets the current world matrix of the camera
  29735. */
  29736. getWorldMatrix(): Matrix;
  29737. /** @hidden */
  29738. _getViewMatrix(): Matrix;
  29739. /**
  29740. * Gets the current view matrix of the camera.
  29741. * @param force forces the camera to recompute the matrix without looking at the cached state
  29742. * @returns the view matrix
  29743. */
  29744. getViewMatrix(force?: boolean): Matrix;
  29745. /**
  29746. * Freeze the projection matrix.
  29747. * It will prevent the cache check of the camera projection compute and can speed up perf
  29748. * if no parameter of the camera are meant to change
  29749. * @param projection Defines manually a projection if necessary
  29750. */
  29751. freezeProjectionMatrix(projection?: Matrix): void;
  29752. /**
  29753. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29754. */
  29755. unfreezeProjectionMatrix(): void;
  29756. /**
  29757. * Gets the current projection matrix of the camera.
  29758. * @param force forces the camera to recompute the matrix without looking at the cached state
  29759. * @returns the projection matrix
  29760. */
  29761. getProjectionMatrix(force?: boolean): Matrix;
  29762. /**
  29763. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29764. * @returns a Matrix
  29765. */
  29766. getTransformationMatrix(): Matrix;
  29767. private _updateFrustumPlanes;
  29768. /**
  29769. * Checks if a cullable object (mesh...) is in the camera frustum
  29770. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29771. * @param target The object to check
  29772. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29773. * @returns true if the object is in frustum otherwise false
  29774. */
  29775. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29776. /**
  29777. * Checks if a cullable object (mesh...) is in the camera frustum
  29778. * Unlike isInFrustum this cheks the full bounding box
  29779. * @param target The object to check
  29780. * @returns true if the object is in frustum otherwise false
  29781. */
  29782. isCompletelyInFrustum(target: ICullable): boolean;
  29783. /**
  29784. * Gets a ray in the forward direction from the camera.
  29785. * @param length Defines the length of the ray to create
  29786. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29787. * @param origin Defines the start point of the ray which defaults to the camera position
  29788. * @returns the forward ray
  29789. */
  29790. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29791. /**
  29792. * Gets a ray in the forward direction from the camera.
  29793. * @param refRay the ray to (re)use when setting the values
  29794. * @param length Defines the length of the ray to create
  29795. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29796. * @param origin Defines the start point of the ray which defaults to the camera position
  29797. * @returns the forward ray
  29798. */
  29799. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29800. /**
  29801. * Releases resources associated with this node.
  29802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29804. */
  29805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29806. /** @hidden */
  29807. _isLeftCamera: boolean;
  29808. /**
  29809. * Gets the left camera of a rig setup in case of Rigged Camera
  29810. */
  29811. get isLeftCamera(): boolean;
  29812. /** @hidden */
  29813. _isRightCamera: boolean;
  29814. /**
  29815. * Gets the right camera of a rig setup in case of Rigged Camera
  29816. */
  29817. get isRightCamera(): boolean;
  29818. /**
  29819. * Gets the left camera of a rig setup in case of Rigged Camera
  29820. */
  29821. get leftCamera(): Nullable<FreeCamera>;
  29822. /**
  29823. * Gets the right camera of a rig setup in case of Rigged Camera
  29824. */
  29825. get rightCamera(): Nullable<FreeCamera>;
  29826. /**
  29827. * Gets the left camera target of a rig setup in case of Rigged Camera
  29828. * @returns the target position
  29829. */
  29830. getLeftTarget(): Nullable<Vector3>;
  29831. /**
  29832. * Gets the right camera target of a rig setup in case of Rigged Camera
  29833. * @returns the target position
  29834. */
  29835. getRightTarget(): Nullable<Vector3>;
  29836. /**
  29837. * @hidden
  29838. */
  29839. setCameraRigMode(mode: number, rigParams: any): void;
  29840. /** @hidden */
  29841. static _setStereoscopicRigMode(camera: Camera): void;
  29842. /** @hidden */
  29843. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29844. /** @hidden */
  29845. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29846. /** @hidden */
  29847. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29848. /** @hidden */
  29849. _getVRProjectionMatrix(): Matrix;
  29850. protected _updateCameraRotationMatrix(): void;
  29851. protected _updateWebVRCameraRotationMatrix(): void;
  29852. /**
  29853. * This function MUST be overwritten by the different WebVR cameras available.
  29854. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29855. * @hidden
  29856. */
  29857. _getWebVRProjectionMatrix(): Matrix;
  29858. /**
  29859. * This function MUST be overwritten by the different WebVR cameras available.
  29860. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29861. * @hidden
  29862. */
  29863. _getWebVRViewMatrix(): Matrix;
  29864. /** @hidden */
  29865. setCameraRigParameter(name: string, value: any): void;
  29866. /**
  29867. * needs to be overridden by children so sub has required properties to be copied
  29868. * @hidden
  29869. */
  29870. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29871. /**
  29872. * May need to be overridden by children
  29873. * @hidden
  29874. */
  29875. _updateRigCameras(): void;
  29876. /** @hidden */
  29877. _setupInputs(): void;
  29878. /**
  29879. * Serialiaze the camera setup to a json represention
  29880. * @returns the JSON representation
  29881. */
  29882. serialize(): any;
  29883. /**
  29884. * Clones the current camera.
  29885. * @param name The cloned camera name
  29886. * @returns the cloned camera
  29887. */
  29888. clone(name: string): Camera;
  29889. /**
  29890. * Gets the direction of the camera relative to a given local axis.
  29891. * @param localAxis Defines the reference axis to provide a relative direction.
  29892. * @return the direction
  29893. */
  29894. getDirection(localAxis: Vector3): Vector3;
  29895. /**
  29896. * Returns the current camera absolute rotation
  29897. */
  29898. get absoluteRotation(): Quaternion;
  29899. /**
  29900. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29901. * @param localAxis Defines the reference axis to provide a relative direction.
  29902. * @param result Defines the vector to store the result in
  29903. */
  29904. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29905. /**
  29906. * Gets a camera constructor for a given camera type
  29907. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29908. * @param name The name of the camera the result will be able to instantiate
  29909. * @param scene The scene the result will construct the camera in
  29910. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29911. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29912. * @returns a factory method to construc the camera
  29913. */
  29914. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29915. /**
  29916. * Compute the world matrix of the camera.
  29917. * @returns the camera world matrix
  29918. */
  29919. computeWorldMatrix(): Matrix;
  29920. /**
  29921. * Parse a JSON and creates the camera from the parsed information
  29922. * @param parsedCamera The JSON to parse
  29923. * @param scene The scene to instantiate the camera in
  29924. * @returns the newly constructed camera
  29925. */
  29926. static Parse(parsedCamera: any, scene: Scene): Camera;
  29927. }
  29928. }
  29929. declare module BABYLON {
  29930. /**
  29931. * Class containing static functions to help procedurally build meshes
  29932. */
  29933. export class DiscBuilder {
  29934. /**
  29935. * Creates a plane polygonal mesh. By default, this is a disc
  29936. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29937. * * 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
  29938. * * 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
  29939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29940. * * 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
  29941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29942. * @param name defines the name of the mesh
  29943. * @param options defines the options used to create the mesh
  29944. * @param scene defines the hosting scene
  29945. * @returns the plane polygonal mesh
  29946. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29947. */
  29948. static CreateDisc(name: string, options: {
  29949. radius?: number;
  29950. tessellation?: number;
  29951. arc?: number;
  29952. updatable?: boolean;
  29953. sideOrientation?: number;
  29954. frontUVs?: Vector4;
  29955. backUVs?: Vector4;
  29956. }, scene?: Nullable<Scene>): Mesh;
  29957. }
  29958. }
  29959. declare module BABYLON {
  29960. /**
  29961. * Options to be used when creating a FresnelParameters.
  29962. */
  29963. export type IFresnelParametersCreationOptions = {
  29964. /**
  29965. * Define the color used on edges (grazing angle)
  29966. */
  29967. leftColor?: Color3;
  29968. /**
  29969. * Define the color used on center
  29970. */
  29971. rightColor?: Color3;
  29972. /**
  29973. * Define bias applied to computed fresnel term
  29974. */
  29975. bias?: number;
  29976. /**
  29977. * Defined the power exponent applied to fresnel term
  29978. */
  29979. power?: number;
  29980. /**
  29981. * Define if the fresnel effect is enable or not.
  29982. */
  29983. isEnabled?: boolean;
  29984. };
  29985. /**
  29986. * Serialized format for FresnelParameters.
  29987. */
  29988. export type IFresnelParametersSerialized = {
  29989. /**
  29990. * Define the color used on edges (grazing angle) [as an array]
  29991. */
  29992. leftColor: number[];
  29993. /**
  29994. * Define the color used on center [as an array]
  29995. */
  29996. rightColor: number[];
  29997. /**
  29998. * Define bias applied to computed fresnel term
  29999. */
  30000. bias: number;
  30001. /**
  30002. * Defined the power exponent applied to fresnel term
  30003. */
  30004. power?: number;
  30005. /**
  30006. * Define if the fresnel effect is enable or not.
  30007. */
  30008. isEnabled: boolean;
  30009. };
  30010. /**
  30011. * This represents all the required information to add a fresnel effect on a material:
  30012. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30013. */
  30014. export class FresnelParameters {
  30015. private _isEnabled;
  30016. /**
  30017. * Define if the fresnel effect is enable or not.
  30018. */
  30019. get isEnabled(): boolean;
  30020. set isEnabled(value: boolean);
  30021. /**
  30022. * Define the color used on edges (grazing angle)
  30023. */
  30024. leftColor: Color3;
  30025. /**
  30026. * Define the color used on center
  30027. */
  30028. rightColor: Color3;
  30029. /**
  30030. * Define bias applied to computed fresnel term
  30031. */
  30032. bias: number;
  30033. /**
  30034. * Defined the power exponent applied to fresnel term
  30035. */
  30036. power: number;
  30037. /**
  30038. * Creates a new FresnelParameters object.
  30039. *
  30040. * @param options provide your own settings to optionally to override defaults
  30041. */
  30042. constructor(options?: IFresnelParametersCreationOptions);
  30043. /**
  30044. * Clones the current fresnel and its valuues
  30045. * @returns a clone fresnel configuration
  30046. */
  30047. clone(): FresnelParameters;
  30048. /**
  30049. * Determines equality between FresnelParameters objects
  30050. * @param otherFresnelParameters defines the second operand
  30051. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30052. */
  30053. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30054. /**
  30055. * Serializes the current fresnel parameters to a JSON representation.
  30056. * @return the JSON serialization
  30057. */
  30058. serialize(): IFresnelParametersSerialized;
  30059. /**
  30060. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30061. * @param parsedFresnelParameters Define the JSON representation
  30062. * @returns the parsed parameters
  30063. */
  30064. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30065. }
  30066. }
  30067. declare module BABYLON {
  30068. /**
  30069. * This groups all the flags used to control the materials channel.
  30070. */
  30071. export class MaterialFlags {
  30072. private static _DiffuseTextureEnabled;
  30073. /**
  30074. * Are diffuse textures enabled in the application.
  30075. */
  30076. static get DiffuseTextureEnabled(): boolean;
  30077. static set DiffuseTextureEnabled(value: boolean);
  30078. private static _DetailTextureEnabled;
  30079. /**
  30080. * Are detail textures enabled in the application.
  30081. */
  30082. static get DetailTextureEnabled(): boolean;
  30083. static set DetailTextureEnabled(value: boolean);
  30084. private static _AmbientTextureEnabled;
  30085. /**
  30086. * Are ambient textures enabled in the application.
  30087. */
  30088. static get AmbientTextureEnabled(): boolean;
  30089. static set AmbientTextureEnabled(value: boolean);
  30090. private static _OpacityTextureEnabled;
  30091. /**
  30092. * Are opacity textures enabled in the application.
  30093. */
  30094. static get OpacityTextureEnabled(): boolean;
  30095. static set OpacityTextureEnabled(value: boolean);
  30096. private static _ReflectionTextureEnabled;
  30097. /**
  30098. * Are reflection textures enabled in the application.
  30099. */
  30100. static get ReflectionTextureEnabled(): boolean;
  30101. static set ReflectionTextureEnabled(value: boolean);
  30102. private static _EmissiveTextureEnabled;
  30103. /**
  30104. * Are emissive textures enabled in the application.
  30105. */
  30106. static get EmissiveTextureEnabled(): boolean;
  30107. static set EmissiveTextureEnabled(value: boolean);
  30108. private static _SpecularTextureEnabled;
  30109. /**
  30110. * Are specular textures enabled in the application.
  30111. */
  30112. static get SpecularTextureEnabled(): boolean;
  30113. static set SpecularTextureEnabled(value: boolean);
  30114. private static _BumpTextureEnabled;
  30115. /**
  30116. * Are bump textures enabled in the application.
  30117. */
  30118. static get BumpTextureEnabled(): boolean;
  30119. static set BumpTextureEnabled(value: boolean);
  30120. private static _LightmapTextureEnabled;
  30121. /**
  30122. * Are lightmap textures enabled in the application.
  30123. */
  30124. static get LightmapTextureEnabled(): boolean;
  30125. static set LightmapTextureEnabled(value: boolean);
  30126. private static _RefractionTextureEnabled;
  30127. /**
  30128. * Are refraction textures enabled in the application.
  30129. */
  30130. static get RefractionTextureEnabled(): boolean;
  30131. static set RefractionTextureEnabled(value: boolean);
  30132. private static _ColorGradingTextureEnabled;
  30133. /**
  30134. * Are color grading textures enabled in the application.
  30135. */
  30136. static get ColorGradingTextureEnabled(): boolean;
  30137. static set ColorGradingTextureEnabled(value: boolean);
  30138. private static _FresnelEnabled;
  30139. /**
  30140. * Are fresnels enabled in the application.
  30141. */
  30142. static get FresnelEnabled(): boolean;
  30143. static set FresnelEnabled(value: boolean);
  30144. private static _ClearCoatTextureEnabled;
  30145. /**
  30146. * Are clear coat textures enabled in the application.
  30147. */
  30148. static get ClearCoatTextureEnabled(): boolean;
  30149. static set ClearCoatTextureEnabled(value: boolean);
  30150. private static _ClearCoatBumpTextureEnabled;
  30151. /**
  30152. * Are clear coat bump textures enabled in the application.
  30153. */
  30154. static get ClearCoatBumpTextureEnabled(): boolean;
  30155. static set ClearCoatBumpTextureEnabled(value: boolean);
  30156. private static _ClearCoatTintTextureEnabled;
  30157. /**
  30158. * Are clear coat tint textures enabled in the application.
  30159. */
  30160. static get ClearCoatTintTextureEnabled(): boolean;
  30161. static set ClearCoatTintTextureEnabled(value: boolean);
  30162. private static _SheenTextureEnabled;
  30163. /**
  30164. * Are sheen textures enabled in the application.
  30165. */
  30166. static get SheenTextureEnabled(): boolean;
  30167. static set SheenTextureEnabled(value: boolean);
  30168. private static _AnisotropicTextureEnabled;
  30169. /**
  30170. * Are anisotropic textures enabled in the application.
  30171. */
  30172. static get AnisotropicTextureEnabled(): boolean;
  30173. static set AnisotropicTextureEnabled(value: boolean);
  30174. private static _ThicknessTextureEnabled;
  30175. /**
  30176. * Are thickness textures enabled in the application.
  30177. */
  30178. static get ThicknessTextureEnabled(): boolean;
  30179. static set ThicknessTextureEnabled(value: boolean);
  30180. }
  30181. }
  30182. declare module BABYLON {
  30183. /** @hidden */
  30184. export var defaultFragmentDeclaration: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module BABYLON {
  30190. /** @hidden */
  30191. export var defaultUboDeclaration: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module BABYLON {
  30197. /** @hidden */
  30198. export var prePassDeclaration: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module BABYLON {
  30204. /** @hidden */
  30205. export var lightFragmentDeclaration: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module BABYLON {
  30211. /** @hidden */
  30212. export var lightUboDeclaration: {
  30213. name: string;
  30214. shader: string;
  30215. };
  30216. }
  30217. declare module BABYLON {
  30218. /** @hidden */
  30219. export var lightsFragmentFunctions: {
  30220. name: string;
  30221. shader: string;
  30222. };
  30223. }
  30224. declare module BABYLON {
  30225. /** @hidden */
  30226. export var shadowsFragmentFunctions: {
  30227. name: string;
  30228. shader: string;
  30229. };
  30230. }
  30231. declare module BABYLON {
  30232. /** @hidden */
  30233. export var fresnelFunction: {
  30234. name: string;
  30235. shader: string;
  30236. };
  30237. }
  30238. declare module BABYLON {
  30239. /** @hidden */
  30240. export var bumpFragmentMainFunctions: {
  30241. name: string;
  30242. shader: string;
  30243. };
  30244. }
  30245. declare module BABYLON {
  30246. /** @hidden */
  30247. export var bumpFragmentFunctions: {
  30248. name: string;
  30249. shader: string;
  30250. };
  30251. }
  30252. declare module BABYLON {
  30253. /** @hidden */
  30254. export var logDepthDeclaration: {
  30255. name: string;
  30256. shader: string;
  30257. };
  30258. }
  30259. declare module BABYLON {
  30260. /** @hidden */
  30261. export var bumpFragment: {
  30262. name: string;
  30263. shader: string;
  30264. };
  30265. }
  30266. declare module BABYLON {
  30267. /** @hidden */
  30268. export var depthPrePass: {
  30269. name: string;
  30270. shader: string;
  30271. };
  30272. }
  30273. declare module BABYLON {
  30274. /** @hidden */
  30275. export var lightFragment: {
  30276. name: string;
  30277. shader: string;
  30278. };
  30279. }
  30280. declare module BABYLON {
  30281. /** @hidden */
  30282. export var logDepthFragment: {
  30283. name: string;
  30284. shader: string;
  30285. };
  30286. }
  30287. declare module BABYLON {
  30288. /** @hidden */
  30289. export var defaultPixelShader: {
  30290. name: string;
  30291. shader: string;
  30292. };
  30293. }
  30294. declare module BABYLON {
  30295. /** @hidden */
  30296. export var defaultVertexDeclaration: {
  30297. name: string;
  30298. shader: string;
  30299. };
  30300. }
  30301. declare module BABYLON {
  30302. /** @hidden */
  30303. export var bumpVertexDeclaration: {
  30304. name: string;
  30305. shader: string;
  30306. };
  30307. }
  30308. declare module BABYLON {
  30309. /** @hidden */
  30310. export var bumpVertex: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module BABYLON {
  30316. /** @hidden */
  30317. export var fogVertex: {
  30318. name: string;
  30319. shader: string;
  30320. };
  30321. }
  30322. declare module BABYLON {
  30323. /** @hidden */
  30324. export var shadowsVertex: {
  30325. name: string;
  30326. shader: string;
  30327. };
  30328. }
  30329. declare module BABYLON {
  30330. /** @hidden */
  30331. export var pointCloudVertex: {
  30332. name: string;
  30333. shader: string;
  30334. };
  30335. }
  30336. declare module BABYLON {
  30337. /** @hidden */
  30338. export var logDepthVertex: {
  30339. name: string;
  30340. shader: string;
  30341. };
  30342. }
  30343. declare module BABYLON {
  30344. /** @hidden */
  30345. export var defaultVertexShader: {
  30346. name: string;
  30347. shader: string;
  30348. };
  30349. }
  30350. declare module BABYLON {
  30351. /**
  30352. * @hidden
  30353. */
  30354. export interface IMaterialDetailMapDefines {
  30355. DETAIL: boolean;
  30356. DETAILDIRECTUV: number;
  30357. DETAIL_NORMALBLENDMETHOD: number;
  30358. /** @hidden */
  30359. _areTexturesDirty: boolean;
  30360. }
  30361. /**
  30362. * Define the code related to the detail map parameters of a material
  30363. *
  30364. * Inspired from:
  30365. * 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
  30366. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30367. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30368. */
  30369. export class DetailMapConfiguration {
  30370. private _texture;
  30371. /**
  30372. * The detail texture of the material.
  30373. */
  30374. texture: Nullable<BaseTexture>;
  30375. /**
  30376. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30377. * Bigger values mean stronger blending
  30378. */
  30379. diffuseBlendLevel: number;
  30380. /**
  30381. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30382. * Bigger values mean stronger blending. Only used with PBR materials
  30383. */
  30384. roughnessBlendLevel: number;
  30385. /**
  30386. * Defines how strong the bump effect from the detail map is
  30387. * Bigger values mean stronger effect
  30388. */
  30389. bumpLevel: number;
  30390. private _normalBlendMethod;
  30391. /**
  30392. * The method used to blend the bump and detail normals together
  30393. */
  30394. normalBlendMethod: number;
  30395. private _isEnabled;
  30396. /**
  30397. * Enable or disable the detail map on this material
  30398. */
  30399. isEnabled: boolean;
  30400. /** @hidden */
  30401. private _internalMarkAllSubMeshesAsTexturesDirty;
  30402. /** @hidden */
  30403. _markAllSubMeshesAsTexturesDirty(): void;
  30404. /**
  30405. * Instantiate a new detail map
  30406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30407. */
  30408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30409. /**
  30410. * Gets whether the submesh is ready to be used or not.
  30411. * @param defines the list of "defines" to update.
  30412. * @param scene defines the scene the material belongs to.
  30413. * @returns - boolean indicating that the submesh is ready or not.
  30414. */
  30415. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30416. /**
  30417. * Update the defines for detail map usage
  30418. * @param defines the list of "defines" to update.
  30419. * @param scene defines the scene the material belongs to.
  30420. */
  30421. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30422. /**
  30423. * Binds the material data.
  30424. * @param uniformBuffer defines the Uniform buffer to fill in.
  30425. * @param scene defines the scene the material belongs to.
  30426. * @param isFrozen defines whether the material is frozen or not.
  30427. */
  30428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30429. /**
  30430. * Checks to see if a texture is used in the material.
  30431. * @param texture - Base texture to use.
  30432. * @returns - Boolean specifying if a texture is used in the material.
  30433. */
  30434. hasTexture(texture: BaseTexture): boolean;
  30435. /**
  30436. * Returns an array of the actively used textures.
  30437. * @param activeTextures Array of BaseTextures
  30438. */
  30439. getActiveTextures(activeTextures: BaseTexture[]): void;
  30440. /**
  30441. * Returns the animatable textures.
  30442. * @param animatables Array of animatable textures.
  30443. */
  30444. getAnimatables(animatables: IAnimatable[]): void;
  30445. /**
  30446. * Disposes the resources of the material.
  30447. * @param forceDisposeTextures - Forces the disposal of all textures.
  30448. */
  30449. dispose(forceDisposeTextures?: boolean): void;
  30450. /**
  30451. * Get the current class name useful for serialization or dynamic coding.
  30452. * @returns "DetailMap"
  30453. */
  30454. getClassName(): string;
  30455. /**
  30456. * Add the required uniforms to the current list.
  30457. * @param uniforms defines the current uniform list.
  30458. */
  30459. static AddUniforms(uniforms: string[]): void;
  30460. /**
  30461. * Add the required samplers to the current list.
  30462. * @param samplers defines the current sampler list.
  30463. */
  30464. static AddSamplers(samplers: string[]): void;
  30465. /**
  30466. * Add the required uniforms to the current buffer.
  30467. * @param uniformBuffer defines the current uniform buffer.
  30468. */
  30469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30470. /**
  30471. * Makes a duplicate of the current instance into another one.
  30472. * @param detailMap define the instance where to copy the info
  30473. */
  30474. copyTo(detailMap: DetailMapConfiguration): void;
  30475. /**
  30476. * Serializes this detail map instance
  30477. * @returns - An object with the serialized instance.
  30478. */
  30479. serialize(): any;
  30480. /**
  30481. * Parses a detail map setting from a serialized object.
  30482. * @param source - Serialized object.
  30483. * @param scene Defines the scene we are parsing for
  30484. * @param rootUrl Defines the rootUrl to load from
  30485. */
  30486. parse(source: any, scene: Scene, rootUrl: string): void;
  30487. }
  30488. }
  30489. declare module BABYLON {
  30490. /** @hidden */
  30491. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30492. MAINUV1: boolean;
  30493. MAINUV2: boolean;
  30494. DIFFUSE: boolean;
  30495. DIFFUSEDIRECTUV: number;
  30496. DETAIL: boolean;
  30497. DETAILDIRECTUV: number;
  30498. DETAIL_NORMALBLENDMETHOD: number;
  30499. AMBIENT: boolean;
  30500. AMBIENTDIRECTUV: number;
  30501. OPACITY: boolean;
  30502. OPACITYDIRECTUV: number;
  30503. OPACITYRGB: boolean;
  30504. REFLECTION: boolean;
  30505. EMISSIVE: boolean;
  30506. EMISSIVEDIRECTUV: number;
  30507. SPECULAR: boolean;
  30508. SPECULARDIRECTUV: number;
  30509. BUMP: boolean;
  30510. BUMPDIRECTUV: number;
  30511. PARALLAX: boolean;
  30512. PARALLAXOCCLUSION: boolean;
  30513. SPECULAROVERALPHA: boolean;
  30514. CLIPPLANE: boolean;
  30515. CLIPPLANE2: boolean;
  30516. CLIPPLANE3: boolean;
  30517. CLIPPLANE4: boolean;
  30518. CLIPPLANE5: boolean;
  30519. CLIPPLANE6: boolean;
  30520. ALPHATEST: boolean;
  30521. DEPTHPREPASS: boolean;
  30522. ALPHAFROMDIFFUSE: boolean;
  30523. POINTSIZE: boolean;
  30524. FOG: boolean;
  30525. SPECULARTERM: boolean;
  30526. DIFFUSEFRESNEL: boolean;
  30527. OPACITYFRESNEL: boolean;
  30528. REFLECTIONFRESNEL: boolean;
  30529. REFRACTIONFRESNEL: boolean;
  30530. EMISSIVEFRESNEL: boolean;
  30531. FRESNEL: boolean;
  30532. NORMAL: boolean;
  30533. UV1: boolean;
  30534. UV2: boolean;
  30535. VERTEXCOLOR: boolean;
  30536. VERTEXALPHA: boolean;
  30537. NUM_BONE_INFLUENCERS: number;
  30538. BonesPerMesh: number;
  30539. BONETEXTURE: boolean;
  30540. INSTANCES: boolean;
  30541. THIN_INSTANCES: boolean;
  30542. GLOSSINESS: boolean;
  30543. ROUGHNESS: boolean;
  30544. EMISSIVEASILLUMINATION: boolean;
  30545. LINKEMISSIVEWITHDIFFUSE: boolean;
  30546. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30547. LIGHTMAP: boolean;
  30548. LIGHTMAPDIRECTUV: number;
  30549. OBJECTSPACE_NORMALMAP: boolean;
  30550. USELIGHTMAPASSHADOWMAP: boolean;
  30551. REFLECTIONMAP_3D: boolean;
  30552. REFLECTIONMAP_SPHERICAL: boolean;
  30553. REFLECTIONMAP_PLANAR: boolean;
  30554. REFLECTIONMAP_CUBIC: boolean;
  30555. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30556. REFLECTIONMAP_PROJECTION: boolean;
  30557. REFLECTIONMAP_SKYBOX: boolean;
  30558. REFLECTIONMAP_EXPLICIT: boolean;
  30559. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30560. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30561. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30562. INVERTCUBICMAP: boolean;
  30563. LOGARITHMICDEPTH: boolean;
  30564. REFRACTION: boolean;
  30565. REFRACTIONMAP_3D: boolean;
  30566. REFLECTIONOVERALPHA: boolean;
  30567. TWOSIDEDLIGHTING: boolean;
  30568. SHADOWFLOAT: boolean;
  30569. MORPHTARGETS: boolean;
  30570. MORPHTARGETS_NORMAL: boolean;
  30571. MORPHTARGETS_TANGENT: boolean;
  30572. MORPHTARGETS_UV: boolean;
  30573. NUM_MORPH_INFLUENCERS: number;
  30574. NONUNIFORMSCALING: boolean;
  30575. PREMULTIPLYALPHA: boolean;
  30576. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30577. ALPHABLEND: boolean;
  30578. PREPASS: boolean;
  30579. PREPASS_IRRADIANCE: boolean;
  30580. PREPASS_IRRADIANCE_INDEX: number;
  30581. PREPASS_ALBEDO: boolean;
  30582. PREPASS_ALBEDO_INDEX: number;
  30583. PREPASS_DEPTHNORMAL: boolean;
  30584. PREPASS_DEPTHNORMAL_INDEX: number;
  30585. SCENE_MRT_COUNT: number;
  30586. RGBDLIGHTMAP: boolean;
  30587. RGBDREFLECTION: boolean;
  30588. RGBDREFRACTION: boolean;
  30589. IMAGEPROCESSING: boolean;
  30590. VIGNETTE: boolean;
  30591. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30592. VIGNETTEBLENDMODEOPAQUE: boolean;
  30593. TONEMAPPING: boolean;
  30594. TONEMAPPING_ACES: boolean;
  30595. CONTRAST: boolean;
  30596. COLORCURVES: boolean;
  30597. COLORGRADING: boolean;
  30598. COLORGRADING3D: boolean;
  30599. SAMPLER3DGREENDEPTH: boolean;
  30600. SAMPLER3DBGRMAP: boolean;
  30601. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30602. MULTIVIEW: boolean;
  30603. /**
  30604. * If the reflection texture on this material is in linear color space
  30605. * @hidden
  30606. */
  30607. IS_REFLECTION_LINEAR: boolean;
  30608. /**
  30609. * If the refraction texture on this material is in linear color space
  30610. * @hidden
  30611. */
  30612. IS_REFRACTION_LINEAR: boolean;
  30613. EXPOSURE: boolean;
  30614. constructor();
  30615. setReflectionMode(modeToEnable: string): void;
  30616. }
  30617. /**
  30618. * This is the default material used in Babylon. It is the best trade off between quality
  30619. * and performances.
  30620. * @see https://doc.babylonjs.com/babylon101/materials
  30621. */
  30622. export class StandardMaterial extends PushMaterial {
  30623. private _diffuseTexture;
  30624. /**
  30625. * The basic texture of the material as viewed under a light.
  30626. */
  30627. diffuseTexture: Nullable<BaseTexture>;
  30628. private _ambientTexture;
  30629. /**
  30630. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30631. */
  30632. ambientTexture: Nullable<BaseTexture>;
  30633. private _opacityTexture;
  30634. /**
  30635. * Define the transparency of the material from a texture.
  30636. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30637. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30638. */
  30639. opacityTexture: Nullable<BaseTexture>;
  30640. private _reflectionTexture;
  30641. /**
  30642. * Define the texture used to display the reflection.
  30643. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30644. */
  30645. reflectionTexture: Nullable<BaseTexture>;
  30646. private _emissiveTexture;
  30647. /**
  30648. * Define texture of the material as if self lit.
  30649. * This will be mixed in the final result even in the absence of light.
  30650. */
  30651. emissiveTexture: Nullable<BaseTexture>;
  30652. private _specularTexture;
  30653. /**
  30654. * Define how the color and intensity of the highlight given by the light in the material.
  30655. */
  30656. specularTexture: Nullable<BaseTexture>;
  30657. private _bumpTexture;
  30658. /**
  30659. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30660. * 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.
  30661. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30662. */
  30663. bumpTexture: Nullable<BaseTexture>;
  30664. private _lightmapTexture;
  30665. /**
  30666. * Complex lighting can be computationally expensive to compute at runtime.
  30667. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30668. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30669. */
  30670. lightmapTexture: Nullable<BaseTexture>;
  30671. private _refractionTexture;
  30672. /**
  30673. * Define the texture used to display the refraction.
  30674. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30675. */
  30676. refractionTexture: Nullable<BaseTexture>;
  30677. /**
  30678. * The color of the material lit by the environmental background lighting.
  30679. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30680. */
  30681. ambientColor: Color3;
  30682. /**
  30683. * The basic color of the material as viewed under a light.
  30684. */
  30685. diffuseColor: Color3;
  30686. /**
  30687. * Define how the color and intensity of the highlight given by the light in the material.
  30688. */
  30689. specularColor: Color3;
  30690. /**
  30691. * Define the color of the material as if self lit.
  30692. * This will be mixed in the final result even in the absence of light.
  30693. */
  30694. emissiveColor: Color3;
  30695. /**
  30696. * Defines how sharp are the highlights in the material.
  30697. * The bigger the value the sharper giving a more glossy feeling to the result.
  30698. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30699. */
  30700. specularPower: number;
  30701. private _useAlphaFromDiffuseTexture;
  30702. /**
  30703. * Does the transparency come from the diffuse texture alpha channel.
  30704. */
  30705. useAlphaFromDiffuseTexture: boolean;
  30706. private _useEmissiveAsIllumination;
  30707. /**
  30708. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30709. */
  30710. useEmissiveAsIllumination: boolean;
  30711. private _linkEmissiveWithDiffuse;
  30712. /**
  30713. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30714. * the emissive level when the final color is close to one.
  30715. */
  30716. linkEmissiveWithDiffuse: boolean;
  30717. private _useSpecularOverAlpha;
  30718. /**
  30719. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30720. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30721. */
  30722. useSpecularOverAlpha: boolean;
  30723. private _useReflectionOverAlpha;
  30724. /**
  30725. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30726. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30727. */
  30728. useReflectionOverAlpha: boolean;
  30729. private _disableLighting;
  30730. /**
  30731. * Does lights from the scene impacts this material.
  30732. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30733. */
  30734. disableLighting: boolean;
  30735. private _useObjectSpaceNormalMap;
  30736. /**
  30737. * Allows using an object space normal map (instead of tangent space).
  30738. */
  30739. useObjectSpaceNormalMap: boolean;
  30740. private _useParallax;
  30741. /**
  30742. * Is parallax enabled or not.
  30743. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30744. */
  30745. useParallax: boolean;
  30746. private _useParallaxOcclusion;
  30747. /**
  30748. * Is parallax occlusion enabled or not.
  30749. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30750. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30751. */
  30752. useParallaxOcclusion: boolean;
  30753. /**
  30754. * 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.
  30755. */
  30756. parallaxScaleBias: number;
  30757. private _roughness;
  30758. /**
  30759. * Helps to define how blurry the reflections should appears in the material.
  30760. */
  30761. roughness: number;
  30762. /**
  30763. * In case of refraction, define the value of the index of refraction.
  30764. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30765. */
  30766. indexOfRefraction: number;
  30767. /**
  30768. * Invert the refraction texture alongside the y axis.
  30769. * It can be useful with procedural textures or probe for instance.
  30770. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30771. */
  30772. invertRefractionY: boolean;
  30773. /**
  30774. * Defines the alpha limits in alpha test mode.
  30775. */
  30776. alphaCutOff: number;
  30777. private _useLightmapAsShadowmap;
  30778. /**
  30779. * In case of light mapping, define whether the map contains light or shadow informations.
  30780. */
  30781. useLightmapAsShadowmap: boolean;
  30782. private _diffuseFresnelParameters;
  30783. /**
  30784. * Define the diffuse fresnel parameters of the material.
  30785. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30786. */
  30787. diffuseFresnelParameters: FresnelParameters;
  30788. private _opacityFresnelParameters;
  30789. /**
  30790. * Define the opacity fresnel parameters of the material.
  30791. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30792. */
  30793. opacityFresnelParameters: FresnelParameters;
  30794. private _reflectionFresnelParameters;
  30795. /**
  30796. * Define the reflection fresnel parameters of the material.
  30797. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30798. */
  30799. reflectionFresnelParameters: FresnelParameters;
  30800. private _refractionFresnelParameters;
  30801. /**
  30802. * Define the refraction fresnel parameters of the material.
  30803. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30804. */
  30805. refractionFresnelParameters: FresnelParameters;
  30806. private _emissiveFresnelParameters;
  30807. /**
  30808. * Define the emissive fresnel parameters of the material.
  30809. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30810. */
  30811. emissiveFresnelParameters: FresnelParameters;
  30812. private _useReflectionFresnelFromSpecular;
  30813. /**
  30814. * If true automatically deducts the fresnels values from the material specularity.
  30815. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30816. */
  30817. useReflectionFresnelFromSpecular: boolean;
  30818. private _useGlossinessFromSpecularMapAlpha;
  30819. /**
  30820. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30821. */
  30822. useGlossinessFromSpecularMapAlpha: boolean;
  30823. private _maxSimultaneousLights;
  30824. /**
  30825. * Defines the maximum number of lights that can be used in the material
  30826. */
  30827. maxSimultaneousLights: number;
  30828. private _invertNormalMapX;
  30829. /**
  30830. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30831. */
  30832. invertNormalMapX: boolean;
  30833. private _invertNormalMapY;
  30834. /**
  30835. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30836. */
  30837. invertNormalMapY: boolean;
  30838. private _twoSidedLighting;
  30839. /**
  30840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30841. */
  30842. twoSidedLighting: boolean;
  30843. /**
  30844. * Default configuration related to image processing available in the standard Material.
  30845. */
  30846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30847. /**
  30848. * Gets the image processing configuration used either in this material.
  30849. */
  30850. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30851. /**
  30852. * Sets the Default image processing configuration used either in the this material.
  30853. *
  30854. * If sets to null, the scene one is in use.
  30855. */
  30856. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30857. /**
  30858. * Keep track of the image processing observer to allow dispose and replace.
  30859. */
  30860. private _imageProcessingObserver;
  30861. /**
  30862. * Attaches a new image processing configuration to the Standard Material.
  30863. * @param configuration
  30864. */
  30865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30866. /**
  30867. * Gets wether the color curves effect is enabled.
  30868. */
  30869. get cameraColorCurvesEnabled(): boolean;
  30870. /**
  30871. * Sets wether the color curves effect is enabled.
  30872. */
  30873. set cameraColorCurvesEnabled(value: boolean);
  30874. /**
  30875. * Gets wether the color grading effect is enabled.
  30876. */
  30877. get cameraColorGradingEnabled(): boolean;
  30878. /**
  30879. * Gets wether the color grading effect is enabled.
  30880. */
  30881. set cameraColorGradingEnabled(value: boolean);
  30882. /**
  30883. * Gets wether tonemapping is enabled or not.
  30884. */
  30885. get cameraToneMappingEnabled(): boolean;
  30886. /**
  30887. * Sets wether tonemapping is enabled or not
  30888. */
  30889. set cameraToneMappingEnabled(value: boolean);
  30890. /**
  30891. * The camera exposure used on this material.
  30892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30893. * This corresponds to a photographic exposure.
  30894. */
  30895. get cameraExposure(): number;
  30896. /**
  30897. * The camera exposure used on this material.
  30898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30899. * This corresponds to a photographic exposure.
  30900. */
  30901. set cameraExposure(value: number);
  30902. /**
  30903. * Gets The camera contrast used on this material.
  30904. */
  30905. get cameraContrast(): number;
  30906. /**
  30907. * Sets The camera contrast used on this material.
  30908. */
  30909. set cameraContrast(value: number);
  30910. /**
  30911. * Gets the Color Grading 2D Lookup Texture.
  30912. */
  30913. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30914. /**
  30915. * Sets the Color Grading 2D Lookup Texture.
  30916. */
  30917. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30918. /**
  30919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30921. * 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;
  30922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30923. */
  30924. get cameraColorCurves(): Nullable<ColorCurves>;
  30925. /**
  30926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30928. * 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;
  30929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30930. */
  30931. set cameraColorCurves(value: Nullable<ColorCurves>);
  30932. /**
  30933. * Can this material render to several textures at once
  30934. */
  30935. get canRenderToMRT(): boolean;
  30936. /**
  30937. * Defines the detail map parameters for the material.
  30938. */
  30939. readonly detailMap: DetailMapConfiguration;
  30940. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30941. protected _worldViewProjectionMatrix: Matrix;
  30942. protected _globalAmbientColor: Color3;
  30943. protected _useLogarithmicDepth: boolean;
  30944. protected _rebuildInParallel: boolean;
  30945. /**
  30946. * Instantiates a new standard material.
  30947. * This is the default material used in Babylon. It is the best trade off between quality
  30948. * and performances.
  30949. * @see https://doc.babylonjs.com/babylon101/materials
  30950. * @param name Define the name of the material in the scene
  30951. * @param scene Define the scene the material belong to
  30952. */
  30953. constructor(name: string, scene: Scene);
  30954. /**
  30955. * Gets a boolean indicating that current material needs to register RTT
  30956. */
  30957. get hasRenderTargetTextures(): boolean;
  30958. /**
  30959. * Gets the current class name of the material e.g. "StandardMaterial"
  30960. * Mainly use in serialization.
  30961. * @returns the class name
  30962. */
  30963. getClassName(): string;
  30964. /**
  30965. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30966. * You can try switching to logarithmic depth.
  30967. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30968. */
  30969. get useLogarithmicDepth(): boolean;
  30970. set useLogarithmicDepth(value: boolean);
  30971. /**
  30972. * Specifies if the material will require alpha blending
  30973. * @returns a boolean specifying if alpha blending is needed
  30974. */
  30975. needAlphaBlending(): boolean;
  30976. /**
  30977. * Specifies if this material should be rendered in alpha test mode
  30978. * @returns a boolean specifying if an alpha test is needed.
  30979. */
  30980. needAlphaTesting(): boolean;
  30981. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30982. /**
  30983. * Get the texture used for alpha test purpose.
  30984. * @returns the diffuse texture in case of the standard material.
  30985. */
  30986. getAlphaTestTexture(): Nullable<BaseTexture>;
  30987. /**
  30988. * Get if the submesh is ready to be used and all its information available.
  30989. * Child classes can use it to update shaders
  30990. * @param mesh defines the mesh to check
  30991. * @param subMesh defines which submesh to check
  30992. * @param useInstances specifies that instances should be used
  30993. * @returns a boolean indicating that the submesh is ready or not
  30994. */
  30995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30996. /**
  30997. * Builds the material UBO layouts.
  30998. * Used internally during the effect preparation.
  30999. */
  31000. buildUniformLayout(): void;
  31001. /**
  31002. * Unbinds the material from the mesh
  31003. */
  31004. unbind(): void;
  31005. /**
  31006. * Binds the submesh to this material by preparing the effect and shader to draw
  31007. * @param world defines the world transformation matrix
  31008. * @param mesh defines the mesh containing the submesh
  31009. * @param subMesh defines the submesh to bind the material to
  31010. */
  31011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31012. /**
  31013. * Get the list of animatables in the material.
  31014. * @returns the list of animatables object used in the material
  31015. */
  31016. getAnimatables(): IAnimatable[];
  31017. /**
  31018. * Gets the active textures from the material
  31019. * @returns an array of textures
  31020. */
  31021. getActiveTextures(): BaseTexture[];
  31022. /**
  31023. * Specifies if the material uses a texture
  31024. * @param texture defines the texture to check against the material
  31025. * @returns a boolean specifying if the material uses the texture
  31026. */
  31027. hasTexture(texture: BaseTexture): boolean;
  31028. /**
  31029. * Disposes the material
  31030. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31031. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31032. */
  31033. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31034. /**
  31035. * Makes a duplicate of the material, and gives it a new name
  31036. * @param name defines the new name for the duplicated material
  31037. * @returns the cloned material
  31038. */
  31039. clone(name: string): StandardMaterial;
  31040. /**
  31041. * Serializes this material in a JSON representation
  31042. * @returns the serialized material object
  31043. */
  31044. serialize(): any;
  31045. /**
  31046. * Creates a standard material from parsed material data
  31047. * @param source defines the JSON representation of the material
  31048. * @param scene defines the hosting scene
  31049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31050. * @returns a new standard material
  31051. */
  31052. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31053. /**
  31054. * Are diffuse textures enabled in the application.
  31055. */
  31056. static get DiffuseTextureEnabled(): boolean;
  31057. static set DiffuseTextureEnabled(value: boolean);
  31058. /**
  31059. * Are detail textures enabled in the application.
  31060. */
  31061. static get DetailTextureEnabled(): boolean;
  31062. static set DetailTextureEnabled(value: boolean);
  31063. /**
  31064. * Are ambient textures enabled in the application.
  31065. */
  31066. static get AmbientTextureEnabled(): boolean;
  31067. static set AmbientTextureEnabled(value: boolean);
  31068. /**
  31069. * Are opacity textures enabled in the application.
  31070. */
  31071. static get OpacityTextureEnabled(): boolean;
  31072. static set OpacityTextureEnabled(value: boolean);
  31073. /**
  31074. * Are reflection textures enabled in the application.
  31075. */
  31076. static get ReflectionTextureEnabled(): boolean;
  31077. static set ReflectionTextureEnabled(value: boolean);
  31078. /**
  31079. * Are emissive textures enabled in the application.
  31080. */
  31081. static get EmissiveTextureEnabled(): boolean;
  31082. static set EmissiveTextureEnabled(value: boolean);
  31083. /**
  31084. * Are specular textures enabled in the application.
  31085. */
  31086. static get SpecularTextureEnabled(): boolean;
  31087. static set SpecularTextureEnabled(value: boolean);
  31088. /**
  31089. * Are bump textures enabled in the application.
  31090. */
  31091. static get BumpTextureEnabled(): boolean;
  31092. static set BumpTextureEnabled(value: boolean);
  31093. /**
  31094. * Are lightmap textures enabled in the application.
  31095. */
  31096. static get LightmapTextureEnabled(): boolean;
  31097. static set LightmapTextureEnabled(value: boolean);
  31098. /**
  31099. * Are refraction textures enabled in the application.
  31100. */
  31101. static get RefractionTextureEnabled(): boolean;
  31102. static set RefractionTextureEnabled(value: boolean);
  31103. /**
  31104. * Are color grading textures enabled in the application.
  31105. */
  31106. static get ColorGradingTextureEnabled(): boolean;
  31107. static set ColorGradingTextureEnabled(value: boolean);
  31108. /**
  31109. * Are fresnels enabled in the application.
  31110. */
  31111. static get FresnelEnabled(): boolean;
  31112. static set FresnelEnabled(value: boolean);
  31113. }
  31114. }
  31115. declare module BABYLON {
  31116. /**
  31117. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31118. *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.
  31119. * The SPS is also a particle system. It provides some methods to manage the particles.
  31120. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31121. *
  31122. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31123. */
  31124. export class SolidParticleSystem implements IDisposable {
  31125. /**
  31126. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31127. * Example : var p = SPS.particles[i];
  31128. */
  31129. particles: SolidParticle[];
  31130. /**
  31131. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31132. */
  31133. nbParticles: number;
  31134. /**
  31135. * If the particles must ever face the camera (default false). Useful for planar particles.
  31136. */
  31137. billboard: boolean;
  31138. /**
  31139. * Recompute normals when adding a shape
  31140. */
  31141. recomputeNormals: boolean;
  31142. /**
  31143. * This a counter ofr your own usage. It's not set by any SPS functions.
  31144. */
  31145. counter: number;
  31146. /**
  31147. * The SPS name. This name is also given to the underlying mesh.
  31148. */
  31149. name: string;
  31150. /**
  31151. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31152. */
  31153. mesh: Mesh;
  31154. /**
  31155. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31156. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31157. */
  31158. vars: any;
  31159. /**
  31160. * This array is populated when the SPS is set as 'pickable'.
  31161. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31162. * Each element of this array is an object `{idx: int, faceId: int}`.
  31163. * `idx` is the picked particle index in the `SPS.particles` array
  31164. * `faceId` is the picked face index counted within this particle.
  31165. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31166. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31167. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31168. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31169. */
  31170. pickedParticles: {
  31171. idx: number;
  31172. faceId: number;
  31173. }[];
  31174. /**
  31175. * This array is populated when the SPS is set as 'pickable'
  31176. * Each key of this array is a submesh index.
  31177. * Each element of this array is a second array defined like this :
  31178. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31179. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31180. * `idx` is the picked particle index in the `SPS.particles` array
  31181. * `faceId` is the picked face index counted within this particle.
  31182. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31183. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31184. */
  31185. pickedBySubMesh: {
  31186. idx: number;
  31187. faceId: number;
  31188. }[][];
  31189. /**
  31190. * This array is populated when `enableDepthSort` is set to true.
  31191. * Each element of this array is an instance of the class DepthSortedParticle.
  31192. */
  31193. depthSortedParticles: DepthSortedParticle[];
  31194. /**
  31195. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31196. * @hidden
  31197. */
  31198. _bSphereOnly: boolean;
  31199. /**
  31200. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31201. * @hidden
  31202. */
  31203. _bSphereRadiusFactor: number;
  31204. private _scene;
  31205. private _positions;
  31206. private _indices;
  31207. private _normals;
  31208. private _colors;
  31209. private _uvs;
  31210. private _indices32;
  31211. private _positions32;
  31212. private _normals32;
  31213. private _fixedNormal32;
  31214. private _colors32;
  31215. private _uvs32;
  31216. private _index;
  31217. private _updatable;
  31218. private _pickable;
  31219. private _isVisibilityBoxLocked;
  31220. private _alwaysVisible;
  31221. private _depthSort;
  31222. private _expandable;
  31223. private _shapeCounter;
  31224. private _copy;
  31225. private _color;
  31226. private _computeParticleColor;
  31227. private _computeParticleTexture;
  31228. private _computeParticleRotation;
  31229. private _computeParticleVertex;
  31230. private _computeBoundingBox;
  31231. private _depthSortParticles;
  31232. private _camera;
  31233. private _mustUnrotateFixedNormals;
  31234. private _particlesIntersect;
  31235. private _needs32Bits;
  31236. private _isNotBuilt;
  31237. private _lastParticleId;
  31238. private _idxOfId;
  31239. private _multimaterialEnabled;
  31240. private _useModelMaterial;
  31241. private _indicesByMaterial;
  31242. private _materialIndexes;
  31243. private _depthSortFunction;
  31244. private _materialSortFunction;
  31245. private _materials;
  31246. private _multimaterial;
  31247. private _materialIndexesById;
  31248. private _defaultMaterial;
  31249. private _autoUpdateSubMeshes;
  31250. private _tmpVertex;
  31251. /**
  31252. * Creates a SPS (Solid Particle System) object.
  31253. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31254. * @param scene (Scene) is the scene in which the SPS is added.
  31255. * @param options defines the options of the sps e.g.
  31256. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31257. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31258. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31259. * * 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.
  31260. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31261. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31262. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31263. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31264. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31265. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31266. */
  31267. constructor(name: string, scene: Scene, options?: {
  31268. updatable?: boolean;
  31269. isPickable?: boolean;
  31270. enableDepthSort?: boolean;
  31271. particleIntersection?: boolean;
  31272. boundingSphereOnly?: boolean;
  31273. bSphereRadiusFactor?: number;
  31274. expandable?: boolean;
  31275. useModelMaterial?: boolean;
  31276. enableMultiMaterial?: boolean;
  31277. });
  31278. /**
  31279. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31280. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31281. * @returns the created mesh
  31282. */
  31283. buildMesh(): Mesh;
  31284. /**
  31285. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31286. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31287. * Thus the particles generated from `digest()` have their property `position` set yet.
  31288. * @param mesh ( Mesh ) is the mesh to be digested
  31289. * @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
  31290. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31291. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31292. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31293. * @returns the current SPS
  31294. */
  31295. digest(mesh: Mesh, options?: {
  31296. facetNb?: number;
  31297. number?: number;
  31298. delta?: number;
  31299. storage?: [];
  31300. }): SolidParticleSystem;
  31301. /**
  31302. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31303. * @hidden
  31304. */
  31305. private _unrotateFixedNormals;
  31306. /**
  31307. * Resets the temporary working copy particle
  31308. * @hidden
  31309. */
  31310. private _resetCopy;
  31311. /**
  31312. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31313. * @param p the current index in the positions array to be updated
  31314. * @param ind the current index in the indices array
  31315. * @param shape a Vector3 array, the shape geometry
  31316. * @param positions the positions array to be updated
  31317. * @param meshInd the shape indices array
  31318. * @param indices the indices array to be updated
  31319. * @param meshUV the shape uv array
  31320. * @param uvs the uv array to be updated
  31321. * @param meshCol the shape color array
  31322. * @param colors the color array to be updated
  31323. * @param meshNor the shape normals array
  31324. * @param normals the normals array to be updated
  31325. * @param idx the particle index
  31326. * @param idxInShape the particle index in its shape
  31327. * @param options the addShape() method passed options
  31328. * @model the particle model
  31329. * @hidden
  31330. */
  31331. private _meshBuilder;
  31332. /**
  31333. * Returns a shape Vector3 array from positions float array
  31334. * @param positions float array
  31335. * @returns a vector3 array
  31336. * @hidden
  31337. */
  31338. private _posToShape;
  31339. /**
  31340. * Returns a shapeUV array from a float uvs (array deep copy)
  31341. * @param uvs as a float array
  31342. * @returns a shapeUV array
  31343. * @hidden
  31344. */
  31345. private _uvsToShapeUV;
  31346. /**
  31347. * Adds a new particle object in the particles array
  31348. * @param idx particle index in particles array
  31349. * @param id particle id
  31350. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31351. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31352. * @param model particle ModelShape object
  31353. * @param shapeId model shape identifier
  31354. * @param idxInShape index of the particle in the current model
  31355. * @param bInfo model bounding info object
  31356. * @param storage target storage array, if any
  31357. * @hidden
  31358. */
  31359. private _addParticle;
  31360. /**
  31361. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31362. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31363. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31364. * @param nb (positive integer) the number of particles to be created from this model
  31365. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31366. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31367. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31368. * @returns the number of shapes in the system
  31369. */
  31370. addShape(mesh: Mesh, nb: number, options?: {
  31371. positionFunction?: any;
  31372. vertexFunction?: any;
  31373. storage?: [];
  31374. }): number;
  31375. /**
  31376. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31377. * @hidden
  31378. */
  31379. private _rebuildParticle;
  31380. /**
  31381. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31382. * @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.
  31383. * @returns the SPS.
  31384. */
  31385. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31386. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31387. * Returns an array with the removed particles.
  31388. * 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.
  31389. * The SPS can't be empty so at least one particle needs to remain in place.
  31390. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31391. * @param start index of the first particle to remove
  31392. * @param end index of the last particle to remove (included)
  31393. * @returns an array populated with the removed particles
  31394. */
  31395. removeParticles(start: number, end: number): SolidParticle[];
  31396. /**
  31397. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31398. * @param solidParticleArray an array populated with Solid Particles objects
  31399. * @returns the SPS
  31400. */
  31401. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31402. /**
  31403. * Creates a new particle and modifies the SPS mesh geometry :
  31404. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31405. * - calls _addParticle() to populate the particle array
  31406. * factorized code from addShape() and insertParticlesFromArray()
  31407. * @param idx particle index in the particles array
  31408. * @param i particle index in its shape
  31409. * @param modelShape particle ModelShape object
  31410. * @param shape shape vertex array
  31411. * @param meshInd shape indices array
  31412. * @param meshUV shape uv array
  31413. * @param meshCol shape color array
  31414. * @param meshNor shape normals array
  31415. * @param bbInfo shape bounding info
  31416. * @param storage target particle storage
  31417. * @options addShape() passed options
  31418. * @hidden
  31419. */
  31420. private _insertNewParticle;
  31421. /**
  31422. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31423. * This method calls `updateParticle()` for each particle of the SPS.
  31424. * For an animated SPS, it is usually called within the render loop.
  31425. * 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.
  31426. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31427. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31428. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31429. * @returns the SPS.
  31430. */
  31431. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31432. /**
  31433. * Disposes the SPS.
  31434. */
  31435. dispose(): void;
  31436. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31437. * idx is the particle index in the SPS
  31438. * faceId is the picked face index counted within this particle.
  31439. * Returns null if the pickInfo can't identify a picked particle.
  31440. * @param pickingInfo (PickingInfo object)
  31441. * @returns {idx: number, faceId: number} or null
  31442. */
  31443. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31444. idx: number;
  31445. faceId: number;
  31446. }>;
  31447. /**
  31448. * Returns a SolidParticle object from its identifier : particle.id
  31449. * @param id (integer) the particle Id
  31450. * @returns the searched particle or null if not found in the SPS.
  31451. */
  31452. getParticleById(id: number): Nullable<SolidParticle>;
  31453. /**
  31454. * Returns a new array populated with the particles having the passed shapeId.
  31455. * @param shapeId (integer) the shape identifier
  31456. * @returns a new solid particle array
  31457. */
  31458. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31459. /**
  31460. * Populates the passed array "ref" with the particles having the passed shapeId.
  31461. * @param shapeId the shape identifier
  31462. * @returns the SPS
  31463. * @param ref
  31464. */
  31465. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31466. /**
  31467. * Computes the required SubMeshes according the materials assigned to the particles.
  31468. * @returns the solid particle system.
  31469. * Does nothing if called before the SPS mesh is built.
  31470. */
  31471. computeSubMeshes(): SolidParticleSystem;
  31472. /**
  31473. * Sorts the solid particles by material when MultiMaterial is enabled.
  31474. * Updates the indices32 array.
  31475. * Updates the indicesByMaterial array.
  31476. * Updates the mesh indices array.
  31477. * @returns the SPS
  31478. * @hidden
  31479. */
  31480. private _sortParticlesByMaterial;
  31481. /**
  31482. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31483. * @hidden
  31484. */
  31485. private _setMaterialIndexesById;
  31486. /**
  31487. * Returns an array with unique values of Materials from the passed array
  31488. * @param array the material array to be checked and filtered
  31489. * @hidden
  31490. */
  31491. private _filterUniqueMaterialId;
  31492. /**
  31493. * Sets a new Standard Material as _defaultMaterial if not already set.
  31494. * @hidden
  31495. */
  31496. private _setDefaultMaterial;
  31497. /**
  31498. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31499. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31500. * @returns the SPS.
  31501. */
  31502. refreshVisibleSize(): SolidParticleSystem;
  31503. /**
  31504. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31505. * @param size the size (float) of the visibility box
  31506. * note : this doesn't lock the SPS mesh bounding box.
  31507. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31508. */
  31509. setVisibilityBox(size: number): void;
  31510. /**
  31511. * Gets whether the SPS as always visible or not
  31512. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31513. */
  31514. get isAlwaysVisible(): boolean;
  31515. /**
  31516. * Sets the SPS as always visible or not
  31517. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31518. */
  31519. set isAlwaysVisible(val: boolean);
  31520. /**
  31521. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31523. */
  31524. set isVisibilityBoxLocked(val: boolean);
  31525. /**
  31526. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31528. */
  31529. get isVisibilityBoxLocked(): boolean;
  31530. /**
  31531. * Tells to `setParticles()` to compute the particle rotations or not.
  31532. * Default value : true. The SPS is faster when it's set to false.
  31533. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31534. */
  31535. set computeParticleRotation(val: boolean);
  31536. /**
  31537. * Tells to `setParticles()` to compute the particle colors or not.
  31538. * Default value : true. The SPS is faster when it's set to false.
  31539. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31540. */
  31541. set computeParticleColor(val: boolean);
  31542. set computeParticleTexture(val: boolean);
  31543. /**
  31544. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31545. * Default value : false. The SPS is faster when it's set to false.
  31546. * Note : the particle custom vertex positions aren't stored values.
  31547. */
  31548. set computeParticleVertex(val: boolean);
  31549. /**
  31550. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31551. */
  31552. set computeBoundingBox(val: boolean);
  31553. /**
  31554. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31555. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31556. * Default : `true`
  31557. */
  31558. set depthSortParticles(val: boolean);
  31559. /**
  31560. * Gets if `setParticles()` computes the particle rotations or not.
  31561. * Default value : true. The SPS is faster when it's set to false.
  31562. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31563. */
  31564. get computeParticleRotation(): boolean;
  31565. /**
  31566. * Gets if `setParticles()` computes the particle colors or not.
  31567. * Default value : true. The SPS is faster when it's set to false.
  31568. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31569. */
  31570. get computeParticleColor(): boolean;
  31571. /**
  31572. * Gets if `setParticles()` computes the particle textures or not.
  31573. * Default value : true. The SPS is faster when it's set to false.
  31574. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31575. */
  31576. get computeParticleTexture(): boolean;
  31577. /**
  31578. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31579. * Default value : false. The SPS is faster when it's set to false.
  31580. * Note : the particle custom vertex positions aren't stored values.
  31581. */
  31582. get computeParticleVertex(): boolean;
  31583. /**
  31584. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31585. */
  31586. get computeBoundingBox(): boolean;
  31587. /**
  31588. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31589. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31590. * Default : `true`
  31591. */
  31592. get depthSortParticles(): boolean;
  31593. /**
  31594. * Gets if the SPS is created as expandable at construction time.
  31595. * Default : `false`
  31596. */
  31597. get expandable(): boolean;
  31598. /**
  31599. * Gets if the SPS supports the Multi Materials
  31600. */
  31601. get multimaterialEnabled(): boolean;
  31602. /**
  31603. * Gets if the SPS uses the model materials for its own multimaterial.
  31604. */
  31605. get useModelMaterial(): boolean;
  31606. /**
  31607. * The SPS used material array.
  31608. */
  31609. get materials(): Material[];
  31610. /**
  31611. * Sets the SPS MultiMaterial from the passed materials.
  31612. * Note : the passed array is internally copied and not used then by reference.
  31613. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31614. */
  31615. setMultiMaterial(materials: Material[]): void;
  31616. /**
  31617. * The SPS computed multimaterial object
  31618. */
  31619. get multimaterial(): MultiMaterial;
  31620. set multimaterial(mm: MultiMaterial);
  31621. /**
  31622. * If the subMeshes must be updated on the next call to setParticles()
  31623. */
  31624. get autoUpdateSubMeshes(): boolean;
  31625. set autoUpdateSubMeshes(val: boolean);
  31626. /**
  31627. * This function does nothing. It may be overwritten to set all the particle first values.
  31628. * The SPS doesn't call this function, you may have to call it by your own.
  31629. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31630. */
  31631. initParticles(): void;
  31632. /**
  31633. * This function does nothing. It may be overwritten to recycle a particle.
  31634. * The SPS doesn't call this function, you may have to call it by your own.
  31635. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31636. * @param particle The particle to recycle
  31637. * @returns the recycled particle
  31638. */
  31639. recycleParticle(particle: SolidParticle): SolidParticle;
  31640. /**
  31641. * Updates a particle : this function should be overwritten by the user.
  31642. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31643. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31644. * @example : just set a particle position or velocity and recycle conditions
  31645. * @param particle The particle to update
  31646. * @returns the updated particle
  31647. */
  31648. updateParticle(particle: SolidParticle): SolidParticle;
  31649. /**
  31650. * Updates a vertex of a particle : it can be overwritten by the user.
  31651. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31652. * @param particle the current particle
  31653. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31654. * @param pt the index of the current vertex in the particle shape
  31655. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31656. * @example : just set a vertex particle position or color
  31657. * @returns the sps
  31658. */
  31659. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31660. /**
  31661. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31662. * This does nothing and may be overwritten by the user.
  31663. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31664. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31665. * @param update the boolean update value actually passed to setParticles()
  31666. */
  31667. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31668. /**
  31669. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31670. * This will be passed three parameters.
  31671. * This does nothing and may be overwritten by the user.
  31672. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31673. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31674. * @param update the boolean update value actually passed to setParticles()
  31675. */
  31676. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31677. }
  31678. }
  31679. declare module BABYLON {
  31680. /**
  31681. * Represents one particle of a solid particle system.
  31682. */
  31683. export class SolidParticle {
  31684. /**
  31685. * particle global index
  31686. */
  31687. idx: number;
  31688. /**
  31689. * particle identifier
  31690. */
  31691. id: number;
  31692. /**
  31693. * The color of the particle
  31694. */
  31695. color: Nullable<Color4>;
  31696. /**
  31697. * The world space position of the particle.
  31698. */
  31699. position: Vector3;
  31700. /**
  31701. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31702. */
  31703. rotation: Vector3;
  31704. /**
  31705. * The world space rotation quaternion of the particle.
  31706. */
  31707. rotationQuaternion: Nullable<Quaternion>;
  31708. /**
  31709. * The scaling of the particle.
  31710. */
  31711. scaling: Vector3;
  31712. /**
  31713. * The uvs of the particle.
  31714. */
  31715. uvs: Vector4;
  31716. /**
  31717. * The current speed of the particle.
  31718. */
  31719. velocity: Vector3;
  31720. /**
  31721. * The pivot point in the particle local space.
  31722. */
  31723. pivot: Vector3;
  31724. /**
  31725. * Must the particle be translated from its pivot point in its local space ?
  31726. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31727. * Default : false
  31728. */
  31729. translateFromPivot: boolean;
  31730. /**
  31731. * Is the particle active or not ?
  31732. */
  31733. alive: boolean;
  31734. /**
  31735. * Is the particle visible or not ?
  31736. */
  31737. isVisible: boolean;
  31738. /**
  31739. * Index of this particle in the global "positions" array (Internal use)
  31740. * @hidden
  31741. */
  31742. _pos: number;
  31743. /**
  31744. * @hidden Index of this particle in the global "indices" array (Internal use)
  31745. */
  31746. _ind: number;
  31747. /**
  31748. * @hidden ModelShape of this particle (Internal use)
  31749. */
  31750. _model: ModelShape;
  31751. /**
  31752. * ModelShape id of this particle
  31753. */
  31754. shapeId: number;
  31755. /**
  31756. * Index of the particle in its shape id
  31757. */
  31758. idxInShape: number;
  31759. /**
  31760. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31761. */
  31762. _modelBoundingInfo: BoundingInfo;
  31763. /**
  31764. * @hidden Particle BoundingInfo object (Internal use)
  31765. */
  31766. _boundingInfo: BoundingInfo;
  31767. /**
  31768. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31769. */
  31770. _sps: SolidParticleSystem;
  31771. /**
  31772. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31773. */
  31774. _stillInvisible: boolean;
  31775. /**
  31776. * @hidden Last computed particle rotation matrix
  31777. */
  31778. _rotationMatrix: number[];
  31779. /**
  31780. * Parent particle Id, if any.
  31781. * Default null.
  31782. */
  31783. parentId: Nullable<number>;
  31784. /**
  31785. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31786. */
  31787. materialIndex: Nullable<number>;
  31788. /**
  31789. * Custom object or properties.
  31790. */
  31791. props: Nullable<any>;
  31792. /**
  31793. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31794. * The possible values are :
  31795. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31796. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31797. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31798. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31799. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31800. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31801. * */
  31802. cullingStrategy: number;
  31803. /**
  31804. * @hidden Internal global position in the SPS.
  31805. */
  31806. _globalPosition: Vector3;
  31807. /**
  31808. * Creates a Solid Particle object.
  31809. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31810. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31811. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31812. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31813. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31814. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31815. * @param shapeId (integer) is the model shape identifier in the SPS.
  31816. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31817. * @param sps defines the sps it is associated to
  31818. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31819. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31820. */
  31821. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31822. /**
  31823. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31824. * @param target the particle target
  31825. * @returns the current particle
  31826. */
  31827. copyToRef(target: SolidParticle): SolidParticle;
  31828. /**
  31829. * Legacy support, changed scale to scaling
  31830. */
  31831. get scale(): Vector3;
  31832. /**
  31833. * Legacy support, changed scale to scaling
  31834. */
  31835. set scale(scale: Vector3);
  31836. /**
  31837. * Legacy support, changed quaternion to rotationQuaternion
  31838. */
  31839. get quaternion(): Nullable<Quaternion>;
  31840. /**
  31841. * Legacy support, changed quaternion to rotationQuaternion
  31842. */
  31843. set quaternion(q: Nullable<Quaternion>);
  31844. /**
  31845. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31846. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31847. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31848. * @returns true if it intersects
  31849. */
  31850. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31851. /**
  31852. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31853. * A particle is in the frustum if its bounding box intersects the frustum
  31854. * @param frustumPlanes defines the frustum to test
  31855. * @returns true if the particle is in the frustum planes
  31856. */
  31857. isInFrustum(frustumPlanes: Plane[]): boolean;
  31858. /**
  31859. * get the rotation matrix of the particle
  31860. * @hidden
  31861. */
  31862. getRotationMatrix(m: Matrix): void;
  31863. }
  31864. /**
  31865. * Represents the shape of the model used by one particle of a solid particle system.
  31866. * SPS internal tool, don't use it manually.
  31867. */
  31868. export class ModelShape {
  31869. /**
  31870. * The shape id
  31871. * @hidden
  31872. */
  31873. shapeID: number;
  31874. /**
  31875. * flat array of model positions (internal use)
  31876. * @hidden
  31877. */
  31878. _shape: Vector3[];
  31879. /**
  31880. * flat array of model UVs (internal use)
  31881. * @hidden
  31882. */
  31883. _shapeUV: number[];
  31884. /**
  31885. * color array of the model
  31886. * @hidden
  31887. */
  31888. _shapeColors: number[];
  31889. /**
  31890. * indices array of the model
  31891. * @hidden
  31892. */
  31893. _indices: number[];
  31894. /**
  31895. * normals array of the model
  31896. * @hidden
  31897. */
  31898. _normals: number[];
  31899. /**
  31900. * length of the shape in the model indices array (internal use)
  31901. * @hidden
  31902. */
  31903. _indicesLength: number;
  31904. /**
  31905. * Custom position function (internal use)
  31906. * @hidden
  31907. */
  31908. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31909. /**
  31910. * Custom vertex function (internal use)
  31911. * @hidden
  31912. */
  31913. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31914. /**
  31915. * Model material (internal use)
  31916. * @hidden
  31917. */
  31918. _material: Nullable<Material>;
  31919. /**
  31920. * 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.
  31921. * SPS internal tool, don't use it manually.
  31922. * @hidden
  31923. */
  31924. 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>);
  31925. }
  31926. /**
  31927. * Represents a Depth Sorted Particle in the solid particle system.
  31928. * @hidden
  31929. */
  31930. export class DepthSortedParticle {
  31931. /**
  31932. * Particle index
  31933. */
  31934. idx: number;
  31935. /**
  31936. * Index of the particle in the "indices" array
  31937. */
  31938. ind: number;
  31939. /**
  31940. * Length of the particle shape in the "indices" array
  31941. */
  31942. indicesLength: number;
  31943. /**
  31944. * Squared distance from the particle to the camera
  31945. */
  31946. sqDistance: number;
  31947. /**
  31948. * Material index when used with MultiMaterials
  31949. */
  31950. materialIndex: number;
  31951. /**
  31952. * Creates a new sorted particle
  31953. * @param materialIndex
  31954. */
  31955. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31956. }
  31957. /**
  31958. * Represents a solid particle vertex
  31959. */
  31960. export class SolidParticleVertex {
  31961. /**
  31962. * Vertex position
  31963. */
  31964. position: Vector3;
  31965. /**
  31966. * Vertex color
  31967. */
  31968. color: Color4;
  31969. /**
  31970. * Vertex UV
  31971. */
  31972. uv: Vector2;
  31973. /**
  31974. * Creates a new solid particle vertex
  31975. */
  31976. constructor();
  31977. /** Vertex x coordinate */
  31978. get x(): number;
  31979. set x(val: number);
  31980. /** Vertex y coordinate */
  31981. get y(): number;
  31982. set y(val: number);
  31983. /** Vertex z coordinate */
  31984. get z(): number;
  31985. set z(val: number);
  31986. }
  31987. }
  31988. declare module BABYLON {
  31989. /**
  31990. * @hidden
  31991. */
  31992. export class _MeshCollisionData {
  31993. _checkCollisions: boolean;
  31994. _collisionMask: number;
  31995. _collisionGroup: number;
  31996. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31997. _collider: Nullable<Collider>;
  31998. _oldPositionForCollisions: Vector3;
  31999. _diffPositionForCollisions: Vector3;
  32000. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32001. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32002. _collisionResponse: boolean;
  32003. }
  32004. }
  32005. declare module BABYLON {
  32006. /** @hidden */
  32007. class _FacetDataStorage {
  32008. facetPositions: Vector3[];
  32009. facetNormals: Vector3[];
  32010. facetPartitioning: number[][];
  32011. facetNb: number;
  32012. partitioningSubdivisions: number;
  32013. partitioningBBoxRatio: number;
  32014. facetDataEnabled: boolean;
  32015. facetParameters: any;
  32016. bbSize: Vector3;
  32017. subDiv: {
  32018. max: number;
  32019. X: number;
  32020. Y: number;
  32021. Z: number;
  32022. };
  32023. facetDepthSort: boolean;
  32024. facetDepthSortEnabled: boolean;
  32025. depthSortedIndices: IndicesArray;
  32026. depthSortedFacets: {
  32027. ind: number;
  32028. sqDistance: number;
  32029. }[];
  32030. facetDepthSortFunction: (f1: {
  32031. ind: number;
  32032. sqDistance: number;
  32033. }, f2: {
  32034. ind: number;
  32035. sqDistance: number;
  32036. }) => number;
  32037. facetDepthSortFrom: Vector3;
  32038. facetDepthSortOrigin: Vector3;
  32039. invertedMatrix: Matrix;
  32040. }
  32041. /**
  32042. * @hidden
  32043. **/
  32044. class _InternalAbstractMeshDataInfo {
  32045. _hasVertexAlpha: boolean;
  32046. _useVertexColors: boolean;
  32047. _numBoneInfluencers: number;
  32048. _applyFog: boolean;
  32049. _receiveShadows: boolean;
  32050. _facetData: _FacetDataStorage;
  32051. _visibility: number;
  32052. _skeleton: Nullable<Skeleton>;
  32053. _layerMask: number;
  32054. _computeBonesUsingShaders: boolean;
  32055. _isActive: boolean;
  32056. _onlyForInstances: boolean;
  32057. _isActiveIntermediate: boolean;
  32058. _onlyForInstancesIntermediate: boolean;
  32059. _actAsRegularMesh: boolean;
  32060. }
  32061. /**
  32062. * Class used to store all common mesh properties
  32063. */
  32064. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32065. /** No occlusion */
  32066. static OCCLUSION_TYPE_NONE: number;
  32067. /** Occlusion set to optimisitic */
  32068. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32069. /** Occlusion set to strict */
  32070. static OCCLUSION_TYPE_STRICT: number;
  32071. /** Use an accurante occlusion algorithm */
  32072. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32073. /** Use a conservative occlusion algorithm */
  32074. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32075. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32076. * Test order :
  32077. * Is the bounding sphere outside the frustum ?
  32078. * If not, are the bounding box vertices outside the frustum ?
  32079. * It not, then the cullable object is in the frustum.
  32080. */
  32081. static readonly CULLINGSTRATEGY_STANDARD: number;
  32082. /** Culling strategy : Bounding Sphere Only.
  32083. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32084. * It's also less accurate than the standard because some not visible objects can still be selected.
  32085. * Test : is the bounding sphere outside the frustum ?
  32086. * If not, then the cullable object is in the frustum.
  32087. */
  32088. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32089. /** Culling strategy : Optimistic Inclusion.
  32090. * This in an inclusion test first, then the standard exclusion test.
  32091. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32092. * 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.
  32093. * Anyway, it's as accurate as the standard strategy.
  32094. * Test :
  32095. * Is the cullable object bounding sphere center in the frustum ?
  32096. * If not, apply the default culling strategy.
  32097. */
  32098. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32099. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32100. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32101. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32102. * 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.
  32103. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32104. * Test :
  32105. * Is the cullable object bounding sphere center in the frustum ?
  32106. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32107. */
  32108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32109. /**
  32110. * No billboard
  32111. */
  32112. static get BILLBOARDMODE_NONE(): number;
  32113. /** Billboard on X axis */
  32114. static get BILLBOARDMODE_X(): number;
  32115. /** Billboard on Y axis */
  32116. static get BILLBOARDMODE_Y(): number;
  32117. /** Billboard on Z axis */
  32118. static get BILLBOARDMODE_Z(): number;
  32119. /** Billboard on all axes */
  32120. static get BILLBOARDMODE_ALL(): number;
  32121. /** Billboard on using position instead of orientation */
  32122. static get BILLBOARDMODE_USE_POSITION(): number;
  32123. /** @hidden */
  32124. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32125. /**
  32126. * The culling strategy to use to check whether the mesh must be rendered or not.
  32127. * This value can be changed at any time and will be used on the next render mesh selection.
  32128. * The possible values are :
  32129. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32130. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32131. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32132. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32133. * Please read each static variable documentation to get details about the culling process.
  32134. * */
  32135. cullingStrategy: number;
  32136. /**
  32137. * Gets the number of facets in the mesh
  32138. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32139. */
  32140. get facetNb(): number;
  32141. /**
  32142. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32143. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32144. */
  32145. get partitioningSubdivisions(): number;
  32146. set partitioningSubdivisions(nb: number);
  32147. /**
  32148. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32149. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32150. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32151. */
  32152. get partitioningBBoxRatio(): number;
  32153. set partitioningBBoxRatio(ratio: number);
  32154. /**
  32155. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32156. * Works only for updatable meshes.
  32157. * Doesn't work with multi-materials
  32158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32159. */
  32160. get mustDepthSortFacets(): boolean;
  32161. set mustDepthSortFacets(sort: boolean);
  32162. /**
  32163. * The location (Vector3) where the facet depth sort must be computed from.
  32164. * By default, the active camera position.
  32165. * Used only when facet depth sort is enabled
  32166. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32167. */
  32168. get facetDepthSortFrom(): Vector3;
  32169. set facetDepthSortFrom(location: Vector3);
  32170. /**
  32171. * gets a boolean indicating if facetData is enabled
  32172. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32173. */
  32174. get isFacetDataEnabled(): boolean;
  32175. /** @hidden */
  32176. _updateNonUniformScalingState(value: boolean): boolean;
  32177. /**
  32178. * An event triggered when this mesh collides with another one
  32179. */
  32180. onCollideObservable: Observable<AbstractMesh>;
  32181. /** Set a function to call when this mesh collides with another one */
  32182. set onCollide(callback: () => void);
  32183. /**
  32184. * An event triggered when the collision's position changes
  32185. */
  32186. onCollisionPositionChangeObservable: Observable<Vector3>;
  32187. /** Set a function to call when the collision's position changes */
  32188. set onCollisionPositionChange(callback: () => void);
  32189. /**
  32190. * An event triggered when material is changed
  32191. */
  32192. onMaterialChangedObservable: Observable<AbstractMesh>;
  32193. /**
  32194. * Gets or sets the orientation for POV movement & rotation
  32195. */
  32196. definedFacingForward: boolean;
  32197. /** @hidden */
  32198. _occlusionQuery: Nullable<WebGLQuery>;
  32199. /** @hidden */
  32200. _renderingGroup: Nullable<RenderingGroup>;
  32201. /**
  32202. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32203. */
  32204. get visibility(): number;
  32205. /**
  32206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32207. */
  32208. set visibility(value: number);
  32209. /** Gets or sets the alpha index used to sort transparent meshes
  32210. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32211. */
  32212. alphaIndex: number;
  32213. /**
  32214. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32215. */
  32216. isVisible: boolean;
  32217. /**
  32218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32219. */
  32220. isPickable: boolean;
  32221. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32222. showSubMeshesBoundingBox: boolean;
  32223. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32224. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32225. */
  32226. isBlocker: boolean;
  32227. /**
  32228. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32229. */
  32230. enablePointerMoveEvents: boolean;
  32231. private _renderingGroupId;
  32232. /**
  32233. * Specifies the rendering group id for this mesh (0 by default)
  32234. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32235. */
  32236. get renderingGroupId(): number;
  32237. set renderingGroupId(value: number);
  32238. private _material;
  32239. /** Gets or sets current material */
  32240. get material(): Nullable<Material>;
  32241. set material(value: Nullable<Material>);
  32242. /**
  32243. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32244. * @see https://doc.babylonjs.com/babylon101/shadows
  32245. */
  32246. get receiveShadows(): boolean;
  32247. set receiveShadows(value: boolean);
  32248. /** Defines color to use when rendering outline */
  32249. outlineColor: Color3;
  32250. /** Define width to use when rendering outline */
  32251. outlineWidth: number;
  32252. /** Defines color to use when rendering overlay */
  32253. overlayColor: Color3;
  32254. /** Defines alpha to use when rendering overlay */
  32255. overlayAlpha: number;
  32256. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32257. get hasVertexAlpha(): boolean;
  32258. set hasVertexAlpha(value: boolean);
  32259. /** 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) */
  32260. get useVertexColors(): boolean;
  32261. set useVertexColors(value: boolean);
  32262. /**
  32263. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32264. */
  32265. get computeBonesUsingShaders(): boolean;
  32266. set computeBonesUsingShaders(value: boolean);
  32267. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32268. get numBoneInfluencers(): number;
  32269. set numBoneInfluencers(value: number);
  32270. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32271. get applyFog(): boolean;
  32272. set applyFog(value: boolean);
  32273. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32274. useOctreeForRenderingSelection: boolean;
  32275. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32276. useOctreeForPicking: boolean;
  32277. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32278. useOctreeForCollisions: boolean;
  32279. /**
  32280. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32281. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32282. */
  32283. get layerMask(): number;
  32284. set layerMask(value: number);
  32285. /**
  32286. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32287. */
  32288. alwaysSelectAsActiveMesh: boolean;
  32289. /**
  32290. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32291. */
  32292. doNotSyncBoundingInfo: boolean;
  32293. /**
  32294. * Gets or sets the current action manager
  32295. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32296. */
  32297. actionManager: Nullable<AbstractActionManager>;
  32298. private _meshCollisionData;
  32299. /**
  32300. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32301. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32302. */
  32303. ellipsoid: Vector3;
  32304. /**
  32305. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32306. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32307. */
  32308. ellipsoidOffset: Vector3;
  32309. /**
  32310. * Gets or sets a collision mask used to mask collisions (default is -1).
  32311. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32312. */
  32313. get collisionMask(): number;
  32314. set collisionMask(mask: number);
  32315. /**
  32316. * Gets or sets a collision response flag (default is true).
  32317. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32318. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32319. * to respond to the collision.
  32320. */
  32321. get collisionResponse(): boolean;
  32322. set collisionResponse(response: boolean);
  32323. /**
  32324. * Gets or sets the current collision group mask (-1 by default).
  32325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32326. */
  32327. get collisionGroup(): number;
  32328. set collisionGroup(mask: number);
  32329. /**
  32330. * Gets or sets current surrounding meshes (null by default).
  32331. *
  32332. * By default collision detection is tested against every mesh in the scene.
  32333. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32334. * meshes will be tested for the collision.
  32335. *
  32336. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32337. */
  32338. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32339. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32340. /**
  32341. * Defines edge width used when edgesRenderer is enabled
  32342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32343. */
  32344. edgesWidth: number;
  32345. /**
  32346. * Defines edge color used when edgesRenderer is enabled
  32347. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32348. */
  32349. edgesColor: Color4;
  32350. /** @hidden */
  32351. _edgesRenderer: Nullable<IEdgesRenderer>;
  32352. /** @hidden */
  32353. _masterMesh: Nullable<AbstractMesh>;
  32354. /** @hidden */
  32355. _boundingInfo: Nullable<BoundingInfo>;
  32356. /** @hidden */
  32357. _renderId: number;
  32358. /**
  32359. * Gets or sets the list of subMeshes
  32360. * @see https://doc.babylonjs.com/how_to/multi_materials
  32361. */
  32362. subMeshes: SubMesh[];
  32363. /** @hidden */
  32364. _intersectionsInProgress: AbstractMesh[];
  32365. /** @hidden */
  32366. _unIndexed: boolean;
  32367. /** @hidden */
  32368. _lightSources: Light[];
  32369. /** Gets the list of lights affecting that mesh */
  32370. get lightSources(): Light[];
  32371. /** @hidden */
  32372. get _positions(): Nullable<Vector3[]>;
  32373. /** @hidden */
  32374. _waitingData: {
  32375. lods: Nullable<any>;
  32376. actions: Nullable<any>;
  32377. freezeWorldMatrix: Nullable<boolean>;
  32378. };
  32379. /** @hidden */
  32380. _bonesTransformMatrices: Nullable<Float32Array>;
  32381. /** @hidden */
  32382. _transformMatrixTexture: Nullable<RawTexture>;
  32383. /**
  32384. * Gets or sets a skeleton to apply skining transformations
  32385. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32386. */
  32387. set skeleton(value: Nullable<Skeleton>);
  32388. get skeleton(): Nullable<Skeleton>;
  32389. /**
  32390. * An event triggered when the mesh is rebuilt.
  32391. */
  32392. onRebuildObservable: Observable<AbstractMesh>;
  32393. /**
  32394. * Creates a new AbstractMesh
  32395. * @param name defines the name of the mesh
  32396. * @param scene defines the hosting scene
  32397. */
  32398. constructor(name: string, scene?: Nullable<Scene>);
  32399. /**
  32400. * Returns the string "AbstractMesh"
  32401. * @returns "AbstractMesh"
  32402. */
  32403. getClassName(): string;
  32404. /**
  32405. * Gets a string representation of the current mesh
  32406. * @param fullDetails defines a boolean indicating if full details must be included
  32407. * @returns a string representation of the current mesh
  32408. */
  32409. toString(fullDetails?: boolean): string;
  32410. /**
  32411. * @hidden
  32412. */
  32413. protected _getEffectiveParent(): Nullable<Node>;
  32414. /** @hidden */
  32415. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32416. /** @hidden */
  32417. _rebuild(): void;
  32418. /** @hidden */
  32419. _resyncLightSources(): void;
  32420. /** @hidden */
  32421. _resyncLightSource(light: Light): void;
  32422. /** @hidden */
  32423. _unBindEffect(): void;
  32424. /** @hidden */
  32425. _removeLightSource(light: Light, dispose: boolean): void;
  32426. private _markSubMeshesAsDirty;
  32427. /** @hidden */
  32428. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32429. /** @hidden */
  32430. _markSubMeshesAsAttributesDirty(): void;
  32431. /** @hidden */
  32432. _markSubMeshesAsMiscDirty(): void;
  32433. /**
  32434. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32435. */
  32436. get scaling(): Vector3;
  32437. set scaling(newScaling: Vector3);
  32438. /**
  32439. * Returns true if the mesh is blocked. Implemented by child classes
  32440. */
  32441. get isBlocked(): boolean;
  32442. /**
  32443. * Returns the mesh itself by default. Implemented by child classes
  32444. * @param camera defines the camera to use to pick the right LOD level
  32445. * @returns the currentAbstractMesh
  32446. */
  32447. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32448. /**
  32449. * Returns 0 by default. Implemented by child classes
  32450. * @returns an integer
  32451. */
  32452. getTotalVertices(): number;
  32453. /**
  32454. * Returns a positive integer : the total number of indices in this mesh geometry.
  32455. * @returns the numner of indices or zero if the mesh has no geometry.
  32456. */
  32457. getTotalIndices(): number;
  32458. /**
  32459. * Returns null by default. Implemented by child classes
  32460. * @returns null
  32461. */
  32462. getIndices(): Nullable<IndicesArray>;
  32463. /**
  32464. * Returns the array of the requested vertex data kind. Implemented by child classes
  32465. * @param kind defines the vertex data kind to use
  32466. * @returns null
  32467. */
  32468. getVerticesData(kind: string): Nullable<FloatArray>;
  32469. /**
  32470. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32471. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32472. * Note that a new underlying VertexBuffer object is created each call.
  32473. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32474. * @param kind defines vertex data kind:
  32475. * * VertexBuffer.PositionKind
  32476. * * VertexBuffer.UVKind
  32477. * * VertexBuffer.UV2Kind
  32478. * * VertexBuffer.UV3Kind
  32479. * * VertexBuffer.UV4Kind
  32480. * * VertexBuffer.UV5Kind
  32481. * * VertexBuffer.UV6Kind
  32482. * * VertexBuffer.ColorKind
  32483. * * VertexBuffer.MatricesIndicesKind
  32484. * * VertexBuffer.MatricesIndicesExtraKind
  32485. * * VertexBuffer.MatricesWeightsKind
  32486. * * VertexBuffer.MatricesWeightsExtraKind
  32487. * @param data defines the data source
  32488. * @param updatable defines if the data must be flagged as updatable (or static)
  32489. * @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
  32490. * @returns the current mesh
  32491. */
  32492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32493. /**
  32494. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32495. * If the mesh has no geometry, it is simply returned as it is.
  32496. * @param kind defines vertex data kind:
  32497. * * VertexBuffer.PositionKind
  32498. * * VertexBuffer.UVKind
  32499. * * VertexBuffer.UV2Kind
  32500. * * VertexBuffer.UV3Kind
  32501. * * VertexBuffer.UV4Kind
  32502. * * VertexBuffer.UV5Kind
  32503. * * VertexBuffer.UV6Kind
  32504. * * VertexBuffer.ColorKind
  32505. * * VertexBuffer.MatricesIndicesKind
  32506. * * VertexBuffer.MatricesIndicesExtraKind
  32507. * * VertexBuffer.MatricesWeightsKind
  32508. * * VertexBuffer.MatricesWeightsExtraKind
  32509. * @param data defines the data source
  32510. * @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
  32511. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32512. * @returns the current mesh
  32513. */
  32514. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32515. /**
  32516. * Sets the mesh indices,
  32517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32518. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32519. * @param totalVertices Defines the total number of vertices
  32520. * @returns the current mesh
  32521. */
  32522. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32523. /**
  32524. * Gets a boolean indicating if specific vertex data is present
  32525. * @param kind defines the vertex data kind to use
  32526. * @returns true is data kind is present
  32527. */
  32528. isVerticesDataPresent(kind: string): boolean;
  32529. /**
  32530. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32531. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32532. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32533. * @returns a BoundingInfo
  32534. */
  32535. getBoundingInfo(): BoundingInfo;
  32536. /**
  32537. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32538. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32539. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32540. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32541. * @returns the current mesh
  32542. */
  32543. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32544. /**
  32545. * Overwrite the current bounding info
  32546. * @param boundingInfo defines the new bounding info
  32547. * @returns the current mesh
  32548. */
  32549. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32550. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32551. get useBones(): boolean;
  32552. /** @hidden */
  32553. _preActivate(): void;
  32554. /** @hidden */
  32555. _preActivateForIntermediateRendering(renderId: number): void;
  32556. /** @hidden */
  32557. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32558. /** @hidden */
  32559. _postActivate(): void;
  32560. /** @hidden */
  32561. _freeze(): void;
  32562. /** @hidden */
  32563. _unFreeze(): void;
  32564. /**
  32565. * Gets the current world matrix
  32566. * @returns a Matrix
  32567. */
  32568. getWorldMatrix(): Matrix;
  32569. /** @hidden */
  32570. _getWorldMatrixDeterminant(): number;
  32571. /**
  32572. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32573. */
  32574. get isAnInstance(): boolean;
  32575. /**
  32576. * Gets a boolean indicating if this mesh has instances
  32577. */
  32578. get hasInstances(): boolean;
  32579. /**
  32580. * Gets a boolean indicating if this mesh has thin instances
  32581. */
  32582. get hasThinInstances(): boolean;
  32583. /**
  32584. * Perform relative position change from the point of view of behind the front of the mesh.
  32585. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32586. * Supports definition of mesh facing forward or backward
  32587. * @param amountRight defines the distance on the right axis
  32588. * @param amountUp defines the distance on the up axis
  32589. * @param amountForward defines the distance on the forward axis
  32590. * @returns the current mesh
  32591. */
  32592. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32593. /**
  32594. * Calculate relative position change from the point of view of behind the front of the mesh.
  32595. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32596. * Supports definition of mesh facing forward or backward
  32597. * @param amountRight defines the distance on the right axis
  32598. * @param amountUp defines the distance on the up axis
  32599. * @param amountForward defines the distance on the forward axis
  32600. * @returns the new displacement vector
  32601. */
  32602. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32603. /**
  32604. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32605. * Supports definition of mesh facing forward or backward
  32606. * @param flipBack defines the flip
  32607. * @param twirlClockwise defines the twirl
  32608. * @param tiltRight defines the tilt
  32609. * @returns the current mesh
  32610. */
  32611. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32612. /**
  32613. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32614. * Supports definition of mesh facing forward or backward.
  32615. * @param flipBack defines the flip
  32616. * @param twirlClockwise defines the twirl
  32617. * @param tiltRight defines the tilt
  32618. * @returns the new rotation vector
  32619. */
  32620. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32621. /**
  32622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32623. * This means the mesh underlying bounding box and sphere are recomputed.
  32624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32625. * @returns the current mesh
  32626. */
  32627. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32628. /** @hidden */
  32629. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32630. /** @hidden */
  32631. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32632. /** @hidden */
  32633. _updateBoundingInfo(): AbstractMesh;
  32634. /** @hidden */
  32635. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32636. /** @hidden */
  32637. protected _afterComputeWorldMatrix(): void;
  32638. /** @hidden */
  32639. get _effectiveMesh(): AbstractMesh;
  32640. /**
  32641. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32642. * A mesh is in the frustum if its bounding box intersects the frustum
  32643. * @param frustumPlanes defines the frustum to test
  32644. * @returns true if the mesh is in the frustum planes
  32645. */
  32646. isInFrustum(frustumPlanes: Plane[]): boolean;
  32647. /**
  32648. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32649. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32650. * @param frustumPlanes defines the frustum to test
  32651. * @returns true if the mesh is completely in the frustum planes
  32652. */
  32653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32654. /**
  32655. * True if the mesh intersects another mesh or a SolidParticle object
  32656. * @param mesh defines a target mesh or SolidParticle to test
  32657. * @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)
  32658. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32659. * @returns true if there is an intersection
  32660. */
  32661. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32662. /**
  32663. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32664. * @param point defines the point to test
  32665. * @returns true if there is an intersection
  32666. */
  32667. intersectsPoint(point: Vector3): boolean;
  32668. /**
  32669. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32670. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32671. */
  32672. get checkCollisions(): boolean;
  32673. set checkCollisions(collisionEnabled: boolean);
  32674. /**
  32675. * Gets Collider object used to compute collisions (not physics)
  32676. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32677. */
  32678. get collider(): Nullable<Collider>;
  32679. /**
  32680. * Move the mesh using collision engine
  32681. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32682. * @param displacement defines the requested displacement vector
  32683. * @returns the current mesh
  32684. */
  32685. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32686. private _onCollisionPositionChange;
  32687. /** @hidden */
  32688. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32689. /** @hidden */
  32690. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32691. /** @hidden */
  32692. _checkCollision(collider: Collider): AbstractMesh;
  32693. /** @hidden */
  32694. _generatePointsArray(): boolean;
  32695. /**
  32696. * Checks if the passed Ray intersects with the mesh
  32697. * @param ray defines the ray to use
  32698. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32699. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32700. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32701. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32702. * @returns the picking info
  32703. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32704. */
  32705. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32706. /**
  32707. * Clones the current mesh
  32708. * @param name defines the mesh name
  32709. * @param newParent defines the new mesh parent
  32710. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32711. * @returns the new mesh
  32712. */
  32713. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32714. /**
  32715. * Disposes all the submeshes of the current meshnp
  32716. * @returns the current mesh
  32717. */
  32718. releaseSubMeshes(): AbstractMesh;
  32719. /**
  32720. * Releases resources associated with this abstract mesh.
  32721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32723. */
  32724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32725. /**
  32726. * Adds the passed mesh as a child to the current mesh
  32727. * @param mesh defines the child mesh
  32728. * @returns the current mesh
  32729. */
  32730. addChild(mesh: AbstractMesh): AbstractMesh;
  32731. /**
  32732. * Removes the passed mesh from the current mesh children list
  32733. * @param mesh defines the child mesh
  32734. * @returns the current mesh
  32735. */
  32736. removeChild(mesh: AbstractMesh): AbstractMesh;
  32737. /** @hidden */
  32738. private _initFacetData;
  32739. /**
  32740. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32741. * This method can be called within the render loop.
  32742. * 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
  32743. * @returns the current mesh
  32744. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32745. */
  32746. updateFacetData(): AbstractMesh;
  32747. /**
  32748. * Returns the facetLocalNormals array.
  32749. * The normals are expressed in the mesh local spac
  32750. * @returns an array of Vector3
  32751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32752. */
  32753. getFacetLocalNormals(): Vector3[];
  32754. /**
  32755. * Returns the facetLocalPositions array.
  32756. * The facet positions are expressed in the mesh local space
  32757. * @returns an array of Vector3
  32758. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32759. */
  32760. getFacetLocalPositions(): Vector3[];
  32761. /**
  32762. * Returns the facetLocalPartioning array
  32763. * @returns an array of array of numbers
  32764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32765. */
  32766. getFacetLocalPartitioning(): number[][];
  32767. /**
  32768. * Returns the i-th facet position in the world system.
  32769. * This method allocates a new Vector3 per call
  32770. * @param i defines the facet index
  32771. * @returns a new Vector3
  32772. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32773. */
  32774. getFacetPosition(i: number): Vector3;
  32775. /**
  32776. * Sets the reference Vector3 with the i-th facet position in the world system
  32777. * @param i defines the facet index
  32778. * @param ref defines the target vector
  32779. * @returns the current mesh
  32780. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32781. */
  32782. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32783. /**
  32784. * Returns the i-th facet normal in the world system.
  32785. * This method allocates a new Vector3 per call
  32786. * @param i defines the facet index
  32787. * @returns a new Vector3
  32788. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32789. */
  32790. getFacetNormal(i: number): Vector3;
  32791. /**
  32792. * Sets the reference Vector3 with the i-th facet normal in the world system
  32793. * @param i defines the facet index
  32794. * @param ref defines the target vector
  32795. * @returns the current mesh
  32796. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32797. */
  32798. getFacetNormalToRef(i: number, ref: Vector3): this;
  32799. /**
  32800. * 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)
  32801. * @param x defines x coordinate
  32802. * @param y defines y coordinate
  32803. * @param z defines z coordinate
  32804. * @returns the array of facet indexes
  32805. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32806. */
  32807. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32808. /**
  32809. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32810. * @param projected sets as the (x,y,z) world projection on the facet
  32811. * @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
  32812. * @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
  32813. * @param x defines x coordinate
  32814. * @param y defines y coordinate
  32815. * @param z defines z coordinate
  32816. * @returns the face index if found (or null instead)
  32817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32818. */
  32819. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32820. /**
  32821. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32822. * @param projected sets as the (x,y,z) local projection on the facet
  32823. * @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
  32824. * @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
  32825. * @param x defines x coordinate
  32826. * @param y defines y coordinate
  32827. * @param z defines z coordinate
  32828. * @returns the face index if found (or null instead)
  32829. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32830. */
  32831. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32832. /**
  32833. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32834. * @returns the parameters
  32835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32836. */
  32837. getFacetDataParameters(): any;
  32838. /**
  32839. * Disables the feature FacetData and frees the related memory
  32840. * @returns the current mesh
  32841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32842. */
  32843. disableFacetData(): AbstractMesh;
  32844. /**
  32845. * Updates the AbstractMesh indices array
  32846. * @param indices defines the data source
  32847. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32848. * @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)
  32849. * @returns the current mesh
  32850. */
  32851. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32852. /**
  32853. * Creates new normals data for the mesh
  32854. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32855. * @returns the current mesh
  32856. */
  32857. createNormals(updatable: boolean): AbstractMesh;
  32858. /**
  32859. * Align the mesh with a normal
  32860. * @param normal defines the normal to use
  32861. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32862. * @returns the current mesh
  32863. */
  32864. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32865. /** @hidden */
  32866. _checkOcclusionQuery(): boolean;
  32867. /**
  32868. * Disables the mesh edge rendering mode
  32869. * @returns the currentAbstractMesh
  32870. */
  32871. disableEdgesRendering(): AbstractMesh;
  32872. /**
  32873. * Enables the edge rendering mode on the mesh.
  32874. * This mode makes the mesh edges visible
  32875. * @param epsilon defines the maximal distance between two angles to detect a face
  32876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32877. * @returns the currentAbstractMesh
  32878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32879. */
  32880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32881. /**
  32882. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32883. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32884. */
  32885. getConnectedParticleSystems(): IParticleSystem[];
  32886. }
  32887. }
  32888. declare module BABYLON {
  32889. /**
  32890. * Interface used to define ActionEvent
  32891. */
  32892. export interface IActionEvent {
  32893. /** The mesh or sprite that triggered the action */
  32894. source: any;
  32895. /** The X mouse cursor position at the time of the event */
  32896. pointerX: number;
  32897. /** The Y mouse cursor position at the time of the event */
  32898. pointerY: number;
  32899. /** The mesh that is currently pointed at (can be null) */
  32900. meshUnderPointer: Nullable<AbstractMesh>;
  32901. /** the original (browser) event that triggered the ActionEvent */
  32902. sourceEvent?: any;
  32903. /** additional data for the event */
  32904. additionalData?: any;
  32905. }
  32906. /**
  32907. * ActionEvent is the event being sent when an action is triggered.
  32908. */
  32909. export class ActionEvent implements IActionEvent {
  32910. /** The mesh or sprite that triggered the action */
  32911. source: any;
  32912. /** The X mouse cursor position at the time of the event */
  32913. pointerX: number;
  32914. /** The Y mouse cursor position at the time of the event */
  32915. pointerY: number;
  32916. /** The mesh that is currently pointed at (can be null) */
  32917. meshUnderPointer: Nullable<AbstractMesh>;
  32918. /** the original (browser) event that triggered the ActionEvent */
  32919. sourceEvent?: any;
  32920. /** additional data for the event */
  32921. additionalData?: any;
  32922. /**
  32923. * Creates a new ActionEvent
  32924. * @param source The mesh or sprite that triggered the action
  32925. * @param pointerX The X mouse cursor position at the time of the event
  32926. * @param pointerY The Y mouse cursor position at the time of the event
  32927. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32928. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32929. * @param additionalData additional data for the event
  32930. */
  32931. constructor(
  32932. /** The mesh or sprite that triggered the action */
  32933. source: any,
  32934. /** The X mouse cursor position at the time of the event */
  32935. pointerX: number,
  32936. /** The Y mouse cursor position at the time of the event */
  32937. pointerY: number,
  32938. /** The mesh that is currently pointed at (can be null) */
  32939. meshUnderPointer: Nullable<AbstractMesh>,
  32940. /** the original (browser) event that triggered the ActionEvent */
  32941. sourceEvent?: any,
  32942. /** additional data for the event */
  32943. additionalData?: any);
  32944. /**
  32945. * Helper function to auto-create an ActionEvent from a source mesh.
  32946. * @param source The source mesh that triggered the event
  32947. * @param evt The original (browser) event
  32948. * @param additionalData additional data for the event
  32949. * @returns the new ActionEvent
  32950. */
  32951. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32952. /**
  32953. * Helper function to auto-create an ActionEvent from a source sprite
  32954. * @param source The source sprite that triggered the event
  32955. * @param scene Scene associated with the sprite
  32956. * @param evt The original (browser) event
  32957. * @param additionalData additional data for the event
  32958. * @returns the new ActionEvent
  32959. */
  32960. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32961. /**
  32962. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32963. * @param scene the scene where the event occurred
  32964. * @param evt The original (browser) event
  32965. * @returns the new ActionEvent
  32966. */
  32967. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32968. /**
  32969. * Helper function to auto-create an ActionEvent from a primitive
  32970. * @param prim defines the target primitive
  32971. * @param pointerPos defines the pointer position
  32972. * @param evt The original (browser) event
  32973. * @param additionalData additional data for the event
  32974. * @returns the new ActionEvent
  32975. */
  32976. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32977. }
  32978. }
  32979. declare module BABYLON {
  32980. /**
  32981. * Abstract class used to decouple action Manager from scene and meshes.
  32982. * Do not instantiate.
  32983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32984. */
  32985. export abstract class AbstractActionManager implements IDisposable {
  32986. /** Gets the list of active triggers */
  32987. static Triggers: {
  32988. [key: string]: number;
  32989. };
  32990. /** Gets the cursor to use when hovering items */
  32991. hoverCursor: string;
  32992. /** Gets the list of actions */
  32993. actions: IAction[];
  32994. /**
  32995. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32996. */
  32997. isRecursive: boolean;
  32998. /**
  32999. * Releases all associated resources
  33000. */
  33001. abstract dispose(): void;
  33002. /**
  33003. * Does this action manager has pointer triggers
  33004. */
  33005. abstract get hasPointerTriggers(): boolean;
  33006. /**
  33007. * Does this action manager has pick triggers
  33008. */
  33009. abstract get hasPickTriggers(): boolean;
  33010. /**
  33011. * Process a specific trigger
  33012. * @param trigger defines the trigger to process
  33013. * @param evt defines the event details to be processed
  33014. */
  33015. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33016. /**
  33017. * Does this action manager handles actions of any of the given triggers
  33018. * @param triggers defines the triggers to be tested
  33019. * @return a boolean indicating whether one (or more) of the triggers is handled
  33020. */
  33021. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33022. /**
  33023. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33024. * speed.
  33025. * @param triggerA defines the trigger to be tested
  33026. * @param triggerB defines the trigger to be tested
  33027. * @return a boolean indicating whether one (or more) of the triggers is handled
  33028. */
  33029. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33030. /**
  33031. * Does this action manager handles actions of a given trigger
  33032. * @param trigger defines the trigger to be tested
  33033. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33034. * @return whether the trigger is handled
  33035. */
  33036. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33037. /**
  33038. * Serialize this manager to a JSON object
  33039. * @param name defines the property name to store this manager
  33040. * @returns a JSON representation of this manager
  33041. */
  33042. abstract serialize(name: string): any;
  33043. /**
  33044. * Registers an action to this action manager
  33045. * @param action defines the action to be registered
  33046. * @return the action amended (prepared) after registration
  33047. */
  33048. abstract registerAction(action: IAction): Nullable<IAction>;
  33049. /**
  33050. * Unregisters an action to this action manager
  33051. * @param action defines the action to be unregistered
  33052. * @return a boolean indicating whether the action has been unregistered
  33053. */
  33054. abstract unregisterAction(action: IAction): Boolean;
  33055. /**
  33056. * Does exist one action manager with at least one trigger
  33057. **/
  33058. static get HasTriggers(): boolean;
  33059. /**
  33060. * Does exist one action manager with at least one pick trigger
  33061. **/
  33062. static get HasPickTriggers(): boolean;
  33063. /**
  33064. * Does exist one action manager that handles actions of a given trigger
  33065. * @param trigger defines the trigger to be tested
  33066. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33067. **/
  33068. static HasSpecificTrigger(trigger: number): boolean;
  33069. }
  33070. }
  33071. declare module BABYLON {
  33072. /**
  33073. * Defines how a node can be built from a string name.
  33074. */
  33075. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33076. /**
  33077. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33078. */
  33079. export class Node implements IBehaviorAware<Node> {
  33080. /** @hidden */
  33081. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33082. private static _NodeConstructors;
  33083. /**
  33084. * Add a new node constructor
  33085. * @param type defines the type name of the node to construct
  33086. * @param constructorFunc defines the constructor function
  33087. */
  33088. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33089. /**
  33090. * Returns a node constructor based on type name
  33091. * @param type defines the type name
  33092. * @param name defines the new node name
  33093. * @param scene defines the hosting scene
  33094. * @param options defines optional options to transmit to constructors
  33095. * @returns the new constructor or null
  33096. */
  33097. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33098. /**
  33099. * Gets or sets the name of the node
  33100. */
  33101. name: string;
  33102. /**
  33103. * Gets or sets the id of the node
  33104. */
  33105. id: string;
  33106. /**
  33107. * Gets or sets the unique id of the node
  33108. */
  33109. uniqueId: number;
  33110. /**
  33111. * Gets or sets a string used to store user defined state for the node
  33112. */
  33113. state: string;
  33114. /**
  33115. * Gets or sets an object used to store user defined information for the node
  33116. */
  33117. metadata: any;
  33118. /**
  33119. * For internal use only. Please do not use.
  33120. */
  33121. reservedDataStore: any;
  33122. /**
  33123. * List of inspectable custom properties (used by the Inspector)
  33124. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33125. */
  33126. inspectableCustomProperties: IInspectable[];
  33127. private _doNotSerialize;
  33128. /**
  33129. * Gets or sets a boolean used to define if the node must be serialized
  33130. */
  33131. get doNotSerialize(): boolean;
  33132. set doNotSerialize(value: boolean);
  33133. /** @hidden */
  33134. _isDisposed: boolean;
  33135. /**
  33136. * Gets a list of Animations associated with the node
  33137. */
  33138. animations: Animation[];
  33139. protected _ranges: {
  33140. [name: string]: Nullable<AnimationRange>;
  33141. };
  33142. /**
  33143. * Callback raised when the node is ready to be used
  33144. */
  33145. onReady: Nullable<(node: Node) => void>;
  33146. private _isEnabled;
  33147. private _isParentEnabled;
  33148. private _isReady;
  33149. /** @hidden */
  33150. _currentRenderId: number;
  33151. private _parentUpdateId;
  33152. /** @hidden */
  33153. _childUpdateId: number;
  33154. /** @hidden */
  33155. _waitingParentId: Nullable<string>;
  33156. /** @hidden */
  33157. _scene: Scene;
  33158. /** @hidden */
  33159. _cache: any;
  33160. private _parentNode;
  33161. private _children;
  33162. /** @hidden */
  33163. _worldMatrix: Matrix;
  33164. /** @hidden */
  33165. _worldMatrixDeterminant: number;
  33166. /** @hidden */
  33167. _worldMatrixDeterminantIsDirty: boolean;
  33168. /** @hidden */
  33169. private _sceneRootNodesIndex;
  33170. /**
  33171. * Gets a boolean indicating if the node has been disposed
  33172. * @returns true if the node was disposed
  33173. */
  33174. isDisposed(): boolean;
  33175. /**
  33176. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33177. * @see https://doc.babylonjs.com/how_to/parenting
  33178. */
  33179. set parent(parent: Nullable<Node>);
  33180. get parent(): Nullable<Node>;
  33181. /** @hidden */
  33182. _addToSceneRootNodes(): void;
  33183. /** @hidden */
  33184. _removeFromSceneRootNodes(): void;
  33185. private _animationPropertiesOverride;
  33186. /**
  33187. * Gets or sets the animation properties override
  33188. */
  33189. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33190. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33191. /**
  33192. * Gets a string identifying the name of the class
  33193. * @returns "Node" string
  33194. */
  33195. getClassName(): string;
  33196. /** @hidden */
  33197. readonly _isNode: boolean;
  33198. /**
  33199. * An event triggered when the mesh is disposed
  33200. */
  33201. onDisposeObservable: Observable<Node>;
  33202. private _onDisposeObserver;
  33203. /**
  33204. * Sets a callback that will be raised when the node will be disposed
  33205. */
  33206. set onDispose(callback: () => void);
  33207. /**
  33208. * Creates a new Node
  33209. * @param name the name and id to be given to this node
  33210. * @param scene the scene this node will be added to
  33211. */
  33212. constructor(name: string, scene?: Nullable<Scene>);
  33213. /**
  33214. * Gets the scene of the node
  33215. * @returns a scene
  33216. */
  33217. getScene(): Scene;
  33218. /**
  33219. * Gets the engine of the node
  33220. * @returns a Engine
  33221. */
  33222. getEngine(): Engine;
  33223. private _behaviors;
  33224. /**
  33225. * Attach a behavior to the node
  33226. * @see https://doc.babylonjs.com/features/behaviour
  33227. * @param behavior defines the behavior to attach
  33228. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33229. * @returns the current Node
  33230. */
  33231. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33232. /**
  33233. * Remove an attached behavior
  33234. * @see https://doc.babylonjs.com/features/behaviour
  33235. * @param behavior defines the behavior to attach
  33236. * @returns the current Node
  33237. */
  33238. removeBehavior(behavior: Behavior<Node>): Node;
  33239. /**
  33240. * Gets the list of attached behaviors
  33241. * @see https://doc.babylonjs.com/features/behaviour
  33242. */
  33243. get behaviors(): Behavior<Node>[];
  33244. /**
  33245. * Gets an attached behavior by name
  33246. * @param name defines the name of the behavior to look for
  33247. * @see https://doc.babylonjs.com/features/behaviour
  33248. * @returns null if behavior was not found else the requested behavior
  33249. */
  33250. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33251. /**
  33252. * Returns the latest update of the World matrix
  33253. * @returns a Matrix
  33254. */
  33255. getWorldMatrix(): Matrix;
  33256. /** @hidden */
  33257. _getWorldMatrixDeterminant(): number;
  33258. /**
  33259. * Returns directly the latest state of the mesh World matrix.
  33260. * A Matrix is returned.
  33261. */
  33262. get worldMatrixFromCache(): Matrix;
  33263. /** @hidden */
  33264. _initCache(): void;
  33265. /** @hidden */
  33266. updateCache(force?: boolean): void;
  33267. /** @hidden */
  33268. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33269. /** @hidden */
  33270. _updateCache(ignoreParentClass?: boolean): void;
  33271. /** @hidden */
  33272. _isSynchronized(): boolean;
  33273. /** @hidden */
  33274. _markSyncedWithParent(): void;
  33275. /** @hidden */
  33276. isSynchronizedWithParent(): boolean;
  33277. /** @hidden */
  33278. isSynchronized(): boolean;
  33279. /**
  33280. * Is this node ready to be used/rendered
  33281. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33282. * @return true if the node is ready
  33283. */
  33284. isReady(completeCheck?: boolean): boolean;
  33285. /**
  33286. * Is this node enabled?
  33287. * 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
  33288. * @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
  33289. * @return whether this node (and its parent) is enabled
  33290. */
  33291. isEnabled(checkAncestors?: boolean): boolean;
  33292. /** @hidden */
  33293. protected _syncParentEnabledState(): void;
  33294. /**
  33295. * Set the enabled state of this node
  33296. * @param value defines the new enabled state
  33297. */
  33298. setEnabled(value: boolean): void;
  33299. /**
  33300. * Is this node a descendant of the given node?
  33301. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33302. * @param ancestor defines the parent node to inspect
  33303. * @returns a boolean indicating if this node is a descendant of the given node
  33304. */
  33305. isDescendantOf(ancestor: Node): boolean;
  33306. /** @hidden */
  33307. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33308. /**
  33309. * Will return all nodes that have this node as ascendant
  33310. * @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
  33311. * @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
  33312. * @return all children nodes of all types
  33313. */
  33314. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33315. /**
  33316. * Get all child-meshes of this node
  33317. * @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)
  33318. * @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
  33319. * @returns an array of AbstractMesh
  33320. */
  33321. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33322. /**
  33323. * Get all direct children of this node
  33324. * @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
  33325. * @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)
  33326. * @returns an array of Node
  33327. */
  33328. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33329. /** @hidden */
  33330. _setReady(state: boolean): void;
  33331. /**
  33332. * Get an animation by name
  33333. * @param name defines the name of the animation to look for
  33334. * @returns null if not found else the requested animation
  33335. */
  33336. getAnimationByName(name: string): Nullable<Animation>;
  33337. /**
  33338. * Creates an animation range for this node
  33339. * @param name defines the name of the range
  33340. * @param from defines the starting key
  33341. * @param to defines the end key
  33342. */
  33343. createAnimationRange(name: string, from: number, to: number): void;
  33344. /**
  33345. * Delete a specific animation range
  33346. * @param name defines the name of the range to delete
  33347. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33348. */
  33349. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33350. /**
  33351. * Get an animation range by name
  33352. * @param name defines the name of the animation range to look for
  33353. * @returns null if not found else the requested animation range
  33354. */
  33355. getAnimationRange(name: string): Nullable<AnimationRange>;
  33356. /**
  33357. * Gets the list of all animation ranges defined on this node
  33358. * @returns an array
  33359. */
  33360. getAnimationRanges(): Nullable<AnimationRange>[];
  33361. /**
  33362. * Will start the animation sequence
  33363. * @param name defines the range frames for animation sequence
  33364. * @param loop defines if the animation should loop (false by default)
  33365. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33366. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33367. * @returns the object created for this animation. If range does not exist, it will return null
  33368. */
  33369. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33370. /**
  33371. * Serialize animation ranges into a JSON compatible object
  33372. * @returns serialization object
  33373. */
  33374. serializeAnimationRanges(): any;
  33375. /**
  33376. * Computes the world matrix of the node
  33377. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33378. * @returns the world matrix
  33379. */
  33380. computeWorldMatrix(force?: boolean): Matrix;
  33381. /**
  33382. * Releases resources associated with this node.
  33383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33385. */
  33386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33387. /**
  33388. * Parse animation range data from a serialization object and store them into a given node
  33389. * @param node defines where to store the animation ranges
  33390. * @param parsedNode defines the serialization object to read data from
  33391. * @param scene defines the hosting scene
  33392. */
  33393. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33394. /**
  33395. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33396. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33397. * @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
  33398. * @returns the new bounding vectors
  33399. */
  33400. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33401. min: Vector3;
  33402. max: Vector3;
  33403. };
  33404. }
  33405. }
  33406. declare module BABYLON {
  33407. /**
  33408. * @hidden
  33409. */
  33410. export class _IAnimationState {
  33411. key: number;
  33412. repeatCount: number;
  33413. workValue?: any;
  33414. loopMode?: number;
  33415. offsetValue?: any;
  33416. highLimitValue?: any;
  33417. }
  33418. /**
  33419. * Class used to store any kind of animation
  33420. */
  33421. export class Animation {
  33422. /**Name of the animation */
  33423. name: string;
  33424. /**Property to animate */
  33425. targetProperty: string;
  33426. /**The frames per second of the animation */
  33427. framePerSecond: number;
  33428. /**The data type of the animation */
  33429. dataType: number;
  33430. /**The loop mode of the animation */
  33431. loopMode?: number | undefined;
  33432. /**Specifies if blending should be enabled */
  33433. enableBlending?: boolean | undefined;
  33434. /**
  33435. * Use matrix interpolation instead of using direct key value when animating matrices
  33436. */
  33437. static AllowMatricesInterpolation: boolean;
  33438. /**
  33439. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33440. */
  33441. static AllowMatrixDecomposeForInterpolation: boolean;
  33442. /** Define the Url to load snippets */
  33443. static SnippetUrl: string;
  33444. /** Snippet ID if the animation was created from the snippet server */
  33445. snippetId: string;
  33446. /**
  33447. * Stores the key frames of the animation
  33448. */
  33449. private _keys;
  33450. /**
  33451. * Stores the easing function of the animation
  33452. */
  33453. private _easingFunction;
  33454. /**
  33455. * @hidden Internal use only
  33456. */
  33457. _runtimeAnimations: RuntimeAnimation[];
  33458. /**
  33459. * The set of event that will be linked to this animation
  33460. */
  33461. private _events;
  33462. /**
  33463. * Stores an array of target property paths
  33464. */
  33465. targetPropertyPath: string[];
  33466. /**
  33467. * Stores the blending speed of the animation
  33468. */
  33469. blendingSpeed: number;
  33470. /**
  33471. * Stores the animation ranges for the animation
  33472. */
  33473. private _ranges;
  33474. /**
  33475. * @hidden Internal use
  33476. */
  33477. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33478. /**
  33479. * Sets up an animation
  33480. * @param property The property to animate
  33481. * @param animationType The animation type to apply
  33482. * @param framePerSecond The frames per second of the animation
  33483. * @param easingFunction The easing function used in the animation
  33484. * @returns The created animation
  33485. */
  33486. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33487. /**
  33488. * Create and start an animation on a node
  33489. * @param name defines the name of the global animation that will be run on all nodes
  33490. * @param node defines the root node where the animation will take place
  33491. * @param targetProperty defines property to animate
  33492. * @param framePerSecond defines the number of frame per second yo use
  33493. * @param totalFrame defines the number of frames in total
  33494. * @param from defines the initial value
  33495. * @param to defines the final value
  33496. * @param loopMode defines which loop mode you want to use (off by default)
  33497. * @param easingFunction defines the easing function to use (linear by default)
  33498. * @param onAnimationEnd defines the callback to call when animation end
  33499. * @returns the animatable created for this animation
  33500. */
  33501. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33502. /**
  33503. * Create and start an animation on a node and its descendants
  33504. * @param name defines the name of the global animation that will be run on all nodes
  33505. * @param node defines the root node where the animation will take place
  33506. * @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
  33507. * @param targetProperty defines property to animate
  33508. * @param framePerSecond defines the number of frame per second to use
  33509. * @param totalFrame defines the number of frames in total
  33510. * @param from defines the initial value
  33511. * @param to defines the final value
  33512. * @param loopMode defines which loop mode you want to use (off by default)
  33513. * @param easingFunction defines the easing function to use (linear by default)
  33514. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33515. * @returns the list of animatables created for all nodes
  33516. * @example https://www.babylonjs-playground.com/#MH0VLI
  33517. */
  33518. 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[]>;
  33519. /**
  33520. * Creates a new animation, merges it with the existing animations and starts it
  33521. * @param name Name of the animation
  33522. * @param node Node which contains the scene that begins the animations
  33523. * @param targetProperty Specifies which property to animate
  33524. * @param framePerSecond The frames per second of the animation
  33525. * @param totalFrame The total number of frames
  33526. * @param from The frame at the beginning of the animation
  33527. * @param to The frame at the end of the animation
  33528. * @param loopMode Specifies the loop mode of the animation
  33529. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33530. * @param onAnimationEnd Callback to run once the animation is complete
  33531. * @returns Nullable animation
  33532. */
  33533. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33534. /**
  33535. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33536. * @param sourceAnimation defines the Animation containing keyframes to convert
  33537. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33538. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33539. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33540. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33541. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33542. */
  33543. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33544. /**
  33545. * Transition property of an host to the target Value
  33546. * @param property The property to transition
  33547. * @param targetValue The target Value of the property
  33548. * @param host The object where the property to animate belongs
  33549. * @param scene Scene used to run the animation
  33550. * @param frameRate Framerate (in frame/s) to use
  33551. * @param transition The transition type we want to use
  33552. * @param duration The duration of the animation, in milliseconds
  33553. * @param onAnimationEnd Callback trigger at the end of the animation
  33554. * @returns Nullable animation
  33555. */
  33556. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33557. /**
  33558. * Return the array of runtime animations currently using this animation
  33559. */
  33560. get runtimeAnimations(): RuntimeAnimation[];
  33561. /**
  33562. * Specifies if any of the runtime animations are currently running
  33563. */
  33564. get hasRunningRuntimeAnimations(): boolean;
  33565. /**
  33566. * Initializes the animation
  33567. * @param name Name of the animation
  33568. * @param targetProperty Property to animate
  33569. * @param framePerSecond The frames per second of the animation
  33570. * @param dataType The data type of the animation
  33571. * @param loopMode The loop mode of the animation
  33572. * @param enableBlending Specifies if blending should be enabled
  33573. */
  33574. constructor(
  33575. /**Name of the animation */
  33576. name: string,
  33577. /**Property to animate */
  33578. targetProperty: string,
  33579. /**The frames per second of the animation */
  33580. framePerSecond: number,
  33581. /**The data type of the animation */
  33582. dataType: number,
  33583. /**The loop mode of the animation */
  33584. loopMode?: number | undefined,
  33585. /**Specifies if blending should be enabled */
  33586. enableBlending?: boolean | undefined);
  33587. /**
  33588. * Converts the animation to a string
  33589. * @param fullDetails support for multiple levels of logging within scene loading
  33590. * @returns String form of the animation
  33591. */
  33592. toString(fullDetails?: boolean): string;
  33593. /**
  33594. * Add an event to this animation
  33595. * @param event Event to add
  33596. */
  33597. addEvent(event: AnimationEvent): void;
  33598. /**
  33599. * Remove all events found at the given frame
  33600. * @param frame The frame to remove events from
  33601. */
  33602. removeEvents(frame: number): void;
  33603. /**
  33604. * Retrieves all the events from the animation
  33605. * @returns Events from the animation
  33606. */
  33607. getEvents(): AnimationEvent[];
  33608. /**
  33609. * Creates an animation range
  33610. * @param name Name of the animation range
  33611. * @param from Starting frame of the animation range
  33612. * @param to Ending frame of the animation
  33613. */
  33614. createRange(name: string, from: number, to: number): void;
  33615. /**
  33616. * Deletes an animation range by name
  33617. * @param name Name of the animation range to delete
  33618. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33619. */
  33620. deleteRange(name: string, deleteFrames?: boolean): void;
  33621. /**
  33622. * Gets the animation range by name, or null if not defined
  33623. * @param name Name of the animation range
  33624. * @returns Nullable animation range
  33625. */
  33626. getRange(name: string): Nullable<AnimationRange>;
  33627. /**
  33628. * Gets the key frames from the animation
  33629. * @returns The key frames of the animation
  33630. */
  33631. getKeys(): Array<IAnimationKey>;
  33632. /**
  33633. * Gets the highest frame rate of the animation
  33634. * @returns Highest frame rate of the animation
  33635. */
  33636. getHighestFrame(): number;
  33637. /**
  33638. * Gets the easing function of the animation
  33639. * @returns Easing function of the animation
  33640. */
  33641. getEasingFunction(): IEasingFunction;
  33642. /**
  33643. * Sets the easing function of the animation
  33644. * @param easingFunction A custom mathematical formula for animation
  33645. */
  33646. setEasingFunction(easingFunction: EasingFunction): void;
  33647. /**
  33648. * Interpolates a scalar linearly
  33649. * @param startValue Start value of the animation curve
  33650. * @param endValue End value of the animation curve
  33651. * @param gradient Scalar amount to interpolate
  33652. * @returns Interpolated scalar value
  33653. */
  33654. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33655. /**
  33656. * Interpolates a scalar cubically
  33657. * @param startValue Start value of the animation curve
  33658. * @param outTangent End tangent of the animation
  33659. * @param endValue End value of the animation curve
  33660. * @param inTangent Start tangent of the animation curve
  33661. * @param gradient Scalar amount to interpolate
  33662. * @returns Interpolated scalar value
  33663. */
  33664. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33665. /**
  33666. * Interpolates a quaternion using a spherical linear interpolation
  33667. * @param startValue Start value of the animation curve
  33668. * @param endValue End value of the animation curve
  33669. * @param gradient Scalar amount to interpolate
  33670. * @returns Interpolated quaternion value
  33671. */
  33672. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33673. /**
  33674. * Interpolates a quaternion cubically
  33675. * @param startValue Start value of the animation curve
  33676. * @param outTangent End tangent of the animation curve
  33677. * @param endValue End value of the animation curve
  33678. * @param inTangent Start tangent of the animation curve
  33679. * @param gradient Scalar amount to interpolate
  33680. * @returns Interpolated quaternion value
  33681. */
  33682. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33683. /**
  33684. * Interpolates a Vector3 linearl
  33685. * @param startValue Start value of the animation curve
  33686. * @param endValue End value of the animation curve
  33687. * @param gradient Scalar amount to interpolate
  33688. * @returns Interpolated scalar value
  33689. */
  33690. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33691. /**
  33692. * Interpolates a Vector3 cubically
  33693. * @param startValue Start value of the animation curve
  33694. * @param outTangent End tangent of the animation
  33695. * @param endValue End value of the animation curve
  33696. * @param inTangent Start tangent of the animation curve
  33697. * @param gradient Scalar amount to interpolate
  33698. * @returns InterpolatedVector3 value
  33699. */
  33700. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33701. /**
  33702. * Interpolates a Vector2 linearly
  33703. * @param startValue Start value of the animation curve
  33704. * @param endValue End value of the animation curve
  33705. * @param gradient Scalar amount to interpolate
  33706. * @returns Interpolated Vector2 value
  33707. */
  33708. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33709. /**
  33710. * Interpolates a Vector2 cubically
  33711. * @param startValue Start value of the animation curve
  33712. * @param outTangent End tangent of the animation
  33713. * @param endValue End value of the animation curve
  33714. * @param inTangent Start tangent of the animation curve
  33715. * @param gradient Scalar amount to interpolate
  33716. * @returns Interpolated Vector2 value
  33717. */
  33718. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33719. /**
  33720. * Interpolates a size linearly
  33721. * @param startValue Start value of the animation curve
  33722. * @param endValue End value of the animation curve
  33723. * @param gradient Scalar amount to interpolate
  33724. * @returns Interpolated Size value
  33725. */
  33726. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33727. /**
  33728. * Interpolates a Color3 linearly
  33729. * @param startValue Start value of the animation curve
  33730. * @param endValue End value of the animation curve
  33731. * @param gradient Scalar amount to interpolate
  33732. * @returns Interpolated Color3 value
  33733. */
  33734. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33735. /**
  33736. * Interpolates a Color4 linearly
  33737. * @param startValue Start value of the animation curve
  33738. * @param endValue End value of the animation curve
  33739. * @param gradient Scalar amount to interpolate
  33740. * @returns Interpolated Color3 value
  33741. */
  33742. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33743. /**
  33744. * @hidden Internal use only
  33745. */
  33746. _getKeyValue(value: any): any;
  33747. /**
  33748. * @hidden Internal use only
  33749. */
  33750. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33751. /**
  33752. * Defines the function to use to interpolate matrices
  33753. * @param startValue defines the start matrix
  33754. * @param endValue defines the end matrix
  33755. * @param gradient defines the gradient between both matrices
  33756. * @param result defines an optional target matrix where to store the interpolation
  33757. * @returns the interpolated matrix
  33758. */
  33759. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33760. /**
  33761. * Makes a copy of the animation
  33762. * @returns Cloned animation
  33763. */
  33764. clone(): Animation;
  33765. /**
  33766. * Sets the key frames of the animation
  33767. * @param values The animation key frames to set
  33768. */
  33769. setKeys(values: Array<IAnimationKey>): void;
  33770. /**
  33771. * Serializes the animation to an object
  33772. * @returns Serialized object
  33773. */
  33774. serialize(): any;
  33775. /**
  33776. * Float animation type
  33777. */
  33778. static readonly ANIMATIONTYPE_FLOAT: number;
  33779. /**
  33780. * Vector3 animation type
  33781. */
  33782. static readonly ANIMATIONTYPE_VECTOR3: number;
  33783. /**
  33784. * Quaternion animation type
  33785. */
  33786. static readonly ANIMATIONTYPE_QUATERNION: number;
  33787. /**
  33788. * Matrix animation type
  33789. */
  33790. static readonly ANIMATIONTYPE_MATRIX: number;
  33791. /**
  33792. * Color3 animation type
  33793. */
  33794. static readonly ANIMATIONTYPE_COLOR3: number;
  33795. /**
  33796. * Color3 animation type
  33797. */
  33798. static readonly ANIMATIONTYPE_COLOR4: number;
  33799. /**
  33800. * Vector2 animation type
  33801. */
  33802. static readonly ANIMATIONTYPE_VECTOR2: number;
  33803. /**
  33804. * Size animation type
  33805. */
  33806. static readonly ANIMATIONTYPE_SIZE: number;
  33807. /**
  33808. * Relative Loop Mode
  33809. */
  33810. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33811. /**
  33812. * Cycle Loop Mode
  33813. */
  33814. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33815. /**
  33816. * Constant Loop Mode
  33817. */
  33818. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33819. /** @hidden */
  33820. static _UniversalLerp(left: any, right: any, amount: number): any;
  33821. /**
  33822. * Parses an animation object and creates an animation
  33823. * @param parsedAnimation Parsed animation object
  33824. * @returns Animation object
  33825. */
  33826. static Parse(parsedAnimation: any): Animation;
  33827. /**
  33828. * Appends the serialized animations from the source animations
  33829. * @param source Source containing the animations
  33830. * @param destination Target to store the animations
  33831. */
  33832. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33833. /**
  33834. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33835. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33836. * @param url defines the url to load from
  33837. * @returns a promise that will resolve to the new animation or an array of animations
  33838. */
  33839. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33840. /**
  33841. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33842. * @param snippetId defines the snippet to load
  33843. * @returns a promise that will resolve to the new animation or a new array of animations
  33844. */
  33845. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33846. }
  33847. }
  33848. declare module BABYLON {
  33849. /**
  33850. * Interface containing an array of animations
  33851. */
  33852. export interface IAnimatable {
  33853. /**
  33854. * Array of animations
  33855. */
  33856. animations: Nullable<Array<Animation>>;
  33857. }
  33858. }
  33859. declare module BABYLON {
  33860. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33861. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33862. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33863. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33864. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33865. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33866. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33867. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33868. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33869. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33870. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33871. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33872. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33873. /**
  33874. * Decorator used to define property that can be serialized as reference to a camera
  33875. * @param sourceName defines the name of the property to decorate
  33876. */
  33877. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33878. /**
  33879. * Class used to help serialization objects
  33880. */
  33881. export class SerializationHelper {
  33882. /** @hidden */
  33883. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33884. /** @hidden */
  33885. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33886. /** @hidden */
  33887. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33888. /** @hidden */
  33889. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33890. /**
  33891. * Appends the serialized animations from the source animations
  33892. * @param source Source containing the animations
  33893. * @param destination Target to store the animations
  33894. */
  33895. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33896. /**
  33897. * Static function used to serialized a specific entity
  33898. * @param entity defines the entity to serialize
  33899. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33900. * @returns a JSON compatible object representing the serialization of the entity
  33901. */
  33902. static Serialize<T>(entity: T, serializationObject?: any): any;
  33903. /**
  33904. * Creates a new entity from a serialization data object
  33905. * @param creationFunction defines a function used to instanciated the new entity
  33906. * @param source defines the source serialization data
  33907. * @param scene defines the hosting scene
  33908. * @param rootUrl defines the root url for resources
  33909. * @returns a new entity
  33910. */
  33911. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33912. /**
  33913. * Clones an object
  33914. * @param creationFunction defines the function used to instanciate the new object
  33915. * @param source defines the source object
  33916. * @returns the cloned object
  33917. */
  33918. static Clone<T>(creationFunction: () => T, source: T): T;
  33919. /**
  33920. * Instanciates a new object based on a source one (some data will be shared between both object)
  33921. * @param creationFunction defines the function used to instanciate the new object
  33922. * @param source defines the source object
  33923. * @returns the new object
  33924. */
  33925. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33926. }
  33927. }
  33928. declare module BABYLON {
  33929. /**
  33930. * Base class of all the textures in babylon.
  33931. * It groups all the common properties the materials, post process, lights... might need
  33932. * in order to make a correct use of the texture.
  33933. */
  33934. export class BaseTexture implements IAnimatable {
  33935. /**
  33936. * Default anisotropic filtering level for the application.
  33937. * It is set to 4 as a good tradeoff between perf and quality.
  33938. */
  33939. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33940. /**
  33941. * Gets or sets the unique id of the texture
  33942. */
  33943. uniqueId: number;
  33944. /**
  33945. * Define the name of the texture.
  33946. */
  33947. name: string;
  33948. /**
  33949. * Gets or sets an object used to store user defined information.
  33950. */
  33951. metadata: any;
  33952. /**
  33953. * For internal use only. Please do not use.
  33954. */
  33955. reservedDataStore: any;
  33956. private _hasAlpha;
  33957. /**
  33958. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33959. */
  33960. set hasAlpha(value: boolean);
  33961. get hasAlpha(): boolean;
  33962. /**
  33963. * Defines if the alpha value should be determined via the rgb values.
  33964. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33965. */
  33966. getAlphaFromRGB: boolean;
  33967. /**
  33968. * Intensity or strength of the texture.
  33969. * It is commonly used by materials to fine tune the intensity of the texture
  33970. */
  33971. level: number;
  33972. /**
  33973. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33974. * This is part of the texture as textures usually maps to one uv set.
  33975. */
  33976. coordinatesIndex: number;
  33977. protected _coordinatesMode: number;
  33978. /**
  33979. * How a texture is mapped.
  33980. *
  33981. * | Value | Type | Description |
  33982. * | ----- | ----------------------------------- | ----------- |
  33983. * | 0 | EXPLICIT_MODE | |
  33984. * | 1 | SPHERICAL_MODE | |
  33985. * | 2 | PLANAR_MODE | |
  33986. * | 3 | CUBIC_MODE | |
  33987. * | 4 | PROJECTION_MODE | |
  33988. * | 5 | SKYBOX_MODE | |
  33989. * | 6 | INVCUBIC_MODE | |
  33990. * | 7 | EQUIRECTANGULAR_MODE | |
  33991. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33992. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33993. */
  33994. set coordinatesMode(value: number);
  33995. get coordinatesMode(): number;
  33996. private _wrapU;
  33997. /**
  33998. * | Value | Type | Description |
  33999. * | ----- | ------------------ | ----------- |
  34000. * | 0 | CLAMP_ADDRESSMODE | |
  34001. * | 1 | WRAP_ADDRESSMODE | |
  34002. * | 2 | MIRROR_ADDRESSMODE | |
  34003. */
  34004. get wrapU(): number;
  34005. set wrapU(value: number);
  34006. private _wrapV;
  34007. /**
  34008. * | Value | Type | Description |
  34009. * | ----- | ------------------ | ----------- |
  34010. * | 0 | CLAMP_ADDRESSMODE | |
  34011. * | 1 | WRAP_ADDRESSMODE | |
  34012. * | 2 | MIRROR_ADDRESSMODE | |
  34013. */
  34014. get wrapV(): number;
  34015. set wrapV(value: number);
  34016. /**
  34017. * | Value | Type | Description |
  34018. * | ----- | ------------------ | ----------- |
  34019. * | 0 | CLAMP_ADDRESSMODE | |
  34020. * | 1 | WRAP_ADDRESSMODE | |
  34021. * | 2 | MIRROR_ADDRESSMODE | |
  34022. */
  34023. wrapR: number;
  34024. /**
  34025. * With compliant hardware and browser (supporting anisotropic filtering)
  34026. * this defines the level of anisotropic filtering in the texture.
  34027. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34028. */
  34029. anisotropicFilteringLevel: number;
  34030. /**
  34031. * Define if the texture is a cube texture or if false a 2d texture.
  34032. */
  34033. get isCube(): boolean;
  34034. set isCube(value: boolean);
  34035. /**
  34036. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34037. */
  34038. get is3D(): boolean;
  34039. set is3D(value: boolean);
  34040. /**
  34041. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34042. */
  34043. get is2DArray(): boolean;
  34044. set is2DArray(value: boolean);
  34045. private _gammaSpace;
  34046. /**
  34047. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34048. * HDR texture are usually stored in linear space.
  34049. * This only impacts the PBR and Background materials
  34050. */
  34051. get gammaSpace(): boolean;
  34052. set gammaSpace(gamma: boolean);
  34053. /**
  34054. * Gets or sets whether or not the texture contains RGBD data.
  34055. */
  34056. get isRGBD(): boolean;
  34057. set isRGBD(value: boolean);
  34058. /**
  34059. * Is Z inverted in the texture (useful in a cube texture).
  34060. */
  34061. invertZ: boolean;
  34062. /**
  34063. * Are mip maps generated for this texture or not.
  34064. */
  34065. get noMipmap(): boolean;
  34066. /**
  34067. * @hidden
  34068. */
  34069. lodLevelInAlpha: boolean;
  34070. /**
  34071. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34072. */
  34073. get lodGenerationOffset(): number;
  34074. set lodGenerationOffset(value: number);
  34075. /**
  34076. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34077. */
  34078. get lodGenerationScale(): number;
  34079. set lodGenerationScale(value: number);
  34080. /**
  34081. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34082. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34083. * average roughness values.
  34084. */
  34085. get linearSpecularLOD(): boolean;
  34086. set linearSpecularLOD(value: boolean);
  34087. /**
  34088. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34089. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34090. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34091. */
  34092. get irradianceTexture(): Nullable<BaseTexture>;
  34093. set irradianceTexture(value: Nullable<BaseTexture>);
  34094. /**
  34095. * Define if the texture is a render target.
  34096. */
  34097. isRenderTarget: boolean;
  34098. /**
  34099. * Define the unique id of the texture in the scene.
  34100. */
  34101. get uid(): string;
  34102. /** @hidden */
  34103. _prefiltered: boolean;
  34104. /**
  34105. * Return a string representation of the texture.
  34106. * @returns the texture as a string
  34107. */
  34108. toString(): string;
  34109. /**
  34110. * Get the class name of the texture.
  34111. * @returns "BaseTexture"
  34112. */
  34113. getClassName(): string;
  34114. /**
  34115. * Define the list of animation attached to the texture.
  34116. */
  34117. animations: Animation[];
  34118. /**
  34119. * An event triggered when the texture is disposed.
  34120. */
  34121. onDisposeObservable: Observable<BaseTexture>;
  34122. private _onDisposeObserver;
  34123. /**
  34124. * Callback triggered when the texture has been disposed.
  34125. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34126. */
  34127. set onDispose(callback: () => void);
  34128. /**
  34129. * Define the current state of the loading sequence when in delayed load mode.
  34130. */
  34131. delayLoadState: number;
  34132. protected _scene: Nullable<Scene>;
  34133. protected _engine: Nullable<ThinEngine>;
  34134. /** @hidden */
  34135. _texture: Nullable<InternalTexture>;
  34136. private _uid;
  34137. /**
  34138. * Define if the texture is preventinga material to render or not.
  34139. * If not and the texture is not ready, the engine will use a default black texture instead.
  34140. */
  34141. get isBlocking(): boolean;
  34142. /**
  34143. * Instantiates a new BaseTexture.
  34144. * Base class of all the textures in babylon.
  34145. * It groups all the common properties the materials, post process, lights... might need
  34146. * in order to make a correct use of the texture.
  34147. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34148. */
  34149. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34150. /**
  34151. * Get the scene the texture belongs to.
  34152. * @returns the scene or null if undefined
  34153. */
  34154. getScene(): Nullable<Scene>;
  34155. /** @hidden */
  34156. protected _getEngine(): Nullable<ThinEngine>;
  34157. /**
  34158. * Get the texture transform matrix used to offset tile the texture for istance.
  34159. * @returns the transformation matrix
  34160. */
  34161. getTextureMatrix(): Matrix;
  34162. /**
  34163. * Get the texture reflection matrix used to rotate/transform the reflection.
  34164. * @returns the reflection matrix
  34165. */
  34166. getReflectionTextureMatrix(): Matrix;
  34167. /**
  34168. * Get the underlying lower level texture from Babylon.
  34169. * @returns the insternal texture
  34170. */
  34171. getInternalTexture(): Nullable<InternalTexture>;
  34172. /**
  34173. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34174. * @returns true if ready or not blocking
  34175. */
  34176. isReadyOrNotBlocking(): boolean;
  34177. /**
  34178. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34179. * @returns true if fully ready
  34180. */
  34181. isReady(): boolean;
  34182. private _cachedSize;
  34183. /**
  34184. * Get the size of the texture.
  34185. * @returns the texture size.
  34186. */
  34187. getSize(): ISize;
  34188. /**
  34189. * Get the base size of the texture.
  34190. * It can be different from the size if the texture has been resized for POT for instance
  34191. * @returns the base size
  34192. */
  34193. getBaseSize(): ISize;
  34194. /**
  34195. * Update the sampling mode of the texture.
  34196. * Default is Trilinear mode.
  34197. *
  34198. * | Value | Type | Description |
  34199. * | ----- | ------------------ | ----------- |
  34200. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34201. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34202. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34203. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34204. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34205. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34206. * | 7 | NEAREST_LINEAR | |
  34207. * | 8 | NEAREST_NEAREST | |
  34208. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34209. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34210. * | 11 | LINEAR_LINEAR | |
  34211. * | 12 | LINEAR_NEAREST | |
  34212. *
  34213. * > _mag_: magnification filter (close to the viewer)
  34214. * > _min_: minification filter (far from the viewer)
  34215. * > _mip_: filter used between mip map levels
  34216. *@param samplingMode Define the new sampling mode of the texture
  34217. */
  34218. updateSamplingMode(samplingMode: number): void;
  34219. /**
  34220. * Scales the texture if is `canRescale()`
  34221. * @param ratio the resize factor we want to use to rescale
  34222. */
  34223. scale(ratio: number): void;
  34224. /**
  34225. * Get if the texture can rescale.
  34226. */
  34227. get canRescale(): boolean;
  34228. /** @hidden */
  34229. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34230. /** @hidden */
  34231. _rebuild(): void;
  34232. /**
  34233. * Triggers the load sequence in delayed load mode.
  34234. */
  34235. delayLoad(): void;
  34236. /**
  34237. * Clones the texture.
  34238. * @returns the cloned texture
  34239. */
  34240. clone(): Nullable<BaseTexture>;
  34241. /**
  34242. * Get the texture underlying type (INT, FLOAT...)
  34243. */
  34244. get textureType(): number;
  34245. /**
  34246. * Get the texture underlying format (RGB, RGBA...)
  34247. */
  34248. get textureFormat(): number;
  34249. /**
  34250. * Indicates that textures need to be re-calculated for all materials
  34251. */
  34252. protected _markAllSubMeshesAsTexturesDirty(): void;
  34253. /**
  34254. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34255. * This will returns an RGBA array buffer containing either in values (0-255) or
  34256. * float values (0-1) depending of the underlying buffer type.
  34257. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34258. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34259. * @param buffer defines a user defined buffer to fill with data (can be null)
  34260. * @returns The Array buffer containing the pixels data.
  34261. */
  34262. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34263. /**
  34264. * Release and destroy the underlying lower level texture aka internalTexture.
  34265. */
  34266. releaseInternalTexture(): void;
  34267. /** @hidden */
  34268. get _lodTextureHigh(): Nullable<BaseTexture>;
  34269. /** @hidden */
  34270. get _lodTextureMid(): Nullable<BaseTexture>;
  34271. /** @hidden */
  34272. get _lodTextureLow(): Nullable<BaseTexture>;
  34273. /**
  34274. * Dispose the texture and release its associated resources.
  34275. */
  34276. dispose(): void;
  34277. /**
  34278. * Serialize the texture into a JSON representation that can be parsed later on.
  34279. * @returns the JSON representation of the texture
  34280. */
  34281. serialize(): any;
  34282. /**
  34283. * Helper function to be called back once a list of texture contains only ready textures.
  34284. * @param textures Define the list of textures to wait for
  34285. * @param callback Define the callback triggered once the entire list will be ready
  34286. */
  34287. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34288. private static _isScene;
  34289. }
  34290. }
  34291. declare module BABYLON {
  34292. /**
  34293. * Options to be used when creating an effect.
  34294. */
  34295. export interface IEffectCreationOptions {
  34296. /**
  34297. * Atrributes that will be used in the shader.
  34298. */
  34299. attributes: string[];
  34300. /**
  34301. * Uniform varible names that will be set in the shader.
  34302. */
  34303. uniformsNames: string[];
  34304. /**
  34305. * Uniform buffer variable names that will be set in the shader.
  34306. */
  34307. uniformBuffersNames: string[];
  34308. /**
  34309. * Sampler texture variable names that will be set in the shader.
  34310. */
  34311. samplers: string[];
  34312. /**
  34313. * Define statements that will be set in the shader.
  34314. */
  34315. defines: any;
  34316. /**
  34317. * Possible fallbacks for this effect to improve performance when needed.
  34318. */
  34319. fallbacks: Nullable<IEffectFallbacks>;
  34320. /**
  34321. * Callback that will be called when the shader is compiled.
  34322. */
  34323. onCompiled: Nullable<(effect: Effect) => void>;
  34324. /**
  34325. * Callback that will be called if an error occurs during shader compilation.
  34326. */
  34327. onError: Nullable<(effect: Effect, errors: string) => void>;
  34328. /**
  34329. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34330. */
  34331. indexParameters?: any;
  34332. /**
  34333. * Max number of lights that can be used in the shader.
  34334. */
  34335. maxSimultaneousLights?: number;
  34336. /**
  34337. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34338. */
  34339. transformFeedbackVaryings?: Nullable<string[]>;
  34340. /**
  34341. * 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
  34342. */
  34343. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34344. /**
  34345. * Is this effect rendering to several color attachments ?
  34346. */
  34347. multiTarget?: boolean;
  34348. }
  34349. /**
  34350. * Effect containing vertex and fragment shader that can be executed on an object.
  34351. */
  34352. export class Effect implements IDisposable {
  34353. /**
  34354. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34355. */
  34356. static ShadersRepository: string;
  34357. /**
  34358. * Enable logging of the shader code when a compilation error occurs
  34359. */
  34360. static LogShaderCodeOnCompilationError: boolean;
  34361. /**
  34362. * Name of the effect.
  34363. */
  34364. name: any;
  34365. /**
  34366. * String container all the define statements that should be set on the shader.
  34367. */
  34368. defines: string;
  34369. /**
  34370. * Callback that will be called when the shader is compiled.
  34371. */
  34372. onCompiled: Nullable<(effect: Effect) => void>;
  34373. /**
  34374. * Callback that will be called if an error occurs during shader compilation.
  34375. */
  34376. onError: Nullable<(effect: Effect, errors: string) => void>;
  34377. /**
  34378. * Callback that will be called when effect is bound.
  34379. */
  34380. onBind: Nullable<(effect: Effect) => void>;
  34381. /**
  34382. * Unique ID of the effect.
  34383. */
  34384. uniqueId: number;
  34385. /**
  34386. * Observable that will be called when the shader is compiled.
  34387. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34388. */
  34389. onCompileObservable: Observable<Effect>;
  34390. /**
  34391. * Observable that will be called if an error occurs during shader compilation.
  34392. */
  34393. onErrorObservable: Observable<Effect>;
  34394. /** @hidden */
  34395. _onBindObservable: Nullable<Observable<Effect>>;
  34396. /**
  34397. * @hidden
  34398. * Specifies if the effect was previously ready
  34399. */
  34400. _wasPreviouslyReady: boolean;
  34401. /**
  34402. * Observable that will be called when effect is bound.
  34403. */
  34404. get onBindObservable(): Observable<Effect>;
  34405. /** @hidden */
  34406. _bonesComputationForcedToCPU: boolean;
  34407. /** @hidden */
  34408. _multiTarget: boolean;
  34409. private static _uniqueIdSeed;
  34410. private _engine;
  34411. private _uniformBuffersNames;
  34412. private _uniformBuffersNamesList;
  34413. private _uniformsNames;
  34414. private _samplerList;
  34415. private _samplers;
  34416. private _isReady;
  34417. private _compilationError;
  34418. private _allFallbacksProcessed;
  34419. private _attributesNames;
  34420. private _attributes;
  34421. private _attributeLocationByName;
  34422. private _uniforms;
  34423. /**
  34424. * Key for the effect.
  34425. * @hidden
  34426. */
  34427. _key: string;
  34428. private _indexParameters;
  34429. private _fallbacks;
  34430. private _vertexSourceCode;
  34431. private _fragmentSourceCode;
  34432. private _vertexSourceCodeOverride;
  34433. private _fragmentSourceCodeOverride;
  34434. private _transformFeedbackVaryings;
  34435. /**
  34436. * Compiled shader to webGL program.
  34437. * @hidden
  34438. */
  34439. _pipelineContext: Nullable<IPipelineContext>;
  34440. private _valueCache;
  34441. private static _baseCache;
  34442. /**
  34443. * Instantiates an effect.
  34444. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34445. * @param baseName Name of the effect.
  34446. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34447. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34448. * @param samplers List of sampler variables that will be passed to the shader.
  34449. * @param engine Engine to be used to render the effect
  34450. * @param defines Define statements to be added to the shader.
  34451. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34452. * @param onCompiled Callback that will be called when the shader is compiled.
  34453. * @param onError Callback that will be called if an error occurs during shader compilation.
  34454. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34455. */
  34456. 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);
  34457. private _useFinalCode;
  34458. /**
  34459. * Unique key for this effect
  34460. */
  34461. get key(): string;
  34462. /**
  34463. * If the effect has been compiled and prepared.
  34464. * @returns if the effect is compiled and prepared.
  34465. */
  34466. isReady(): boolean;
  34467. private _isReadyInternal;
  34468. /**
  34469. * The engine the effect was initialized with.
  34470. * @returns the engine.
  34471. */
  34472. getEngine(): Engine;
  34473. /**
  34474. * The pipeline context for this effect
  34475. * @returns the associated pipeline context
  34476. */
  34477. getPipelineContext(): Nullable<IPipelineContext>;
  34478. /**
  34479. * The set of names of attribute variables for the shader.
  34480. * @returns An array of attribute names.
  34481. */
  34482. getAttributesNames(): string[];
  34483. /**
  34484. * Returns the attribute at the given index.
  34485. * @param index The index of the attribute.
  34486. * @returns The location of the attribute.
  34487. */
  34488. getAttributeLocation(index: number): number;
  34489. /**
  34490. * Returns the attribute based on the name of the variable.
  34491. * @param name of the attribute to look up.
  34492. * @returns the attribute location.
  34493. */
  34494. getAttributeLocationByName(name: string): number;
  34495. /**
  34496. * The number of attributes.
  34497. * @returns the numnber of attributes.
  34498. */
  34499. getAttributesCount(): number;
  34500. /**
  34501. * Gets the index of a uniform variable.
  34502. * @param uniformName of the uniform to look up.
  34503. * @returns the index.
  34504. */
  34505. getUniformIndex(uniformName: string): number;
  34506. /**
  34507. * Returns the attribute based on the name of the variable.
  34508. * @param uniformName of the uniform to look up.
  34509. * @returns the location of the uniform.
  34510. */
  34511. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34512. /**
  34513. * Returns an array of sampler variable names
  34514. * @returns The array of sampler variable names.
  34515. */
  34516. getSamplers(): string[];
  34517. /**
  34518. * Returns an array of uniform variable names
  34519. * @returns The array of uniform variable names.
  34520. */
  34521. getUniformNames(): string[];
  34522. /**
  34523. * Returns an array of uniform buffer variable names
  34524. * @returns The array of uniform buffer variable names.
  34525. */
  34526. getUniformBuffersNames(): string[];
  34527. /**
  34528. * Returns the index parameters used to create the effect
  34529. * @returns The index parameters object
  34530. */
  34531. getIndexParameters(): any;
  34532. /**
  34533. * The error from the last compilation.
  34534. * @returns the error string.
  34535. */
  34536. getCompilationError(): string;
  34537. /**
  34538. * Gets a boolean indicating that all fallbacks were used during compilation
  34539. * @returns true if all fallbacks were used
  34540. */
  34541. allFallbacksProcessed(): boolean;
  34542. /**
  34543. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34544. * @param func The callback to be used.
  34545. */
  34546. executeWhenCompiled(func: (effect: Effect) => void): void;
  34547. private _checkIsReady;
  34548. private _loadShader;
  34549. /**
  34550. * Gets the vertex shader source code of this effect
  34551. */
  34552. get vertexSourceCode(): string;
  34553. /**
  34554. * Gets the fragment shader source code of this effect
  34555. */
  34556. get fragmentSourceCode(): string;
  34557. /**
  34558. * Recompiles the webGL program
  34559. * @param vertexSourceCode The source code for the vertex shader.
  34560. * @param fragmentSourceCode The source code for the fragment shader.
  34561. * @param onCompiled Callback called when completed.
  34562. * @param onError Callback called on error.
  34563. * @hidden
  34564. */
  34565. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34566. /**
  34567. * Prepares the effect
  34568. * @hidden
  34569. */
  34570. _prepareEffect(): void;
  34571. private _getShaderCodeAndErrorLine;
  34572. private _processCompilationErrors;
  34573. /**
  34574. * Checks if the effect is supported. (Must be called after compilation)
  34575. */
  34576. get isSupported(): boolean;
  34577. /**
  34578. * Binds a texture to the engine to be used as output of the shader.
  34579. * @param channel Name of the output variable.
  34580. * @param texture Texture to bind.
  34581. * @hidden
  34582. */
  34583. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34584. /**
  34585. * Sets a texture on the engine to be used in the shader.
  34586. * @param channel Name of the sampler variable.
  34587. * @param texture Texture to set.
  34588. */
  34589. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34590. /**
  34591. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34592. * @param channel Name of the sampler variable.
  34593. * @param texture Texture to set.
  34594. */
  34595. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34596. /**
  34597. * Sets an array of textures on the engine to be used in the shader.
  34598. * @param channel Name of the variable.
  34599. * @param textures Textures to set.
  34600. */
  34601. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34602. /**
  34603. * 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)
  34604. * @param channel Name of the sampler variable.
  34605. * @param postProcess Post process to get the input texture from.
  34606. */
  34607. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34608. /**
  34609. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34610. * 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)
  34611. * @param channel Name of the sampler variable.
  34612. * @param postProcess Post process to get the output texture from.
  34613. */
  34614. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34615. /** @hidden */
  34616. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34617. /** @hidden */
  34618. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34619. /** @hidden */
  34620. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34621. /** @hidden */
  34622. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34623. /**
  34624. * Binds a buffer to a uniform.
  34625. * @param buffer Buffer to bind.
  34626. * @param name Name of the uniform variable to bind to.
  34627. */
  34628. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34629. /**
  34630. * Binds block to a uniform.
  34631. * @param blockName Name of the block to bind.
  34632. * @param index Index to bind.
  34633. */
  34634. bindUniformBlock(blockName: string, index: number): void;
  34635. /**
  34636. * Sets an interger value on a uniform variable.
  34637. * @param uniformName Name of the variable.
  34638. * @param value Value to be set.
  34639. * @returns this effect.
  34640. */
  34641. setInt(uniformName: string, value: number): Effect;
  34642. /**
  34643. * Sets an int array on a uniform variable.
  34644. * @param uniformName Name of the variable.
  34645. * @param array array to be set.
  34646. * @returns this effect.
  34647. */
  34648. setIntArray(uniformName: string, array: Int32Array): Effect;
  34649. /**
  34650. * 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)
  34651. * @param uniformName Name of the variable.
  34652. * @param array array to be set.
  34653. * @returns this effect.
  34654. */
  34655. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34656. /**
  34657. * 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)
  34658. * @param uniformName Name of the variable.
  34659. * @param array array to be set.
  34660. * @returns this effect.
  34661. */
  34662. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34663. /**
  34664. * 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)
  34665. * @param uniformName Name of the variable.
  34666. * @param array array to be set.
  34667. * @returns this effect.
  34668. */
  34669. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34670. /**
  34671. * Sets an float array on a uniform variable.
  34672. * @param uniformName Name of the variable.
  34673. * @param array array to be set.
  34674. * @returns this effect.
  34675. */
  34676. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34677. /**
  34678. * 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)
  34679. * @param uniformName Name of the variable.
  34680. * @param array array to be set.
  34681. * @returns this effect.
  34682. */
  34683. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34684. /**
  34685. * 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)
  34686. * @param uniformName Name of the variable.
  34687. * @param array array to be set.
  34688. * @returns this effect.
  34689. */
  34690. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34691. /**
  34692. * 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)
  34693. * @param uniformName Name of the variable.
  34694. * @param array array to be set.
  34695. * @returns this effect.
  34696. */
  34697. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34698. /**
  34699. * Sets an array on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param array array to be set.
  34702. * @returns this effect.
  34703. */
  34704. setArray(uniformName: string, array: number[]): Effect;
  34705. /**
  34706. * 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)
  34707. * @param uniformName Name of the variable.
  34708. * @param array array to be set.
  34709. * @returns this effect.
  34710. */
  34711. setArray2(uniformName: string, array: number[]): Effect;
  34712. /**
  34713. * 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)
  34714. * @param uniformName Name of the variable.
  34715. * @param array array to be set.
  34716. * @returns this effect.
  34717. */
  34718. setArray3(uniformName: string, array: number[]): Effect;
  34719. /**
  34720. * 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)
  34721. * @param uniformName Name of the variable.
  34722. * @param array array to be set.
  34723. * @returns this effect.
  34724. */
  34725. setArray4(uniformName: string, array: number[]): Effect;
  34726. /**
  34727. * Sets matrices on a uniform variable.
  34728. * @param uniformName Name of the variable.
  34729. * @param matrices matrices to be set.
  34730. * @returns this effect.
  34731. */
  34732. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34733. /**
  34734. * Sets matrix on a uniform variable.
  34735. * @param uniformName Name of the variable.
  34736. * @param matrix matrix to be set.
  34737. * @returns this effect.
  34738. */
  34739. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34740. /**
  34741. * 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)
  34742. * @param uniformName Name of the variable.
  34743. * @param matrix matrix to be set.
  34744. * @returns this effect.
  34745. */
  34746. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34747. /**
  34748. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34749. * @param uniformName Name of the variable.
  34750. * @param matrix matrix to be set.
  34751. * @returns this effect.
  34752. */
  34753. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34754. /**
  34755. * Sets a float on a uniform variable.
  34756. * @param uniformName Name of the variable.
  34757. * @param value value to be set.
  34758. * @returns this effect.
  34759. */
  34760. setFloat(uniformName: string, value: number): Effect;
  34761. /**
  34762. * Sets a boolean on a uniform variable.
  34763. * @param uniformName Name of the variable.
  34764. * @param bool value to be set.
  34765. * @returns this effect.
  34766. */
  34767. setBool(uniformName: string, bool: boolean): Effect;
  34768. /**
  34769. * Sets a Vector2 on a uniform variable.
  34770. * @param uniformName Name of the variable.
  34771. * @param vector2 vector2 to be set.
  34772. * @returns this effect.
  34773. */
  34774. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34775. /**
  34776. * Sets a float2 on a uniform variable.
  34777. * @param uniformName Name of the variable.
  34778. * @param x First float in float2.
  34779. * @param y Second float in float2.
  34780. * @returns this effect.
  34781. */
  34782. setFloat2(uniformName: string, x: number, y: number): Effect;
  34783. /**
  34784. * Sets a Vector3 on a uniform variable.
  34785. * @param uniformName Name of the variable.
  34786. * @param vector3 Value to be set.
  34787. * @returns this effect.
  34788. */
  34789. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34790. /**
  34791. * Sets a float3 on a uniform variable.
  34792. * @param uniformName Name of the variable.
  34793. * @param x First float in float3.
  34794. * @param y Second float in float3.
  34795. * @param z Third float in float3.
  34796. * @returns this effect.
  34797. */
  34798. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34799. /**
  34800. * Sets a Vector4 on a uniform variable.
  34801. * @param uniformName Name of the variable.
  34802. * @param vector4 Value to be set.
  34803. * @returns this effect.
  34804. */
  34805. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34806. /**
  34807. * Sets a float4 on a uniform variable.
  34808. * @param uniformName Name of the variable.
  34809. * @param x First float in float4.
  34810. * @param y Second float in float4.
  34811. * @param z Third float in float4.
  34812. * @param w Fourth float in float4.
  34813. * @returns this effect.
  34814. */
  34815. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34816. /**
  34817. * Sets a Color3 on a uniform variable.
  34818. * @param uniformName Name of the variable.
  34819. * @param color3 Value to be set.
  34820. * @returns this effect.
  34821. */
  34822. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34823. /**
  34824. * Sets a Color4 on a uniform variable.
  34825. * @param uniformName Name of the variable.
  34826. * @param color3 Value to be set.
  34827. * @param alpha Alpha value to be set.
  34828. * @returns this effect.
  34829. */
  34830. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34831. /**
  34832. * Sets a Color4 on a uniform variable
  34833. * @param uniformName defines the name of the variable
  34834. * @param color4 defines the value to be set
  34835. * @returns this effect.
  34836. */
  34837. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34838. /** Release all associated resources */
  34839. dispose(): void;
  34840. /**
  34841. * This function will add a new shader to the shader store
  34842. * @param name the name of the shader
  34843. * @param pixelShader optional pixel shader content
  34844. * @param vertexShader optional vertex shader content
  34845. */
  34846. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34847. /**
  34848. * Store of each shader (The can be looked up using effect.key)
  34849. */
  34850. static ShadersStore: {
  34851. [key: string]: string;
  34852. };
  34853. /**
  34854. * Store of each included file for a shader (The can be looked up using effect.key)
  34855. */
  34856. static IncludesShadersStore: {
  34857. [key: string]: string;
  34858. };
  34859. /**
  34860. * Resets the cache of effects.
  34861. */
  34862. static ResetCache(): void;
  34863. }
  34864. }
  34865. declare module BABYLON {
  34866. /**
  34867. * Interface used to describe the capabilities of the engine relatively to the current browser
  34868. */
  34869. export interface EngineCapabilities {
  34870. /** Maximum textures units per fragment shader */
  34871. maxTexturesImageUnits: number;
  34872. /** Maximum texture units per vertex shader */
  34873. maxVertexTextureImageUnits: number;
  34874. /** Maximum textures units in the entire pipeline */
  34875. maxCombinedTexturesImageUnits: number;
  34876. /** Maximum texture size */
  34877. maxTextureSize: number;
  34878. /** Maximum texture samples */
  34879. maxSamples?: number;
  34880. /** Maximum cube texture size */
  34881. maxCubemapTextureSize: number;
  34882. /** Maximum render texture size */
  34883. maxRenderTextureSize: number;
  34884. /** Maximum number of vertex attributes */
  34885. maxVertexAttribs: number;
  34886. /** Maximum number of varyings */
  34887. maxVaryingVectors: number;
  34888. /** Maximum number of uniforms per vertex shader */
  34889. maxVertexUniformVectors: number;
  34890. /** Maximum number of uniforms per fragment shader */
  34891. maxFragmentUniformVectors: number;
  34892. /** Defines if standard derivates (dx/dy) are supported */
  34893. standardDerivatives: boolean;
  34894. /** Defines if s3tc texture compression is supported */
  34895. s3tc?: WEBGL_compressed_texture_s3tc;
  34896. /** Defines if pvrtc texture compression is supported */
  34897. pvrtc: any;
  34898. /** Defines if etc1 texture compression is supported */
  34899. etc1: any;
  34900. /** Defines if etc2 texture compression is supported */
  34901. etc2: any;
  34902. /** Defines if astc texture compression is supported */
  34903. astc: any;
  34904. /** Defines if bptc texture compression is supported */
  34905. bptc: any;
  34906. /** Defines if float textures are supported */
  34907. textureFloat: boolean;
  34908. /** Defines if vertex array objects are supported */
  34909. vertexArrayObject: boolean;
  34910. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34911. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34912. /** Gets the maximum level of anisotropy supported */
  34913. maxAnisotropy: number;
  34914. /** Defines if instancing is supported */
  34915. instancedArrays: boolean;
  34916. /** Defines if 32 bits indices are supported */
  34917. uintIndices: boolean;
  34918. /** Defines if high precision shaders are supported */
  34919. highPrecisionShaderSupported: boolean;
  34920. /** Defines if depth reading in the fragment shader is supported */
  34921. fragmentDepthSupported: boolean;
  34922. /** Defines if float texture linear filtering is supported*/
  34923. textureFloatLinearFiltering: boolean;
  34924. /** Defines if rendering to float textures is supported */
  34925. textureFloatRender: boolean;
  34926. /** Defines if half float textures are supported*/
  34927. textureHalfFloat: boolean;
  34928. /** Defines if half float texture linear filtering is supported*/
  34929. textureHalfFloatLinearFiltering: boolean;
  34930. /** Defines if rendering to half float textures is supported */
  34931. textureHalfFloatRender: boolean;
  34932. /** Defines if textureLOD shader command is supported */
  34933. textureLOD: boolean;
  34934. /** Defines if draw buffers extension is supported */
  34935. drawBuffersExtension: boolean;
  34936. /** Defines if depth textures are supported */
  34937. depthTextureExtension: boolean;
  34938. /** Defines if float color buffer are supported */
  34939. colorBufferFloat: boolean;
  34940. /** Gets disjoint timer query extension (null if not supported) */
  34941. timerQuery?: EXT_disjoint_timer_query;
  34942. /** Defines if timestamp can be used with timer query */
  34943. canUseTimestampForTimerQuery: boolean;
  34944. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34945. multiview?: any;
  34946. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34947. oculusMultiview?: any;
  34948. /** Function used to let the system compiles shaders in background */
  34949. parallelShaderCompile?: {
  34950. COMPLETION_STATUS_KHR: number;
  34951. };
  34952. /** Max number of texture samples for MSAA */
  34953. maxMSAASamples: number;
  34954. /** Defines if the blend min max extension is supported */
  34955. blendMinMax: boolean;
  34956. }
  34957. }
  34958. declare module BABYLON {
  34959. /**
  34960. * @hidden
  34961. **/
  34962. export class DepthCullingState {
  34963. private _isDepthTestDirty;
  34964. private _isDepthMaskDirty;
  34965. private _isDepthFuncDirty;
  34966. private _isCullFaceDirty;
  34967. private _isCullDirty;
  34968. private _isZOffsetDirty;
  34969. private _isFrontFaceDirty;
  34970. private _depthTest;
  34971. private _depthMask;
  34972. private _depthFunc;
  34973. private _cull;
  34974. private _cullFace;
  34975. private _zOffset;
  34976. private _frontFace;
  34977. /**
  34978. * Initializes the state.
  34979. */
  34980. constructor();
  34981. get isDirty(): boolean;
  34982. get zOffset(): number;
  34983. set zOffset(value: number);
  34984. get cullFace(): Nullable<number>;
  34985. set cullFace(value: Nullable<number>);
  34986. get cull(): Nullable<boolean>;
  34987. set cull(value: Nullable<boolean>);
  34988. get depthFunc(): Nullable<number>;
  34989. set depthFunc(value: Nullable<number>);
  34990. get depthMask(): boolean;
  34991. set depthMask(value: boolean);
  34992. get depthTest(): boolean;
  34993. set depthTest(value: boolean);
  34994. get frontFace(): Nullable<number>;
  34995. set frontFace(value: Nullable<number>);
  34996. reset(): void;
  34997. apply(gl: WebGLRenderingContext): void;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /**
  35002. * @hidden
  35003. **/
  35004. export class StencilState {
  35005. /** 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 */
  35006. static readonly ALWAYS: number;
  35007. /** Passed to stencilOperation to specify that stencil value must be kept */
  35008. static readonly KEEP: number;
  35009. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35010. static readonly REPLACE: number;
  35011. private _isStencilTestDirty;
  35012. private _isStencilMaskDirty;
  35013. private _isStencilFuncDirty;
  35014. private _isStencilOpDirty;
  35015. private _stencilTest;
  35016. private _stencilMask;
  35017. private _stencilFunc;
  35018. private _stencilFuncRef;
  35019. private _stencilFuncMask;
  35020. private _stencilOpStencilFail;
  35021. private _stencilOpDepthFail;
  35022. private _stencilOpStencilDepthPass;
  35023. get isDirty(): boolean;
  35024. get stencilFunc(): number;
  35025. set stencilFunc(value: number);
  35026. get stencilFuncRef(): number;
  35027. set stencilFuncRef(value: number);
  35028. get stencilFuncMask(): number;
  35029. set stencilFuncMask(value: number);
  35030. get stencilOpStencilFail(): number;
  35031. set stencilOpStencilFail(value: number);
  35032. get stencilOpDepthFail(): number;
  35033. set stencilOpDepthFail(value: number);
  35034. get stencilOpStencilDepthPass(): number;
  35035. set stencilOpStencilDepthPass(value: number);
  35036. get stencilMask(): number;
  35037. set stencilMask(value: number);
  35038. get stencilTest(): boolean;
  35039. set stencilTest(value: boolean);
  35040. constructor();
  35041. reset(): void;
  35042. apply(gl: WebGLRenderingContext): void;
  35043. }
  35044. }
  35045. declare module BABYLON {
  35046. /**
  35047. * @hidden
  35048. **/
  35049. export class AlphaState {
  35050. private _isAlphaBlendDirty;
  35051. private _isBlendFunctionParametersDirty;
  35052. private _isBlendEquationParametersDirty;
  35053. private _isBlendConstantsDirty;
  35054. private _alphaBlend;
  35055. private _blendFunctionParameters;
  35056. private _blendEquationParameters;
  35057. private _blendConstants;
  35058. /**
  35059. * Initializes the state.
  35060. */
  35061. constructor();
  35062. get isDirty(): boolean;
  35063. get alphaBlend(): boolean;
  35064. set alphaBlend(value: boolean);
  35065. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35066. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35067. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35068. reset(): void;
  35069. apply(gl: WebGLRenderingContext): void;
  35070. }
  35071. }
  35072. declare module BABYLON {
  35073. /** @hidden */
  35074. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35075. attributeProcessor(attribute: string): string;
  35076. varyingProcessor(varying: string, isFragment: boolean): string;
  35077. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35078. }
  35079. }
  35080. declare module BABYLON {
  35081. /**
  35082. * Interface for attribute information associated with buffer instanciation
  35083. */
  35084. export interface InstancingAttributeInfo {
  35085. /**
  35086. * Name of the GLSL attribute
  35087. * if attribute index is not specified, this is used to retrieve the index from the effect
  35088. */
  35089. attributeName: string;
  35090. /**
  35091. * Index/offset of the attribute in the vertex shader
  35092. * if not specified, this will be computes from the name.
  35093. */
  35094. index?: number;
  35095. /**
  35096. * size of the attribute, 1, 2, 3 or 4
  35097. */
  35098. attributeSize: number;
  35099. /**
  35100. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35101. */
  35102. offset: number;
  35103. /**
  35104. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35105. * default to 1
  35106. */
  35107. divisor?: number;
  35108. /**
  35109. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35110. * default is FLOAT
  35111. */
  35112. attributeType?: number;
  35113. /**
  35114. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35115. */
  35116. normalized?: boolean;
  35117. }
  35118. }
  35119. declare module BABYLON {
  35120. interface ThinEngine {
  35121. /**
  35122. * Update a video texture
  35123. * @param texture defines the texture to update
  35124. * @param video defines the video element to use
  35125. * @param invertY defines if data must be stored with Y axis inverted
  35126. */
  35127. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35128. }
  35129. }
  35130. declare module BABYLON {
  35131. interface ThinEngine {
  35132. /**
  35133. * Creates a dynamic texture
  35134. * @param width defines the width of the texture
  35135. * @param height defines the height of the texture
  35136. * @param generateMipMaps defines if the engine should generate the mip levels
  35137. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35138. * @returns the dynamic texture inside an InternalTexture
  35139. */
  35140. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35141. /**
  35142. * Update the content of a dynamic texture
  35143. * @param texture defines the texture to update
  35144. * @param canvas defines the canvas containing the source
  35145. * @param invertY defines if data must be stored with Y axis inverted
  35146. * @param premulAlpha defines if alpha is stored as premultiplied
  35147. * @param format defines the format of the data
  35148. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35149. */
  35150. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35151. }
  35152. }
  35153. declare module BABYLON {
  35154. /**
  35155. * Settings for finer control over video usage
  35156. */
  35157. export interface VideoTextureSettings {
  35158. /**
  35159. * Applies `autoplay` to video, if specified
  35160. */
  35161. autoPlay?: boolean;
  35162. /**
  35163. * Applies `loop` to video, if specified
  35164. */
  35165. loop?: boolean;
  35166. /**
  35167. * Automatically updates internal texture from video at every frame in the render loop
  35168. */
  35169. autoUpdateTexture: boolean;
  35170. /**
  35171. * Image src displayed during the video loading or until the user interacts with the video.
  35172. */
  35173. poster?: string;
  35174. }
  35175. /**
  35176. * If you want to display a video in your scene, this is the special texture for that.
  35177. * This special texture works similar to other textures, with the exception of a few parameters.
  35178. * @see https://doc.babylonjs.com/how_to/video_texture
  35179. */
  35180. export class VideoTexture extends Texture {
  35181. /**
  35182. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35183. */
  35184. readonly autoUpdateTexture: boolean;
  35185. /**
  35186. * The video instance used by the texture internally
  35187. */
  35188. readonly video: HTMLVideoElement;
  35189. private _onUserActionRequestedObservable;
  35190. /**
  35191. * Event triggerd when a dom action is required by the user to play the video.
  35192. * This happens due to recent changes in browser policies preventing video to auto start.
  35193. */
  35194. get onUserActionRequestedObservable(): Observable<Texture>;
  35195. private _generateMipMaps;
  35196. private _stillImageCaptured;
  35197. private _displayingPosterTexture;
  35198. private _settings;
  35199. private _createInternalTextureOnEvent;
  35200. private _frameId;
  35201. private _currentSrc;
  35202. /**
  35203. * Creates a video texture.
  35204. * If you want to display a video in your scene, this is the special texture for that.
  35205. * This special texture works similar to other textures, with the exception of a few parameters.
  35206. * @see https://doc.babylonjs.com/how_to/video_texture
  35207. * @param name optional name, will detect from video source, if not defined
  35208. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35209. * @param scene is obviously the current scene.
  35210. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35211. * @param invertY is false by default but can be used to invert video on Y axis
  35212. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35213. * @param settings allows finer control over video usage
  35214. */
  35215. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35216. private _getName;
  35217. private _getVideo;
  35218. private _createInternalTexture;
  35219. private reset;
  35220. /**
  35221. * @hidden Internal method to initiate `update`.
  35222. */
  35223. _rebuild(): void;
  35224. /**
  35225. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35226. */
  35227. update(): void;
  35228. /**
  35229. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35230. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35231. */
  35232. updateTexture(isVisible: boolean): void;
  35233. protected _updateInternalTexture: () => void;
  35234. /**
  35235. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35236. * @param url New url.
  35237. */
  35238. updateURL(url: string): void;
  35239. /**
  35240. * Clones the texture.
  35241. * @returns the cloned texture
  35242. */
  35243. clone(): VideoTexture;
  35244. /**
  35245. * Dispose the texture and release its associated resources.
  35246. */
  35247. dispose(): void;
  35248. /**
  35249. * Creates a video texture straight from a stream.
  35250. * @param scene Define the scene the texture should be created in
  35251. * @param stream Define the stream the texture should be created from
  35252. * @returns The created video texture as a promise
  35253. */
  35254. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35255. /**
  35256. * Creates a video texture straight from your WebCam video feed.
  35257. * @param scene Define the scene the texture should be created in
  35258. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35259. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35260. * @returns The created video texture as a promise
  35261. */
  35262. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35263. minWidth: number;
  35264. maxWidth: number;
  35265. minHeight: number;
  35266. maxHeight: number;
  35267. deviceId: string;
  35268. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35269. /**
  35270. * Creates a video texture straight from your WebCam video feed.
  35271. * @param scene Define the scene the texture should be created in
  35272. * @param onReady Define a callback to triggered once the texture will be ready
  35273. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35274. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35275. */
  35276. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35277. minWidth: number;
  35278. maxWidth: number;
  35279. minHeight: number;
  35280. maxHeight: number;
  35281. deviceId: string;
  35282. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35283. }
  35284. }
  35285. declare module BABYLON {
  35286. /**
  35287. * Defines the interface used by objects working like Scene
  35288. * @hidden
  35289. */
  35290. export interface ISceneLike {
  35291. _addPendingData(data: any): void;
  35292. _removePendingData(data: any): void;
  35293. offlineProvider: IOfflineProvider;
  35294. }
  35295. /**
  35296. * Information about the current host
  35297. */
  35298. export interface HostInformation {
  35299. /**
  35300. * Defines if the current host is a mobile
  35301. */
  35302. isMobile: boolean;
  35303. }
  35304. /** Interface defining initialization parameters for Engine class */
  35305. export interface EngineOptions extends WebGLContextAttributes {
  35306. /**
  35307. * Defines if the engine should no exceed a specified device ratio
  35308. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35309. */
  35310. limitDeviceRatio?: number;
  35311. /**
  35312. * Defines if webvr should be enabled automatically
  35313. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35314. */
  35315. autoEnableWebVR?: boolean;
  35316. /**
  35317. * Defines if webgl2 should be turned off even if supported
  35318. * @see https://doc.babylonjs.com/features/webgl2
  35319. */
  35320. disableWebGL2Support?: boolean;
  35321. /**
  35322. * Defines if webaudio should be initialized as well
  35323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35324. */
  35325. audioEngine?: boolean;
  35326. /**
  35327. * Defines if animations should run using a deterministic lock step
  35328. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35329. */
  35330. deterministicLockstep?: boolean;
  35331. /** Defines the maximum steps to use with deterministic lock step mode */
  35332. lockstepMaxSteps?: number;
  35333. /** Defines the seconds between each deterministic lock step */
  35334. timeStep?: number;
  35335. /**
  35336. * Defines that engine should ignore context lost events
  35337. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35338. */
  35339. doNotHandleContextLost?: boolean;
  35340. /**
  35341. * Defines that engine should ignore modifying touch action attribute and style
  35342. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35343. */
  35344. doNotHandleTouchAction?: boolean;
  35345. /**
  35346. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35347. */
  35348. useHighPrecisionFloats?: boolean;
  35349. /**
  35350. * Make the canvas XR Compatible for XR sessions
  35351. */
  35352. xrCompatible?: boolean;
  35353. /**
  35354. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35355. */
  35356. useHighPrecisionMatrix?: boolean;
  35357. }
  35358. /**
  35359. * The base engine class (root of all engines)
  35360. */
  35361. export class ThinEngine {
  35362. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35363. static ExceptionList: ({
  35364. key: string;
  35365. capture: string;
  35366. captureConstraint: number;
  35367. targets: string[];
  35368. } | {
  35369. key: string;
  35370. capture: null;
  35371. captureConstraint: null;
  35372. targets: string[];
  35373. })[];
  35374. /** @hidden */
  35375. static _TextureLoaders: IInternalTextureLoader[];
  35376. /**
  35377. * Returns the current npm package of the sdk
  35378. */
  35379. static get NpmPackage(): string;
  35380. /**
  35381. * Returns the current version of the framework
  35382. */
  35383. static get Version(): string;
  35384. /**
  35385. * Returns a string describing the current engine
  35386. */
  35387. get description(): string;
  35388. /**
  35389. * Gets or sets the epsilon value used by collision engine
  35390. */
  35391. static CollisionsEpsilon: number;
  35392. /**
  35393. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35394. */
  35395. static get ShadersRepository(): string;
  35396. static set ShadersRepository(value: string);
  35397. /** @hidden */
  35398. _shaderProcessor: IShaderProcessor;
  35399. /**
  35400. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35401. */
  35402. forcePOTTextures: boolean;
  35403. /**
  35404. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35405. */
  35406. isFullscreen: boolean;
  35407. /**
  35408. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35409. */
  35410. cullBackFaces: boolean;
  35411. /**
  35412. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35413. */
  35414. renderEvenInBackground: boolean;
  35415. /**
  35416. * Gets or sets a boolean indicating that cache can be kept between frames
  35417. */
  35418. preventCacheWipeBetweenFrames: boolean;
  35419. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35420. validateShaderPrograms: boolean;
  35421. /**
  35422. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35423. * This can provide greater z depth for distant objects.
  35424. */
  35425. useReverseDepthBuffer: boolean;
  35426. /**
  35427. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35428. */
  35429. disableUniformBuffers: boolean;
  35430. /** @hidden */
  35431. _uniformBuffers: UniformBuffer[];
  35432. /**
  35433. * Gets a boolean indicating that the engine supports uniform buffers
  35434. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35435. */
  35436. get supportsUniformBuffers(): boolean;
  35437. /** @hidden */
  35438. _gl: WebGLRenderingContext;
  35439. /** @hidden */
  35440. _webGLVersion: number;
  35441. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35442. protected _windowIsBackground: boolean;
  35443. protected _creationOptions: EngineOptions;
  35444. protected _highPrecisionShadersAllowed: boolean;
  35445. /** @hidden */
  35446. get _shouldUseHighPrecisionShader(): boolean;
  35447. /**
  35448. * Gets a boolean indicating that only power of 2 textures are supported
  35449. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35450. */
  35451. get needPOTTextures(): boolean;
  35452. /** @hidden */
  35453. _badOS: boolean;
  35454. /** @hidden */
  35455. _badDesktopOS: boolean;
  35456. private _hardwareScalingLevel;
  35457. /** @hidden */
  35458. _caps: EngineCapabilities;
  35459. private _isStencilEnable;
  35460. private _glVersion;
  35461. private _glRenderer;
  35462. private _glVendor;
  35463. /** @hidden */
  35464. _videoTextureSupported: boolean;
  35465. protected _renderingQueueLaunched: boolean;
  35466. protected _activeRenderLoops: (() => void)[];
  35467. /**
  35468. * Observable signaled when a context lost event is raised
  35469. */
  35470. onContextLostObservable: Observable<ThinEngine>;
  35471. /**
  35472. * Observable signaled when a context restored event is raised
  35473. */
  35474. onContextRestoredObservable: Observable<ThinEngine>;
  35475. private _onContextLost;
  35476. private _onContextRestored;
  35477. protected _contextWasLost: boolean;
  35478. /** @hidden */
  35479. _doNotHandleContextLost: boolean;
  35480. /**
  35481. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35482. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35483. */
  35484. get doNotHandleContextLost(): boolean;
  35485. set doNotHandleContextLost(value: boolean);
  35486. /**
  35487. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35488. */
  35489. disableVertexArrayObjects: boolean;
  35490. /** @hidden */
  35491. protected _colorWrite: boolean;
  35492. /** @hidden */
  35493. protected _colorWriteChanged: boolean;
  35494. /** @hidden */
  35495. protected _depthCullingState: DepthCullingState;
  35496. /** @hidden */
  35497. protected _stencilState: StencilState;
  35498. /** @hidden */
  35499. _alphaState: AlphaState;
  35500. /** @hidden */
  35501. _alphaMode: number;
  35502. /** @hidden */
  35503. _alphaEquation: number;
  35504. /** @hidden */
  35505. _internalTexturesCache: InternalTexture[];
  35506. /** @hidden */
  35507. protected _activeChannel: number;
  35508. private _currentTextureChannel;
  35509. /** @hidden */
  35510. protected _boundTexturesCache: {
  35511. [key: string]: Nullable<InternalTexture>;
  35512. };
  35513. /** @hidden */
  35514. protected _currentEffect: Nullable<Effect>;
  35515. /** @hidden */
  35516. protected _currentProgram: Nullable<WebGLProgram>;
  35517. private _compiledEffects;
  35518. private _vertexAttribArraysEnabled;
  35519. /** @hidden */
  35520. protected _cachedViewport: Nullable<IViewportLike>;
  35521. private _cachedVertexArrayObject;
  35522. /** @hidden */
  35523. protected _cachedVertexBuffers: any;
  35524. /** @hidden */
  35525. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35526. /** @hidden */
  35527. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35528. /** @hidden */
  35529. _currentRenderTarget: Nullable<InternalTexture>;
  35530. private _uintIndicesCurrentlySet;
  35531. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35532. /** @hidden */
  35533. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35534. /** @hidden */
  35535. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35536. private _currentBufferPointers;
  35537. private _currentInstanceLocations;
  35538. private _currentInstanceBuffers;
  35539. private _textureUnits;
  35540. /** @hidden */
  35541. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35542. /** @hidden */
  35543. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35544. /** @hidden */
  35545. _boundRenderFunction: any;
  35546. private _vaoRecordInProgress;
  35547. private _mustWipeVertexAttributes;
  35548. private _emptyTexture;
  35549. private _emptyCubeTexture;
  35550. private _emptyTexture3D;
  35551. private _emptyTexture2DArray;
  35552. /** @hidden */
  35553. _frameHandler: number;
  35554. private _nextFreeTextureSlots;
  35555. private _maxSimultaneousTextures;
  35556. private _activeRequests;
  35557. /** @hidden */
  35558. _transformTextureUrl: Nullable<(url: string) => string>;
  35559. /**
  35560. * Gets information about the current host
  35561. */
  35562. hostInformation: HostInformation;
  35563. protected get _supportsHardwareTextureRescaling(): boolean;
  35564. private _framebufferDimensionsObject;
  35565. /**
  35566. * sets the object from which width and height will be taken from when getting render width and height
  35567. * Will fallback to the gl object
  35568. * @param dimensions the framebuffer width and height that will be used.
  35569. */
  35570. set framebufferDimensionsObject(dimensions: Nullable<{
  35571. framebufferWidth: number;
  35572. framebufferHeight: number;
  35573. }>);
  35574. /**
  35575. * Gets the current viewport
  35576. */
  35577. get currentViewport(): Nullable<IViewportLike>;
  35578. /**
  35579. * Gets the default empty texture
  35580. */
  35581. get emptyTexture(): InternalTexture;
  35582. /**
  35583. * Gets the default empty 3D texture
  35584. */
  35585. get emptyTexture3D(): InternalTexture;
  35586. /**
  35587. * Gets the default empty 2D array texture
  35588. */
  35589. get emptyTexture2DArray(): InternalTexture;
  35590. /**
  35591. * Gets the default empty cube texture
  35592. */
  35593. get emptyCubeTexture(): InternalTexture;
  35594. /**
  35595. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35596. */
  35597. readonly premultipliedAlpha: boolean;
  35598. /**
  35599. * Observable event triggered before each texture is initialized
  35600. */
  35601. onBeforeTextureInitObservable: Observable<Texture>;
  35602. /**
  35603. * Creates a new engine
  35604. * @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
  35605. * @param antialias defines enable antialiasing (default: false)
  35606. * @param options defines further options to be sent to the getContext() function
  35607. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35608. */
  35609. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35610. private _rebuildInternalTextures;
  35611. private _rebuildEffects;
  35612. /**
  35613. * Gets a boolean indicating if all created effects are ready
  35614. * @returns true if all effects are ready
  35615. */
  35616. areAllEffectsReady(): boolean;
  35617. protected _rebuildBuffers(): void;
  35618. protected _initGLContext(): void;
  35619. /**
  35620. * Gets version of the current webGL context
  35621. */
  35622. get webGLVersion(): number;
  35623. /**
  35624. * Gets a string identifying the name of the class
  35625. * @returns "Engine" string
  35626. */
  35627. getClassName(): string;
  35628. /**
  35629. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35630. */
  35631. get isStencilEnable(): boolean;
  35632. /** @hidden */
  35633. _prepareWorkingCanvas(): void;
  35634. /**
  35635. * Reset the texture cache to empty state
  35636. */
  35637. resetTextureCache(): void;
  35638. /**
  35639. * Gets an object containing information about the current webGL context
  35640. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35641. */
  35642. getGlInfo(): {
  35643. vendor: string;
  35644. renderer: string;
  35645. version: string;
  35646. };
  35647. /**
  35648. * Defines the hardware scaling level.
  35649. * By default the hardware scaling level is computed from the window device ratio.
  35650. * 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.
  35651. * @param level defines the level to use
  35652. */
  35653. setHardwareScalingLevel(level: number): void;
  35654. /**
  35655. * Gets the current hardware scaling level.
  35656. * By default the hardware scaling level is computed from the window device ratio.
  35657. * 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.
  35658. * @returns a number indicating the current hardware scaling level
  35659. */
  35660. getHardwareScalingLevel(): number;
  35661. /**
  35662. * Gets the list of loaded textures
  35663. * @returns an array containing all loaded textures
  35664. */
  35665. getLoadedTexturesCache(): InternalTexture[];
  35666. /**
  35667. * Gets the object containing all engine capabilities
  35668. * @returns the EngineCapabilities object
  35669. */
  35670. getCaps(): EngineCapabilities;
  35671. /**
  35672. * stop executing a render loop function and remove it from the execution array
  35673. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35674. */
  35675. stopRenderLoop(renderFunction?: () => void): void;
  35676. /** @hidden */
  35677. _renderLoop(): void;
  35678. /**
  35679. * Gets the HTML canvas attached with the current webGL context
  35680. * @returns a HTML canvas
  35681. */
  35682. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35683. /**
  35684. * Gets host window
  35685. * @returns the host window object
  35686. */
  35687. getHostWindow(): Nullable<Window>;
  35688. /**
  35689. * Gets the current render width
  35690. * @param useScreen defines if screen size must be used (or the current render target if any)
  35691. * @returns a number defining the current render width
  35692. */
  35693. getRenderWidth(useScreen?: boolean): number;
  35694. /**
  35695. * Gets the current render height
  35696. * @param useScreen defines if screen size must be used (or the current render target if any)
  35697. * @returns a number defining the current render height
  35698. */
  35699. getRenderHeight(useScreen?: boolean): number;
  35700. /**
  35701. * Can be used to override the current requestAnimationFrame requester.
  35702. * @hidden
  35703. */
  35704. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35705. /**
  35706. * Register and execute a render loop. The engine can have more than one render function
  35707. * @param renderFunction defines the function to continuously execute
  35708. */
  35709. runRenderLoop(renderFunction: () => void): void;
  35710. /**
  35711. * Clear the current render buffer or the current render target (if any is set up)
  35712. * @param color defines the color to use
  35713. * @param backBuffer defines if the back buffer must be cleared
  35714. * @param depth defines if the depth buffer must be cleared
  35715. * @param stencil defines if the stencil buffer must be cleared
  35716. */
  35717. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35718. private _viewportCached;
  35719. /** @hidden */
  35720. _viewport(x: number, y: number, width: number, height: number): void;
  35721. /**
  35722. * Set the WebGL's viewport
  35723. * @param viewport defines the viewport element to be used
  35724. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35725. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35726. */
  35727. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35728. /**
  35729. * Begin a new frame
  35730. */
  35731. beginFrame(): void;
  35732. /**
  35733. * Enf the current frame
  35734. */
  35735. endFrame(): void;
  35736. /**
  35737. * Resize the view according to the canvas' size
  35738. */
  35739. resize(): void;
  35740. /**
  35741. * Force a specific size of the canvas
  35742. * @param width defines the new canvas' width
  35743. * @param height defines the new canvas' height
  35744. * @returns true if the size was changed
  35745. */
  35746. setSize(width: number, height: number): boolean;
  35747. /**
  35748. * Binds the frame buffer to the specified texture.
  35749. * @param texture The texture to render to or null for the default canvas
  35750. * @param faceIndex The face of the texture to render to in case of cube texture
  35751. * @param requiredWidth The width of the target to render to
  35752. * @param requiredHeight The height of the target to render to
  35753. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35754. * @param lodLevel defines the lod level to bind to the frame buffer
  35755. * @param layer defines the 2d array index to bind to frame buffer to
  35756. */
  35757. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35758. /** @hidden */
  35759. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35760. /**
  35761. * Unbind the current render target texture from the webGL context
  35762. * @param texture defines the render target texture to unbind
  35763. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35764. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35765. */
  35766. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35767. /**
  35768. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35769. */
  35770. flushFramebuffer(): void;
  35771. /**
  35772. * Unbind the current render target and bind the default framebuffer
  35773. */
  35774. restoreDefaultFramebuffer(): void;
  35775. /** @hidden */
  35776. protected _resetVertexBufferBinding(): void;
  35777. /**
  35778. * Creates a vertex buffer
  35779. * @param data the data for the vertex buffer
  35780. * @returns the new WebGL static buffer
  35781. */
  35782. createVertexBuffer(data: DataArray): DataBuffer;
  35783. private _createVertexBuffer;
  35784. /**
  35785. * Creates a dynamic vertex buffer
  35786. * @param data the data for the dynamic vertex buffer
  35787. * @returns the new WebGL dynamic buffer
  35788. */
  35789. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35790. protected _resetIndexBufferBinding(): void;
  35791. /**
  35792. * Creates a new index buffer
  35793. * @param indices defines the content of the index buffer
  35794. * @param updatable defines if the index buffer must be updatable
  35795. * @returns a new webGL buffer
  35796. */
  35797. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35798. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35799. /**
  35800. * Bind a webGL buffer to the webGL context
  35801. * @param buffer defines the buffer to bind
  35802. */
  35803. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35804. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35805. private bindBuffer;
  35806. /**
  35807. * update the bound buffer with the given data
  35808. * @param data defines the data to update
  35809. */
  35810. updateArrayBuffer(data: Float32Array): void;
  35811. private _vertexAttribPointer;
  35812. /** @hidden */
  35813. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35814. private _bindVertexBuffersAttributes;
  35815. /**
  35816. * Records a vertex array object
  35817. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35818. * @param vertexBuffers defines the list of vertex buffers to store
  35819. * @param indexBuffer defines the index buffer to store
  35820. * @param effect defines the effect to store
  35821. * @returns the new vertex array object
  35822. */
  35823. recordVertexArrayObject(vertexBuffers: {
  35824. [key: string]: VertexBuffer;
  35825. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35826. /**
  35827. * Bind a specific vertex array object
  35828. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35829. * @param vertexArrayObject defines the vertex array object to bind
  35830. * @param indexBuffer defines the index buffer to bind
  35831. */
  35832. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35833. /**
  35834. * Bind webGl buffers directly to the webGL context
  35835. * @param vertexBuffer defines the vertex buffer to bind
  35836. * @param indexBuffer defines the index buffer to bind
  35837. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35838. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35839. * @param effect defines the effect associated with the vertex buffer
  35840. */
  35841. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35842. private _unbindVertexArrayObject;
  35843. /**
  35844. * Bind a list of vertex buffers to the webGL context
  35845. * @param vertexBuffers defines the list of vertex buffers to bind
  35846. * @param indexBuffer defines the index buffer to bind
  35847. * @param effect defines the effect associated with the vertex buffers
  35848. */
  35849. bindBuffers(vertexBuffers: {
  35850. [key: string]: Nullable<VertexBuffer>;
  35851. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35852. /**
  35853. * Unbind all instance attributes
  35854. */
  35855. unbindInstanceAttributes(): void;
  35856. /**
  35857. * Release and free the memory of a vertex array object
  35858. * @param vao defines the vertex array object to delete
  35859. */
  35860. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35861. /** @hidden */
  35862. _releaseBuffer(buffer: DataBuffer): boolean;
  35863. protected _deleteBuffer(buffer: DataBuffer): void;
  35864. /**
  35865. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35866. * @param instancesBuffer defines the webGL buffer to update and bind
  35867. * @param data defines the data to store in the buffer
  35868. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35869. */
  35870. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35871. /**
  35872. * Bind the content of a webGL buffer used with instantiation
  35873. * @param instancesBuffer defines the webGL buffer to bind
  35874. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35875. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35876. */
  35877. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35878. /**
  35879. * Disable the instance attribute corresponding to the name in parameter
  35880. * @param name defines the name of the attribute to disable
  35881. */
  35882. disableInstanceAttributeByName(name: string): void;
  35883. /**
  35884. * Disable the instance attribute corresponding to the location in parameter
  35885. * @param attributeLocation defines the attribute location of the attribute to disable
  35886. */
  35887. disableInstanceAttribute(attributeLocation: number): void;
  35888. /**
  35889. * Disable the attribute corresponding to the location in parameter
  35890. * @param attributeLocation defines the attribute location of the attribute to disable
  35891. */
  35892. disableAttributeByIndex(attributeLocation: number): void;
  35893. /**
  35894. * Send a draw order
  35895. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35896. * @param indexStart defines the starting index
  35897. * @param indexCount defines the number of index to draw
  35898. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35899. */
  35900. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35901. /**
  35902. * Draw a list of points
  35903. * @param verticesStart defines the index of first vertex to draw
  35904. * @param verticesCount defines the count of vertices to draw
  35905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35906. */
  35907. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35908. /**
  35909. * Draw a list of unindexed primitives
  35910. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35911. * @param verticesStart defines the index of first vertex to draw
  35912. * @param verticesCount defines the count of vertices to draw
  35913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35914. */
  35915. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35916. /**
  35917. * Draw a list of indexed primitives
  35918. * @param fillMode defines the primitive to use
  35919. * @param indexStart defines the starting index
  35920. * @param indexCount defines the number of index to draw
  35921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35922. */
  35923. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35924. /**
  35925. * Draw a list of unindexed primitives
  35926. * @param fillMode defines the primitive to use
  35927. * @param verticesStart defines the index of first vertex to draw
  35928. * @param verticesCount defines the count of vertices to draw
  35929. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35930. */
  35931. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35932. private _drawMode;
  35933. /** @hidden */
  35934. protected _reportDrawCall(): void;
  35935. /** @hidden */
  35936. _releaseEffect(effect: Effect): void;
  35937. /** @hidden */
  35938. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35939. /**
  35940. * Create a new effect (used to store vertex/fragment shaders)
  35941. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35942. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35943. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35944. * @param samplers defines an array of string used to represent textures
  35945. * @param defines defines the string containing the defines to use to compile the shaders
  35946. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35947. * @param onCompiled defines a function to call when the effect creation is successful
  35948. * @param onError defines a function to call when the effect creation has failed
  35949. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35950. * @returns the new Effect
  35951. */
  35952. 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;
  35953. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35954. private _compileShader;
  35955. private _compileRawShader;
  35956. /** @hidden */
  35957. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35958. /**
  35959. * Directly creates a webGL program
  35960. * @param pipelineContext defines the pipeline context to attach to
  35961. * @param vertexCode defines the vertex shader code to use
  35962. * @param fragmentCode defines the fragment shader code to use
  35963. * @param context defines the webGL context to use (if not set, the current one will be used)
  35964. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35965. * @returns the new webGL program
  35966. */
  35967. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35968. /**
  35969. * Creates a webGL program
  35970. * @param pipelineContext defines the pipeline context to attach to
  35971. * @param vertexCode defines the vertex shader code to use
  35972. * @param fragmentCode defines the fragment shader code to use
  35973. * @param defines defines the string containing the defines to use to compile the shaders
  35974. * @param context defines the webGL context to use (if not set, the current one will be used)
  35975. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35976. * @returns the new webGL program
  35977. */
  35978. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35979. /**
  35980. * Creates a new pipeline context
  35981. * @returns the new pipeline
  35982. */
  35983. createPipelineContext(): IPipelineContext;
  35984. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35985. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35986. /** @hidden */
  35987. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35988. /** @hidden */
  35989. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35990. /** @hidden */
  35991. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35992. /**
  35993. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35994. * @param pipelineContext defines the pipeline context to use
  35995. * @param uniformsNames defines the list of uniform names
  35996. * @returns an array of webGL uniform locations
  35997. */
  35998. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35999. /**
  36000. * Gets the lsit of active attributes for a given webGL program
  36001. * @param pipelineContext defines the pipeline context to use
  36002. * @param attributesNames defines the list of attribute names to get
  36003. * @returns an array of indices indicating the offset of each attribute
  36004. */
  36005. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36006. /**
  36007. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36008. * @param effect defines the effect to activate
  36009. */
  36010. enableEffect(effect: Nullable<Effect>): void;
  36011. /**
  36012. * Set the value of an uniform to a number (int)
  36013. * @param uniform defines the webGL uniform location where to store the value
  36014. * @param value defines the int number to store
  36015. * @returns true if the value was set
  36016. */
  36017. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36018. /**
  36019. * Set the value of an uniform to an array of int32
  36020. * @param uniform defines the webGL uniform location where to store the value
  36021. * @param array defines the array of int32 to store
  36022. * @returns true if the value was set
  36023. */
  36024. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36025. /**
  36026. * Set the value of an uniform to an array of int32 (stored as vec2)
  36027. * @param uniform defines the webGL uniform location where to store the value
  36028. * @param array defines the array of int32 to store
  36029. * @returns true if the value was set
  36030. */
  36031. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36032. /**
  36033. * Set the value of an uniform to an array of int32 (stored as vec3)
  36034. * @param uniform defines the webGL uniform location where to store the value
  36035. * @param array defines the array of int32 to store
  36036. * @returns true if the value was set
  36037. */
  36038. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36039. /**
  36040. * Set the value of an uniform to an array of int32 (stored as vec4)
  36041. * @param uniform defines the webGL uniform location where to store the value
  36042. * @param array defines the array of int32 to store
  36043. * @returns true if the value was set
  36044. */
  36045. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36046. /**
  36047. * Set the value of an uniform to an array of number
  36048. * @param uniform defines the webGL uniform location where to store the value
  36049. * @param array defines the array of number to store
  36050. * @returns true if the value was set
  36051. */
  36052. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36053. /**
  36054. * Set the value of an uniform to an array of number (stored as vec2)
  36055. * @param uniform defines the webGL uniform location where to store the value
  36056. * @param array defines the array of number to store
  36057. * @returns true if the value was set
  36058. */
  36059. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36060. /**
  36061. * Set the value of an uniform to an array of number (stored as vec3)
  36062. * @param uniform defines the webGL uniform location where to store the value
  36063. * @param array defines the array of number to store
  36064. * @returns true if the value was set
  36065. */
  36066. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36067. /**
  36068. * Set the value of an uniform to an array of number (stored as vec4)
  36069. * @param uniform defines the webGL uniform location where to store the value
  36070. * @param array defines the array of number to store
  36071. * @returns true if the value was set
  36072. */
  36073. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36074. /**
  36075. * Set the value of an uniform to an array of float32 (stored as matrices)
  36076. * @param uniform defines the webGL uniform location where to store the value
  36077. * @param matrices defines the array of float32 to store
  36078. * @returns true if the value was set
  36079. */
  36080. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  36081. /**
  36082. * Set the value of an uniform to a matrix (3x3)
  36083. * @param uniform defines the webGL uniform location where to store the value
  36084. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36085. * @returns true if the value was set
  36086. */
  36087. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36088. /**
  36089. * Set the value of an uniform to a matrix (2x2)
  36090. * @param uniform defines the webGL uniform location where to store the value
  36091. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36092. * @returns true if the value was set
  36093. */
  36094. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36095. /**
  36096. * Set the value of an uniform to a number (float)
  36097. * @param uniform defines the webGL uniform location where to store the value
  36098. * @param value defines the float number to store
  36099. * @returns true if the value was transfered
  36100. */
  36101. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36102. /**
  36103. * Set the value of an uniform to a vec2
  36104. * @param uniform defines the webGL uniform location where to store the value
  36105. * @param x defines the 1st component of the value
  36106. * @param y defines the 2nd component of the value
  36107. * @returns true if the value was set
  36108. */
  36109. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  36110. /**
  36111. * Set the value of an uniform to a vec3
  36112. * @param uniform defines the webGL uniform location where to store the value
  36113. * @param x defines the 1st component of the value
  36114. * @param y defines the 2nd component of the value
  36115. * @param z defines the 3rd component of the value
  36116. * @returns true if the value was set
  36117. */
  36118. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  36119. /**
  36120. * Set the value of an uniform to a vec4
  36121. * @param uniform defines the webGL uniform location where to store the value
  36122. * @param x defines the 1st component of the value
  36123. * @param y defines the 2nd component of the value
  36124. * @param z defines the 3rd component of the value
  36125. * @param w defines the 4th component of the value
  36126. * @returns true if the value was set
  36127. */
  36128. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  36129. /**
  36130. * Apply all cached states (depth, culling, stencil and alpha)
  36131. */
  36132. applyStates(): void;
  36133. /**
  36134. * Enable or disable color writing
  36135. * @param enable defines the state to set
  36136. */
  36137. setColorWrite(enable: boolean): void;
  36138. /**
  36139. * Gets a boolean indicating if color writing is enabled
  36140. * @returns the current color writing state
  36141. */
  36142. getColorWrite(): boolean;
  36143. /**
  36144. * Gets the depth culling state manager
  36145. */
  36146. get depthCullingState(): DepthCullingState;
  36147. /**
  36148. * Gets the alpha state manager
  36149. */
  36150. get alphaState(): AlphaState;
  36151. /**
  36152. * Gets the stencil state manager
  36153. */
  36154. get stencilState(): StencilState;
  36155. /**
  36156. * Clears the list of texture accessible through engine.
  36157. * This can help preventing texture load conflict due to name collision.
  36158. */
  36159. clearInternalTexturesCache(): void;
  36160. /**
  36161. * Force the entire cache to be cleared
  36162. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36163. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36164. */
  36165. wipeCaches(bruteForce?: boolean): void;
  36166. /** @hidden */
  36167. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36168. min: number;
  36169. mag: number;
  36170. };
  36171. /** @hidden */
  36172. _createTexture(): WebGLTexture;
  36173. /**
  36174. * Usually called from Texture.ts.
  36175. * Passed information to create a WebGLTexture
  36176. * @param url defines a value which contains one of the following:
  36177. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36178. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36179. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36180. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36181. * @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)
  36182. * @param scene needed for loading to the correct scene
  36183. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36184. * @param onLoad optional callback to be called upon successful completion
  36185. * @param onError optional callback to be called upon failure
  36186. * @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
  36187. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36188. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36189. * @param forcedExtension defines the extension to use to pick the right loader
  36190. * @param mimeType defines an optional mime type
  36191. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36192. */
  36193. 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;
  36194. /**
  36195. * Loads an image as an HTMLImageElement.
  36196. * @param input url string, ArrayBuffer, or Blob to load
  36197. * @param onLoad callback called when the image successfully loads
  36198. * @param onError callback called when the image fails to load
  36199. * @param offlineProvider offline provider for caching
  36200. * @param mimeType optional mime type
  36201. * @returns the HTMLImageElement of the loaded image
  36202. * @hidden
  36203. */
  36204. 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>;
  36205. /**
  36206. * @hidden
  36207. */
  36208. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36209. private _unpackFlipYCached;
  36210. /**
  36211. * In case you are sharing the context with other applications, it might
  36212. * be interested to not cache the unpack flip y state to ensure a consistent
  36213. * value would be set.
  36214. */
  36215. enableUnpackFlipYCached: boolean;
  36216. /** @hidden */
  36217. _unpackFlipY(value: boolean): void;
  36218. /** @hidden */
  36219. _getUnpackAlignement(): number;
  36220. private _getTextureTarget;
  36221. /**
  36222. * Update the sampling mode of a given texture
  36223. * @param samplingMode defines the required sampling mode
  36224. * @param texture defines the texture to update
  36225. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36226. */
  36227. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36228. /**
  36229. * Update the sampling mode of a given texture
  36230. * @param texture defines the texture to update
  36231. * @param wrapU defines the texture wrap mode of the u coordinates
  36232. * @param wrapV defines the texture wrap mode of the v coordinates
  36233. * @param wrapR defines the texture wrap mode of the r coordinates
  36234. */
  36235. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36236. /** @hidden */
  36237. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36238. width: number;
  36239. height: number;
  36240. layers?: number;
  36241. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36242. /** @hidden */
  36243. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36244. /** @hidden */
  36245. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36246. /**
  36247. * Update a portion of an internal texture
  36248. * @param texture defines the texture to update
  36249. * @param imageData defines the data to store into the texture
  36250. * @param xOffset defines the x coordinates of the update rectangle
  36251. * @param yOffset defines the y coordinates of the update rectangle
  36252. * @param width defines the width of the update rectangle
  36253. * @param height defines the height of the update rectangle
  36254. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36255. * @param lod defines the lod level to update (0 by default)
  36256. */
  36257. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36258. /** @hidden */
  36259. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36260. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36261. private _prepareWebGLTexture;
  36262. /** @hidden */
  36263. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36264. private _getDepthStencilBuffer;
  36265. /** @hidden */
  36266. _releaseFramebufferObjects(texture: InternalTexture): void;
  36267. /** @hidden */
  36268. _releaseTexture(texture: InternalTexture): void;
  36269. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36270. protected _setProgram(program: WebGLProgram): void;
  36271. protected _boundUniforms: {
  36272. [key: number]: WebGLUniformLocation;
  36273. };
  36274. /**
  36275. * Binds an effect to the webGL context
  36276. * @param effect defines the effect to bind
  36277. */
  36278. bindSamplers(effect: Effect): void;
  36279. private _activateCurrentTexture;
  36280. /** @hidden */
  36281. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36282. /** @hidden */
  36283. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36284. /**
  36285. * Unbind all textures from the webGL context
  36286. */
  36287. unbindAllTextures(): void;
  36288. /**
  36289. * Sets a texture to the according uniform.
  36290. * @param channel The texture channel
  36291. * @param uniform The uniform to set
  36292. * @param texture The texture to apply
  36293. */
  36294. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36295. private _bindSamplerUniformToChannel;
  36296. private _getTextureWrapMode;
  36297. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36298. /**
  36299. * Sets an array of texture to the webGL context
  36300. * @param channel defines the channel where the texture array must be set
  36301. * @param uniform defines the associated uniform location
  36302. * @param textures defines the array of textures to bind
  36303. */
  36304. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36305. /** @hidden */
  36306. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36307. private _setTextureParameterFloat;
  36308. private _setTextureParameterInteger;
  36309. /**
  36310. * Unbind all vertex attributes from the webGL context
  36311. */
  36312. unbindAllAttributes(): void;
  36313. /**
  36314. * 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
  36315. */
  36316. releaseEffects(): void;
  36317. /**
  36318. * Dispose and release all associated resources
  36319. */
  36320. dispose(): void;
  36321. /**
  36322. * Attach a new callback raised when context lost event is fired
  36323. * @param callback defines the callback to call
  36324. */
  36325. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36326. /**
  36327. * Attach a new callback raised when context restored event is fired
  36328. * @param callback defines the callback to call
  36329. */
  36330. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36331. /**
  36332. * Get the current error code of the webGL context
  36333. * @returns the error code
  36334. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36335. */
  36336. getError(): number;
  36337. private _canRenderToFloatFramebuffer;
  36338. private _canRenderToHalfFloatFramebuffer;
  36339. private _canRenderToFramebuffer;
  36340. /** @hidden */
  36341. _getWebGLTextureType(type: number): number;
  36342. /** @hidden */
  36343. _getInternalFormat(format: number): number;
  36344. /** @hidden */
  36345. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36346. /** @hidden */
  36347. _getRGBAMultiSampleBufferFormat(type: number): number;
  36348. /** @hidden */
  36349. _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;
  36350. /**
  36351. * Loads a file from a url
  36352. * @param url url to load
  36353. * @param onSuccess callback called when the file successfully loads
  36354. * @param onProgress callback called while file is loading (if the server supports this mode)
  36355. * @param offlineProvider defines the offline provider for caching
  36356. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36357. * @param onError callback called when the file fails to load
  36358. * @returns a file request object
  36359. * @hidden
  36360. */
  36361. 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;
  36362. /**
  36363. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36364. * @param x defines the x coordinate of the rectangle where pixels must be read
  36365. * @param y defines the y coordinate of the rectangle where pixels must be read
  36366. * @param width defines the width of the rectangle where pixels must be read
  36367. * @param height defines the height of the rectangle where pixels must be read
  36368. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36369. * @returns a Uint8Array containing RGBA colors
  36370. */
  36371. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36372. private static _isSupported;
  36373. /**
  36374. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36375. * @returns true if the engine can be created
  36376. * @ignorenaming
  36377. */
  36378. static isSupported(): boolean;
  36379. /**
  36380. * Find the next highest power of two.
  36381. * @param x Number to start search from.
  36382. * @return Next highest power of two.
  36383. */
  36384. static CeilingPOT(x: number): number;
  36385. /**
  36386. * Find the next lowest power of two.
  36387. * @param x Number to start search from.
  36388. * @return Next lowest power of two.
  36389. */
  36390. static FloorPOT(x: number): number;
  36391. /**
  36392. * Find the nearest power of two.
  36393. * @param x Number to start search from.
  36394. * @return Next nearest power of two.
  36395. */
  36396. static NearestPOT(x: number): number;
  36397. /**
  36398. * Get the closest exponent of two
  36399. * @param value defines the value to approximate
  36400. * @param max defines the maximum value to return
  36401. * @param mode defines how to define the closest value
  36402. * @returns closest exponent of two of the given value
  36403. */
  36404. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36405. /**
  36406. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36407. * @param func - the function to be called
  36408. * @param requester - the object that will request the next frame. Falls back to window.
  36409. * @returns frame number
  36410. */
  36411. static QueueNewFrame(func: () => void, requester?: any): number;
  36412. /**
  36413. * Gets host document
  36414. * @returns the host document object
  36415. */
  36416. getHostDocument(): Nullable<Document>;
  36417. }
  36418. }
  36419. declare module BABYLON {
  36420. /**
  36421. * Class representing spherical harmonics coefficients to the 3rd degree
  36422. */
  36423. export class SphericalHarmonics {
  36424. /**
  36425. * Defines whether or not the harmonics have been prescaled for rendering.
  36426. */
  36427. preScaled: boolean;
  36428. /**
  36429. * The l0,0 coefficients of the spherical harmonics
  36430. */
  36431. l00: Vector3;
  36432. /**
  36433. * The l1,-1 coefficients of the spherical harmonics
  36434. */
  36435. l1_1: Vector3;
  36436. /**
  36437. * The l1,0 coefficients of the spherical harmonics
  36438. */
  36439. l10: Vector3;
  36440. /**
  36441. * The l1,1 coefficients of the spherical harmonics
  36442. */
  36443. l11: Vector3;
  36444. /**
  36445. * The l2,-2 coefficients of the spherical harmonics
  36446. */
  36447. l2_2: Vector3;
  36448. /**
  36449. * The l2,-1 coefficients of the spherical harmonics
  36450. */
  36451. l2_1: Vector3;
  36452. /**
  36453. * The l2,0 coefficients of the spherical harmonics
  36454. */
  36455. l20: Vector3;
  36456. /**
  36457. * The l2,1 coefficients of the spherical harmonics
  36458. */
  36459. l21: Vector3;
  36460. /**
  36461. * The l2,2 coefficients of the spherical harmonics
  36462. */
  36463. l22: Vector3;
  36464. /**
  36465. * Adds a light to the spherical harmonics
  36466. * @param direction the direction of the light
  36467. * @param color the color of the light
  36468. * @param deltaSolidAngle the delta solid angle of the light
  36469. */
  36470. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36471. /**
  36472. * Scales the spherical harmonics by the given amount
  36473. * @param scale the amount to scale
  36474. */
  36475. scaleInPlace(scale: number): void;
  36476. /**
  36477. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36478. *
  36479. * ```
  36480. * E_lm = A_l * L_lm
  36481. * ```
  36482. *
  36483. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36484. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36485. * the scaling factors are given in equation 9.
  36486. */
  36487. convertIncidentRadianceToIrradiance(): void;
  36488. /**
  36489. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36490. *
  36491. * ```
  36492. * L = (1/pi) * E * rho
  36493. * ```
  36494. *
  36495. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36496. */
  36497. convertIrradianceToLambertianRadiance(): void;
  36498. /**
  36499. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36500. * required operations at run time.
  36501. *
  36502. * This is simply done by scaling back the SH with Ylm constants parameter.
  36503. * The trigonometric part being applied by the shader at run time.
  36504. */
  36505. preScaleForRendering(): void;
  36506. /**
  36507. * Constructs a spherical harmonics from an array.
  36508. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36509. * @returns the spherical harmonics
  36510. */
  36511. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36512. /**
  36513. * Gets the spherical harmonics from polynomial
  36514. * @param polynomial the spherical polynomial
  36515. * @returns the spherical harmonics
  36516. */
  36517. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36518. }
  36519. /**
  36520. * Class representing spherical polynomial coefficients to the 3rd degree
  36521. */
  36522. export class SphericalPolynomial {
  36523. private _harmonics;
  36524. /**
  36525. * The spherical harmonics used to create the polynomials.
  36526. */
  36527. get preScaledHarmonics(): SphericalHarmonics;
  36528. /**
  36529. * The x coefficients of the spherical polynomial
  36530. */
  36531. x: Vector3;
  36532. /**
  36533. * The y coefficients of the spherical polynomial
  36534. */
  36535. y: Vector3;
  36536. /**
  36537. * The z coefficients of the spherical polynomial
  36538. */
  36539. z: Vector3;
  36540. /**
  36541. * The xx coefficients of the spherical polynomial
  36542. */
  36543. xx: Vector3;
  36544. /**
  36545. * The yy coefficients of the spherical polynomial
  36546. */
  36547. yy: Vector3;
  36548. /**
  36549. * The zz coefficients of the spherical polynomial
  36550. */
  36551. zz: Vector3;
  36552. /**
  36553. * The xy coefficients of the spherical polynomial
  36554. */
  36555. xy: Vector3;
  36556. /**
  36557. * The yz coefficients of the spherical polynomial
  36558. */
  36559. yz: Vector3;
  36560. /**
  36561. * The zx coefficients of the spherical polynomial
  36562. */
  36563. zx: Vector3;
  36564. /**
  36565. * Adds an ambient color to the spherical polynomial
  36566. * @param color the color to add
  36567. */
  36568. addAmbient(color: Color3): void;
  36569. /**
  36570. * Scales the spherical polynomial by the given amount
  36571. * @param scale the amount to scale
  36572. */
  36573. scaleInPlace(scale: number): void;
  36574. /**
  36575. * Gets the spherical polynomial from harmonics
  36576. * @param harmonics the spherical harmonics
  36577. * @returns the spherical polynomial
  36578. */
  36579. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36580. /**
  36581. * Constructs a spherical polynomial from an array.
  36582. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36583. * @returns the spherical polynomial
  36584. */
  36585. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36586. }
  36587. }
  36588. declare module BABYLON {
  36589. /**
  36590. * Defines the source of the internal texture
  36591. */
  36592. export enum InternalTextureSource {
  36593. /**
  36594. * The source of the texture data is unknown
  36595. */
  36596. Unknown = 0,
  36597. /**
  36598. * Texture data comes from an URL
  36599. */
  36600. Url = 1,
  36601. /**
  36602. * Texture data is only used for temporary storage
  36603. */
  36604. Temp = 2,
  36605. /**
  36606. * Texture data comes from raw data (ArrayBuffer)
  36607. */
  36608. Raw = 3,
  36609. /**
  36610. * Texture content is dynamic (video or dynamic texture)
  36611. */
  36612. Dynamic = 4,
  36613. /**
  36614. * Texture content is generated by rendering to it
  36615. */
  36616. RenderTarget = 5,
  36617. /**
  36618. * Texture content is part of a multi render target process
  36619. */
  36620. MultiRenderTarget = 6,
  36621. /**
  36622. * Texture data comes from a cube data file
  36623. */
  36624. Cube = 7,
  36625. /**
  36626. * Texture data comes from a raw cube data
  36627. */
  36628. CubeRaw = 8,
  36629. /**
  36630. * Texture data come from a prefiltered cube data file
  36631. */
  36632. CubePrefiltered = 9,
  36633. /**
  36634. * Texture content is raw 3D data
  36635. */
  36636. Raw3D = 10,
  36637. /**
  36638. * Texture content is raw 2D array data
  36639. */
  36640. Raw2DArray = 11,
  36641. /**
  36642. * Texture content is a depth texture
  36643. */
  36644. Depth = 12,
  36645. /**
  36646. * Texture data comes from a raw cube data encoded with RGBD
  36647. */
  36648. CubeRawRGBD = 13
  36649. }
  36650. /**
  36651. * Class used to store data associated with WebGL texture data for the engine
  36652. * This class should not be used directly
  36653. */
  36654. export class InternalTexture {
  36655. /** @hidden */
  36656. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36657. /**
  36658. * Defines if the texture is ready
  36659. */
  36660. isReady: boolean;
  36661. /**
  36662. * Defines if the texture is a cube texture
  36663. */
  36664. isCube: boolean;
  36665. /**
  36666. * Defines if the texture contains 3D data
  36667. */
  36668. is3D: boolean;
  36669. /**
  36670. * Defines if the texture contains 2D array data
  36671. */
  36672. is2DArray: boolean;
  36673. /**
  36674. * Defines if the texture contains multiview data
  36675. */
  36676. isMultiview: boolean;
  36677. /**
  36678. * Gets the URL used to load this texture
  36679. */
  36680. url: string;
  36681. /**
  36682. * Gets the sampling mode of the texture
  36683. */
  36684. samplingMode: number;
  36685. /**
  36686. * Gets a boolean indicating if the texture needs mipmaps generation
  36687. */
  36688. generateMipMaps: boolean;
  36689. /**
  36690. * Gets the number of samples used by the texture (WebGL2+ only)
  36691. */
  36692. samples: number;
  36693. /**
  36694. * Gets the type of the texture (int, float...)
  36695. */
  36696. type: number;
  36697. /**
  36698. * Gets the format of the texture (RGB, RGBA...)
  36699. */
  36700. format: number;
  36701. /**
  36702. * Observable called when the texture is loaded
  36703. */
  36704. onLoadedObservable: Observable<InternalTexture>;
  36705. /**
  36706. * Gets the width of the texture
  36707. */
  36708. width: number;
  36709. /**
  36710. * Gets the height of the texture
  36711. */
  36712. height: number;
  36713. /**
  36714. * Gets the depth of the texture
  36715. */
  36716. depth: number;
  36717. /**
  36718. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36719. */
  36720. baseWidth: number;
  36721. /**
  36722. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36723. */
  36724. baseHeight: number;
  36725. /**
  36726. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36727. */
  36728. baseDepth: number;
  36729. /**
  36730. * Gets a boolean indicating if the texture is inverted on Y axis
  36731. */
  36732. invertY: boolean;
  36733. /** @hidden */
  36734. _invertVScale: boolean;
  36735. /** @hidden */
  36736. _associatedChannel: number;
  36737. /** @hidden */
  36738. _source: InternalTextureSource;
  36739. /** @hidden */
  36740. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36741. /** @hidden */
  36742. _bufferView: Nullable<ArrayBufferView>;
  36743. /** @hidden */
  36744. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36745. /** @hidden */
  36746. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36747. /** @hidden */
  36748. _size: number;
  36749. /** @hidden */
  36750. _extension: string;
  36751. /** @hidden */
  36752. _files: Nullable<string[]>;
  36753. /** @hidden */
  36754. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36755. /** @hidden */
  36756. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36757. /** @hidden */
  36758. _framebuffer: Nullable<WebGLFramebuffer>;
  36759. /** @hidden */
  36760. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36761. /** @hidden */
  36762. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36763. /** @hidden */
  36764. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36765. /** @hidden */
  36766. _attachments: Nullable<number[]>;
  36767. /** @hidden */
  36768. _textureArray: Nullable<InternalTexture[]>;
  36769. /** @hidden */
  36770. _cachedCoordinatesMode: Nullable<number>;
  36771. /** @hidden */
  36772. _cachedWrapU: Nullable<number>;
  36773. /** @hidden */
  36774. _cachedWrapV: Nullable<number>;
  36775. /** @hidden */
  36776. _cachedWrapR: Nullable<number>;
  36777. /** @hidden */
  36778. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36779. /** @hidden */
  36780. _isDisabled: boolean;
  36781. /** @hidden */
  36782. _compression: Nullable<string>;
  36783. /** @hidden */
  36784. _generateStencilBuffer: boolean;
  36785. /** @hidden */
  36786. _generateDepthBuffer: boolean;
  36787. /** @hidden */
  36788. _comparisonFunction: number;
  36789. /** @hidden */
  36790. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36791. /** @hidden */
  36792. _lodGenerationScale: number;
  36793. /** @hidden */
  36794. _lodGenerationOffset: number;
  36795. /** @hidden */
  36796. _depthStencilTexture: Nullable<InternalTexture>;
  36797. /** @hidden */
  36798. _colorTextureArray: Nullable<WebGLTexture>;
  36799. /** @hidden */
  36800. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36801. /** @hidden */
  36802. _lodTextureHigh: Nullable<BaseTexture>;
  36803. /** @hidden */
  36804. _lodTextureMid: Nullable<BaseTexture>;
  36805. /** @hidden */
  36806. _lodTextureLow: Nullable<BaseTexture>;
  36807. /** @hidden */
  36808. _isRGBD: boolean;
  36809. /** @hidden */
  36810. _linearSpecularLOD: boolean;
  36811. /** @hidden */
  36812. _irradianceTexture: Nullable<BaseTexture>;
  36813. /** @hidden */
  36814. _webGLTexture: Nullable<WebGLTexture>;
  36815. /** @hidden */
  36816. _references: number;
  36817. /** @hidden */
  36818. _gammaSpace: Nullable<boolean>;
  36819. private _engine;
  36820. /**
  36821. * Gets the Engine the texture belongs to.
  36822. * @returns The babylon engine
  36823. */
  36824. getEngine(): ThinEngine;
  36825. /**
  36826. * Gets the data source type of the texture
  36827. */
  36828. get source(): InternalTextureSource;
  36829. /**
  36830. * Creates a new InternalTexture
  36831. * @param engine defines the engine to use
  36832. * @param source defines the type of data that will be used
  36833. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36834. */
  36835. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36836. /**
  36837. * Increments the number of references (ie. the number of Texture that point to it)
  36838. */
  36839. incrementReferences(): void;
  36840. /**
  36841. * Change the size of the texture (not the size of the content)
  36842. * @param width defines the new width
  36843. * @param height defines the new height
  36844. * @param depth defines the new depth (1 by default)
  36845. */
  36846. updateSize(width: int, height: int, depth?: int): void;
  36847. /** @hidden */
  36848. _rebuild(): void;
  36849. /** @hidden */
  36850. _swapAndDie(target: InternalTexture): void;
  36851. /**
  36852. * Dispose the current allocated resources
  36853. */
  36854. dispose(): void;
  36855. }
  36856. }
  36857. declare module BABYLON {
  36858. /**
  36859. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36860. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36861. */
  36862. export class Analyser {
  36863. /**
  36864. * Gets or sets the smoothing
  36865. * @ignorenaming
  36866. */
  36867. SMOOTHING: number;
  36868. /**
  36869. * Gets or sets the FFT table size
  36870. * @ignorenaming
  36871. */
  36872. FFT_SIZE: number;
  36873. /**
  36874. * Gets or sets the bar graph amplitude
  36875. * @ignorenaming
  36876. */
  36877. BARGRAPHAMPLITUDE: number;
  36878. /**
  36879. * Gets or sets the position of the debug canvas
  36880. * @ignorenaming
  36881. */
  36882. DEBUGCANVASPOS: {
  36883. x: number;
  36884. y: number;
  36885. };
  36886. /**
  36887. * Gets or sets the debug canvas size
  36888. * @ignorenaming
  36889. */
  36890. DEBUGCANVASSIZE: {
  36891. width: number;
  36892. height: number;
  36893. };
  36894. private _byteFreqs;
  36895. private _byteTime;
  36896. private _floatFreqs;
  36897. private _webAudioAnalyser;
  36898. private _debugCanvas;
  36899. private _debugCanvasContext;
  36900. private _scene;
  36901. private _registerFunc;
  36902. private _audioEngine;
  36903. /**
  36904. * Creates a new analyser
  36905. * @param scene defines hosting scene
  36906. */
  36907. constructor(scene: Scene);
  36908. /**
  36909. * Get the number of data values you will have to play with for the visualization
  36910. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36911. * @returns a number
  36912. */
  36913. getFrequencyBinCount(): number;
  36914. /**
  36915. * Gets the current frequency data as a byte array
  36916. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36917. * @returns a Uint8Array
  36918. */
  36919. getByteFrequencyData(): Uint8Array;
  36920. /**
  36921. * Gets the current waveform as a byte array
  36922. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36923. * @returns a Uint8Array
  36924. */
  36925. getByteTimeDomainData(): Uint8Array;
  36926. /**
  36927. * Gets the current frequency data as a float array
  36928. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36929. * @returns a Float32Array
  36930. */
  36931. getFloatFrequencyData(): Float32Array;
  36932. /**
  36933. * Renders the debug canvas
  36934. */
  36935. drawDebugCanvas(): void;
  36936. /**
  36937. * Stops rendering the debug canvas and removes it
  36938. */
  36939. stopDebugCanvas(): void;
  36940. /**
  36941. * Connects two audio nodes
  36942. * @param inputAudioNode defines first node to connect
  36943. * @param outputAudioNode defines second node to connect
  36944. */
  36945. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36946. /**
  36947. * Releases all associated resources
  36948. */
  36949. dispose(): void;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. /**
  36954. * This represents an audio engine and it is responsible
  36955. * to play, synchronize and analyse sounds throughout the application.
  36956. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36957. */
  36958. export interface IAudioEngine extends IDisposable {
  36959. /**
  36960. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36961. */
  36962. readonly canUseWebAudio: boolean;
  36963. /**
  36964. * Gets the current AudioContext if available.
  36965. */
  36966. readonly audioContext: Nullable<AudioContext>;
  36967. /**
  36968. * The master gain node defines the global audio volume of your audio engine.
  36969. */
  36970. readonly masterGain: GainNode;
  36971. /**
  36972. * Gets whether or not mp3 are supported by your browser.
  36973. */
  36974. readonly isMP3supported: boolean;
  36975. /**
  36976. * Gets whether or not ogg are supported by your browser.
  36977. */
  36978. readonly isOGGsupported: boolean;
  36979. /**
  36980. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36981. * @ignoreNaming
  36982. */
  36983. WarnedWebAudioUnsupported: boolean;
  36984. /**
  36985. * Defines if the audio engine relies on a custom unlocked button.
  36986. * In this case, the embedded button will not be displayed.
  36987. */
  36988. useCustomUnlockedButton: boolean;
  36989. /**
  36990. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36991. */
  36992. readonly unlocked: boolean;
  36993. /**
  36994. * Event raised when audio has been unlocked on the browser.
  36995. */
  36996. onAudioUnlockedObservable: Observable<AudioEngine>;
  36997. /**
  36998. * Event raised when audio has been locked on the browser.
  36999. */
  37000. onAudioLockedObservable: Observable<AudioEngine>;
  37001. /**
  37002. * Flags the audio engine in Locked state.
  37003. * This happens due to new browser policies preventing audio to autoplay.
  37004. */
  37005. lock(): void;
  37006. /**
  37007. * Unlocks the audio engine once a user action has been done on the dom.
  37008. * This is helpful to resume play once browser policies have been satisfied.
  37009. */
  37010. unlock(): void;
  37011. /**
  37012. * Gets the global volume sets on the master gain.
  37013. * @returns the global volume if set or -1 otherwise
  37014. */
  37015. getGlobalVolume(): number;
  37016. /**
  37017. * Sets the global volume of your experience (sets on the master gain).
  37018. * @param newVolume Defines the new global volume of the application
  37019. */
  37020. setGlobalVolume(newVolume: number): void;
  37021. /**
  37022. * Connect the audio engine to an audio analyser allowing some amazing
  37023. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37024. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37025. * @param analyser The analyser to connect to the engine
  37026. */
  37027. connectToAnalyser(analyser: Analyser): void;
  37028. }
  37029. /**
  37030. * This represents the default audio engine used in babylon.
  37031. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37032. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37033. */
  37034. export class AudioEngine implements IAudioEngine {
  37035. private _audioContext;
  37036. private _audioContextInitialized;
  37037. private _muteButton;
  37038. private _hostElement;
  37039. /**
  37040. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37041. */
  37042. canUseWebAudio: boolean;
  37043. /**
  37044. * The master gain node defines the global audio volume of your audio engine.
  37045. */
  37046. masterGain: GainNode;
  37047. /**
  37048. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37049. * @ignoreNaming
  37050. */
  37051. WarnedWebAudioUnsupported: boolean;
  37052. /**
  37053. * Gets whether or not mp3 are supported by your browser.
  37054. */
  37055. isMP3supported: boolean;
  37056. /**
  37057. * Gets whether or not ogg are supported by your browser.
  37058. */
  37059. isOGGsupported: boolean;
  37060. /**
  37061. * Gets whether audio has been unlocked on the device.
  37062. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37063. * a user interaction has happened.
  37064. */
  37065. unlocked: boolean;
  37066. /**
  37067. * Defines if the audio engine relies on a custom unlocked button.
  37068. * In this case, the embedded button will not be displayed.
  37069. */
  37070. useCustomUnlockedButton: boolean;
  37071. /**
  37072. * Event raised when audio has been unlocked on the browser.
  37073. */
  37074. onAudioUnlockedObservable: Observable<AudioEngine>;
  37075. /**
  37076. * Event raised when audio has been locked on the browser.
  37077. */
  37078. onAudioLockedObservable: Observable<AudioEngine>;
  37079. /**
  37080. * Gets the current AudioContext if available.
  37081. */
  37082. get audioContext(): Nullable<AudioContext>;
  37083. private _connectedAnalyser;
  37084. /**
  37085. * Instantiates a new audio engine.
  37086. *
  37087. * There should be only one per page as some browsers restrict the number
  37088. * of audio contexts you can create.
  37089. * @param hostElement defines the host element where to display the mute icon if necessary
  37090. */
  37091. constructor(hostElement?: Nullable<HTMLElement>);
  37092. /**
  37093. * Flags the audio engine in Locked state.
  37094. * This happens due to new browser policies preventing audio to autoplay.
  37095. */
  37096. lock(): void;
  37097. /**
  37098. * Unlocks the audio engine once a user action has been done on the dom.
  37099. * This is helpful to resume play once browser policies have been satisfied.
  37100. */
  37101. unlock(): void;
  37102. private _resumeAudioContext;
  37103. private _initializeAudioContext;
  37104. private _tryToRun;
  37105. private _triggerRunningState;
  37106. private _triggerSuspendedState;
  37107. private _displayMuteButton;
  37108. private _moveButtonToTopLeft;
  37109. private _onResize;
  37110. private _hideMuteButton;
  37111. /**
  37112. * Destroy and release the resources associated with the audio ccontext.
  37113. */
  37114. dispose(): void;
  37115. /**
  37116. * Gets the global volume sets on the master gain.
  37117. * @returns the global volume if set or -1 otherwise
  37118. */
  37119. getGlobalVolume(): number;
  37120. /**
  37121. * Sets the global volume of your experience (sets on the master gain).
  37122. * @param newVolume Defines the new global volume of the application
  37123. */
  37124. setGlobalVolume(newVolume: number): void;
  37125. /**
  37126. * Connect the audio engine to an audio analyser allowing some amazing
  37127. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37129. * @param analyser The analyser to connect to the engine
  37130. */
  37131. connectToAnalyser(analyser: Analyser): void;
  37132. }
  37133. }
  37134. declare module BABYLON {
  37135. /**
  37136. * Interface used to present a loading screen while loading a scene
  37137. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37138. */
  37139. export interface ILoadingScreen {
  37140. /**
  37141. * Function called to display the loading screen
  37142. */
  37143. displayLoadingUI: () => void;
  37144. /**
  37145. * Function called to hide the loading screen
  37146. */
  37147. hideLoadingUI: () => void;
  37148. /**
  37149. * Gets or sets the color to use for the background
  37150. */
  37151. loadingUIBackgroundColor: string;
  37152. /**
  37153. * Gets or sets the text to display while loading
  37154. */
  37155. loadingUIText: string;
  37156. }
  37157. /**
  37158. * Class used for the default loading screen
  37159. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37160. */
  37161. export class DefaultLoadingScreen implements ILoadingScreen {
  37162. private _renderingCanvas;
  37163. private _loadingText;
  37164. private _loadingDivBackgroundColor;
  37165. private _loadingDiv;
  37166. private _loadingTextDiv;
  37167. /** Gets or sets the logo url to use for the default loading screen */
  37168. static DefaultLogoUrl: string;
  37169. /** Gets or sets the spinner url to use for the default loading screen */
  37170. static DefaultSpinnerUrl: string;
  37171. /**
  37172. * Creates a new default loading screen
  37173. * @param _renderingCanvas defines the canvas used to render the scene
  37174. * @param _loadingText defines the default text to display
  37175. * @param _loadingDivBackgroundColor defines the default background color
  37176. */
  37177. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37178. /**
  37179. * Function called to display the loading screen
  37180. */
  37181. displayLoadingUI(): void;
  37182. /**
  37183. * Function called to hide the loading screen
  37184. */
  37185. hideLoadingUI(): void;
  37186. /**
  37187. * Gets or sets the text to display while loading
  37188. */
  37189. set loadingUIText(text: string);
  37190. get loadingUIText(): string;
  37191. /**
  37192. * Gets or sets the color to use for the background
  37193. */
  37194. get loadingUIBackgroundColor(): string;
  37195. set loadingUIBackgroundColor(color: string);
  37196. private _resizeLoadingUI;
  37197. }
  37198. }
  37199. declare module BABYLON {
  37200. /**
  37201. * Interface for any object that can request an animation frame
  37202. */
  37203. export interface ICustomAnimationFrameRequester {
  37204. /**
  37205. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37206. */
  37207. renderFunction?: Function;
  37208. /**
  37209. * Called to request the next frame to render to
  37210. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37211. */
  37212. requestAnimationFrame: Function;
  37213. /**
  37214. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37215. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37216. */
  37217. requestID?: number;
  37218. }
  37219. }
  37220. declare module BABYLON {
  37221. /**
  37222. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37223. */
  37224. export class PerformanceMonitor {
  37225. private _enabled;
  37226. private _rollingFrameTime;
  37227. private _lastFrameTimeMs;
  37228. /**
  37229. * constructor
  37230. * @param frameSampleSize The number of samples required to saturate the sliding window
  37231. */
  37232. constructor(frameSampleSize?: number);
  37233. /**
  37234. * Samples current frame
  37235. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37236. */
  37237. sampleFrame(timeMs?: number): void;
  37238. /**
  37239. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37240. */
  37241. get averageFrameTime(): number;
  37242. /**
  37243. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37244. */
  37245. get averageFrameTimeVariance(): number;
  37246. /**
  37247. * Returns the frame time of the most recent frame
  37248. */
  37249. get instantaneousFrameTime(): number;
  37250. /**
  37251. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37252. */
  37253. get averageFPS(): number;
  37254. /**
  37255. * Returns the average framerate in frames per second using the most recent frame time
  37256. */
  37257. get instantaneousFPS(): number;
  37258. /**
  37259. * Returns true if enough samples have been taken to completely fill the sliding window
  37260. */
  37261. get isSaturated(): boolean;
  37262. /**
  37263. * Enables contributions to the sliding window sample set
  37264. */
  37265. enable(): void;
  37266. /**
  37267. * Disables contributions to the sliding window sample set
  37268. * Samples will not be interpolated over the disabled period
  37269. */
  37270. disable(): void;
  37271. /**
  37272. * Returns true if sampling is enabled
  37273. */
  37274. get isEnabled(): boolean;
  37275. /**
  37276. * Resets performance monitor
  37277. */
  37278. reset(): void;
  37279. }
  37280. /**
  37281. * RollingAverage
  37282. *
  37283. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37284. */
  37285. export class RollingAverage {
  37286. /**
  37287. * Current average
  37288. */
  37289. average: number;
  37290. /**
  37291. * Current variance
  37292. */
  37293. variance: number;
  37294. protected _samples: Array<number>;
  37295. protected _sampleCount: number;
  37296. protected _pos: number;
  37297. protected _m2: number;
  37298. /**
  37299. * constructor
  37300. * @param length The number of samples required to saturate the sliding window
  37301. */
  37302. constructor(length: number);
  37303. /**
  37304. * Adds a sample to the sample set
  37305. * @param v The sample value
  37306. */
  37307. add(v: number): void;
  37308. /**
  37309. * Returns previously added values or null if outside of history or outside the sliding window domain
  37310. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37311. * @return Value previously recorded with add() or null if outside of range
  37312. */
  37313. history(i: number): number;
  37314. /**
  37315. * Returns true if enough samples have been taken to completely fill the sliding window
  37316. * @return true if sample-set saturated
  37317. */
  37318. isSaturated(): boolean;
  37319. /**
  37320. * Resets the rolling average (equivalent to 0 samples taken so far)
  37321. */
  37322. reset(): void;
  37323. /**
  37324. * Wraps a value around the sample range boundaries
  37325. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37326. * @return Wrapped position in sample range
  37327. */
  37328. protected _wrapPosition(i: number): number;
  37329. }
  37330. }
  37331. declare module BABYLON {
  37332. /**
  37333. * This class is used to track a performance counter which is number based.
  37334. * The user has access to many properties which give statistics of different nature.
  37335. *
  37336. * The implementer can track two kinds of Performance Counter: time and count.
  37337. * 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.
  37338. * 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.
  37339. */
  37340. export class PerfCounter {
  37341. /**
  37342. * Gets or sets a global boolean to turn on and off all the counters
  37343. */
  37344. static Enabled: boolean;
  37345. /**
  37346. * Returns the smallest value ever
  37347. */
  37348. get min(): number;
  37349. /**
  37350. * Returns the biggest value ever
  37351. */
  37352. get max(): number;
  37353. /**
  37354. * Returns the average value since the performance counter is running
  37355. */
  37356. get average(): number;
  37357. /**
  37358. * Returns the average value of the last second the counter was monitored
  37359. */
  37360. get lastSecAverage(): number;
  37361. /**
  37362. * Returns the current value
  37363. */
  37364. get current(): number;
  37365. /**
  37366. * Gets the accumulated total
  37367. */
  37368. get total(): number;
  37369. /**
  37370. * Gets the total value count
  37371. */
  37372. get count(): number;
  37373. /**
  37374. * Creates a new counter
  37375. */
  37376. constructor();
  37377. /**
  37378. * Call this method to start monitoring a new frame.
  37379. * 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.
  37380. */
  37381. fetchNewFrame(): void;
  37382. /**
  37383. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37384. * @param newCount the count value to add to the monitored count
  37385. * @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.
  37386. */
  37387. addCount(newCount: number, fetchResult: boolean): void;
  37388. /**
  37389. * Start monitoring this performance counter
  37390. */
  37391. beginMonitoring(): void;
  37392. /**
  37393. * Compute the time lapsed since the previous beginMonitoring() call.
  37394. * @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
  37395. */
  37396. endMonitoring(newFrame?: boolean): void;
  37397. private _fetchResult;
  37398. private _startMonitoringTime;
  37399. private _min;
  37400. private _max;
  37401. private _average;
  37402. private _current;
  37403. private _totalValueCount;
  37404. private _totalAccumulated;
  37405. private _lastSecAverage;
  37406. private _lastSecAccumulated;
  37407. private _lastSecTime;
  37408. private _lastSecValueCount;
  37409. }
  37410. }
  37411. declare module BABYLON {
  37412. interface ThinEngine {
  37413. /** @hidden */
  37414. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37415. }
  37416. }
  37417. declare module BABYLON {
  37418. /**
  37419. * Defines the interface used by display changed events
  37420. */
  37421. export interface IDisplayChangedEventArgs {
  37422. /** Gets the vrDisplay object (if any) */
  37423. vrDisplay: Nullable<any>;
  37424. /** Gets a boolean indicating if webVR is supported */
  37425. vrSupported: boolean;
  37426. }
  37427. /**
  37428. * Defines the interface used by objects containing a viewport (like a camera)
  37429. */
  37430. interface IViewportOwnerLike {
  37431. /**
  37432. * Gets or sets the viewport
  37433. */
  37434. viewport: IViewportLike;
  37435. }
  37436. /**
  37437. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37438. */
  37439. export class Engine extends ThinEngine {
  37440. /** Defines that alpha blending is disabled */
  37441. static readonly ALPHA_DISABLE: number;
  37442. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37443. static readonly ALPHA_ADD: number;
  37444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37445. static readonly ALPHA_COMBINE: number;
  37446. /** Defines that alpha blending to DEST - SRC * DEST */
  37447. static readonly ALPHA_SUBTRACT: number;
  37448. /** Defines that alpha blending to SRC * DEST */
  37449. static readonly ALPHA_MULTIPLY: number;
  37450. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37451. static readonly ALPHA_MAXIMIZED: number;
  37452. /** Defines that alpha blending to SRC + DEST */
  37453. static readonly ALPHA_ONEONE: number;
  37454. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37455. static readonly ALPHA_PREMULTIPLIED: number;
  37456. /**
  37457. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37458. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37459. */
  37460. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37461. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37462. static readonly ALPHA_INTERPOLATE: number;
  37463. /**
  37464. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37465. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37466. */
  37467. static readonly ALPHA_SCREENMODE: number;
  37468. /** Defines that the ressource is not delayed*/
  37469. static readonly DELAYLOADSTATE_NONE: number;
  37470. /** Defines that the ressource was successfully delay loaded */
  37471. static readonly DELAYLOADSTATE_LOADED: number;
  37472. /** Defines that the ressource is currently delay loading */
  37473. static readonly DELAYLOADSTATE_LOADING: number;
  37474. /** Defines that the ressource is delayed and has not started loading */
  37475. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37477. static readonly NEVER: number;
  37478. /** 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 */
  37479. static readonly ALWAYS: number;
  37480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37481. static readonly LESS: number;
  37482. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37483. static readonly EQUAL: number;
  37484. /** 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 */
  37485. static readonly LEQUAL: number;
  37486. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37487. static readonly GREATER: number;
  37488. /** 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 */
  37489. static readonly GEQUAL: number;
  37490. /** 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 */
  37491. static readonly NOTEQUAL: number;
  37492. /** Passed to stencilOperation to specify that stencil value must be kept */
  37493. static readonly KEEP: number;
  37494. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37495. static readonly REPLACE: number;
  37496. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37497. static readonly INCR: number;
  37498. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37499. static readonly DECR: number;
  37500. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37501. static readonly INVERT: number;
  37502. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37503. static readonly INCR_WRAP: number;
  37504. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37505. static readonly DECR_WRAP: number;
  37506. /** Texture is not repeating outside of 0..1 UVs */
  37507. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37508. /** Texture is repeating outside of 0..1 UVs */
  37509. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37510. /** Texture is repeating and mirrored */
  37511. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37512. /** ALPHA */
  37513. static readonly TEXTUREFORMAT_ALPHA: number;
  37514. /** LUMINANCE */
  37515. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37516. /** LUMINANCE_ALPHA */
  37517. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37518. /** RGB */
  37519. static readonly TEXTUREFORMAT_RGB: number;
  37520. /** RGBA */
  37521. static readonly TEXTUREFORMAT_RGBA: number;
  37522. /** RED */
  37523. static readonly TEXTUREFORMAT_RED: number;
  37524. /** RED (2nd reference) */
  37525. static readonly TEXTUREFORMAT_R: number;
  37526. /** RG */
  37527. static readonly TEXTUREFORMAT_RG: number;
  37528. /** RED_INTEGER */
  37529. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37530. /** RED_INTEGER (2nd reference) */
  37531. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37532. /** RG_INTEGER */
  37533. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37534. /** RGB_INTEGER */
  37535. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37536. /** RGBA_INTEGER */
  37537. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37538. /** UNSIGNED_BYTE */
  37539. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37540. /** UNSIGNED_BYTE (2nd reference) */
  37541. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37542. /** FLOAT */
  37543. static readonly TEXTURETYPE_FLOAT: number;
  37544. /** HALF_FLOAT */
  37545. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37546. /** BYTE */
  37547. static readonly TEXTURETYPE_BYTE: number;
  37548. /** SHORT */
  37549. static readonly TEXTURETYPE_SHORT: number;
  37550. /** UNSIGNED_SHORT */
  37551. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37552. /** INT */
  37553. static readonly TEXTURETYPE_INT: number;
  37554. /** UNSIGNED_INT */
  37555. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37556. /** UNSIGNED_SHORT_4_4_4_4 */
  37557. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37558. /** UNSIGNED_SHORT_5_5_5_1 */
  37559. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37560. /** UNSIGNED_SHORT_5_6_5 */
  37561. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37562. /** UNSIGNED_INT_2_10_10_10_REV */
  37563. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37564. /** UNSIGNED_INT_24_8 */
  37565. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37566. /** UNSIGNED_INT_10F_11F_11F_REV */
  37567. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37568. /** UNSIGNED_INT_5_9_9_9_REV */
  37569. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37570. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37571. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37572. /** nearest is mag = nearest and min = nearest and mip = linear */
  37573. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37575. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37576. /** Trilinear is mag = linear and min = linear and mip = linear */
  37577. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37578. /** nearest is mag = nearest and min = nearest and mip = linear */
  37579. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37580. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37581. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37582. /** Trilinear is mag = linear and min = linear and mip = linear */
  37583. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37584. /** mag = nearest and min = nearest and mip = nearest */
  37585. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37586. /** mag = nearest and min = linear and mip = nearest */
  37587. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37588. /** mag = nearest and min = linear and mip = linear */
  37589. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37590. /** mag = nearest and min = linear and mip = none */
  37591. static readonly TEXTURE_NEAREST_LINEAR: number;
  37592. /** mag = nearest and min = nearest and mip = none */
  37593. static readonly TEXTURE_NEAREST_NEAREST: number;
  37594. /** mag = linear and min = nearest and mip = nearest */
  37595. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37596. /** mag = linear and min = nearest and mip = linear */
  37597. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37598. /** mag = linear and min = linear and mip = none */
  37599. static readonly TEXTURE_LINEAR_LINEAR: number;
  37600. /** mag = linear and min = nearest and mip = none */
  37601. static readonly TEXTURE_LINEAR_NEAREST: number;
  37602. /** Explicit coordinates mode */
  37603. static readonly TEXTURE_EXPLICIT_MODE: number;
  37604. /** Spherical coordinates mode */
  37605. static readonly TEXTURE_SPHERICAL_MODE: number;
  37606. /** Planar coordinates mode */
  37607. static readonly TEXTURE_PLANAR_MODE: number;
  37608. /** Cubic coordinates mode */
  37609. static readonly TEXTURE_CUBIC_MODE: number;
  37610. /** Projection coordinates mode */
  37611. static readonly TEXTURE_PROJECTION_MODE: number;
  37612. /** Skybox coordinates mode */
  37613. static readonly TEXTURE_SKYBOX_MODE: number;
  37614. /** Inverse Cubic coordinates mode */
  37615. static readonly TEXTURE_INVCUBIC_MODE: number;
  37616. /** Equirectangular coordinates mode */
  37617. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37618. /** Equirectangular Fixed coordinates mode */
  37619. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37620. /** Equirectangular Fixed Mirrored coordinates mode */
  37621. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37622. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37623. static readonly SCALEMODE_FLOOR: number;
  37624. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37625. static readonly SCALEMODE_NEAREST: number;
  37626. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37627. static readonly SCALEMODE_CEILING: number;
  37628. /**
  37629. * Returns the current npm package of the sdk
  37630. */
  37631. static get NpmPackage(): string;
  37632. /**
  37633. * Returns the current version of the framework
  37634. */
  37635. static get Version(): string;
  37636. /** Gets the list of created engines */
  37637. static get Instances(): Engine[];
  37638. /**
  37639. * Gets the latest created engine
  37640. */
  37641. static get LastCreatedEngine(): Nullable<Engine>;
  37642. /**
  37643. * Gets the latest created scene
  37644. */
  37645. static get LastCreatedScene(): Nullable<Scene>;
  37646. /**
  37647. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37648. * @param flag defines which part of the materials must be marked as dirty
  37649. * @param predicate defines a predicate used to filter which materials should be affected
  37650. */
  37651. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37652. /**
  37653. * Method called to create the default loading screen.
  37654. * This can be overriden in your own app.
  37655. * @param canvas The rendering canvas element
  37656. * @returns The loading screen
  37657. */
  37658. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37659. /**
  37660. * Method called to create the default rescale post process on each engine.
  37661. */
  37662. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37663. /**
  37664. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37665. **/
  37666. enableOfflineSupport: boolean;
  37667. /**
  37668. * 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)
  37669. **/
  37670. disableManifestCheck: boolean;
  37671. /**
  37672. * Gets the list of created scenes
  37673. */
  37674. scenes: Scene[];
  37675. /**
  37676. * Event raised when a new scene is created
  37677. */
  37678. onNewSceneAddedObservable: Observable<Scene>;
  37679. /**
  37680. * Gets the list of created postprocesses
  37681. */
  37682. postProcesses: PostProcess[];
  37683. /**
  37684. * Gets a boolean indicating if the pointer is currently locked
  37685. */
  37686. isPointerLock: boolean;
  37687. /**
  37688. * Observable event triggered each time the rendering canvas is resized
  37689. */
  37690. onResizeObservable: Observable<Engine>;
  37691. /**
  37692. * Observable event triggered each time the canvas loses focus
  37693. */
  37694. onCanvasBlurObservable: Observable<Engine>;
  37695. /**
  37696. * Observable event triggered each time the canvas gains focus
  37697. */
  37698. onCanvasFocusObservable: Observable<Engine>;
  37699. /**
  37700. * Observable event triggered each time the canvas receives pointerout event
  37701. */
  37702. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37703. /**
  37704. * Observable raised when the engine begins a new frame
  37705. */
  37706. onBeginFrameObservable: Observable<Engine>;
  37707. /**
  37708. * If set, will be used to request the next animation frame for the render loop
  37709. */
  37710. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37711. /**
  37712. * Observable raised when the engine ends the current frame
  37713. */
  37714. onEndFrameObservable: Observable<Engine>;
  37715. /**
  37716. * Observable raised when the engine is about to compile a shader
  37717. */
  37718. onBeforeShaderCompilationObservable: Observable<Engine>;
  37719. /**
  37720. * Observable raised when the engine has jsut compiled a shader
  37721. */
  37722. onAfterShaderCompilationObservable: Observable<Engine>;
  37723. /**
  37724. * Gets the audio engine
  37725. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37726. * @ignorenaming
  37727. */
  37728. static audioEngine: IAudioEngine;
  37729. /**
  37730. * Default AudioEngine factory responsible of creating the Audio Engine.
  37731. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37732. */
  37733. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37734. /**
  37735. * Default offline support factory responsible of creating a tool used to store data locally.
  37736. * By default, this will create a Database object if the workload has been embedded.
  37737. */
  37738. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37739. private _loadingScreen;
  37740. private _pointerLockRequested;
  37741. private _rescalePostProcess;
  37742. private _deterministicLockstep;
  37743. private _lockstepMaxSteps;
  37744. private _timeStep;
  37745. protected get _supportsHardwareTextureRescaling(): boolean;
  37746. private _fps;
  37747. private _deltaTime;
  37748. /** @hidden */
  37749. _drawCalls: PerfCounter;
  37750. /** 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 */
  37751. canvasTabIndex: number;
  37752. /**
  37753. * Turn this value on if you want to pause FPS computation when in background
  37754. */
  37755. disablePerformanceMonitorInBackground: boolean;
  37756. private _performanceMonitor;
  37757. /**
  37758. * Gets the performance monitor attached to this engine
  37759. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37760. */
  37761. get performanceMonitor(): PerformanceMonitor;
  37762. private _onFocus;
  37763. private _onBlur;
  37764. private _onCanvasPointerOut;
  37765. private _onCanvasBlur;
  37766. private _onCanvasFocus;
  37767. private _onFullscreenChange;
  37768. private _onPointerLockChange;
  37769. /**
  37770. * Gets the HTML element used to attach event listeners
  37771. * @returns a HTML element
  37772. */
  37773. getInputElement(): Nullable<HTMLElement>;
  37774. /**
  37775. * Creates a new engine
  37776. * @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
  37777. * @param antialias defines enable antialiasing (default: false)
  37778. * @param options defines further options to be sent to the getContext() function
  37779. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37780. */
  37781. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37782. /**
  37783. * Gets current aspect ratio
  37784. * @param viewportOwner defines the camera to use to get the aspect ratio
  37785. * @param useScreen defines if screen size must be used (or the current render target if any)
  37786. * @returns a number defining the aspect ratio
  37787. */
  37788. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37789. /**
  37790. * Gets current screen aspect ratio
  37791. * @returns a number defining the aspect ratio
  37792. */
  37793. getScreenAspectRatio(): number;
  37794. /**
  37795. * Gets the client rect of the HTML canvas attached with the current webGL context
  37796. * @returns a client rectanglee
  37797. */
  37798. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37799. /**
  37800. * Gets the client rect of the HTML element used for events
  37801. * @returns a client rectanglee
  37802. */
  37803. getInputElementClientRect(): Nullable<ClientRect>;
  37804. /**
  37805. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37806. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37807. * @returns true if engine is in deterministic lock step mode
  37808. */
  37809. isDeterministicLockStep(): boolean;
  37810. /**
  37811. * Gets the max steps when engine is running in deterministic lock step
  37812. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37813. * @returns the max steps
  37814. */
  37815. getLockstepMaxSteps(): number;
  37816. /**
  37817. * Returns the time in ms between steps when using deterministic lock step.
  37818. * @returns time step in (ms)
  37819. */
  37820. getTimeStep(): number;
  37821. /**
  37822. * Force the mipmap generation for the given render target texture
  37823. * @param texture defines the render target texture to use
  37824. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37825. */
  37826. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37827. /** States */
  37828. /**
  37829. * Set various states to the webGL context
  37830. * @param culling defines backface culling state
  37831. * @param zOffset defines the value to apply to zOffset (0 by default)
  37832. * @param force defines if states must be applied even if cache is up to date
  37833. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37834. */
  37835. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37836. /**
  37837. * Set the z offset to apply to current rendering
  37838. * @param value defines the offset to apply
  37839. */
  37840. setZOffset(value: number): void;
  37841. /**
  37842. * Gets the current value of the zOffset
  37843. * @returns the current zOffset state
  37844. */
  37845. getZOffset(): number;
  37846. /**
  37847. * Enable or disable depth buffering
  37848. * @param enable defines the state to set
  37849. */
  37850. setDepthBuffer(enable: boolean): void;
  37851. /**
  37852. * Gets a boolean indicating if depth writing is enabled
  37853. * @returns the current depth writing state
  37854. */
  37855. getDepthWrite(): boolean;
  37856. /**
  37857. * Enable or disable depth writing
  37858. * @param enable defines the state to set
  37859. */
  37860. setDepthWrite(enable: boolean): void;
  37861. /**
  37862. * Gets a boolean indicating if stencil buffer is enabled
  37863. * @returns the current stencil buffer state
  37864. */
  37865. getStencilBuffer(): boolean;
  37866. /**
  37867. * Enable or disable the stencil buffer
  37868. * @param enable defines if the stencil buffer must be enabled or disabled
  37869. */
  37870. setStencilBuffer(enable: boolean): void;
  37871. /**
  37872. * Gets the current stencil mask
  37873. * @returns a number defining the new stencil mask to use
  37874. */
  37875. getStencilMask(): number;
  37876. /**
  37877. * Sets the current stencil mask
  37878. * @param mask defines the new stencil mask to use
  37879. */
  37880. setStencilMask(mask: number): void;
  37881. /**
  37882. * Gets the current stencil function
  37883. * @returns a number defining the stencil function to use
  37884. */
  37885. getStencilFunction(): number;
  37886. /**
  37887. * Gets the current stencil reference value
  37888. * @returns a number defining the stencil reference value to use
  37889. */
  37890. getStencilFunctionReference(): number;
  37891. /**
  37892. * Gets the current stencil mask
  37893. * @returns a number defining the stencil mask to use
  37894. */
  37895. getStencilFunctionMask(): number;
  37896. /**
  37897. * Sets the current stencil function
  37898. * @param stencilFunc defines the new stencil function to use
  37899. */
  37900. setStencilFunction(stencilFunc: number): void;
  37901. /**
  37902. * Sets the current stencil reference
  37903. * @param reference defines the new stencil reference to use
  37904. */
  37905. setStencilFunctionReference(reference: number): void;
  37906. /**
  37907. * Sets the current stencil mask
  37908. * @param mask defines the new stencil mask to use
  37909. */
  37910. setStencilFunctionMask(mask: number): void;
  37911. /**
  37912. * Gets the current stencil operation when stencil fails
  37913. * @returns a number defining stencil operation to use when stencil fails
  37914. */
  37915. getStencilOperationFail(): number;
  37916. /**
  37917. * Gets the current stencil operation when depth fails
  37918. * @returns a number defining stencil operation to use when depth fails
  37919. */
  37920. getStencilOperationDepthFail(): number;
  37921. /**
  37922. * Gets the current stencil operation when stencil passes
  37923. * @returns a number defining stencil operation to use when stencil passes
  37924. */
  37925. getStencilOperationPass(): number;
  37926. /**
  37927. * Sets the stencil operation to use when stencil fails
  37928. * @param operation defines the stencil operation to use when stencil fails
  37929. */
  37930. setStencilOperationFail(operation: number): void;
  37931. /**
  37932. * Sets the stencil operation to use when depth fails
  37933. * @param operation defines the stencil operation to use when depth fails
  37934. */
  37935. setStencilOperationDepthFail(operation: number): void;
  37936. /**
  37937. * Sets the stencil operation to use when stencil passes
  37938. * @param operation defines the stencil operation to use when stencil passes
  37939. */
  37940. setStencilOperationPass(operation: number): void;
  37941. /**
  37942. * Sets a boolean indicating if the dithering state is enabled or disabled
  37943. * @param value defines the dithering state
  37944. */
  37945. setDitheringState(value: boolean): void;
  37946. /**
  37947. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37948. * @param value defines the rasterizer state
  37949. */
  37950. setRasterizerState(value: boolean): void;
  37951. /**
  37952. * Gets the current depth function
  37953. * @returns a number defining the depth function
  37954. */
  37955. getDepthFunction(): Nullable<number>;
  37956. /**
  37957. * Sets the current depth function
  37958. * @param depthFunc defines the function to use
  37959. */
  37960. setDepthFunction(depthFunc: number): void;
  37961. /**
  37962. * Sets the current depth function to GREATER
  37963. */
  37964. setDepthFunctionToGreater(): void;
  37965. /**
  37966. * Sets the current depth function to GEQUAL
  37967. */
  37968. setDepthFunctionToGreaterOrEqual(): void;
  37969. /**
  37970. * Sets the current depth function to LESS
  37971. */
  37972. setDepthFunctionToLess(): void;
  37973. /**
  37974. * Sets the current depth function to LEQUAL
  37975. */
  37976. setDepthFunctionToLessOrEqual(): void;
  37977. private _cachedStencilBuffer;
  37978. private _cachedStencilFunction;
  37979. private _cachedStencilMask;
  37980. private _cachedStencilOperationPass;
  37981. private _cachedStencilOperationFail;
  37982. private _cachedStencilOperationDepthFail;
  37983. private _cachedStencilReference;
  37984. /**
  37985. * Caches the the state of the stencil buffer
  37986. */
  37987. cacheStencilState(): void;
  37988. /**
  37989. * Restores the state of the stencil buffer
  37990. */
  37991. restoreStencilState(): void;
  37992. /**
  37993. * Directly set the WebGL Viewport
  37994. * @param x defines the x coordinate of the viewport (in screen space)
  37995. * @param y defines the y coordinate of the viewport (in screen space)
  37996. * @param width defines the width of the viewport (in screen space)
  37997. * @param height defines the height of the viewport (in screen space)
  37998. * @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
  37999. */
  38000. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38001. /**
  38002. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38003. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38004. * @param y defines the y-coordinate of the corner of the clear rectangle
  38005. * @param width defines the width of the clear rectangle
  38006. * @param height defines the height of the clear rectangle
  38007. * @param clearColor defines the clear color
  38008. */
  38009. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38010. /**
  38011. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38012. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38013. * @param y defines the y-coordinate of the corner of the clear rectangle
  38014. * @param width defines the width of the clear rectangle
  38015. * @param height defines the height of the clear rectangle
  38016. */
  38017. enableScissor(x: number, y: number, width: number, height: number): void;
  38018. /**
  38019. * Disable previously set scissor test rectangle
  38020. */
  38021. disableScissor(): void;
  38022. protected _reportDrawCall(): void;
  38023. /**
  38024. * Initializes a webVR display and starts listening to display change events
  38025. * The onVRDisplayChangedObservable will be notified upon these changes
  38026. * @returns The onVRDisplayChangedObservable
  38027. */
  38028. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38029. /** @hidden */
  38030. _prepareVRComponent(): void;
  38031. /** @hidden */
  38032. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38033. /** @hidden */
  38034. _submitVRFrame(): void;
  38035. /**
  38036. * Call this function to leave webVR mode
  38037. * Will do nothing if webVR is not supported or if there is no webVR device
  38038. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38039. */
  38040. disableVR(): void;
  38041. /**
  38042. * Gets a boolean indicating that the system is in VR mode and is presenting
  38043. * @returns true if VR mode is engaged
  38044. */
  38045. isVRPresenting(): boolean;
  38046. /** @hidden */
  38047. _requestVRFrame(): void;
  38048. /** @hidden */
  38049. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38050. /**
  38051. * Gets the source code of the vertex shader associated with a specific webGL program
  38052. * @param program defines the program to use
  38053. * @returns a string containing the source code of the vertex shader associated with the program
  38054. */
  38055. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38056. /**
  38057. * Gets the source code of the fragment shader associated with a specific webGL program
  38058. * @param program defines the program to use
  38059. * @returns a string containing the source code of the fragment shader associated with the program
  38060. */
  38061. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38062. /**
  38063. * Sets a depth stencil texture from a render target to the according uniform.
  38064. * @param channel The texture channel
  38065. * @param uniform The uniform to set
  38066. * @param texture The render target texture containing the depth stencil texture to apply
  38067. */
  38068. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38069. /**
  38070. * Sets a texture to the webGL context from a postprocess
  38071. * @param channel defines the channel to use
  38072. * @param postProcess defines the source postprocess
  38073. */
  38074. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38075. /**
  38076. * Binds the output of the passed in post process to the texture channel specified
  38077. * @param channel The channel the texture should be bound to
  38078. * @param postProcess The post process which's output should be bound
  38079. */
  38080. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38081. protected _rebuildBuffers(): void;
  38082. /** @hidden */
  38083. _renderFrame(): void;
  38084. _renderLoop(): void;
  38085. /** @hidden */
  38086. _renderViews(): boolean;
  38087. /**
  38088. * Toggle full screen mode
  38089. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38090. */
  38091. switchFullscreen(requestPointerLock: boolean): void;
  38092. /**
  38093. * Enters full screen mode
  38094. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38095. */
  38096. enterFullscreen(requestPointerLock: boolean): void;
  38097. /**
  38098. * Exits full screen mode
  38099. */
  38100. exitFullscreen(): void;
  38101. /**
  38102. * Enters Pointerlock mode
  38103. */
  38104. enterPointerlock(): void;
  38105. /**
  38106. * Exits Pointerlock mode
  38107. */
  38108. exitPointerlock(): void;
  38109. /**
  38110. * Begin a new frame
  38111. */
  38112. beginFrame(): void;
  38113. /**
  38114. * Enf the current frame
  38115. */
  38116. endFrame(): void;
  38117. resize(): void;
  38118. /**
  38119. * Force a specific size of the canvas
  38120. * @param width defines the new canvas' width
  38121. * @param height defines the new canvas' height
  38122. * @returns true if the size was changed
  38123. */
  38124. setSize(width: number, height: number): boolean;
  38125. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38126. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38127. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38128. _releaseTexture(texture: InternalTexture): void;
  38129. /**
  38130. * @hidden
  38131. * Rescales a texture
  38132. * @param source input texutre
  38133. * @param destination destination texture
  38134. * @param scene scene to use to render the resize
  38135. * @param internalFormat format to use when resizing
  38136. * @param onComplete callback to be called when resize has completed
  38137. */
  38138. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38139. /**
  38140. * Gets the current framerate
  38141. * @returns a number representing the framerate
  38142. */
  38143. getFps(): number;
  38144. /**
  38145. * Gets the time spent between current and previous frame
  38146. * @returns a number representing the delta time in ms
  38147. */
  38148. getDeltaTime(): number;
  38149. private _measureFps;
  38150. /** @hidden */
  38151. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38152. /**
  38153. * Updates the sample count of a render target texture
  38154. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38155. * @param texture defines the texture to update
  38156. * @param samples defines the sample count to set
  38157. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38158. */
  38159. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38160. /**
  38161. * Updates a depth texture Comparison Mode and Function.
  38162. * If the comparison Function is equal to 0, the mode will be set to none.
  38163. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38164. * @param texture The texture to set the comparison function for
  38165. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38166. */
  38167. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38168. /**
  38169. * Creates a webGL buffer to use with instanciation
  38170. * @param capacity defines the size of the buffer
  38171. * @returns the webGL buffer
  38172. */
  38173. createInstancesBuffer(capacity: number): DataBuffer;
  38174. /**
  38175. * Delete a webGL buffer used with instanciation
  38176. * @param buffer defines the webGL buffer to delete
  38177. */
  38178. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38179. private _clientWaitAsync;
  38180. /** @hidden */
  38181. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38182. dispose(): void;
  38183. private _disableTouchAction;
  38184. /**
  38185. * Display the loading screen
  38186. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38187. */
  38188. displayLoadingUI(): void;
  38189. /**
  38190. * Hide the loading screen
  38191. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38192. */
  38193. hideLoadingUI(): void;
  38194. /**
  38195. * Gets the current loading screen object
  38196. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38197. */
  38198. get loadingScreen(): ILoadingScreen;
  38199. /**
  38200. * Sets the current loading screen object
  38201. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38202. */
  38203. set loadingScreen(loadingScreen: ILoadingScreen);
  38204. /**
  38205. * Sets the current loading screen text
  38206. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38207. */
  38208. set loadingUIText(text: string);
  38209. /**
  38210. * Sets the current loading screen background color
  38211. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38212. */
  38213. set loadingUIBackgroundColor(color: string);
  38214. /** Pointerlock and fullscreen */
  38215. /**
  38216. * Ask the browser to promote the current element to pointerlock mode
  38217. * @param element defines the DOM element to promote
  38218. */
  38219. static _RequestPointerlock(element: HTMLElement): void;
  38220. /**
  38221. * Asks the browser to exit pointerlock mode
  38222. */
  38223. static _ExitPointerlock(): void;
  38224. /**
  38225. * Ask the browser to promote the current element to fullscreen rendering mode
  38226. * @param element defines the DOM element to promote
  38227. */
  38228. static _RequestFullscreen(element: HTMLElement): void;
  38229. /**
  38230. * Asks the browser to exit fullscreen mode
  38231. */
  38232. static _ExitFullscreen(): void;
  38233. }
  38234. }
  38235. declare module BABYLON {
  38236. /**
  38237. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38238. * during the life time of the application.
  38239. */
  38240. export class EngineStore {
  38241. /** Gets the list of created engines */
  38242. static Instances: Engine[];
  38243. /** @hidden */
  38244. static _LastCreatedScene: Nullable<Scene>;
  38245. /**
  38246. * Gets the latest created engine
  38247. */
  38248. static get LastCreatedEngine(): Nullable<Engine>;
  38249. /**
  38250. * Gets the latest created scene
  38251. */
  38252. static get LastCreatedScene(): Nullable<Scene>;
  38253. /**
  38254. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38255. * @ignorenaming
  38256. */
  38257. static UseFallbackTexture: boolean;
  38258. /**
  38259. * Texture content used if a texture cannot loaded
  38260. * @ignorenaming
  38261. */
  38262. static FallbackTexture: string;
  38263. }
  38264. }
  38265. declare module BABYLON {
  38266. /**
  38267. * Helper class that provides a small promise polyfill
  38268. */
  38269. export class PromisePolyfill {
  38270. /**
  38271. * Static function used to check if the polyfill is required
  38272. * If this is the case then the function will inject the polyfill to window.Promise
  38273. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38274. */
  38275. static Apply(force?: boolean): void;
  38276. }
  38277. }
  38278. declare module BABYLON {
  38279. /**
  38280. * Interface for screenshot methods with describe argument called `size` as object with options
  38281. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38282. */
  38283. export interface IScreenshotSize {
  38284. /**
  38285. * number in pixels for canvas height
  38286. */
  38287. height?: number;
  38288. /**
  38289. * multiplier allowing render at a higher or lower resolution
  38290. * If value is defined then height and width will be ignored and taken from camera
  38291. */
  38292. precision?: number;
  38293. /**
  38294. * number in pixels for canvas width
  38295. */
  38296. width?: number;
  38297. }
  38298. }
  38299. declare module BABYLON {
  38300. interface IColor4Like {
  38301. r: float;
  38302. g: float;
  38303. b: float;
  38304. a: float;
  38305. }
  38306. /**
  38307. * Class containing a set of static utilities functions
  38308. */
  38309. export class Tools {
  38310. /**
  38311. * Gets or sets the base URL to use to load assets
  38312. */
  38313. static get BaseUrl(): string;
  38314. static set BaseUrl(value: string);
  38315. /**
  38316. * Enable/Disable Custom HTTP Request Headers globally.
  38317. * default = false
  38318. * @see CustomRequestHeaders
  38319. */
  38320. static UseCustomRequestHeaders: boolean;
  38321. /**
  38322. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38323. * i.e. when loading files, where the server/service expects an Authorization header
  38324. */
  38325. static CustomRequestHeaders: {
  38326. [key: string]: string;
  38327. };
  38328. /**
  38329. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38330. */
  38331. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38332. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38333. /**
  38334. * Default behaviour for cors in the application.
  38335. * It can be a string if the expected behavior is identical in the entire app.
  38336. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38337. */
  38338. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38339. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38340. /**
  38341. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38342. * @ignorenaming
  38343. */
  38344. static get UseFallbackTexture(): boolean;
  38345. static set UseFallbackTexture(value: boolean);
  38346. /**
  38347. * Use this object to register external classes like custom textures or material
  38348. * to allow the laoders to instantiate them
  38349. */
  38350. static get RegisteredExternalClasses(): {
  38351. [key: string]: Object;
  38352. };
  38353. static set RegisteredExternalClasses(classes: {
  38354. [key: string]: Object;
  38355. });
  38356. /**
  38357. * Texture content used if a texture cannot loaded
  38358. * @ignorenaming
  38359. */
  38360. static get fallbackTexture(): string;
  38361. static set fallbackTexture(value: string);
  38362. /**
  38363. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38364. * @param u defines the coordinate on X axis
  38365. * @param v defines the coordinate on Y axis
  38366. * @param width defines the width of the source data
  38367. * @param height defines the height of the source data
  38368. * @param pixels defines the source byte array
  38369. * @param color defines the output color
  38370. */
  38371. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38372. /**
  38373. * Interpolates between a and b via alpha
  38374. * @param a The lower value (returned when alpha = 0)
  38375. * @param b The upper value (returned when alpha = 1)
  38376. * @param alpha The interpolation-factor
  38377. * @return The mixed value
  38378. */
  38379. static Mix(a: number, b: number, alpha: number): number;
  38380. /**
  38381. * Tries to instantiate a new object from a given class name
  38382. * @param className defines the class name to instantiate
  38383. * @returns the new object or null if the system was not able to do the instantiation
  38384. */
  38385. static Instantiate(className: string): any;
  38386. /**
  38387. * Provides a slice function that will work even on IE
  38388. * @param data defines the array to slice
  38389. * @param start defines the start of the data (optional)
  38390. * @param end defines the end of the data (optional)
  38391. * @returns the new sliced array
  38392. */
  38393. static Slice<T>(data: T, start?: number, end?: number): T;
  38394. /**
  38395. * Polyfill for setImmediate
  38396. * @param action defines the action to execute after the current execution block
  38397. */
  38398. static SetImmediate(action: () => void): void;
  38399. /**
  38400. * Function indicating if a number is an exponent of 2
  38401. * @param value defines the value to test
  38402. * @returns true if the value is an exponent of 2
  38403. */
  38404. static IsExponentOfTwo(value: number): boolean;
  38405. private static _tmpFloatArray;
  38406. /**
  38407. * Returns the nearest 32-bit single precision float representation of a Number
  38408. * @param value A Number. If the parameter is of a different type, it will get converted
  38409. * to a number or to NaN if it cannot be converted
  38410. * @returns number
  38411. */
  38412. static FloatRound(value: number): number;
  38413. /**
  38414. * Extracts the filename from a path
  38415. * @param path defines the path to use
  38416. * @returns the filename
  38417. */
  38418. static GetFilename(path: string): string;
  38419. /**
  38420. * Extracts the "folder" part of a path (everything before the filename).
  38421. * @param uri The URI to extract the info from
  38422. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38423. * @returns The "folder" part of the path
  38424. */
  38425. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38426. /**
  38427. * Extracts text content from a DOM element hierarchy
  38428. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38429. */
  38430. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38431. /**
  38432. * Convert an angle in radians to degrees
  38433. * @param angle defines the angle to convert
  38434. * @returns the angle in degrees
  38435. */
  38436. static ToDegrees(angle: number): number;
  38437. /**
  38438. * Convert an angle in degrees to radians
  38439. * @param angle defines the angle to convert
  38440. * @returns the angle in radians
  38441. */
  38442. static ToRadians(angle: number): number;
  38443. /**
  38444. * Returns an array if obj is not an array
  38445. * @param obj defines the object to evaluate as an array
  38446. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38447. * @returns either obj directly if obj is an array or a new array containing obj
  38448. */
  38449. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38450. /**
  38451. * Gets the pointer prefix to use
  38452. * @param engine defines the engine we are finding the prefix for
  38453. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38454. */
  38455. static GetPointerPrefix(engine: Engine): string;
  38456. /**
  38457. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38458. * @param url define the url we are trying
  38459. * @param element define the dom element where to configure the cors policy
  38460. */
  38461. static SetCorsBehavior(url: string | string[], element: {
  38462. crossOrigin: string | null;
  38463. }): void;
  38464. /**
  38465. * Removes unwanted characters from an url
  38466. * @param url defines the url to clean
  38467. * @returns the cleaned url
  38468. */
  38469. static CleanUrl(url: string): string;
  38470. /**
  38471. * Gets or sets a function used to pre-process url before using them to load assets
  38472. */
  38473. static get PreprocessUrl(): (url: string) => string;
  38474. static set PreprocessUrl(processor: (url: string) => string);
  38475. /**
  38476. * Loads an image as an HTMLImageElement.
  38477. * @param input url string, ArrayBuffer, or Blob to load
  38478. * @param onLoad callback called when the image successfully loads
  38479. * @param onError callback called when the image fails to load
  38480. * @param offlineProvider offline provider for caching
  38481. * @param mimeType optional mime type
  38482. * @returns the HTMLImageElement of the loaded image
  38483. */
  38484. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38485. /**
  38486. * Loads a file from a url
  38487. * @param url url string, ArrayBuffer, or Blob to load
  38488. * @param onSuccess callback called when the file successfully loads
  38489. * @param onProgress callback called while file is loading (if the server supports this mode)
  38490. * @param offlineProvider defines the offline provider for caching
  38491. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38492. * @param onError callback called when the file fails to load
  38493. * @returns a file request object
  38494. */
  38495. 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;
  38496. /**
  38497. * Loads a file from a url
  38498. * @param url the file url to load
  38499. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38500. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38501. */
  38502. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38503. /**
  38504. * Load a script (identified by an url). When the url returns, the
  38505. * content of this file is added into a new script element, attached to the DOM (body element)
  38506. * @param scriptUrl defines the url of the script to laod
  38507. * @param onSuccess defines the callback called when the script is loaded
  38508. * @param onError defines the callback to call if an error occurs
  38509. * @param scriptId defines the id of the script element
  38510. */
  38511. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38512. /**
  38513. * Load an asynchronous script (identified by an url). When the url returns, the
  38514. * content of this file is added into a new script element, attached to the DOM (body element)
  38515. * @param scriptUrl defines the url of the script to laod
  38516. * @param scriptId defines the id of the script element
  38517. * @returns a promise request object
  38518. */
  38519. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38520. /**
  38521. * Loads a file from a blob
  38522. * @param fileToLoad defines the blob to use
  38523. * @param callback defines the callback to call when data is loaded
  38524. * @param progressCallback defines the callback to call during loading process
  38525. * @returns a file request object
  38526. */
  38527. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38528. /**
  38529. * Reads a file from a File object
  38530. * @param file defines the file to load
  38531. * @param onSuccess defines the callback to call when data is loaded
  38532. * @param onProgress defines the callback to call during loading process
  38533. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38534. * @param onError defines the callback to call when an error occurs
  38535. * @returns a file request object
  38536. */
  38537. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38538. /**
  38539. * Creates a data url from a given string content
  38540. * @param content defines the content to convert
  38541. * @returns the new data url link
  38542. */
  38543. static FileAsURL(content: string): string;
  38544. /**
  38545. * Format the given number to a specific decimal format
  38546. * @param value defines the number to format
  38547. * @param decimals defines the number of decimals to use
  38548. * @returns the formatted string
  38549. */
  38550. static Format(value: number, decimals?: number): string;
  38551. /**
  38552. * Tries to copy an object by duplicating every property
  38553. * @param source defines the source object
  38554. * @param destination defines the target object
  38555. * @param doNotCopyList defines a list of properties to avoid
  38556. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38557. */
  38558. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38559. /**
  38560. * Gets a boolean indicating if the given object has no own property
  38561. * @param obj defines the object to test
  38562. * @returns true if object has no own property
  38563. */
  38564. static IsEmpty(obj: any): boolean;
  38565. /**
  38566. * Function used to register events at window level
  38567. * @param windowElement defines the Window object to use
  38568. * @param events defines the events to register
  38569. */
  38570. static RegisterTopRootEvents(windowElement: Window, events: {
  38571. name: string;
  38572. handler: Nullable<(e: FocusEvent) => any>;
  38573. }[]): void;
  38574. /**
  38575. * Function used to unregister events from window level
  38576. * @param windowElement defines the Window object to use
  38577. * @param events defines the events to unregister
  38578. */
  38579. static UnregisterTopRootEvents(windowElement: Window, events: {
  38580. name: string;
  38581. handler: Nullable<(e: FocusEvent) => any>;
  38582. }[]): void;
  38583. /**
  38584. * @ignore
  38585. */
  38586. static _ScreenshotCanvas: HTMLCanvasElement;
  38587. /**
  38588. * Dumps the current bound framebuffer
  38589. * @param width defines the rendering width
  38590. * @param height defines the rendering height
  38591. * @param engine defines the hosting engine
  38592. * @param successCallback defines the callback triggered once the data are available
  38593. * @param mimeType defines the mime type of the result
  38594. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38595. */
  38596. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38597. /**
  38598. * Converts the canvas data to blob.
  38599. * This acts as a polyfill for browsers not supporting the to blob function.
  38600. * @param canvas Defines the canvas to extract the data from
  38601. * @param successCallback Defines the callback triggered once the data are available
  38602. * @param mimeType Defines the mime type of the result
  38603. */
  38604. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38605. /**
  38606. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38607. * @param successCallback defines the callback triggered once the data are available
  38608. * @param mimeType defines the mime type of the result
  38609. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38610. */
  38611. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38612. /**
  38613. * Downloads a blob in the browser
  38614. * @param blob defines the blob to download
  38615. * @param fileName defines the name of the downloaded file
  38616. */
  38617. static Download(blob: Blob, fileName: string): void;
  38618. /**
  38619. * Captures a screenshot of the current rendering
  38620. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38621. * @param engine defines the rendering engine
  38622. * @param camera defines the source camera
  38623. * @param size This parameter can be set to a single number or to an object with the
  38624. * following (optional) properties: precision, width, height. If a single number is passed,
  38625. * it will be used for both width and height. If an object is passed, the screenshot size
  38626. * will be derived from the parameters. The precision property is a multiplier allowing
  38627. * rendering at a higher or lower resolution
  38628. * @param successCallback defines the callback receives a single parameter which contains the
  38629. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38630. * src parameter of an <img> to display it
  38631. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38632. * Check your browser for supported MIME types
  38633. */
  38634. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38635. /**
  38636. * Captures a screenshot of the current rendering
  38637. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38638. * @param engine defines the rendering engine
  38639. * @param camera defines the source camera
  38640. * @param size This parameter can be set to a single number or to an object with the
  38641. * following (optional) properties: precision, width, height. If a single number is passed,
  38642. * it will be used for both width and height. If an object is passed, the screenshot size
  38643. * will be derived from the parameters. The precision property is a multiplier allowing
  38644. * rendering at a higher or lower resolution
  38645. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38646. * Check your browser for supported MIME types
  38647. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38648. * to the src parameter of an <img> to display it
  38649. */
  38650. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38651. /**
  38652. * Generates an image screenshot from the specified camera.
  38653. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38654. * @param engine The engine to use for rendering
  38655. * @param camera The camera to use for rendering
  38656. * @param size This parameter can be set to a single number or to an object with the
  38657. * following (optional) properties: precision, width, height. If a single number is passed,
  38658. * it will be used for both width and height. If an object is passed, the screenshot size
  38659. * will be derived from the parameters. The precision property is a multiplier allowing
  38660. * rendering at a higher or lower resolution
  38661. * @param successCallback The callback receives a single parameter which contains the
  38662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38663. * src parameter of an <img> to display it
  38664. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38665. * Check your browser for supported MIME types
  38666. * @param samples Texture samples (default: 1)
  38667. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38668. * @param fileName A name for for the downloaded file.
  38669. */
  38670. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38671. /**
  38672. * Generates an image screenshot from the specified camera.
  38673. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38674. * @param engine The engine to use for rendering
  38675. * @param camera The camera to use for rendering
  38676. * @param size This parameter can be set to a single number or to an object with the
  38677. * following (optional) properties: precision, width, height. If a single number is passed,
  38678. * it will be used for both width and height. If an object is passed, the screenshot size
  38679. * will be derived from the parameters. The precision property is a multiplier allowing
  38680. * rendering at a higher or lower resolution
  38681. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38682. * Check your browser for supported MIME types
  38683. * @param samples Texture samples (default: 1)
  38684. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38685. * @param fileName A name for for the downloaded file.
  38686. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38687. * to the src parameter of an <img> to display it
  38688. */
  38689. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38690. /**
  38691. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38692. * Be aware Math.random() could cause collisions, but:
  38693. * "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"
  38694. * @returns a pseudo random id
  38695. */
  38696. static RandomId(): string;
  38697. /**
  38698. * Test if the given uri is a base64 string
  38699. * @param uri The uri to test
  38700. * @return True if the uri is a base64 string or false otherwise
  38701. */
  38702. static IsBase64(uri: string): boolean;
  38703. /**
  38704. * Decode the given base64 uri.
  38705. * @param uri The uri to decode
  38706. * @return The decoded base64 data.
  38707. */
  38708. static DecodeBase64(uri: string): ArrayBuffer;
  38709. /**
  38710. * Gets the absolute url.
  38711. * @param url the input url
  38712. * @return the absolute url
  38713. */
  38714. static GetAbsoluteUrl(url: string): string;
  38715. /**
  38716. * No log
  38717. */
  38718. static readonly NoneLogLevel: number;
  38719. /**
  38720. * Only message logs
  38721. */
  38722. static readonly MessageLogLevel: number;
  38723. /**
  38724. * Only warning logs
  38725. */
  38726. static readonly WarningLogLevel: number;
  38727. /**
  38728. * Only error logs
  38729. */
  38730. static readonly ErrorLogLevel: number;
  38731. /**
  38732. * All logs
  38733. */
  38734. static readonly AllLogLevel: number;
  38735. /**
  38736. * Gets a value indicating the number of loading errors
  38737. * @ignorenaming
  38738. */
  38739. static get errorsCount(): number;
  38740. /**
  38741. * Callback called when a new log is added
  38742. */
  38743. static OnNewCacheEntry: (entry: string) => void;
  38744. /**
  38745. * Log a message to the console
  38746. * @param message defines the message to log
  38747. */
  38748. static Log(message: string): void;
  38749. /**
  38750. * Write a warning message to the console
  38751. * @param message defines the message to log
  38752. */
  38753. static Warn(message: string): void;
  38754. /**
  38755. * Write an error message to the console
  38756. * @param message defines the message to log
  38757. */
  38758. static Error(message: string): void;
  38759. /**
  38760. * Gets current log cache (list of logs)
  38761. */
  38762. static get LogCache(): string;
  38763. /**
  38764. * Clears the log cache
  38765. */
  38766. static ClearLogCache(): void;
  38767. /**
  38768. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38769. */
  38770. static set LogLevels(level: number);
  38771. /**
  38772. * Checks if the window object exists
  38773. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38774. */
  38775. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38776. /**
  38777. * No performance log
  38778. */
  38779. static readonly PerformanceNoneLogLevel: number;
  38780. /**
  38781. * Use user marks to log performance
  38782. */
  38783. static readonly PerformanceUserMarkLogLevel: number;
  38784. /**
  38785. * Log performance to the console
  38786. */
  38787. static readonly PerformanceConsoleLogLevel: number;
  38788. private static _performance;
  38789. /**
  38790. * Sets the current performance log level
  38791. */
  38792. static set PerformanceLogLevel(level: number);
  38793. private static _StartPerformanceCounterDisabled;
  38794. private static _EndPerformanceCounterDisabled;
  38795. private static _StartUserMark;
  38796. private static _EndUserMark;
  38797. private static _StartPerformanceConsole;
  38798. private static _EndPerformanceConsole;
  38799. /**
  38800. * Starts a performance counter
  38801. */
  38802. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38803. /**
  38804. * Ends a specific performance coutner
  38805. */
  38806. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38807. /**
  38808. * Gets either window.performance.now() if supported or Date.now() else
  38809. */
  38810. static get Now(): number;
  38811. /**
  38812. * This method will return the name of the class used to create the instance of the given object.
  38813. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38814. * @param object the object to get the class name from
  38815. * @param isType defines if the object is actually a type
  38816. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38817. */
  38818. static GetClassName(object: any, isType?: boolean): string;
  38819. /**
  38820. * Gets the first element of an array satisfying a given predicate
  38821. * @param array defines the array to browse
  38822. * @param predicate defines the predicate to use
  38823. * @returns null if not found or the element
  38824. */
  38825. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38826. /**
  38827. * This method will return the name of the full name of the class, including its owning module (if any).
  38828. * 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).
  38829. * @param object the object to get the class name from
  38830. * @param isType defines if the object is actually a type
  38831. * @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.
  38832. * @ignorenaming
  38833. */
  38834. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38835. /**
  38836. * Returns a promise that resolves after the given amount of time.
  38837. * @param delay Number of milliseconds to delay
  38838. * @returns Promise that resolves after the given amount of time
  38839. */
  38840. static DelayAsync(delay: number): Promise<void>;
  38841. /**
  38842. * Utility function to detect if the current user agent is Safari
  38843. * @returns whether or not the current user agent is safari
  38844. */
  38845. static IsSafari(): boolean;
  38846. }
  38847. /**
  38848. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38849. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38850. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38851. * @param name The name of the class, case should be preserved
  38852. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38853. */
  38854. export function className(name: string, module?: string): (target: Object) => void;
  38855. /**
  38856. * An implementation of a loop for asynchronous functions.
  38857. */
  38858. export class AsyncLoop {
  38859. /**
  38860. * Defines the number of iterations for the loop
  38861. */
  38862. iterations: number;
  38863. /**
  38864. * Defines the current index of the loop.
  38865. */
  38866. index: number;
  38867. private _done;
  38868. private _fn;
  38869. private _successCallback;
  38870. /**
  38871. * Constructor.
  38872. * @param iterations the number of iterations.
  38873. * @param func the function to run each iteration
  38874. * @param successCallback the callback that will be called upon succesful execution
  38875. * @param offset starting offset.
  38876. */
  38877. constructor(
  38878. /**
  38879. * Defines the number of iterations for the loop
  38880. */
  38881. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38882. /**
  38883. * Execute the next iteration. Must be called after the last iteration was finished.
  38884. */
  38885. executeNext(): void;
  38886. /**
  38887. * Break the loop and run the success callback.
  38888. */
  38889. breakLoop(): void;
  38890. /**
  38891. * Create and run an async loop.
  38892. * @param iterations the number of iterations.
  38893. * @param fn the function to run each iteration
  38894. * @param successCallback the callback that will be called upon succesful execution
  38895. * @param offset starting offset.
  38896. * @returns the created async loop object
  38897. */
  38898. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38899. /**
  38900. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38901. * @param iterations total number of iterations
  38902. * @param syncedIterations number of synchronous iterations in each async iteration.
  38903. * @param fn the function to call each iteration.
  38904. * @param callback a success call back that will be called when iterating stops.
  38905. * @param breakFunction a break condition (optional)
  38906. * @param timeout timeout settings for the setTimeout function. default - 0.
  38907. * @returns the created async loop object
  38908. */
  38909. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38910. }
  38911. }
  38912. declare module BABYLON {
  38913. /**
  38914. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38915. * The underlying implementation relies on an associative array to ensure the best performances.
  38916. * The value can be anything including 'null' but except 'undefined'
  38917. */
  38918. export class StringDictionary<T> {
  38919. /**
  38920. * This will clear this dictionary and copy the content from the 'source' one.
  38921. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38922. * @param source the dictionary to take the content from and copy to this dictionary
  38923. */
  38924. copyFrom(source: StringDictionary<T>): void;
  38925. /**
  38926. * Get a value based from its key
  38927. * @param key the given key to get the matching value from
  38928. * @return the value if found, otherwise undefined is returned
  38929. */
  38930. get(key: string): T | undefined;
  38931. /**
  38932. * Get a value from its key or add it if it doesn't exist.
  38933. * This method will ensure you that a given key/data will be present in the dictionary.
  38934. * @param key the given key to get the matching value from
  38935. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38936. * The factory will only be invoked if there's no data for the given key.
  38937. * @return the value corresponding to the key.
  38938. */
  38939. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38940. /**
  38941. * Get a value from its key if present in the dictionary otherwise add it
  38942. * @param key the key to get the value from
  38943. * @param val if there's no such key/value pair in the dictionary add it with this value
  38944. * @return the value corresponding to the key
  38945. */
  38946. getOrAdd(key: string, val: T): T;
  38947. /**
  38948. * Check if there's a given key in the dictionary
  38949. * @param key the key to check for
  38950. * @return true if the key is present, false otherwise
  38951. */
  38952. contains(key: string): boolean;
  38953. /**
  38954. * Add a new key and its corresponding value
  38955. * @param key the key to add
  38956. * @param value the value corresponding to the key
  38957. * @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
  38958. */
  38959. add(key: string, value: T): boolean;
  38960. /**
  38961. * Update a specific value associated to a key
  38962. * @param key defines the key to use
  38963. * @param value defines the value to store
  38964. * @returns true if the value was updated (or false if the key was not found)
  38965. */
  38966. set(key: string, value: T): boolean;
  38967. /**
  38968. * Get the element of the given key and remove it from the dictionary
  38969. * @param key defines the key to search
  38970. * @returns the value associated with the key or null if not found
  38971. */
  38972. getAndRemove(key: string): Nullable<T>;
  38973. /**
  38974. * Remove a key/value from the dictionary.
  38975. * @param key the key to remove
  38976. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38977. */
  38978. remove(key: string): boolean;
  38979. /**
  38980. * Clear the whole content of the dictionary
  38981. */
  38982. clear(): void;
  38983. /**
  38984. * Gets the current count
  38985. */
  38986. get count(): number;
  38987. /**
  38988. * Execute a callback on each key/val of the dictionary.
  38989. * Note that you can remove any element in this dictionary in the callback implementation
  38990. * @param callback the callback to execute on a given key/value pair
  38991. */
  38992. forEach(callback: (key: string, val: T) => void): void;
  38993. /**
  38994. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38995. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38996. * Note that you can remove any element in this dictionary in the callback implementation
  38997. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38998. * @returns the first item
  38999. */
  39000. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39001. private _count;
  39002. private _data;
  39003. }
  39004. }
  39005. declare module BABYLON {
  39006. /** @hidden */
  39007. export interface ICollisionCoordinator {
  39008. createCollider(): Collider;
  39009. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39010. init(scene: Scene): void;
  39011. }
  39012. /** @hidden */
  39013. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39014. private _scene;
  39015. private _scaledPosition;
  39016. private _scaledVelocity;
  39017. private _finalPosition;
  39018. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39019. createCollider(): Collider;
  39020. init(scene: Scene): void;
  39021. private _collideWithWorld;
  39022. }
  39023. }
  39024. declare module BABYLON {
  39025. /**
  39026. * Class used to manage all inputs for the scene.
  39027. */
  39028. export class InputManager {
  39029. /** The distance in pixel that you have to move to prevent some events */
  39030. static DragMovementThreshold: number;
  39031. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39032. static LongPressDelay: number;
  39033. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39034. static DoubleClickDelay: number;
  39035. /** If you need to check double click without raising a single click at first click, enable this flag */
  39036. static ExclusiveDoubleClickMode: boolean;
  39037. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  39038. private _alreadyAttached;
  39039. private _wheelEventName;
  39040. private _onPointerMove;
  39041. private _onPointerDown;
  39042. private _onPointerUp;
  39043. private _initClickEvent;
  39044. private _initActionManager;
  39045. private _delayedSimpleClick;
  39046. private _delayedSimpleClickTimeout;
  39047. private _previousDelayedSimpleClickTimeout;
  39048. private _meshPickProceed;
  39049. private _previousButtonPressed;
  39050. private _currentPickResult;
  39051. private _previousPickResult;
  39052. private _totalPointersPressed;
  39053. private _doubleClickOccured;
  39054. private _pointerOverMesh;
  39055. private _pickedDownMesh;
  39056. private _pickedUpMesh;
  39057. private _pointerX;
  39058. private _pointerY;
  39059. private _unTranslatedPointerX;
  39060. private _unTranslatedPointerY;
  39061. private _startingPointerPosition;
  39062. private _previousStartingPointerPosition;
  39063. private _startingPointerTime;
  39064. private _previousStartingPointerTime;
  39065. private _pointerCaptures;
  39066. private _meshUnderPointerId;
  39067. private _onKeyDown;
  39068. private _onKeyUp;
  39069. private _onCanvasFocusObserver;
  39070. private _onCanvasBlurObserver;
  39071. private _scene;
  39072. /**
  39073. * Creates a new InputManager
  39074. * @param scene defines the hosting scene
  39075. */
  39076. constructor(scene: Scene);
  39077. /**
  39078. * Gets the mesh that is currently under the pointer
  39079. */
  39080. get meshUnderPointer(): Nullable<AbstractMesh>;
  39081. /**
  39082. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39083. * @param pointerId the pointer id to use
  39084. * @returns The mesh under this pointer id or null if not found
  39085. */
  39086. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39087. /**
  39088. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39089. */
  39090. get unTranslatedPointer(): Vector2;
  39091. /**
  39092. * Gets or sets the current on-screen X position of the pointer
  39093. */
  39094. get pointerX(): number;
  39095. set pointerX(value: number);
  39096. /**
  39097. * Gets or sets the current on-screen Y position of the pointer
  39098. */
  39099. get pointerY(): number;
  39100. set pointerY(value: number);
  39101. private _updatePointerPosition;
  39102. private _processPointerMove;
  39103. private _setRayOnPointerInfo;
  39104. private _checkPrePointerObservable;
  39105. /**
  39106. * Use this method to simulate a pointer move on a mesh
  39107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39110. */
  39111. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39112. /**
  39113. * Use this method to simulate a pointer down on a mesh
  39114. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39115. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39116. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39117. */
  39118. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39119. private _processPointerDown;
  39120. /** @hidden */
  39121. _isPointerSwiping(): boolean;
  39122. /**
  39123. * Use this method to simulate a pointer up on a mesh
  39124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39127. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39128. */
  39129. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39130. private _processPointerUp;
  39131. /**
  39132. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39133. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39134. * @returns true if the pointer was captured
  39135. */
  39136. isPointerCaptured(pointerId?: number): boolean;
  39137. /**
  39138. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39139. * @param attachUp defines if you want to attach events to pointerup
  39140. * @param attachDown defines if you want to attach events to pointerdown
  39141. * @param attachMove defines if you want to attach events to pointermove
  39142. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39143. */
  39144. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39145. /**
  39146. * Detaches all event handlers
  39147. */
  39148. detachControl(): void;
  39149. /**
  39150. * Force the value of meshUnderPointer
  39151. * @param mesh defines the mesh to use
  39152. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39153. */
  39154. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39155. /**
  39156. * Gets the mesh under the pointer
  39157. * @returns a Mesh or null if no mesh is under the pointer
  39158. */
  39159. getPointerOverMesh(): Nullable<AbstractMesh>;
  39160. }
  39161. }
  39162. declare module BABYLON {
  39163. /**
  39164. * This class defines the direct association between an animation and a target
  39165. */
  39166. export class TargetedAnimation {
  39167. /**
  39168. * Animation to perform
  39169. */
  39170. animation: Animation;
  39171. /**
  39172. * Target to animate
  39173. */
  39174. target: any;
  39175. /**
  39176. * Returns the string "TargetedAnimation"
  39177. * @returns "TargetedAnimation"
  39178. */
  39179. getClassName(): string;
  39180. /**
  39181. * Serialize the object
  39182. * @returns the JSON object representing the current entity
  39183. */
  39184. serialize(): any;
  39185. }
  39186. /**
  39187. * Use this class to create coordinated animations on multiple targets
  39188. */
  39189. export class AnimationGroup implements IDisposable {
  39190. /** The name of the animation group */
  39191. name: string;
  39192. private _scene;
  39193. private _targetedAnimations;
  39194. private _animatables;
  39195. private _from;
  39196. private _to;
  39197. private _isStarted;
  39198. private _isPaused;
  39199. private _speedRatio;
  39200. private _loopAnimation;
  39201. private _isAdditive;
  39202. /**
  39203. * Gets or sets the unique id of the node
  39204. */
  39205. uniqueId: number;
  39206. /**
  39207. * This observable will notify when one animation have ended
  39208. */
  39209. onAnimationEndObservable: Observable<TargetedAnimation>;
  39210. /**
  39211. * Observer raised when one animation loops
  39212. */
  39213. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39214. /**
  39215. * Observer raised when all animations have looped
  39216. */
  39217. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39218. /**
  39219. * This observable will notify when all animations have ended.
  39220. */
  39221. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39222. /**
  39223. * This observable will notify when all animations have paused.
  39224. */
  39225. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39226. /**
  39227. * This observable will notify when all animations are playing.
  39228. */
  39229. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39230. /**
  39231. * Gets the first frame
  39232. */
  39233. get from(): number;
  39234. /**
  39235. * Gets the last frame
  39236. */
  39237. get to(): number;
  39238. /**
  39239. * Define if the animations are started
  39240. */
  39241. get isStarted(): boolean;
  39242. /**
  39243. * Gets a value indicating that the current group is playing
  39244. */
  39245. get isPlaying(): boolean;
  39246. /**
  39247. * Gets or sets the speed ratio to use for all animations
  39248. */
  39249. get speedRatio(): number;
  39250. /**
  39251. * Gets or sets the speed ratio to use for all animations
  39252. */
  39253. set speedRatio(value: number);
  39254. /**
  39255. * Gets or sets if all animations should loop or not
  39256. */
  39257. get loopAnimation(): boolean;
  39258. set loopAnimation(value: boolean);
  39259. /**
  39260. * Gets or sets if all animations should be evaluated additively
  39261. */
  39262. get isAdditive(): boolean;
  39263. set isAdditive(value: boolean);
  39264. /**
  39265. * Gets the targeted animations for this animation group
  39266. */
  39267. get targetedAnimations(): Array<TargetedAnimation>;
  39268. /**
  39269. * returning the list of animatables controlled by this animation group.
  39270. */
  39271. get animatables(): Array<Animatable>;
  39272. /**
  39273. * Gets the list of target animations
  39274. */
  39275. get children(): TargetedAnimation[];
  39276. /**
  39277. * Instantiates a new Animation Group.
  39278. * This helps managing several animations at once.
  39279. * @see https://doc.babylonjs.com/how_to/group
  39280. * @param name Defines the name of the group
  39281. * @param scene Defines the scene the group belongs to
  39282. */
  39283. constructor(
  39284. /** The name of the animation group */
  39285. name: string, scene?: Nullable<Scene>);
  39286. /**
  39287. * Add an animation (with its target) in the group
  39288. * @param animation defines the animation we want to add
  39289. * @param target defines the target of the animation
  39290. * @returns the TargetedAnimation object
  39291. */
  39292. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39293. /**
  39294. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39295. * It can add constant keys at begin or end
  39296. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39297. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39298. * @returns the animation group
  39299. */
  39300. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39301. private _animationLoopCount;
  39302. private _animationLoopFlags;
  39303. private _processLoop;
  39304. /**
  39305. * Start all animations on given targets
  39306. * @param loop defines if animations must loop
  39307. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39308. * @param from defines the from key (optional)
  39309. * @param to defines the to key (optional)
  39310. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39311. * @returns the current animation group
  39312. */
  39313. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39314. /**
  39315. * Pause all animations
  39316. * @returns the animation group
  39317. */
  39318. pause(): AnimationGroup;
  39319. /**
  39320. * Play all animations to initial state
  39321. * This function will start() the animations if they were not started or will restart() them if they were paused
  39322. * @param loop defines if animations must loop
  39323. * @returns the animation group
  39324. */
  39325. play(loop?: boolean): AnimationGroup;
  39326. /**
  39327. * Reset all animations to initial state
  39328. * @returns the animation group
  39329. */
  39330. reset(): AnimationGroup;
  39331. /**
  39332. * Restart animations from key 0
  39333. * @returns the animation group
  39334. */
  39335. restart(): AnimationGroup;
  39336. /**
  39337. * Stop all animations
  39338. * @returns the animation group
  39339. */
  39340. stop(): AnimationGroup;
  39341. /**
  39342. * Set animation weight for all animatables
  39343. * @param weight defines the weight to use
  39344. * @return the animationGroup
  39345. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39346. */
  39347. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39348. /**
  39349. * Synchronize and normalize all animatables with a source animatable
  39350. * @param root defines the root animatable to synchronize with
  39351. * @return the animationGroup
  39352. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39353. */
  39354. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39355. /**
  39356. * Goes to a specific frame in this animation group
  39357. * @param frame the frame number to go to
  39358. * @return the animationGroup
  39359. */
  39360. goToFrame(frame: number): AnimationGroup;
  39361. /**
  39362. * Dispose all associated resources
  39363. */
  39364. dispose(): void;
  39365. private _checkAnimationGroupEnded;
  39366. /**
  39367. * Clone the current animation group and returns a copy
  39368. * @param newName defines the name of the new group
  39369. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39370. * @returns the new aniamtion group
  39371. */
  39372. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39373. /**
  39374. * Serializes the animationGroup to an object
  39375. * @returns Serialized object
  39376. */
  39377. serialize(): any;
  39378. /**
  39379. * Returns a new AnimationGroup object parsed from the source provided.
  39380. * @param parsedAnimationGroup defines the source
  39381. * @param scene defines the scene that will receive the animationGroup
  39382. * @returns a new AnimationGroup
  39383. */
  39384. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39385. /**
  39386. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39387. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39388. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39389. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39390. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39391. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39392. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39393. */
  39394. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39395. /**
  39396. * Returns the string "AnimationGroup"
  39397. * @returns "AnimationGroup"
  39398. */
  39399. getClassName(): string;
  39400. /**
  39401. * Creates a detailled string about the object
  39402. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39403. * @returns a string representing the object
  39404. */
  39405. toString(fullDetails?: boolean): string;
  39406. }
  39407. }
  39408. declare module BABYLON {
  39409. /**
  39410. * Define an interface for all classes that will hold resources
  39411. */
  39412. export interface IDisposable {
  39413. /**
  39414. * Releases all held resources
  39415. */
  39416. dispose(): void;
  39417. }
  39418. /** Interface defining initialization parameters for Scene class */
  39419. export interface SceneOptions {
  39420. /**
  39421. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39422. * It will improve performance when the number of geometries becomes important.
  39423. */
  39424. useGeometryUniqueIdsMap?: boolean;
  39425. /**
  39426. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39427. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39428. */
  39429. useMaterialMeshMap?: boolean;
  39430. /**
  39431. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39432. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39433. */
  39434. useClonedMeshMap?: boolean;
  39435. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39436. virtual?: boolean;
  39437. }
  39438. /**
  39439. * Represents a scene to be rendered by the engine.
  39440. * @see https://doc.babylonjs.com/features/scene
  39441. */
  39442. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39443. /** The fog is deactivated */
  39444. static readonly FOGMODE_NONE: number;
  39445. /** The fog density is following an exponential function */
  39446. static readonly FOGMODE_EXP: number;
  39447. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39448. static readonly FOGMODE_EXP2: number;
  39449. /** The fog density is following a linear function. */
  39450. static readonly FOGMODE_LINEAR: number;
  39451. /**
  39452. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39453. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39454. */
  39455. static MinDeltaTime: number;
  39456. /**
  39457. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39459. */
  39460. static MaxDeltaTime: number;
  39461. /**
  39462. * Factory used to create the default material.
  39463. * @param name The name of the material to create
  39464. * @param scene The scene to create the material for
  39465. * @returns The default material
  39466. */
  39467. static DefaultMaterialFactory(scene: Scene): Material;
  39468. /**
  39469. * Factory used to create the a collision coordinator.
  39470. * @returns The collision coordinator
  39471. */
  39472. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39473. /** @hidden */
  39474. _inputManager: InputManager;
  39475. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39476. cameraToUseForPointers: Nullable<Camera>;
  39477. /** @hidden */
  39478. readonly _isScene: boolean;
  39479. /** @hidden */
  39480. _blockEntityCollection: boolean;
  39481. /**
  39482. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39483. */
  39484. autoClear: boolean;
  39485. /**
  39486. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39487. */
  39488. autoClearDepthAndStencil: boolean;
  39489. /**
  39490. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39491. */
  39492. clearColor: Color4;
  39493. /**
  39494. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39495. */
  39496. ambientColor: Color3;
  39497. /**
  39498. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39499. * It should only be one of the following (if not the default embedded one):
  39500. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39501. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39502. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39503. * The material properties need to be setup according to the type of texture in use.
  39504. */
  39505. environmentBRDFTexture: BaseTexture;
  39506. /**
  39507. * Texture used in all pbr material as the reflection texture.
  39508. * As in the majority of the scene they are the same (exception for multi room and so on),
  39509. * this is easier to reference from here than from all the materials.
  39510. */
  39511. get environmentTexture(): Nullable<BaseTexture>;
  39512. /**
  39513. * Texture used in all pbr material as the reflection texture.
  39514. * As in the majority of the scene they are the same (exception for multi room and so on),
  39515. * this is easier to set here than in all the materials.
  39516. */
  39517. set environmentTexture(value: Nullable<BaseTexture>);
  39518. /** @hidden */
  39519. protected _environmentIntensity: number;
  39520. /**
  39521. * Intensity of the environment in all pbr material.
  39522. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39523. * As in the majority of the scene they are the same (exception for multi room and so on),
  39524. * this is easier to reference from here than from all the materials.
  39525. */
  39526. get environmentIntensity(): number;
  39527. /**
  39528. * Intensity of the environment in all pbr material.
  39529. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39530. * As in the majority of the scene they are the same (exception for multi room and so on),
  39531. * this is easier to set here than in all the materials.
  39532. */
  39533. set environmentIntensity(value: number);
  39534. /** @hidden */
  39535. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39536. /**
  39537. * Default image processing configuration used either in the rendering
  39538. * Forward main pass or through the imageProcessingPostProcess if present.
  39539. * As in the majority of the scene they are the same (exception for multi camera),
  39540. * this is easier to reference from here than from all the materials and post process.
  39541. *
  39542. * No setter as we it is a shared configuration, you can set the values instead.
  39543. */
  39544. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39545. private _forceWireframe;
  39546. /**
  39547. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39548. */
  39549. set forceWireframe(value: boolean);
  39550. get forceWireframe(): boolean;
  39551. private _skipFrustumClipping;
  39552. /**
  39553. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39554. */
  39555. set skipFrustumClipping(value: boolean);
  39556. get skipFrustumClipping(): boolean;
  39557. private _forcePointsCloud;
  39558. /**
  39559. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39560. */
  39561. set forcePointsCloud(value: boolean);
  39562. get forcePointsCloud(): boolean;
  39563. /**
  39564. * Gets or sets the active clipplane 1
  39565. */
  39566. clipPlane: Nullable<Plane>;
  39567. /**
  39568. * Gets or sets the active clipplane 2
  39569. */
  39570. clipPlane2: Nullable<Plane>;
  39571. /**
  39572. * Gets or sets the active clipplane 3
  39573. */
  39574. clipPlane3: Nullable<Plane>;
  39575. /**
  39576. * Gets or sets the active clipplane 4
  39577. */
  39578. clipPlane4: Nullable<Plane>;
  39579. /**
  39580. * Gets or sets the active clipplane 5
  39581. */
  39582. clipPlane5: Nullable<Plane>;
  39583. /**
  39584. * Gets or sets the active clipplane 6
  39585. */
  39586. clipPlane6: Nullable<Plane>;
  39587. /**
  39588. * Gets or sets a boolean indicating if animations are enabled
  39589. */
  39590. animationsEnabled: boolean;
  39591. private _animationPropertiesOverride;
  39592. /**
  39593. * Gets or sets the animation properties override
  39594. */
  39595. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39596. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39597. /**
  39598. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39599. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39600. */
  39601. useConstantAnimationDeltaTime: boolean;
  39602. /**
  39603. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39604. * Please note that it requires to run a ray cast through the scene on every frame
  39605. */
  39606. constantlyUpdateMeshUnderPointer: boolean;
  39607. /**
  39608. * Defines the HTML cursor to use when hovering over interactive elements
  39609. */
  39610. hoverCursor: string;
  39611. /**
  39612. * Defines the HTML default cursor to use (empty by default)
  39613. */
  39614. defaultCursor: string;
  39615. /**
  39616. * Defines whether cursors are handled by the scene.
  39617. */
  39618. doNotHandleCursors: boolean;
  39619. /**
  39620. * This is used to call preventDefault() on pointer down
  39621. * in order to block unwanted artifacts like system double clicks
  39622. */
  39623. preventDefaultOnPointerDown: boolean;
  39624. /**
  39625. * This is used to call preventDefault() on pointer up
  39626. * in order to block unwanted artifacts like system double clicks
  39627. */
  39628. preventDefaultOnPointerUp: boolean;
  39629. /**
  39630. * Gets or sets user defined metadata
  39631. */
  39632. metadata: any;
  39633. /**
  39634. * For internal use only. Please do not use.
  39635. */
  39636. reservedDataStore: any;
  39637. /**
  39638. * Gets the name of the plugin used to load this scene (null by default)
  39639. */
  39640. loadingPluginName: string;
  39641. /**
  39642. * Use this array to add regular expressions used to disable offline support for specific urls
  39643. */
  39644. disableOfflineSupportExceptionRules: RegExp[];
  39645. /**
  39646. * An event triggered when the scene is disposed.
  39647. */
  39648. onDisposeObservable: Observable<Scene>;
  39649. private _onDisposeObserver;
  39650. /** Sets a function to be executed when this scene is disposed. */
  39651. set onDispose(callback: () => void);
  39652. /**
  39653. * An event triggered before rendering the scene (right after animations and physics)
  39654. */
  39655. onBeforeRenderObservable: Observable<Scene>;
  39656. private _onBeforeRenderObserver;
  39657. /** Sets a function to be executed before rendering this scene */
  39658. set beforeRender(callback: Nullable<() => void>);
  39659. /**
  39660. * An event triggered after rendering the scene
  39661. */
  39662. onAfterRenderObservable: Observable<Scene>;
  39663. /**
  39664. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39665. */
  39666. onAfterRenderCameraObservable: Observable<Camera>;
  39667. private _onAfterRenderObserver;
  39668. /** Sets a function to be executed after rendering this scene */
  39669. set afterRender(callback: Nullable<() => void>);
  39670. /**
  39671. * An event triggered before animating the scene
  39672. */
  39673. onBeforeAnimationsObservable: Observable<Scene>;
  39674. /**
  39675. * An event triggered after animations processing
  39676. */
  39677. onAfterAnimationsObservable: Observable<Scene>;
  39678. /**
  39679. * An event triggered before draw calls are ready to be sent
  39680. */
  39681. onBeforeDrawPhaseObservable: Observable<Scene>;
  39682. /**
  39683. * An event triggered after draw calls have been sent
  39684. */
  39685. onAfterDrawPhaseObservable: Observable<Scene>;
  39686. /**
  39687. * An event triggered when the scene is ready
  39688. */
  39689. onReadyObservable: Observable<Scene>;
  39690. /**
  39691. * An event triggered before rendering a camera
  39692. */
  39693. onBeforeCameraRenderObservable: Observable<Camera>;
  39694. private _onBeforeCameraRenderObserver;
  39695. /** Sets a function to be executed before rendering a camera*/
  39696. set beforeCameraRender(callback: () => void);
  39697. /**
  39698. * An event triggered after rendering a camera
  39699. */
  39700. onAfterCameraRenderObservable: Observable<Camera>;
  39701. private _onAfterCameraRenderObserver;
  39702. /** Sets a function to be executed after rendering a camera*/
  39703. set afterCameraRender(callback: () => void);
  39704. /**
  39705. * An event triggered when active meshes evaluation is about to start
  39706. */
  39707. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39708. /**
  39709. * An event triggered when active meshes evaluation is done
  39710. */
  39711. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39712. /**
  39713. * An event triggered when particles rendering is about to start
  39714. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39715. */
  39716. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39717. /**
  39718. * An event triggered when particles rendering is done
  39719. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39720. */
  39721. onAfterParticlesRenderingObservable: Observable<Scene>;
  39722. /**
  39723. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39724. */
  39725. onDataLoadedObservable: Observable<Scene>;
  39726. /**
  39727. * An event triggered when a camera is created
  39728. */
  39729. onNewCameraAddedObservable: Observable<Camera>;
  39730. /**
  39731. * An event triggered when a camera is removed
  39732. */
  39733. onCameraRemovedObservable: Observable<Camera>;
  39734. /**
  39735. * An event triggered when a light is created
  39736. */
  39737. onNewLightAddedObservable: Observable<Light>;
  39738. /**
  39739. * An event triggered when a light is removed
  39740. */
  39741. onLightRemovedObservable: Observable<Light>;
  39742. /**
  39743. * An event triggered when a geometry is created
  39744. */
  39745. onNewGeometryAddedObservable: Observable<Geometry>;
  39746. /**
  39747. * An event triggered when a geometry is removed
  39748. */
  39749. onGeometryRemovedObservable: Observable<Geometry>;
  39750. /**
  39751. * An event triggered when a transform node is created
  39752. */
  39753. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39754. /**
  39755. * An event triggered when a transform node is removed
  39756. */
  39757. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39758. /**
  39759. * An event triggered when a mesh is created
  39760. */
  39761. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39762. /**
  39763. * An event triggered when a mesh is removed
  39764. */
  39765. onMeshRemovedObservable: Observable<AbstractMesh>;
  39766. /**
  39767. * An event triggered when a skeleton is created
  39768. */
  39769. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39770. /**
  39771. * An event triggered when a skeleton is removed
  39772. */
  39773. onSkeletonRemovedObservable: Observable<Skeleton>;
  39774. /**
  39775. * An event triggered when a material is created
  39776. */
  39777. onNewMaterialAddedObservable: Observable<Material>;
  39778. /**
  39779. * An event triggered when a material is removed
  39780. */
  39781. onMaterialRemovedObservable: Observable<Material>;
  39782. /**
  39783. * An event triggered when a texture is created
  39784. */
  39785. onNewTextureAddedObservable: Observable<BaseTexture>;
  39786. /**
  39787. * An event triggered when a texture is removed
  39788. */
  39789. onTextureRemovedObservable: Observable<BaseTexture>;
  39790. /**
  39791. * An event triggered when render targets are about to be rendered
  39792. * Can happen multiple times per frame.
  39793. */
  39794. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39795. /**
  39796. * An event triggered when render targets were rendered.
  39797. * Can happen multiple times per frame.
  39798. */
  39799. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39800. /**
  39801. * An event triggered before calculating deterministic simulation step
  39802. */
  39803. onBeforeStepObservable: Observable<Scene>;
  39804. /**
  39805. * An event triggered after calculating deterministic simulation step
  39806. */
  39807. onAfterStepObservable: Observable<Scene>;
  39808. /**
  39809. * An event triggered when the activeCamera property is updated
  39810. */
  39811. onActiveCameraChanged: Observable<Scene>;
  39812. /**
  39813. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39814. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39815. * 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)
  39816. */
  39817. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39818. /**
  39819. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39820. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39821. * 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)
  39822. */
  39823. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39824. /**
  39825. * This Observable will when a mesh has been imported into the scene.
  39826. */
  39827. onMeshImportedObservable: Observable<AbstractMesh>;
  39828. /**
  39829. * This Observable will when an animation file has been imported into the scene.
  39830. */
  39831. onAnimationFileImportedObservable: Observable<Scene>;
  39832. /**
  39833. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39834. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39835. */
  39836. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39837. /** @hidden */
  39838. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39839. /**
  39840. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39841. */
  39842. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39843. /**
  39844. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39845. */
  39846. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39847. /**
  39848. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39849. */
  39850. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39851. /** Callback called when a pointer move is detected */
  39852. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39853. /** Callback called when a pointer down is detected */
  39854. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39855. /** Callback called when a pointer up is detected */
  39856. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39857. /** Callback called when a pointer pick is detected */
  39858. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39859. /**
  39860. * 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).
  39861. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39862. */
  39863. onPrePointerObservable: Observable<PointerInfoPre>;
  39864. /**
  39865. * Observable event triggered each time an input event is received from the rendering canvas
  39866. */
  39867. onPointerObservable: Observable<PointerInfo>;
  39868. /**
  39869. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39870. */
  39871. get unTranslatedPointer(): Vector2;
  39872. /**
  39873. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39874. */
  39875. static get DragMovementThreshold(): number;
  39876. static set DragMovementThreshold(value: number);
  39877. /**
  39878. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39879. */
  39880. static get LongPressDelay(): number;
  39881. static set LongPressDelay(value: number);
  39882. /**
  39883. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39884. */
  39885. static get DoubleClickDelay(): number;
  39886. static set DoubleClickDelay(value: number);
  39887. /** If you need to check double click without raising a single click at first click, enable this flag */
  39888. static get ExclusiveDoubleClickMode(): boolean;
  39889. static set ExclusiveDoubleClickMode(value: boolean);
  39890. /** @hidden */
  39891. _mirroredCameraPosition: Nullable<Vector3>;
  39892. /**
  39893. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39894. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39895. */
  39896. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39897. /**
  39898. * Observable event triggered each time an keyboard event is received from the hosting window
  39899. */
  39900. onKeyboardObservable: Observable<KeyboardInfo>;
  39901. private _useRightHandedSystem;
  39902. /**
  39903. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39904. */
  39905. set useRightHandedSystem(value: boolean);
  39906. get useRightHandedSystem(): boolean;
  39907. private _timeAccumulator;
  39908. private _currentStepId;
  39909. private _currentInternalStep;
  39910. /**
  39911. * Sets the step Id used by deterministic lock step
  39912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39913. * @param newStepId defines the step Id
  39914. */
  39915. setStepId(newStepId: number): void;
  39916. /**
  39917. * Gets the step Id used by deterministic lock step
  39918. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39919. * @returns the step Id
  39920. */
  39921. getStepId(): number;
  39922. /**
  39923. * Gets the internal step used by deterministic lock step
  39924. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39925. * @returns the internal step
  39926. */
  39927. getInternalStep(): number;
  39928. private _fogEnabled;
  39929. /**
  39930. * Gets or sets a boolean indicating if fog is enabled on this scene
  39931. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39932. * (Default is true)
  39933. */
  39934. set fogEnabled(value: boolean);
  39935. get fogEnabled(): boolean;
  39936. private _fogMode;
  39937. /**
  39938. * Gets or sets the fog mode to use
  39939. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39940. * | mode | value |
  39941. * | --- | --- |
  39942. * | FOGMODE_NONE | 0 |
  39943. * | FOGMODE_EXP | 1 |
  39944. * | FOGMODE_EXP2 | 2 |
  39945. * | FOGMODE_LINEAR | 3 |
  39946. */
  39947. set fogMode(value: number);
  39948. get fogMode(): number;
  39949. /**
  39950. * Gets or sets the fog color to use
  39951. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39952. * (Default is Color3(0.2, 0.2, 0.3))
  39953. */
  39954. fogColor: Color3;
  39955. /**
  39956. * Gets or sets the fog density to use
  39957. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39958. * (Default is 0.1)
  39959. */
  39960. fogDensity: number;
  39961. /**
  39962. * Gets or sets the fog start distance to use
  39963. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39964. * (Default is 0)
  39965. */
  39966. fogStart: number;
  39967. /**
  39968. * Gets or sets the fog end distance to use
  39969. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39970. * (Default is 1000)
  39971. */
  39972. fogEnd: number;
  39973. /**
  39974. * Flag indicating that the frame buffer binding is handled by another component
  39975. */
  39976. prePass: boolean;
  39977. private _shadowsEnabled;
  39978. /**
  39979. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39980. */
  39981. set shadowsEnabled(value: boolean);
  39982. get shadowsEnabled(): boolean;
  39983. private _lightsEnabled;
  39984. /**
  39985. * Gets or sets a boolean indicating if lights are enabled on this scene
  39986. */
  39987. set lightsEnabled(value: boolean);
  39988. get lightsEnabled(): boolean;
  39989. /** All of the active cameras added to this scene. */
  39990. activeCameras: Camera[];
  39991. /** @hidden */
  39992. _activeCamera: Nullable<Camera>;
  39993. /** Gets or sets the current active camera */
  39994. get activeCamera(): Nullable<Camera>;
  39995. set activeCamera(value: Nullable<Camera>);
  39996. private _defaultMaterial;
  39997. /** The default material used on meshes when no material is affected */
  39998. get defaultMaterial(): Material;
  39999. /** The default material used on meshes when no material is affected */
  40000. set defaultMaterial(value: Material);
  40001. private _texturesEnabled;
  40002. /**
  40003. * Gets or sets a boolean indicating if textures are enabled on this scene
  40004. */
  40005. set texturesEnabled(value: boolean);
  40006. get texturesEnabled(): boolean;
  40007. /**
  40008. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40009. */
  40010. physicsEnabled: boolean;
  40011. /**
  40012. * Gets or sets a boolean indicating if particles are enabled on this scene
  40013. */
  40014. particlesEnabled: boolean;
  40015. /**
  40016. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40017. */
  40018. spritesEnabled: boolean;
  40019. private _skeletonsEnabled;
  40020. /**
  40021. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40022. */
  40023. set skeletonsEnabled(value: boolean);
  40024. get skeletonsEnabled(): boolean;
  40025. /**
  40026. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40027. */
  40028. lensFlaresEnabled: boolean;
  40029. /**
  40030. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40031. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40032. */
  40033. collisionsEnabled: boolean;
  40034. private _collisionCoordinator;
  40035. /** @hidden */
  40036. get collisionCoordinator(): ICollisionCoordinator;
  40037. /**
  40038. * Defines the gravity applied to this scene (used only for collisions)
  40039. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40040. */
  40041. gravity: Vector3;
  40042. /**
  40043. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40044. */
  40045. postProcessesEnabled: boolean;
  40046. /**
  40047. * Gets the current postprocess manager
  40048. */
  40049. postProcessManager: PostProcessManager;
  40050. /**
  40051. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40052. */
  40053. renderTargetsEnabled: boolean;
  40054. /**
  40055. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40056. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40057. */
  40058. dumpNextRenderTargets: boolean;
  40059. /**
  40060. * The list of user defined render targets added to the scene
  40061. */
  40062. customRenderTargets: RenderTargetTexture[];
  40063. /**
  40064. * Defines if texture loading must be delayed
  40065. * If true, textures will only be loaded when they need to be rendered
  40066. */
  40067. useDelayedTextureLoading: boolean;
  40068. /**
  40069. * Gets the list of meshes imported to the scene through SceneLoader
  40070. */
  40071. importedMeshesFiles: String[];
  40072. /**
  40073. * Gets or sets a boolean indicating if probes are enabled on this scene
  40074. */
  40075. probesEnabled: boolean;
  40076. /**
  40077. * Gets or sets the current offline provider to use to store scene data
  40078. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40079. */
  40080. offlineProvider: IOfflineProvider;
  40081. /**
  40082. * Gets or sets the action manager associated with the scene
  40083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40084. */
  40085. actionManager: AbstractActionManager;
  40086. private _meshesForIntersections;
  40087. /**
  40088. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40089. */
  40090. proceduralTexturesEnabled: boolean;
  40091. private _engine;
  40092. private _totalVertices;
  40093. /** @hidden */
  40094. _activeIndices: PerfCounter;
  40095. /** @hidden */
  40096. _activeParticles: PerfCounter;
  40097. /** @hidden */
  40098. _activeBones: PerfCounter;
  40099. private _animationRatio;
  40100. /** @hidden */
  40101. _animationTimeLast: number;
  40102. /** @hidden */
  40103. _animationTime: number;
  40104. /**
  40105. * Gets or sets a general scale for animation speed
  40106. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40107. */
  40108. animationTimeScale: number;
  40109. /** @hidden */
  40110. _cachedMaterial: Nullable<Material>;
  40111. /** @hidden */
  40112. _cachedEffect: Nullable<Effect>;
  40113. /** @hidden */
  40114. _cachedVisibility: Nullable<number>;
  40115. private _renderId;
  40116. private _frameId;
  40117. private _executeWhenReadyTimeoutId;
  40118. private _intermediateRendering;
  40119. private _viewUpdateFlag;
  40120. private _projectionUpdateFlag;
  40121. /** @hidden */
  40122. _toBeDisposed: Nullable<IDisposable>[];
  40123. private _activeRequests;
  40124. /** @hidden */
  40125. _pendingData: any[];
  40126. private _isDisposed;
  40127. /**
  40128. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40129. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40130. */
  40131. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40132. private _activeMeshes;
  40133. private _processedMaterials;
  40134. private _renderTargets;
  40135. /** @hidden */
  40136. _activeParticleSystems: SmartArray<IParticleSystem>;
  40137. private _activeSkeletons;
  40138. private _softwareSkinnedMeshes;
  40139. private _renderingManager;
  40140. /** @hidden */
  40141. _activeAnimatables: Animatable[];
  40142. private _transformMatrix;
  40143. private _sceneUbo;
  40144. /** @hidden */
  40145. _viewMatrix: Matrix;
  40146. private _projectionMatrix;
  40147. /** @hidden */
  40148. _forcedViewPosition: Nullable<Vector3>;
  40149. /** @hidden */
  40150. _frustumPlanes: Plane[];
  40151. /**
  40152. * Gets the list of frustum planes (built from the active camera)
  40153. */
  40154. get frustumPlanes(): Plane[];
  40155. /**
  40156. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40157. * This is useful if there are more lights that the maximum simulteanous authorized
  40158. */
  40159. requireLightSorting: boolean;
  40160. /** @hidden */
  40161. readonly useMaterialMeshMap: boolean;
  40162. /** @hidden */
  40163. readonly useClonedMeshMap: boolean;
  40164. private _externalData;
  40165. private _uid;
  40166. /**
  40167. * @hidden
  40168. * Backing store of defined scene components.
  40169. */
  40170. _components: ISceneComponent[];
  40171. /**
  40172. * @hidden
  40173. * Backing store of defined scene components.
  40174. */
  40175. _serializableComponents: ISceneSerializableComponent[];
  40176. /**
  40177. * List of components to register on the next registration step.
  40178. */
  40179. private _transientComponents;
  40180. /**
  40181. * Registers the transient components if needed.
  40182. */
  40183. private _registerTransientComponents;
  40184. /**
  40185. * @hidden
  40186. * Add a component to the scene.
  40187. * Note that the ccomponent could be registered on th next frame if this is called after
  40188. * the register component stage.
  40189. * @param component Defines the component to add to the scene
  40190. */
  40191. _addComponent(component: ISceneComponent): void;
  40192. /**
  40193. * @hidden
  40194. * Gets a component from the scene.
  40195. * @param name defines the name of the component to retrieve
  40196. * @returns the component or null if not present
  40197. */
  40198. _getComponent(name: string): Nullable<ISceneComponent>;
  40199. /**
  40200. * @hidden
  40201. * Defines the actions happening before camera updates.
  40202. */
  40203. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40204. /**
  40205. * @hidden
  40206. * Defines the actions happening before clear the canvas.
  40207. */
  40208. _beforeClearStage: Stage<SimpleStageAction>;
  40209. /**
  40210. * @hidden
  40211. * Defines the actions when collecting render targets for the frame.
  40212. */
  40213. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40214. /**
  40215. * @hidden
  40216. * Defines the actions happening for one camera in the frame.
  40217. */
  40218. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40219. /**
  40220. * @hidden
  40221. * Defines the actions happening during the per mesh ready checks.
  40222. */
  40223. _isReadyForMeshStage: Stage<MeshStageAction>;
  40224. /**
  40225. * @hidden
  40226. * Defines the actions happening before evaluate active mesh checks.
  40227. */
  40228. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40229. /**
  40230. * @hidden
  40231. * Defines the actions happening during the evaluate sub mesh checks.
  40232. */
  40233. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40234. /**
  40235. * @hidden
  40236. * Defines the actions happening during the active mesh stage.
  40237. */
  40238. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40239. /**
  40240. * @hidden
  40241. * Defines the actions happening during the per camera render target step.
  40242. */
  40243. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40244. /**
  40245. * @hidden
  40246. * Defines the actions happening just before the active camera is drawing.
  40247. */
  40248. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40249. /**
  40250. * @hidden
  40251. * Defines the actions happening just before a render target is drawing.
  40252. */
  40253. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40254. /**
  40255. * @hidden
  40256. * Defines the actions happening just before a rendering group is drawing.
  40257. */
  40258. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40259. /**
  40260. * @hidden
  40261. * Defines the actions happening just before a mesh is drawing.
  40262. */
  40263. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40264. /**
  40265. * @hidden
  40266. * Defines the actions happening just after a mesh has been drawn.
  40267. */
  40268. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40269. /**
  40270. * @hidden
  40271. * Defines the actions happening just after a rendering group has been drawn.
  40272. */
  40273. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40274. /**
  40275. * @hidden
  40276. * Defines the actions happening just after the active camera has been drawn.
  40277. */
  40278. _afterCameraDrawStage: Stage<CameraStageAction>;
  40279. /**
  40280. * @hidden
  40281. * Defines the actions happening just after a render target has been drawn.
  40282. */
  40283. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40284. /**
  40285. * @hidden
  40286. * Defines the actions happening just after rendering all cameras and computing intersections.
  40287. */
  40288. _afterRenderStage: Stage<SimpleStageAction>;
  40289. /**
  40290. * @hidden
  40291. * Defines the actions happening when a pointer move event happens.
  40292. */
  40293. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40294. /**
  40295. * @hidden
  40296. * Defines the actions happening when a pointer down event happens.
  40297. */
  40298. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40299. /**
  40300. * @hidden
  40301. * Defines the actions happening when a pointer up event happens.
  40302. */
  40303. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40304. /**
  40305. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40306. */
  40307. private geometriesByUniqueId;
  40308. /**
  40309. * Creates a new Scene
  40310. * @param engine defines the engine to use to render this scene
  40311. * @param options defines the scene options
  40312. */
  40313. constructor(engine: Engine, options?: SceneOptions);
  40314. /**
  40315. * Gets a string identifying the name of the class
  40316. * @returns "Scene" string
  40317. */
  40318. getClassName(): string;
  40319. private _defaultMeshCandidates;
  40320. /**
  40321. * @hidden
  40322. */
  40323. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40324. private _defaultSubMeshCandidates;
  40325. /**
  40326. * @hidden
  40327. */
  40328. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40329. /**
  40330. * Sets the default candidate providers for the scene.
  40331. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40332. * and getCollidingSubMeshCandidates to their default function
  40333. */
  40334. setDefaultCandidateProviders(): void;
  40335. /**
  40336. * Gets the mesh that is currently under the pointer
  40337. */
  40338. get meshUnderPointer(): Nullable<AbstractMesh>;
  40339. /**
  40340. * Gets or sets the current on-screen X position of the pointer
  40341. */
  40342. get pointerX(): number;
  40343. set pointerX(value: number);
  40344. /**
  40345. * Gets or sets the current on-screen Y position of the pointer
  40346. */
  40347. get pointerY(): number;
  40348. set pointerY(value: number);
  40349. /**
  40350. * Gets the cached material (ie. the latest rendered one)
  40351. * @returns the cached material
  40352. */
  40353. getCachedMaterial(): Nullable<Material>;
  40354. /**
  40355. * Gets the cached effect (ie. the latest rendered one)
  40356. * @returns the cached effect
  40357. */
  40358. getCachedEffect(): Nullable<Effect>;
  40359. /**
  40360. * Gets the cached visibility state (ie. the latest rendered one)
  40361. * @returns the cached visibility state
  40362. */
  40363. getCachedVisibility(): Nullable<number>;
  40364. /**
  40365. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40366. * @param material defines the current material
  40367. * @param effect defines the current effect
  40368. * @param visibility defines the current visibility state
  40369. * @returns true if one parameter is not cached
  40370. */
  40371. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40372. /**
  40373. * Gets the engine associated with the scene
  40374. * @returns an Engine
  40375. */
  40376. getEngine(): Engine;
  40377. /**
  40378. * Gets the total number of vertices rendered per frame
  40379. * @returns the total number of vertices rendered per frame
  40380. */
  40381. getTotalVertices(): number;
  40382. /**
  40383. * Gets the performance counter for total vertices
  40384. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40385. */
  40386. get totalVerticesPerfCounter(): PerfCounter;
  40387. /**
  40388. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40389. * @returns the total number of active indices rendered per frame
  40390. */
  40391. getActiveIndices(): number;
  40392. /**
  40393. * Gets the performance counter for active indices
  40394. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40395. */
  40396. get totalActiveIndicesPerfCounter(): PerfCounter;
  40397. /**
  40398. * Gets the total number of active particles rendered per frame
  40399. * @returns the total number of active particles rendered per frame
  40400. */
  40401. getActiveParticles(): number;
  40402. /**
  40403. * Gets the performance counter for active particles
  40404. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40405. */
  40406. get activeParticlesPerfCounter(): PerfCounter;
  40407. /**
  40408. * Gets the total number of active bones rendered per frame
  40409. * @returns the total number of active bones rendered per frame
  40410. */
  40411. getActiveBones(): number;
  40412. /**
  40413. * Gets the performance counter for active bones
  40414. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40415. */
  40416. get activeBonesPerfCounter(): PerfCounter;
  40417. /**
  40418. * Gets the array of active meshes
  40419. * @returns an array of AbstractMesh
  40420. */
  40421. getActiveMeshes(): SmartArray<AbstractMesh>;
  40422. /**
  40423. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40424. * @returns a number
  40425. */
  40426. getAnimationRatio(): number;
  40427. /**
  40428. * Gets an unique Id for the current render phase
  40429. * @returns a number
  40430. */
  40431. getRenderId(): number;
  40432. /**
  40433. * Gets an unique Id for the current frame
  40434. * @returns a number
  40435. */
  40436. getFrameId(): number;
  40437. /** Call this function if you want to manually increment the render Id*/
  40438. incrementRenderId(): void;
  40439. private _createUbo;
  40440. /**
  40441. * Use this method to simulate a pointer move on a mesh
  40442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40445. * @returns the current scene
  40446. */
  40447. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40448. /**
  40449. * Use this method to simulate a pointer down on a mesh
  40450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40453. * @returns the current scene
  40454. */
  40455. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40456. /**
  40457. * Use this method to simulate a pointer up on a mesh
  40458. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40459. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40460. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40461. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40462. * @returns the current scene
  40463. */
  40464. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40465. /**
  40466. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40467. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40468. * @returns true if the pointer was captured
  40469. */
  40470. isPointerCaptured(pointerId?: number): boolean;
  40471. /**
  40472. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40473. * @param attachUp defines if you want to attach events to pointerup
  40474. * @param attachDown defines if you want to attach events to pointerdown
  40475. * @param attachMove defines if you want to attach events to pointermove
  40476. */
  40477. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40478. /** Detaches all event handlers*/
  40479. detachControl(): void;
  40480. /**
  40481. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40482. * Delay loaded resources are not taking in account
  40483. * @return true if all required resources are ready
  40484. */
  40485. isReady(): boolean;
  40486. /** Resets all cached information relative to material (including effect and visibility) */
  40487. resetCachedMaterial(): void;
  40488. /**
  40489. * Registers a function to be called before every frame render
  40490. * @param func defines the function to register
  40491. */
  40492. registerBeforeRender(func: () => void): void;
  40493. /**
  40494. * Unregisters a function called before every frame render
  40495. * @param func defines the function to unregister
  40496. */
  40497. unregisterBeforeRender(func: () => void): void;
  40498. /**
  40499. * Registers a function to be called after every frame render
  40500. * @param func defines the function to register
  40501. */
  40502. registerAfterRender(func: () => void): void;
  40503. /**
  40504. * Unregisters a function called after every frame render
  40505. * @param func defines the function to unregister
  40506. */
  40507. unregisterAfterRender(func: () => void): void;
  40508. private _executeOnceBeforeRender;
  40509. /**
  40510. * The provided function will run before render once and will be disposed afterwards.
  40511. * A timeout delay can be provided so that the function will be executed in N ms.
  40512. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40513. * @param func The function to be executed.
  40514. * @param timeout optional delay in ms
  40515. */
  40516. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40517. /** @hidden */
  40518. _addPendingData(data: any): void;
  40519. /** @hidden */
  40520. _removePendingData(data: any): void;
  40521. /**
  40522. * Returns the number of items waiting to be loaded
  40523. * @returns the number of items waiting to be loaded
  40524. */
  40525. getWaitingItemsCount(): number;
  40526. /**
  40527. * Returns a boolean indicating if the scene is still loading data
  40528. */
  40529. get isLoading(): boolean;
  40530. /**
  40531. * Registers a function to be executed when the scene is ready
  40532. * @param {Function} func - the function to be executed
  40533. */
  40534. executeWhenReady(func: () => void): void;
  40535. /**
  40536. * Returns a promise that resolves when the scene is ready
  40537. * @returns A promise that resolves when the scene is ready
  40538. */
  40539. whenReadyAsync(): Promise<void>;
  40540. /** @hidden */
  40541. _checkIsReady(): void;
  40542. /**
  40543. * Gets all animatable attached to the scene
  40544. */
  40545. get animatables(): Animatable[];
  40546. /**
  40547. * Resets the last animation time frame.
  40548. * Useful to override when animations start running when loading a scene for the first time.
  40549. */
  40550. resetLastAnimationTimeFrame(): void;
  40551. /**
  40552. * Gets the current view matrix
  40553. * @returns a Matrix
  40554. */
  40555. getViewMatrix(): Matrix;
  40556. /**
  40557. * Gets the current projection matrix
  40558. * @returns a Matrix
  40559. */
  40560. getProjectionMatrix(): Matrix;
  40561. /**
  40562. * Gets the current transform matrix
  40563. * @returns a Matrix made of View * Projection
  40564. */
  40565. getTransformMatrix(): Matrix;
  40566. /**
  40567. * Sets the current transform matrix
  40568. * @param viewL defines the View matrix to use
  40569. * @param projectionL defines the Projection matrix to use
  40570. * @param viewR defines the right View matrix to use (if provided)
  40571. * @param projectionR defines the right Projection matrix to use (if provided)
  40572. */
  40573. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40574. /**
  40575. * Gets the uniform buffer used to store scene data
  40576. * @returns a UniformBuffer
  40577. */
  40578. getSceneUniformBuffer(): UniformBuffer;
  40579. /**
  40580. * Gets an unique (relatively to the current scene) Id
  40581. * @returns an unique number for the scene
  40582. */
  40583. getUniqueId(): number;
  40584. /**
  40585. * Add a mesh to the list of scene's meshes
  40586. * @param newMesh defines the mesh to add
  40587. * @param recursive if all child meshes should also be added to the scene
  40588. */
  40589. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40590. /**
  40591. * Remove a mesh for the list of scene's meshes
  40592. * @param toRemove defines the mesh to remove
  40593. * @param recursive if all child meshes should also be removed from the scene
  40594. * @returns the index where the mesh was in the mesh list
  40595. */
  40596. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40597. /**
  40598. * Add a transform node to the list of scene's transform nodes
  40599. * @param newTransformNode defines the transform node to add
  40600. */
  40601. addTransformNode(newTransformNode: TransformNode): void;
  40602. /**
  40603. * Remove a transform node for the list of scene's transform nodes
  40604. * @param toRemove defines the transform node to remove
  40605. * @returns the index where the transform node was in the transform node list
  40606. */
  40607. removeTransformNode(toRemove: TransformNode): number;
  40608. /**
  40609. * Remove a skeleton for the list of scene's skeletons
  40610. * @param toRemove defines the skeleton to remove
  40611. * @returns the index where the skeleton was in the skeleton list
  40612. */
  40613. removeSkeleton(toRemove: Skeleton): number;
  40614. /**
  40615. * Remove a morph target for the list of scene's morph targets
  40616. * @param toRemove defines the morph target to remove
  40617. * @returns the index where the morph target was in the morph target list
  40618. */
  40619. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40620. /**
  40621. * Remove a light for the list of scene's lights
  40622. * @param toRemove defines the light to remove
  40623. * @returns the index where the light was in the light list
  40624. */
  40625. removeLight(toRemove: Light): number;
  40626. /**
  40627. * Remove a camera for the list of scene's cameras
  40628. * @param toRemove defines the camera to remove
  40629. * @returns the index where the camera was in the camera list
  40630. */
  40631. removeCamera(toRemove: Camera): number;
  40632. /**
  40633. * Remove a particle system for the list of scene's particle systems
  40634. * @param toRemove defines the particle system to remove
  40635. * @returns the index where the particle system was in the particle system list
  40636. */
  40637. removeParticleSystem(toRemove: IParticleSystem): number;
  40638. /**
  40639. * Remove a animation for the list of scene's animations
  40640. * @param toRemove defines the animation to remove
  40641. * @returns the index where the animation was in the animation list
  40642. */
  40643. removeAnimation(toRemove: Animation): number;
  40644. /**
  40645. * Will stop the animation of the given target
  40646. * @param target - the target
  40647. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40648. * @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)
  40649. */
  40650. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40651. /**
  40652. * Removes the given animation group from this scene.
  40653. * @param toRemove The animation group to remove
  40654. * @returns The index of the removed animation group
  40655. */
  40656. removeAnimationGroup(toRemove: AnimationGroup): number;
  40657. /**
  40658. * Removes the given multi-material from this scene.
  40659. * @param toRemove The multi-material to remove
  40660. * @returns The index of the removed multi-material
  40661. */
  40662. removeMultiMaterial(toRemove: MultiMaterial): number;
  40663. /**
  40664. * Removes the given material from this scene.
  40665. * @param toRemove The material to remove
  40666. * @returns The index of the removed material
  40667. */
  40668. removeMaterial(toRemove: Material): number;
  40669. /**
  40670. * Removes the given action manager from this scene.
  40671. * @param toRemove The action manager to remove
  40672. * @returns The index of the removed action manager
  40673. */
  40674. removeActionManager(toRemove: AbstractActionManager): number;
  40675. /**
  40676. * Removes the given texture from this scene.
  40677. * @param toRemove The texture to remove
  40678. * @returns The index of the removed texture
  40679. */
  40680. removeTexture(toRemove: BaseTexture): number;
  40681. /**
  40682. * Adds the given light to this scene
  40683. * @param newLight The light to add
  40684. */
  40685. addLight(newLight: Light): void;
  40686. /**
  40687. * Sorts the list list based on light priorities
  40688. */
  40689. sortLightsByPriority(): void;
  40690. /**
  40691. * Adds the given camera to this scene
  40692. * @param newCamera The camera to add
  40693. */
  40694. addCamera(newCamera: Camera): void;
  40695. /**
  40696. * Adds the given skeleton to this scene
  40697. * @param newSkeleton The skeleton to add
  40698. */
  40699. addSkeleton(newSkeleton: Skeleton): void;
  40700. /**
  40701. * Adds the given particle system to this scene
  40702. * @param newParticleSystem The particle system to add
  40703. */
  40704. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40705. /**
  40706. * Adds the given animation to this scene
  40707. * @param newAnimation The animation to add
  40708. */
  40709. addAnimation(newAnimation: Animation): void;
  40710. /**
  40711. * Adds the given animation group to this scene.
  40712. * @param newAnimationGroup The animation group to add
  40713. */
  40714. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40715. /**
  40716. * Adds the given multi-material to this scene
  40717. * @param newMultiMaterial The multi-material to add
  40718. */
  40719. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40720. /**
  40721. * Adds the given material to this scene
  40722. * @param newMaterial The material to add
  40723. */
  40724. addMaterial(newMaterial: Material): void;
  40725. /**
  40726. * Adds the given morph target to this scene
  40727. * @param newMorphTargetManager The morph target to add
  40728. */
  40729. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40730. /**
  40731. * Adds the given geometry to this scene
  40732. * @param newGeometry The geometry to add
  40733. */
  40734. addGeometry(newGeometry: Geometry): void;
  40735. /**
  40736. * Adds the given action manager to this scene
  40737. * @param newActionManager The action manager to add
  40738. */
  40739. addActionManager(newActionManager: AbstractActionManager): void;
  40740. /**
  40741. * Adds the given texture to this scene.
  40742. * @param newTexture The texture to add
  40743. */
  40744. addTexture(newTexture: BaseTexture): void;
  40745. /**
  40746. * Switch active camera
  40747. * @param newCamera defines the new active camera
  40748. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40749. */
  40750. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40751. /**
  40752. * sets the active camera of the scene using its ID
  40753. * @param id defines the camera's ID
  40754. * @return the new active camera or null if none found.
  40755. */
  40756. setActiveCameraByID(id: string): Nullable<Camera>;
  40757. /**
  40758. * sets the active camera of the scene using its name
  40759. * @param name defines the camera's name
  40760. * @returns the new active camera or null if none found.
  40761. */
  40762. setActiveCameraByName(name: string): Nullable<Camera>;
  40763. /**
  40764. * get an animation group using its name
  40765. * @param name defines the material's name
  40766. * @return the animation group or null if none found.
  40767. */
  40768. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40769. /**
  40770. * Get a material using its unique id
  40771. * @param uniqueId defines the material's unique id
  40772. * @return the material or null if none found.
  40773. */
  40774. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40775. /**
  40776. * get a material using its id
  40777. * @param id defines the material's ID
  40778. * @return the material or null if none found.
  40779. */
  40780. getMaterialByID(id: string): Nullable<Material>;
  40781. /**
  40782. * Gets a the last added material using a given id
  40783. * @param id defines the material's ID
  40784. * @return the last material with the given id or null if none found.
  40785. */
  40786. getLastMaterialByID(id: string): Nullable<Material>;
  40787. /**
  40788. * Gets a material using its name
  40789. * @param name defines the material's name
  40790. * @return the material or null if none found.
  40791. */
  40792. getMaterialByName(name: string): Nullable<Material>;
  40793. /**
  40794. * Get a texture using its unique id
  40795. * @param uniqueId defines the texture's unique id
  40796. * @return the texture or null if none found.
  40797. */
  40798. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40799. /**
  40800. * Gets a camera using its id
  40801. * @param id defines the id to look for
  40802. * @returns the camera or null if not found
  40803. */
  40804. getCameraByID(id: string): Nullable<Camera>;
  40805. /**
  40806. * Gets a camera using its unique id
  40807. * @param uniqueId defines the unique id to look for
  40808. * @returns the camera or null if not found
  40809. */
  40810. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40811. /**
  40812. * Gets a camera using its name
  40813. * @param name defines the camera's name
  40814. * @return the camera or null if none found.
  40815. */
  40816. getCameraByName(name: string): Nullable<Camera>;
  40817. /**
  40818. * Gets a bone using its id
  40819. * @param id defines the bone's id
  40820. * @return the bone or null if not found
  40821. */
  40822. getBoneByID(id: string): Nullable<Bone>;
  40823. /**
  40824. * Gets a bone using its id
  40825. * @param name defines the bone's name
  40826. * @return the bone or null if not found
  40827. */
  40828. getBoneByName(name: string): Nullable<Bone>;
  40829. /**
  40830. * Gets a light node using its name
  40831. * @param name defines the the light's name
  40832. * @return the light or null if none found.
  40833. */
  40834. getLightByName(name: string): Nullable<Light>;
  40835. /**
  40836. * Gets a light node using its id
  40837. * @param id defines the light's id
  40838. * @return the light or null if none found.
  40839. */
  40840. getLightByID(id: string): Nullable<Light>;
  40841. /**
  40842. * Gets a light node using its scene-generated unique ID
  40843. * @param uniqueId defines the light's unique id
  40844. * @return the light or null if none found.
  40845. */
  40846. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40847. /**
  40848. * Gets a particle system by id
  40849. * @param id defines the particle system id
  40850. * @return the corresponding system or null if none found
  40851. */
  40852. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40853. /**
  40854. * Gets a geometry using its ID
  40855. * @param id defines the geometry's id
  40856. * @return the geometry or null if none found.
  40857. */
  40858. getGeometryByID(id: string): Nullable<Geometry>;
  40859. private _getGeometryByUniqueID;
  40860. /**
  40861. * Add a new geometry to this scene
  40862. * @param geometry defines the geometry to be added to the scene.
  40863. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40864. * @return a boolean defining if the geometry was added or not
  40865. */
  40866. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40867. /**
  40868. * Removes an existing geometry
  40869. * @param geometry defines the geometry to be removed from the scene
  40870. * @return a boolean defining if the geometry was removed or not
  40871. */
  40872. removeGeometry(geometry: Geometry): boolean;
  40873. /**
  40874. * Gets the list of geometries attached to the scene
  40875. * @returns an array of Geometry
  40876. */
  40877. getGeometries(): Geometry[];
  40878. /**
  40879. * Gets the first added mesh found of a given ID
  40880. * @param id defines the id to search for
  40881. * @return the mesh found or null if not found at all
  40882. */
  40883. getMeshByID(id: string): Nullable<AbstractMesh>;
  40884. /**
  40885. * Gets a list of meshes using their id
  40886. * @param id defines the id to search for
  40887. * @returns a list of meshes
  40888. */
  40889. getMeshesByID(id: string): Array<AbstractMesh>;
  40890. /**
  40891. * Gets the first added transform node found of a given ID
  40892. * @param id defines the id to search for
  40893. * @return the found transform node or null if not found at all.
  40894. */
  40895. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40896. /**
  40897. * Gets a transform node with its auto-generated unique id
  40898. * @param uniqueId efines the unique id to search for
  40899. * @return the found transform node or null if not found at all.
  40900. */
  40901. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40902. /**
  40903. * Gets a list of transform nodes using their id
  40904. * @param id defines the id to search for
  40905. * @returns a list of transform nodes
  40906. */
  40907. getTransformNodesByID(id: string): Array<TransformNode>;
  40908. /**
  40909. * Gets a mesh with its auto-generated unique id
  40910. * @param uniqueId defines the unique id to search for
  40911. * @return the found mesh or null if not found at all.
  40912. */
  40913. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40914. /**
  40915. * Gets a the last added mesh using a given id
  40916. * @param id defines the id to search for
  40917. * @return the found mesh or null if not found at all.
  40918. */
  40919. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40920. /**
  40921. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40922. * @param id defines the id to search for
  40923. * @return the found node or null if not found at all
  40924. */
  40925. getLastEntryByID(id: string): Nullable<Node>;
  40926. /**
  40927. * Gets a node (Mesh, Camera, Light) using a given id
  40928. * @param id defines the id to search for
  40929. * @return the found node or null if not found at all
  40930. */
  40931. getNodeByID(id: string): Nullable<Node>;
  40932. /**
  40933. * Gets a node (Mesh, Camera, Light) using a given name
  40934. * @param name defines the name to search for
  40935. * @return the found node or null if not found at all.
  40936. */
  40937. getNodeByName(name: string): Nullable<Node>;
  40938. /**
  40939. * Gets a mesh using a given name
  40940. * @param name defines the name to search for
  40941. * @return the found mesh or null if not found at all.
  40942. */
  40943. getMeshByName(name: string): Nullable<AbstractMesh>;
  40944. /**
  40945. * Gets a transform node using a given name
  40946. * @param name defines the name to search for
  40947. * @return the found transform node or null if not found at all.
  40948. */
  40949. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40950. /**
  40951. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40952. * @param id defines the id to search for
  40953. * @return the found skeleton or null if not found at all.
  40954. */
  40955. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40956. /**
  40957. * Gets a skeleton using a given auto generated unique id
  40958. * @param uniqueId defines the unique id to search for
  40959. * @return the found skeleton or null if not found at all.
  40960. */
  40961. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40962. /**
  40963. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40964. * @param id defines the id to search for
  40965. * @return the found skeleton or null if not found at all.
  40966. */
  40967. getSkeletonById(id: string): Nullable<Skeleton>;
  40968. /**
  40969. * Gets a skeleton using a given name
  40970. * @param name defines the name to search for
  40971. * @return the found skeleton or null if not found at all.
  40972. */
  40973. getSkeletonByName(name: string): Nullable<Skeleton>;
  40974. /**
  40975. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40976. * @param id defines the id to search for
  40977. * @return the found morph target manager or null if not found at all.
  40978. */
  40979. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40980. /**
  40981. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40982. * @param id defines the id to search for
  40983. * @return the found morph target or null if not found at all.
  40984. */
  40985. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40986. /**
  40987. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40988. * @param name defines the name to search for
  40989. * @return the found morph target or null if not found at all.
  40990. */
  40991. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40992. /**
  40993. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40994. * @param name defines the name to search for
  40995. * @return the found post process or null if not found at all.
  40996. */
  40997. getPostProcessByName(name: string): Nullable<PostProcess>;
  40998. /**
  40999. * Gets a boolean indicating if the given mesh is active
  41000. * @param mesh defines the mesh to look for
  41001. * @returns true if the mesh is in the active list
  41002. */
  41003. isActiveMesh(mesh: AbstractMesh): boolean;
  41004. /**
  41005. * Return a unique id as a string which can serve as an identifier for the scene
  41006. */
  41007. get uid(): string;
  41008. /**
  41009. * Add an externaly attached data from its key.
  41010. * This method call will fail and return false, if such key already exists.
  41011. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41012. * @param key the unique key that identifies the data
  41013. * @param data the data object to associate to the key for this Engine instance
  41014. * @return true if no such key were already present and the data was added successfully, false otherwise
  41015. */
  41016. addExternalData<T>(key: string, data: T): boolean;
  41017. /**
  41018. * Get an externaly attached data from its key
  41019. * @param key the unique key that identifies the data
  41020. * @return the associated data, if present (can be null), or undefined if not present
  41021. */
  41022. getExternalData<T>(key: string): Nullable<T>;
  41023. /**
  41024. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41025. * @param key the unique key that identifies the data
  41026. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41027. * @return the associated data, can be null if the factory returned null.
  41028. */
  41029. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41030. /**
  41031. * Remove an externaly attached data from the Engine instance
  41032. * @param key the unique key that identifies the data
  41033. * @return true if the data was successfully removed, false if it doesn't exist
  41034. */
  41035. removeExternalData(key: string): boolean;
  41036. private _evaluateSubMesh;
  41037. /**
  41038. * Clear the processed materials smart array preventing retention point in material dispose.
  41039. */
  41040. freeProcessedMaterials(): void;
  41041. private _preventFreeActiveMeshesAndRenderingGroups;
  41042. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41043. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41044. * when disposing several meshes in a row or a hierarchy of meshes.
  41045. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41046. */
  41047. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41048. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41049. /**
  41050. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41051. */
  41052. freeActiveMeshes(): void;
  41053. /**
  41054. * Clear the info related to rendering groups preventing retention points during dispose.
  41055. */
  41056. freeRenderingGroups(): void;
  41057. /** @hidden */
  41058. _isInIntermediateRendering(): boolean;
  41059. /**
  41060. * Lambda returning the list of potentially active meshes.
  41061. */
  41062. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41063. /**
  41064. * Lambda returning the list of potentially active sub meshes.
  41065. */
  41066. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41067. /**
  41068. * Lambda returning the list of potentially intersecting sub meshes.
  41069. */
  41070. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41071. /**
  41072. * Lambda returning the list of potentially colliding sub meshes.
  41073. */
  41074. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41075. private _activeMeshesFrozen;
  41076. private _skipEvaluateActiveMeshesCompletely;
  41077. /**
  41078. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41079. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41080. * @returns the current scene
  41081. */
  41082. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41083. /**
  41084. * Use this function to restart evaluating active meshes on every frame
  41085. * @returns the current scene
  41086. */
  41087. unfreezeActiveMeshes(): Scene;
  41088. private _evaluateActiveMeshes;
  41089. private _activeMesh;
  41090. /**
  41091. * Update the transform matrix to update from the current active camera
  41092. * @param force defines a boolean used to force the update even if cache is up to date
  41093. */
  41094. updateTransformMatrix(force?: boolean): void;
  41095. private _bindFrameBuffer;
  41096. /** @hidden */
  41097. _allowPostProcessClearColor: boolean;
  41098. /** @hidden */
  41099. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41100. private _processSubCameras;
  41101. private _checkIntersections;
  41102. /** @hidden */
  41103. _advancePhysicsEngineStep(step: number): void;
  41104. /**
  41105. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41106. */
  41107. getDeterministicFrameTime: () => number;
  41108. /** @hidden */
  41109. _animate(): void;
  41110. /** Execute all animations (for a frame) */
  41111. animate(): void;
  41112. /**
  41113. * Render the scene
  41114. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41115. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41116. */
  41117. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41118. /**
  41119. * Freeze all materials
  41120. * A frozen material will not be updatable but should be faster to render
  41121. */
  41122. freezeMaterials(): void;
  41123. /**
  41124. * Unfreeze all materials
  41125. * A frozen material will not be updatable but should be faster to render
  41126. */
  41127. unfreezeMaterials(): void;
  41128. /**
  41129. * Releases all held ressources
  41130. */
  41131. dispose(): void;
  41132. /**
  41133. * Gets if the scene is already disposed
  41134. */
  41135. get isDisposed(): boolean;
  41136. /**
  41137. * Call this function to reduce memory footprint of the scene.
  41138. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41139. */
  41140. clearCachedVertexData(): void;
  41141. /**
  41142. * This function will remove the local cached buffer data from texture.
  41143. * It will save memory but will prevent the texture from being rebuilt
  41144. */
  41145. cleanCachedTextureBuffer(): void;
  41146. /**
  41147. * Get the world extend vectors with an optional filter
  41148. *
  41149. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41150. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41151. */
  41152. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41153. min: Vector3;
  41154. max: Vector3;
  41155. };
  41156. /**
  41157. * Creates a ray that can be used to pick in the scene
  41158. * @param x defines the x coordinate of the origin (on-screen)
  41159. * @param y defines the y coordinate of the origin (on-screen)
  41160. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41161. * @param camera defines the camera to use for the picking
  41162. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41163. * @returns a Ray
  41164. */
  41165. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41166. /**
  41167. * Creates a ray that can be used to pick in the scene
  41168. * @param x defines the x coordinate of the origin (on-screen)
  41169. * @param y defines the y coordinate of the origin (on-screen)
  41170. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41171. * @param result defines the ray where to store the picking ray
  41172. * @param camera defines the camera to use for the picking
  41173. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41174. * @returns the current scene
  41175. */
  41176. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41177. /**
  41178. * Creates a ray that can be used to pick in the scene
  41179. * @param x defines the x coordinate of the origin (on-screen)
  41180. * @param y defines the y coordinate of the origin (on-screen)
  41181. * @param camera defines the camera to use for the picking
  41182. * @returns a Ray
  41183. */
  41184. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41185. /**
  41186. * Creates a ray that can be used to pick in the scene
  41187. * @param x defines the x coordinate of the origin (on-screen)
  41188. * @param y defines the y coordinate of the origin (on-screen)
  41189. * @param result defines the ray where to store the picking ray
  41190. * @param camera defines the camera to use for the picking
  41191. * @returns the current scene
  41192. */
  41193. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41194. /** Launch a ray to try to pick a mesh in the scene
  41195. * @param x position on screen
  41196. * @param y position on screen
  41197. * @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
  41198. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41199. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41200. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41201. * @returns a PickingInfo
  41202. */
  41203. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41204. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41205. * @param x position on screen
  41206. * @param y position on screen
  41207. * @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
  41208. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41209. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41210. * @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)
  41211. */
  41212. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41213. /** Use the given ray to pick a mesh in the scene
  41214. * @param ray The ray to use to pick meshes
  41215. * @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
  41216. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41217. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41218. * @returns a PickingInfo
  41219. */
  41220. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41221. /**
  41222. * Launch a ray to try to pick a mesh in the scene
  41223. * @param x X position on screen
  41224. * @param y Y position on screen
  41225. * @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
  41226. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41227. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41228. * @returns an array of PickingInfo
  41229. */
  41230. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41231. /**
  41232. * Launch a ray to try to pick a mesh in the scene
  41233. * @param ray Ray to use
  41234. * @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
  41235. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41236. * @returns an array of PickingInfo
  41237. */
  41238. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41239. /**
  41240. * Force the value of meshUnderPointer
  41241. * @param mesh defines the mesh to use
  41242. * @param pointerId optional pointer id when using more than one pointer
  41243. */
  41244. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41245. /**
  41246. * Gets the mesh under the pointer
  41247. * @returns a Mesh or null if no mesh is under the pointer
  41248. */
  41249. getPointerOverMesh(): Nullable<AbstractMesh>;
  41250. /** @hidden */
  41251. _rebuildGeometries(): void;
  41252. /** @hidden */
  41253. _rebuildTextures(): void;
  41254. private _getByTags;
  41255. /**
  41256. * Get a list of meshes by tags
  41257. * @param tagsQuery defines the tags query to use
  41258. * @param forEach defines a predicate used to filter results
  41259. * @returns an array of Mesh
  41260. */
  41261. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41262. /**
  41263. * Get a list of cameras by tags
  41264. * @param tagsQuery defines the tags query to use
  41265. * @param forEach defines a predicate used to filter results
  41266. * @returns an array of Camera
  41267. */
  41268. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41269. /**
  41270. * Get a list of lights by tags
  41271. * @param tagsQuery defines the tags query to use
  41272. * @param forEach defines a predicate used to filter results
  41273. * @returns an array of Light
  41274. */
  41275. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41276. /**
  41277. * Get a list of materials by tags
  41278. * @param tagsQuery defines the tags query to use
  41279. * @param forEach defines a predicate used to filter results
  41280. * @returns an array of Material
  41281. */
  41282. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41283. /**
  41284. * Get a list of transform nodes by tags
  41285. * @param tagsQuery defines the tags query to use
  41286. * @param forEach defines a predicate used to filter results
  41287. * @returns an array of TransformNode
  41288. */
  41289. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41290. /**
  41291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41292. * This allowed control for front to back rendering or reversly depending of the special needs.
  41293. *
  41294. * @param renderingGroupId The rendering group id corresponding to its index
  41295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41298. */
  41299. 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;
  41300. /**
  41301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41302. *
  41303. * @param renderingGroupId The rendering group id corresponding to its index
  41304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41307. */
  41308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41309. /**
  41310. * Gets the current auto clear configuration for one rendering group of the rendering
  41311. * manager.
  41312. * @param index the rendering group index to get the information for
  41313. * @returns The auto clear setup for the requested rendering group
  41314. */
  41315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41316. private _blockMaterialDirtyMechanism;
  41317. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41318. get blockMaterialDirtyMechanism(): boolean;
  41319. set blockMaterialDirtyMechanism(value: boolean);
  41320. /**
  41321. * Will flag all materials as dirty to trigger new shader compilation
  41322. * @param flag defines the flag used to specify which material part must be marked as dirty
  41323. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41324. */
  41325. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41326. /** @hidden */
  41327. _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;
  41328. /** @hidden */
  41329. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41330. /** @hidden */
  41331. _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;
  41332. /** @hidden */
  41333. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41334. /** @hidden */
  41335. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41336. /** @hidden */
  41337. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41338. }
  41339. }
  41340. declare module BABYLON {
  41341. /**
  41342. * Set of assets to keep when moving a scene into an asset container.
  41343. */
  41344. export class KeepAssets extends AbstractScene {
  41345. }
  41346. /**
  41347. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41348. */
  41349. export class InstantiatedEntries {
  41350. /**
  41351. * List of new root nodes (eg. nodes with no parent)
  41352. */
  41353. rootNodes: TransformNode[];
  41354. /**
  41355. * List of new skeletons
  41356. */
  41357. skeletons: Skeleton[];
  41358. /**
  41359. * List of new animation groups
  41360. */
  41361. animationGroups: AnimationGroup[];
  41362. }
  41363. /**
  41364. * Container with a set of assets that can be added or removed from a scene.
  41365. */
  41366. export class AssetContainer extends AbstractScene {
  41367. private _wasAddedToScene;
  41368. /**
  41369. * The scene the AssetContainer belongs to.
  41370. */
  41371. scene: Scene;
  41372. /**
  41373. * Instantiates an AssetContainer.
  41374. * @param scene The scene the AssetContainer belongs to.
  41375. */
  41376. constructor(scene: Scene);
  41377. /**
  41378. * Instantiate or clone all meshes and add the new ones to the scene.
  41379. * Skeletons and animation groups will all be cloned
  41380. * @param nameFunction defines an optional function used to get new names for clones
  41381. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41382. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41383. */
  41384. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41385. /**
  41386. * Adds all the assets from the container to the scene.
  41387. */
  41388. addAllToScene(): void;
  41389. /**
  41390. * Removes all the assets in the container from the scene
  41391. */
  41392. removeAllFromScene(): void;
  41393. /**
  41394. * Disposes all the assets in the container
  41395. */
  41396. dispose(): void;
  41397. private _moveAssets;
  41398. /**
  41399. * Removes all the assets contained in the scene and adds them to the container.
  41400. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41401. */
  41402. moveAllFromScene(keepAssets?: KeepAssets): void;
  41403. /**
  41404. * 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.
  41405. * @returns the root mesh
  41406. */
  41407. createRootMesh(): Mesh;
  41408. /**
  41409. * Merge animations (direct and animation groups) from this asset container into a scene
  41410. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41411. * @param animatables set of animatables to retarget to a node from the scene
  41412. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41413. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41414. */
  41415. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41416. }
  41417. }
  41418. declare module BABYLON {
  41419. /**
  41420. * Defines how the parser contract is defined.
  41421. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41422. */
  41423. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41424. /**
  41425. * Defines how the individual parser contract is defined.
  41426. * These parser can parse an individual asset
  41427. */
  41428. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41429. /**
  41430. * Base class of the scene acting as a container for the different elements composing a scene.
  41431. * This class is dynamically extended by the different components of the scene increasing
  41432. * flexibility and reducing coupling
  41433. */
  41434. export abstract class AbstractScene {
  41435. /**
  41436. * Stores the list of available parsers in the application.
  41437. */
  41438. private static _BabylonFileParsers;
  41439. /**
  41440. * Stores the list of available individual parsers in the application.
  41441. */
  41442. private static _IndividualBabylonFileParsers;
  41443. /**
  41444. * Adds a parser in the list of available ones
  41445. * @param name Defines the name of the parser
  41446. * @param parser Defines the parser to add
  41447. */
  41448. static AddParser(name: string, parser: BabylonFileParser): void;
  41449. /**
  41450. * Gets a general parser from the list of avaialble ones
  41451. * @param name Defines the name of the parser
  41452. * @returns the requested parser or null
  41453. */
  41454. static GetParser(name: string): Nullable<BabylonFileParser>;
  41455. /**
  41456. * Adds n individual parser in the list of available ones
  41457. * @param name Defines the name of the parser
  41458. * @param parser Defines the parser to add
  41459. */
  41460. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41461. /**
  41462. * Gets an individual parser from the list of avaialble ones
  41463. * @param name Defines the name of the parser
  41464. * @returns the requested parser or null
  41465. */
  41466. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41467. /**
  41468. * Parser json data and populate both a scene and its associated container object
  41469. * @param jsonData Defines the data to parse
  41470. * @param scene Defines the scene to parse the data for
  41471. * @param container Defines the container attached to the parsing sequence
  41472. * @param rootUrl Defines the root url of the data
  41473. */
  41474. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41475. /**
  41476. * Gets the list of root nodes (ie. nodes with no parent)
  41477. */
  41478. rootNodes: Node[];
  41479. /** All of the cameras added to this scene
  41480. * @see https://doc.babylonjs.com/babylon101/cameras
  41481. */
  41482. cameras: Camera[];
  41483. /**
  41484. * All of the lights added to this scene
  41485. * @see https://doc.babylonjs.com/babylon101/lights
  41486. */
  41487. lights: Light[];
  41488. /**
  41489. * All of the (abstract) meshes added to this scene
  41490. */
  41491. meshes: AbstractMesh[];
  41492. /**
  41493. * The list of skeletons added to the scene
  41494. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41495. */
  41496. skeletons: Skeleton[];
  41497. /**
  41498. * All of the particle systems added to this scene
  41499. * @see https://doc.babylonjs.com/babylon101/particles
  41500. */
  41501. particleSystems: IParticleSystem[];
  41502. /**
  41503. * Gets a list of Animations associated with the scene
  41504. */
  41505. animations: Animation[];
  41506. /**
  41507. * All of the animation groups added to this scene
  41508. * @see https://doc.babylonjs.com/how_to/group
  41509. */
  41510. animationGroups: AnimationGroup[];
  41511. /**
  41512. * All of the multi-materials added to this scene
  41513. * @see https://doc.babylonjs.com/how_to/multi_materials
  41514. */
  41515. multiMaterials: MultiMaterial[];
  41516. /**
  41517. * All of the materials added to this scene
  41518. * In the context of a Scene, it is not supposed to be modified manually.
  41519. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41520. * Note also that the order of the Material within the array is not significant and might change.
  41521. * @see https://doc.babylonjs.com/babylon101/materials
  41522. */
  41523. materials: Material[];
  41524. /**
  41525. * The list of morph target managers added to the scene
  41526. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41527. */
  41528. morphTargetManagers: MorphTargetManager[];
  41529. /**
  41530. * The list of geometries used in the scene.
  41531. */
  41532. geometries: Geometry[];
  41533. /**
  41534. * All of the tranform nodes added to this scene
  41535. * In the context of a Scene, it is not supposed to be modified manually.
  41536. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41537. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41538. * @see https://doc.babylonjs.com/how_to/transformnode
  41539. */
  41540. transformNodes: TransformNode[];
  41541. /**
  41542. * ActionManagers available on the scene.
  41543. */
  41544. actionManagers: AbstractActionManager[];
  41545. /**
  41546. * Textures to keep.
  41547. */
  41548. textures: BaseTexture[];
  41549. /** @hidden */
  41550. protected _environmentTexture: Nullable<BaseTexture>;
  41551. /**
  41552. * Texture used in all pbr material as the reflection texture.
  41553. * As in the majority of the scene they are the same (exception for multi room and so on),
  41554. * this is easier to reference from here than from all the materials.
  41555. */
  41556. get environmentTexture(): Nullable<BaseTexture>;
  41557. set environmentTexture(value: Nullable<BaseTexture>);
  41558. /**
  41559. * The list of postprocesses added to the scene
  41560. */
  41561. postProcesses: PostProcess[];
  41562. /**
  41563. * @returns all meshes, lights, cameras, transformNodes and bones
  41564. */
  41565. getNodes(): Array<Node>;
  41566. }
  41567. }
  41568. declare module BABYLON {
  41569. /**
  41570. * Interface used to define options for Sound class
  41571. */
  41572. export interface ISoundOptions {
  41573. /**
  41574. * Does the sound autoplay once loaded.
  41575. */
  41576. autoplay?: boolean;
  41577. /**
  41578. * Does the sound loop after it finishes playing once.
  41579. */
  41580. loop?: boolean;
  41581. /**
  41582. * Sound's volume
  41583. */
  41584. volume?: number;
  41585. /**
  41586. * Is it a spatial sound?
  41587. */
  41588. spatialSound?: boolean;
  41589. /**
  41590. * Maximum distance to hear that sound
  41591. */
  41592. maxDistance?: number;
  41593. /**
  41594. * Uses user defined attenuation function
  41595. */
  41596. useCustomAttenuation?: boolean;
  41597. /**
  41598. * Define the roll off factor of spatial sounds.
  41599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41600. */
  41601. rolloffFactor?: number;
  41602. /**
  41603. * Define the reference distance the sound should be heard perfectly.
  41604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41605. */
  41606. refDistance?: number;
  41607. /**
  41608. * Define the distance attenuation model the sound will follow.
  41609. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41610. */
  41611. distanceModel?: string;
  41612. /**
  41613. * Defines the playback speed (1 by default)
  41614. */
  41615. playbackRate?: number;
  41616. /**
  41617. * Defines if the sound is from a streaming source
  41618. */
  41619. streaming?: boolean;
  41620. /**
  41621. * Defines an optional length (in seconds) inside the sound file
  41622. */
  41623. length?: number;
  41624. /**
  41625. * Defines an optional offset (in seconds) inside the sound file
  41626. */
  41627. offset?: number;
  41628. /**
  41629. * If true, URLs will not be required to state the audio file codec to use.
  41630. */
  41631. skipCodecCheck?: boolean;
  41632. }
  41633. /**
  41634. * Defines a sound that can be played in the application.
  41635. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41636. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41637. */
  41638. export class Sound {
  41639. /**
  41640. * The name of the sound in the scene.
  41641. */
  41642. name: string;
  41643. /**
  41644. * Does the sound autoplay once loaded.
  41645. */
  41646. autoplay: boolean;
  41647. /**
  41648. * Does the sound loop after it finishes playing once.
  41649. */
  41650. loop: boolean;
  41651. /**
  41652. * Does the sound use a custom attenuation curve to simulate the falloff
  41653. * happening when the source gets further away from the camera.
  41654. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41655. */
  41656. useCustomAttenuation: boolean;
  41657. /**
  41658. * The sound track id this sound belongs to.
  41659. */
  41660. soundTrackId: number;
  41661. /**
  41662. * Is this sound currently played.
  41663. */
  41664. isPlaying: boolean;
  41665. /**
  41666. * Is this sound currently paused.
  41667. */
  41668. isPaused: boolean;
  41669. /**
  41670. * Does this sound enables spatial sound.
  41671. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41672. */
  41673. spatialSound: boolean;
  41674. /**
  41675. * Define the reference distance the sound should be heard perfectly.
  41676. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41677. */
  41678. refDistance: number;
  41679. /**
  41680. * Define the roll off factor of spatial sounds.
  41681. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41682. */
  41683. rolloffFactor: number;
  41684. /**
  41685. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41687. */
  41688. maxDistance: number;
  41689. /**
  41690. * Define the distance attenuation model the sound will follow.
  41691. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41692. */
  41693. distanceModel: string;
  41694. /**
  41695. * @hidden
  41696. * Back Compat
  41697. **/
  41698. onended: () => any;
  41699. /**
  41700. * Gets or sets an object used to store user defined information for the sound.
  41701. */
  41702. metadata: any;
  41703. /**
  41704. * Observable event when the current playing sound finishes.
  41705. */
  41706. onEndedObservable: Observable<Sound>;
  41707. private _panningModel;
  41708. private _playbackRate;
  41709. private _streaming;
  41710. private _startTime;
  41711. private _startOffset;
  41712. private _position;
  41713. /** @hidden */
  41714. _positionInEmitterSpace: boolean;
  41715. private _localDirection;
  41716. private _volume;
  41717. private _isReadyToPlay;
  41718. private _isDirectional;
  41719. private _readyToPlayCallback;
  41720. private _audioBuffer;
  41721. private _soundSource;
  41722. private _streamingSource;
  41723. private _soundPanner;
  41724. private _soundGain;
  41725. private _inputAudioNode;
  41726. private _outputAudioNode;
  41727. private _coneInnerAngle;
  41728. private _coneOuterAngle;
  41729. private _coneOuterGain;
  41730. private _scene;
  41731. private _connectedTransformNode;
  41732. private _customAttenuationFunction;
  41733. private _registerFunc;
  41734. private _isOutputConnected;
  41735. private _htmlAudioElement;
  41736. private _urlType;
  41737. private _length?;
  41738. private _offset?;
  41739. /** @hidden */
  41740. static _SceneComponentInitialization: (scene: Scene) => void;
  41741. /**
  41742. * Create a sound and attach it to a scene
  41743. * @param name Name of your sound
  41744. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41745. * @param scene defines the scene the sound belongs to
  41746. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41747. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41748. */
  41749. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41750. /**
  41751. * Release the sound and its associated resources
  41752. */
  41753. dispose(): void;
  41754. /**
  41755. * Gets if the sounds is ready to be played or not.
  41756. * @returns true if ready, otherwise false
  41757. */
  41758. isReady(): boolean;
  41759. private _soundLoaded;
  41760. /**
  41761. * Sets the data of the sound from an audiobuffer
  41762. * @param audioBuffer The audioBuffer containing the data
  41763. */
  41764. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41765. /**
  41766. * Updates the current sounds options such as maxdistance, loop...
  41767. * @param options A JSON object containing values named as the object properties
  41768. */
  41769. updateOptions(options: ISoundOptions): void;
  41770. private _createSpatialParameters;
  41771. private _updateSpatialParameters;
  41772. /**
  41773. * Switch the panning model to HRTF:
  41774. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41776. */
  41777. switchPanningModelToHRTF(): void;
  41778. /**
  41779. * Switch the panning model to Equal Power:
  41780. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41781. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41782. */
  41783. switchPanningModelToEqualPower(): void;
  41784. private _switchPanningModel;
  41785. /**
  41786. * Connect this sound to a sound track audio node like gain...
  41787. * @param soundTrackAudioNode the sound track audio node to connect to
  41788. */
  41789. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41790. /**
  41791. * Transform this sound into a directional source
  41792. * @param coneInnerAngle Size of the inner cone in degree
  41793. * @param coneOuterAngle Size of the outer cone in degree
  41794. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41795. */
  41796. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41797. /**
  41798. * Gets or sets the inner angle for the directional cone.
  41799. */
  41800. get directionalConeInnerAngle(): number;
  41801. /**
  41802. * Gets or sets the inner angle for the directional cone.
  41803. */
  41804. set directionalConeInnerAngle(value: number);
  41805. /**
  41806. * Gets or sets the outer angle for the directional cone.
  41807. */
  41808. get directionalConeOuterAngle(): number;
  41809. /**
  41810. * Gets or sets the outer angle for the directional cone.
  41811. */
  41812. set directionalConeOuterAngle(value: number);
  41813. /**
  41814. * Sets the position of the emitter if spatial sound is enabled
  41815. * @param newPosition Defines the new posisiton
  41816. */
  41817. setPosition(newPosition: Vector3): void;
  41818. /**
  41819. * Sets the local direction of the emitter if spatial sound is enabled
  41820. * @param newLocalDirection Defines the new local direction
  41821. */
  41822. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41823. private _updateDirection;
  41824. /** @hidden */
  41825. updateDistanceFromListener(): void;
  41826. /**
  41827. * Sets a new custom attenuation function for the sound.
  41828. * @param callback Defines the function used for the attenuation
  41829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41830. */
  41831. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41832. /**
  41833. * Play the sound
  41834. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41835. * @param offset (optional) Start the sound at a specific time in seconds
  41836. * @param length (optional) Sound duration (in seconds)
  41837. */
  41838. play(time?: number, offset?: number, length?: number): void;
  41839. private _onended;
  41840. /**
  41841. * Stop the sound
  41842. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41843. */
  41844. stop(time?: number): void;
  41845. /**
  41846. * Put the sound in pause
  41847. */
  41848. pause(): void;
  41849. /**
  41850. * Sets a dedicated volume for this sounds
  41851. * @param newVolume Define the new volume of the sound
  41852. * @param time Define time for gradual change to new volume
  41853. */
  41854. setVolume(newVolume: number, time?: number): void;
  41855. /**
  41856. * Set the sound play back rate
  41857. * @param newPlaybackRate Define the playback rate the sound should be played at
  41858. */
  41859. setPlaybackRate(newPlaybackRate: number): void;
  41860. /**
  41861. * Gets the volume of the sound.
  41862. * @returns the volume of the sound
  41863. */
  41864. getVolume(): number;
  41865. /**
  41866. * Attach the sound to a dedicated mesh
  41867. * @param transformNode The transform node to connect the sound with
  41868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41869. */
  41870. attachToMesh(transformNode: TransformNode): void;
  41871. /**
  41872. * Detach the sound from the previously attached mesh
  41873. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41874. */
  41875. detachFromMesh(): void;
  41876. private _onRegisterAfterWorldMatrixUpdate;
  41877. /**
  41878. * Clone the current sound in the scene.
  41879. * @returns the new sound clone
  41880. */
  41881. clone(): Nullable<Sound>;
  41882. /**
  41883. * Gets the current underlying audio buffer containing the data
  41884. * @returns the audio buffer
  41885. */
  41886. getAudioBuffer(): Nullable<AudioBuffer>;
  41887. /**
  41888. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41889. * @returns the source node
  41890. */
  41891. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41892. /**
  41893. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41894. * @returns the gain node
  41895. */
  41896. getSoundGain(): Nullable<GainNode>;
  41897. /**
  41898. * Serializes the Sound in a JSON representation
  41899. * @returns the JSON representation of the sound
  41900. */
  41901. serialize(): any;
  41902. /**
  41903. * Parse a JSON representation of a sound to innstantiate in a given scene
  41904. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41905. * @param scene Define the scene the new parsed sound should be created in
  41906. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41907. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41908. * @returns the newly parsed sound
  41909. */
  41910. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41911. }
  41912. }
  41913. declare module BABYLON {
  41914. /**
  41915. * This defines an action helpful to play a defined sound on a triggered action.
  41916. */
  41917. export class PlaySoundAction extends Action {
  41918. private _sound;
  41919. /**
  41920. * Instantiate the action
  41921. * @param triggerOptions defines the trigger options
  41922. * @param sound defines the sound to play
  41923. * @param condition defines the trigger related conditions
  41924. */
  41925. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41926. /** @hidden */
  41927. _prepare(): void;
  41928. /**
  41929. * Execute the action and play the sound.
  41930. */
  41931. execute(): void;
  41932. /**
  41933. * Serializes the actions and its related information.
  41934. * @param parent defines the object to serialize in
  41935. * @returns the serialized object
  41936. */
  41937. serialize(parent: any): any;
  41938. }
  41939. /**
  41940. * This defines an action helpful to stop a defined sound on a triggered action.
  41941. */
  41942. export class StopSoundAction extends Action {
  41943. private _sound;
  41944. /**
  41945. * Instantiate the action
  41946. * @param triggerOptions defines the trigger options
  41947. * @param sound defines the sound to stop
  41948. * @param condition defines the trigger related conditions
  41949. */
  41950. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41951. /** @hidden */
  41952. _prepare(): void;
  41953. /**
  41954. * Execute the action and stop the sound.
  41955. */
  41956. execute(): void;
  41957. /**
  41958. * Serializes the actions and its related information.
  41959. * @param parent defines the object to serialize in
  41960. * @returns the serialized object
  41961. */
  41962. serialize(parent: any): any;
  41963. }
  41964. }
  41965. declare module BABYLON {
  41966. /**
  41967. * This defines an action responsible to change the value of a property
  41968. * by interpolating between its current value and the newly set one once triggered.
  41969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41970. */
  41971. export class InterpolateValueAction extends Action {
  41972. /**
  41973. * Defines the path of the property where the value should be interpolated
  41974. */
  41975. propertyPath: string;
  41976. /**
  41977. * Defines the target value at the end of the interpolation.
  41978. */
  41979. value: any;
  41980. /**
  41981. * Defines the time it will take for the property to interpolate to the value.
  41982. */
  41983. duration: number;
  41984. /**
  41985. * Defines if the other scene animations should be stopped when the action has been triggered
  41986. */
  41987. stopOtherAnimations?: boolean;
  41988. /**
  41989. * Defines a callback raised once the interpolation animation has been done.
  41990. */
  41991. onInterpolationDone?: () => void;
  41992. /**
  41993. * Observable triggered once the interpolation animation has been done.
  41994. */
  41995. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41996. private _target;
  41997. private _effectiveTarget;
  41998. private _property;
  41999. /**
  42000. * Instantiate the action
  42001. * @param triggerOptions defines the trigger options
  42002. * @param target defines the object containing the value to interpolate
  42003. * @param propertyPath defines the path to the property in the target object
  42004. * @param value defines the target value at the end of the interpolation
  42005. * @param duration deines the time it will take for the property to interpolate to the value.
  42006. * @param condition defines the trigger related conditions
  42007. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42008. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42009. */
  42010. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42011. /** @hidden */
  42012. _prepare(): void;
  42013. /**
  42014. * Execute the action starts the value interpolation.
  42015. */
  42016. execute(): void;
  42017. /**
  42018. * Serializes the actions and its related information.
  42019. * @param parent defines the object to serialize in
  42020. * @returns the serialized object
  42021. */
  42022. serialize(parent: any): any;
  42023. }
  42024. }
  42025. declare module BABYLON {
  42026. /**
  42027. * Options allowed during the creation of a sound track.
  42028. */
  42029. export interface ISoundTrackOptions {
  42030. /**
  42031. * The volume the sound track should take during creation
  42032. */
  42033. volume?: number;
  42034. /**
  42035. * Define if the sound track is the main sound track of the scene
  42036. */
  42037. mainTrack?: boolean;
  42038. }
  42039. /**
  42040. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42041. * It will be also used in a future release to apply effects on a specific track.
  42042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42043. */
  42044. export class SoundTrack {
  42045. /**
  42046. * The unique identifier of the sound track in the scene.
  42047. */
  42048. id: number;
  42049. /**
  42050. * The list of sounds included in the sound track.
  42051. */
  42052. soundCollection: Array<Sound>;
  42053. private _outputAudioNode;
  42054. private _scene;
  42055. private _connectedAnalyser;
  42056. private _options;
  42057. private _isInitialized;
  42058. /**
  42059. * Creates a new sound track.
  42060. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42061. * @param scene Define the scene the sound track belongs to
  42062. * @param options
  42063. */
  42064. constructor(scene: Scene, options?: ISoundTrackOptions);
  42065. private _initializeSoundTrackAudioGraph;
  42066. /**
  42067. * Release the sound track and its associated resources
  42068. */
  42069. dispose(): void;
  42070. /**
  42071. * Adds a sound to this sound track
  42072. * @param sound define the cound to add
  42073. * @ignoreNaming
  42074. */
  42075. AddSound(sound: Sound): void;
  42076. /**
  42077. * Removes a sound to this sound track
  42078. * @param sound define the cound to remove
  42079. * @ignoreNaming
  42080. */
  42081. RemoveSound(sound: Sound): void;
  42082. /**
  42083. * Set a global volume for the full sound track.
  42084. * @param newVolume Define the new volume of the sound track
  42085. */
  42086. setVolume(newVolume: number): void;
  42087. /**
  42088. * Switch the panning model to HRTF:
  42089. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42090. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42091. */
  42092. switchPanningModelToHRTF(): void;
  42093. /**
  42094. * Switch the panning model to Equal Power:
  42095. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42096. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42097. */
  42098. switchPanningModelToEqualPower(): void;
  42099. /**
  42100. * Connect the sound track to an audio analyser allowing some amazing
  42101. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42102. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42103. * @param analyser The analyser to connect to the engine
  42104. */
  42105. connectToAnalyser(analyser: Analyser): void;
  42106. }
  42107. }
  42108. declare module BABYLON {
  42109. interface AbstractScene {
  42110. /**
  42111. * The list of sounds used in the scene.
  42112. */
  42113. sounds: Nullable<Array<Sound>>;
  42114. }
  42115. interface Scene {
  42116. /**
  42117. * @hidden
  42118. * Backing field
  42119. */
  42120. _mainSoundTrack: SoundTrack;
  42121. /**
  42122. * The main sound track played by the scene.
  42123. * It cotains your primary collection of sounds.
  42124. */
  42125. mainSoundTrack: SoundTrack;
  42126. /**
  42127. * The list of sound tracks added to the scene
  42128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42129. */
  42130. soundTracks: Nullable<Array<SoundTrack>>;
  42131. /**
  42132. * Gets a sound using a given name
  42133. * @param name defines the name to search for
  42134. * @return the found sound or null if not found at all.
  42135. */
  42136. getSoundByName(name: string): Nullable<Sound>;
  42137. /**
  42138. * Gets or sets if audio support is enabled
  42139. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42140. */
  42141. audioEnabled: boolean;
  42142. /**
  42143. * Gets or sets if audio will be output to headphones
  42144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42145. */
  42146. headphone: boolean;
  42147. /**
  42148. * Gets or sets custom audio listener position provider
  42149. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42150. */
  42151. audioListenerPositionProvider: Nullable<() => Vector3>;
  42152. /**
  42153. * Gets or sets a refresh rate when using 3D audio positioning
  42154. */
  42155. audioPositioningRefreshRate: number;
  42156. }
  42157. /**
  42158. * Defines the sound scene component responsible to manage any sounds
  42159. * in a given scene.
  42160. */
  42161. export class AudioSceneComponent implements ISceneSerializableComponent {
  42162. private static _CameraDirectionLH;
  42163. private static _CameraDirectionRH;
  42164. /**
  42165. * The component name helpfull to identify the component in the list of scene components.
  42166. */
  42167. readonly name: string;
  42168. /**
  42169. * The scene the component belongs to.
  42170. */
  42171. scene: Scene;
  42172. private _audioEnabled;
  42173. /**
  42174. * Gets whether audio is enabled or not.
  42175. * Please use related enable/disable method to switch state.
  42176. */
  42177. get audioEnabled(): boolean;
  42178. private _headphone;
  42179. /**
  42180. * Gets whether audio is outputing to headphone or not.
  42181. * Please use the according Switch methods to change output.
  42182. */
  42183. get headphone(): boolean;
  42184. /**
  42185. * Gets or sets a refresh rate when using 3D audio positioning
  42186. */
  42187. audioPositioningRefreshRate: number;
  42188. private _audioListenerPositionProvider;
  42189. /**
  42190. * Gets the current audio listener position provider
  42191. */
  42192. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42193. /**
  42194. * Sets a custom listener position for all sounds in the scene
  42195. * By default, this is the position of the first active camera
  42196. */
  42197. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42198. /**
  42199. * Creates a new instance of the component for the given scene
  42200. * @param scene Defines the scene to register the component in
  42201. */
  42202. constructor(scene: Scene);
  42203. /**
  42204. * Registers the component in a given scene
  42205. */
  42206. register(): void;
  42207. /**
  42208. * Rebuilds the elements related to this component in case of
  42209. * context lost for instance.
  42210. */
  42211. rebuild(): void;
  42212. /**
  42213. * Serializes the component data to the specified json object
  42214. * @param serializationObject The object to serialize to
  42215. */
  42216. serialize(serializationObject: any): void;
  42217. /**
  42218. * Adds all the elements from the container to the scene
  42219. * @param container the container holding the elements
  42220. */
  42221. addFromContainer(container: AbstractScene): void;
  42222. /**
  42223. * Removes all the elements in the container from the scene
  42224. * @param container contains the elements to remove
  42225. * @param dispose if the removed element should be disposed (default: false)
  42226. */
  42227. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42228. /**
  42229. * Disposes the component and the associated ressources.
  42230. */
  42231. dispose(): void;
  42232. /**
  42233. * Disables audio in the associated scene.
  42234. */
  42235. disableAudio(): void;
  42236. /**
  42237. * Enables audio in the associated scene.
  42238. */
  42239. enableAudio(): void;
  42240. /**
  42241. * Switch audio to headphone output.
  42242. */
  42243. switchAudioModeForHeadphones(): void;
  42244. /**
  42245. * Switch audio to normal speakers.
  42246. */
  42247. switchAudioModeForNormalSpeakers(): void;
  42248. private _cachedCameraDirection;
  42249. private _cachedCameraPosition;
  42250. private _lastCheck;
  42251. private _afterRender;
  42252. }
  42253. }
  42254. declare module BABYLON {
  42255. /**
  42256. * Wraps one or more Sound objects and selects one with random weight for playback.
  42257. */
  42258. export class WeightedSound {
  42259. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42260. loop: boolean;
  42261. private _coneInnerAngle;
  42262. private _coneOuterAngle;
  42263. private _volume;
  42264. /** A Sound is currently playing. */
  42265. isPlaying: boolean;
  42266. /** A Sound is currently paused. */
  42267. isPaused: boolean;
  42268. private _sounds;
  42269. private _weights;
  42270. private _currentIndex?;
  42271. /**
  42272. * Creates a new WeightedSound from the list of sounds given.
  42273. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42274. * @param sounds Array of Sounds that will be selected from.
  42275. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42276. */
  42277. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42278. /**
  42279. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42280. */
  42281. get directionalConeInnerAngle(): number;
  42282. /**
  42283. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42284. */
  42285. set directionalConeInnerAngle(value: number);
  42286. /**
  42287. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42288. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42289. */
  42290. get directionalConeOuterAngle(): number;
  42291. /**
  42292. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42293. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42294. */
  42295. set directionalConeOuterAngle(value: number);
  42296. /**
  42297. * Playback volume.
  42298. */
  42299. get volume(): number;
  42300. /**
  42301. * Playback volume.
  42302. */
  42303. set volume(value: number);
  42304. private _onended;
  42305. /**
  42306. * Suspend playback
  42307. */
  42308. pause(): void;
  42309. /**
  42310. * Stop playback
  42311. */
  42312. stop(): void;
  42313. /**
  42314. * Start playback.
  42315. * @param startOffset Position the clip head at a specific time in seconds.
  42316. */
  42317. play(startOffset?: number): void;
  42318. }
  42319. }
  42320. declare module BABYLON {
  42321. /**
  42322. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42323. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42324. */
  42325. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42326. /**
  42327. * Gets the name of the behavior.
  42328. */
  42329. get name(): string;
  42330. /**
  42331. * The easing function used by animations
  42332. */
  42333. static EasingFunction: BackEase;
  42334. /**
  42335. * The easing mode used by animations
  42336. */
  42337. static EasingMode: number;
  42338. /**
  42339. * The duration of the animation, in milliseconds
  42340. */
  42341. transitionDuration: number;
  42342. /**
  42343. * Length of the distance animated by the transition when lower radius is reached
  42344. */
  42345. lowerRadiusTransitionRange: number;
  42346. /**
  42347. * Length of the distance animated by the transition when upper radius is reached
  42348. */
  42349. upperRadiusTransitionRange: number;
  42350. private _autoTransitionRange;
  42351. /**
  42352. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42353. */
  42354. get autoTransitionRange(): boolean;
  42355. /**
  42356. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42357. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42358. */
  42359. set autoTransitionRange(value: boolean);
  42360. private _attachedCamera;
  42361. private _onAfterCheckInputsObserver;
  42362. private _onMeshTargetChangedObserver;
  42363. /**
  42364. * Initializes the behavior.
  42365. */
  42366. init(): void;
  42367. /**
  42368. * Attaches the behavior to its arc rotate camera.
  42369. * @param camera Defines the camera to attach the behavior to
  42370. */
  42371. attach(camera: ArcRotateCamera): void;
  42372. /**
  42373. * Detaches the behavior from its current arc rotate camera.
  42374. */
  42375. detach(): void;
  42376. private _radiusIsAnimating;
  42377. private _radiusBounceTransition;
  42378. private _animatables;
  42379. private _cachedWheelPrecision;
  42380. /**
  42381. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42382. * @param radiusLimit The limit to check against.
  42383. * @return Bool to indicate if at limit.
  42384. */
  42385. private _isRadiusAtLimit;
  42386. /**
  42387. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42388. * @param radiusDelta The delta by which to animate to. Can be negative.
  42389. */
  42390. private _applyBoundRadiusAnimation;
  42391. /**
  42392. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42393. */
  42394. protected _clearAnimationLocks(): void;
  42395. /**
  42396. * Stops and removes all animations that have been applied to the camera
  42397. */
  42398. stopAllAnimations(): void;
  42399. }
  42400. }
  42401. declare module BABYLON {
  42402. /**
  42403. * 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.
  42404. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42405. */
  42406. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42407. /**
  42408. * Gets the name of the behavior.
  42409. */
  42410. get name(): string;
  42411. private _mode;
  42412. private _radiusScale;
  42413. private _positionScale;
  42414. private _defaultElevation;
  42415. private _elevationReturnTime;
  42416. private _elevationReturnWaitTime;
  42417. private _zoomStopsAnimation;
  42418. private _framingTime;
  42419. /**
  42420. * The easing function used by animations
  42421. */
  42422. static EasingFunction: ExponentialEase;
  42423. /**
  42424. * The easing mode used by animations
  42425. */
  42426. static EasingMode: number;
  42427. /**
  42428. * Sets the current mode used by the behavior
  42429. */
  42430. set mode(mode: number);
  42431. /**
  42432. * Gets current mode used by the behavior.
  42433. */
  42434. get mode(): number;
  42435. /**
  42436. * Sets the scale applied to the radius (1 by default)
  42437. */
  42438. set radiusScale(radius: number);
  42439. /**
  42440. * Gets the scale applied to the radius
  42441. */
  42442. get radiusScale(): number;
  42443. /**
  42444. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42445. */
  42446. set positionScale(scale: number);
  42447. /**
  42448. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42449. */
  42450. get positionScale(): number;
  42451. /**
  42452. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42453. * behaviour is triggered, in radians.
  42454. */
  42455. set defaultElevation(elevation: number);
  42456. /**
  42457. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42458. * behaviour is triggered, in radians.
  42459. */
  42460. get defaultElevation(): number;
  42461. /**
  42462. * Sets the time (in milliseconds) taken to return to the default beta position.
  42463. * Negative value indicates camera should not return to default.
  42464. */
  42465. set elevationReturnTime(speed: number);
  42466. /**
  42467. * Gets the time (in milliseconds) taken to return to the default beta position.
  42468. * Negative value indicates camera should not return to default.
  42469. */
  42470. get elevationReturnTime(): number;
  42471. /**
  42472. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42473. */
  42474. set elevationReturnWaitTime(time: number);
  42475. /**
  42476. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42477. */
  42478. get elevationReturnWaitTime(): number;
  42479. /**
  42480. * Sets the flag that indicates if user zooming should stop animation.
  42481. */
  42482. set zoomStopsAnimation(flag: boolean);
  42483. /**
  42484. * Gets the flag that indicates if user zooming should stop animation.
  42485. */
  42486. get zoomStopsAnimation(): boolean;
  42487. /**
  42488. * Sets the transition time when framing the mesh, in milliseconds
  42489. */
  42490. set framingTime(time: number);
  42491. /**
  42492. * Gets the transition time when framing the mesh, in milliseconds
  42493. */
  42494. get framingTime(): number;
  42495. /**
  42496. * Define if the behavior should automatically change the configured
  42497. * camera limits and sensibilities.
  42498. */
  42499. autoCorrectCameraLimitsAndSensibility: boolean;
  42500. private _onPrePointerObservableObserver;
  42501. private _onAfterCheckInputsObserver;
  42502. private _onMeshTargetChangedObserver;
  42503. private _attachedCamera;
  42504. private _isPointerDown;
  42505. private _lastInteractionTime;
  42506. /**
  42507. * Initializes the behavior.
  42508. */
  42509. init(): void;
  42510. /**
  42511. * Attaches the behavior to its arc rotate camera.
  42512. * @param camera Defines the camera to attach the behavior to
  42513. */
  42514. attach(camera: ArcRotateCamera): void;
  42515. /**
  42516. * Detaches the behavior from its current arc rotate camera.
  42517. */
  42518. detach(): void;
  42519. private _animatables;
  42520. private _betaIsAnimating;
  42521. private _betaTransition;
  42522. private _radiusTransition;
  42523. private _vectorTransition;
  42524. /**
  42525. * Targets the given mesh and updates zoom level accordingly.
  42526. * @param mesh The mesh to target.
  42527. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42528. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42529. */
  42530. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42531. /**
  42532. * Targets the given mesh with its children and updates zoom level accordingly.
  42533. * @param mesh The mesh to target.
  42534. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42535. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42536. */
  42537. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42538. /**
  42539. * Targets the given meshes with their children and updates zoom level accordingly.
  42540. * @param meshes The mesh to target.
  42541. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42542. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42543. */
  42544. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42545. /**
  42546. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42547. * @param minimumWorld Determines the smaller position of the bounding box extend
  42548. * @param maximumWorld Determines the bigger position of the bounding box extend
  42549. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42550. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42551. */
  42552. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42553. /**
  42554. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42555. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42556. * frustum width.
  42557. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42558. * to fully enclose the mesh in the viewing frustum.
  42559. */
  42560. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42561. /**
  42562. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42563. * is automatically returned to its default position (expected to be above ground plane).
  42564. */
  42565. private _maintainCameraAboveGround;
  42566. /**
  42567. * Returns the frustum slope based on the canvas ratio and camera FOV
  42568. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42569. */
  42570. private _getFrustumSlope;
  42571. /**
  42572. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42573. */
  42574. private _clearAnimationLocks;
  42575. /**
  42576. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42577. */
  42578. private _applyUserInteraction;
  42579. /**
  42580. * Stops and removes all animations that have been applied to the camera
  42581. */
  42582. stopAllAnimations(): void;
  42583. /**
  42584. * Gets a value indicating if the user is moving the camera
  42585. */
  42586. get isUserIsMoving(): boolean;
  42587. /**
  42588. * The camera can move all the way towards the mesh.
  42589. */
  42590. static IgnoreBoundsSizeMode: number;
  42591. /**
  42592. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42593. */
  42594. static FitFrustumSidesMode: number;
  42595. }
  42596. }
  42597. declare module BABYLON {
  42598. /**
  42599. * Base class for Camera Pointer Inputs.
  42600. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42601. * for example usage.
  42602. */
  42603. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42604. /**
  42605. * Defines the camera the input is attached to.
  42606. */
  42607. abstract camera: Camera;
  42608. /**
  42609. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42610. */
  42611. protected _altKey: boolean;
  42612. protected _ctrlKey: boolean;
  42613. protected _metaKey: boolean;
  42614. protected _shiftKey: boolean;
  42615. /**
  42616. * Which mouse buttons were pressed at time of last mouse event.
  42617. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42618. */
  42619. protected _buttonsPressed: number;
  42620. /**
  42621. * Defines the buttons associated with the input to handle camera move.
  42622. */
  42623. buttons: number[];
  42624. /**
  42625. * Attach the input controls to a specific dom element to get the input from.
  42626. * @param element Defines the element the controls should be listened from
  42627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42628. */
  42629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42630. /**
  42631. * Detach the current controls from the specified dom element.
  42632. * @param element Defines the element to stop listening the inputs from
  42633. */
  42634. detachControl(element: Nullable<HTMLElement>): void;
  42635. /**
  42636. * Gets the class name of the current input.
  42637. * @returns the class name
  42638. */
  42639. getClassName(): string;
  42640. /**
  42641. * Get the friendly name associated with the input class.
  42642. * @returns the input friendly name
  42643. */
  42644. getSimpleName(): string;
  42645. /**
  42646. * Called on pointer POINTERDOUBLETAP event.
  42647. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42648. */
  42649. protected onDoubleTap(type: string): void;
  42650. /**
  42651. * Called on pointer POINTERMOVE event if only a single touch is active.
  42652. * Override this method to provide functionality.
  42653. */
  42654. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42655. /**
  42656. * Called on pointer POINTERMOVE event if multiple touches are active.
  42657. * Override this method to provide functionality.
  42658. */
  42659. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42660. /**
  42661. * Called on JS contextmenu event.
  42662. * Override this method to provide functionality.
  42663. */
  42664. protected onContextMenu(evt: PointerEvent): void;
  42665. /**
  42666. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42667. * press.
  42668. * Override this method to provide functionality.
  42669. */
  42670. protected onButtonDown(evt: PointerEvent): void;
  42671. /**
  42672. * Called each time a new POINTERUP event occurs. Ie, for each button
  42673. * release.
  42674. * Override this method to provide functionality.
  42675. */
  42676. protected onButtonUp(evt: PointerEvent): void;
  42677. /**
  42678. * Called when window becomes inactive.
  42679. * Override this method to provide functionality.
  42680. */
  42681. protected onLostFocus(): void;
  42682. private _pointerInput;
  42683. private _observer;
  42684. private _onLostFocus;
  42685. private pointA;
  42686. private pointB;
  42687. }
  42688. }
  42689. declare module BABYLON {
  42690. /**
  42691. * Manage the pointers inputs to control an arc rotate camera.
  42692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42693. */
  42694. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42695. /**
  42696. * Defines the camera the input is attached to.
  42697. */
  42698. camera: ArcRotateCamera;
  42699. /**
  42700. * Gets the class name of the current input.
  42701. * @returns the class name
  42702. */
  42703. getClassName(): string;
  42704. /**
  42705. * Defines the buttons associated with the input to handle camera move.
  42706. */
  42707. buttons: number[];
  42708. /**
  42709. * Defines the pointer angular sensibility along the X axis or how fast is
  42710. * the camera rotating.
  42711. */
  42712. angularSensibilityX: number;
  42713. /**
  42714. * Defines the pointer angular sensibility along the Y axis or how fast is
  42715. * the camera rotating.
  42716. */
  42717. angularSensibilityY: number;
  42718. /**
  42719. * Defines the pointer pinch precision or how fast is the camera zooming.
  42720. */
  42721. pinchPrecision: number;
  42722. /**
  42723. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42724. * from 0.
  42725. * It defines the percentage of current camera.radius to use as delta when
  42726. * pinch zoom is used.
  42727. */
  42728. pinchDeltaPercentage: number;
  42729. /**
  42730. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42731. * that any object in the plane at the camera's target point will scale
  42732. * perfectly with finger motion.
  42733. * Overrides pinchDeltaPercentage and pinchPrecision.
  42734. */
  42735. useNaturalPinchZoom: boolean;
  42736. /**
  42737. * Defines the pointer panning sensibility or how fast is the camera moving.
  42738. */
  42739. panningSensibility: number;
  42740. /**
  42741. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42742. */
  42743. multiTouchPanning: boolean;
  42744. /**
  42745. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42746. * zoom (pinch) through multitouch.
  42747. */
  42748. multiTouchPanAndZoom: boolean;
  42749. /**
  42750. * Revers pinch action direction.
  42751. */
  42752. pinchInwards: boolean;
  42753. private _isPanClick;
  42754. private _twoFingerActivityCount;
  42755. private _isPinching;
  42756. /**
  42757. * Called on pointer POINTERMOVE event if only a single touch is active.
  42758. */
  42759. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42760. /**
  42761. * Called on pointer POINTERDOUBLETAP event.
  42762. */
  42763. protected onDoubleTap(type: string): void;
  42764. /**
  42765. * Called on pointer POINTERMOVE event if multiple touches are active.
  42766. */
  42767. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42768. /**
  42769. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42770. * press.
  42771. */
  42772. protected onButtonDown(evt: PointerEvent): void;
  42773. /**
  42774. * Called each time a new POINTERUP event occurs. Ie, for each button
  42775. * release.
  42776. */
  42777. protected onButtonUp(evt: PointerEvent): void;
  42778. /**
  42779. * Called when window becomes inactive.
  42780. */
  42781. protected onLostFocus(): void;
  42782. }
  42783. }
  42784. declare module BABYLON {
  42785. /**
  42786. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42788. */
  42789. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42790. /**
  42791. * Defines the camera the input is attached to.
  42792. */
  42793. camera: ArcRotateCamera;
  42794. /**
  42795. * Defines the list of key codes associated with the up action (increase alpha)
  42796. */
  42797. keysUp: number[];
  42798. /**
  42799. * Defines the list of key codes associated with the down action (decrease alpha)
  42800. */
  42801. keysDown: number[];
  42802. /**
  42803. * Defines the list of key codes associated with the left action (increase beta)
  42804. */
  42805. keysLeft: number[];
  42806. /**
  42807. * Defines the list of key codes associated with the right action (decrease beta)
  42808. */
  42809. keysRight: number[];
  42810. /**
  42811. * Defines the list of key codes associated with the reset action.
  42812. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42813. */
  42814. keysReset: number[];
  42815. /**
  42816. * Defines the panning sensibility of the inputs.
  42817. * (How fast is the camera panning)
  42818. */
  42819. panningSensibility: number;
  42820. /**
  42821. * Defines the zooming sensibility of the inputs.
  42822. * (How fast is the camera zooming)
  42823. */
  42824. zoomingSensibility: number;
  42825. /**
  42826. * Defines whether maintaining the alt key down switch the movement mode from
  42827. * orientation to zoom.
  42828. */
  42829. useAltToZoom: boolean;
  42830. /**
  42831. * Rotation speed of the camera
  42832. */
  42833. angularSpeed: number;
  42834. private _keys;
  42835. private _ctrlPressed;
  42836. private _altPressed;
  42837. private _onCanvasBlurObserver;
  42838. private _onKeyboardObserver;
  42839. private _engine;
  42840. private _scene;
  42841. /**
  42842. * Attach the input controls to a specific dom element to get the input from.
  42843. * @param element Defines the element the controls should be listened from
  42844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42845. */
  42846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42847. /**
  42848. * Detach the current controls from the specified dom element.
  42849. * @param element Defines the element to stop listening the inputs from
  42850. */
  42851. detachControl(element: Nullable<HTMLElement>): void;
  42852. /**
  42853. * Update the current camera state depending on the inputs that have been used this frame.
  42854. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42855. */
  42856. checkInputs(): void;
  42857. /**
  42858. * Gets the class name of the current intput.
  42859. * @returns the class name
  42860. */
  42861. getClassName(): string;
  42862. /**
  42863. * Get the friendly name associated with the input class.
  42864. * @returns the input friendly name
  42865. */
  42866. getSimpleName(): string;
  42867. }
  42868. }
  42869. declare module BABYLON {
  42870. /**
  42871. * Manage the mouse wheel inputs to control an arc rotate camera.
  42872. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42873. */
  42874. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42875. /**
  42876. * Defines the camera the input is attached to.
  42877. */
  42878. camera: ArcRotateCamera;
  42879. /**
  42880. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42881. */
  42882. wheelPrecision: number;
  42883. /**
  42884. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42885. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42886. */
  42887. wheelDeltaPercentage: number;
  42888. private _wheel;
  42889. private _observer;
  42890. private computeDeltaFromMouseWheelLegacyEvent;
  42891. /**
  42892. * Attach the input controls to a specific dom element to get the input from.
  42893. * @param element Defines the element the controls should be listened from
  42894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42895. */
  42896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42897. /**
  42898. * Detach the current controls from the specified dom element.
  42899. * @param element Defines the element to stop listening the inputs from
  42900. */
  42901. detachControl(element: Nullable<HTMLElement>): void;
  42902. /**
  42903. * Gets the class name of the current intput.
  42904. * @returns the class name
  42905. */
  42906. getClassName(): string;
  42907. /**
  42908. * Get the friendly name associated with the input class.
  42909. * @returns the input friendly name
  42910. */
  42911. getSimpleName(): string;
  42912. }
  42913. }
  42914. declare module BABYLON {
  42915. /**
  42916. * Default Inputs manager for the ArcRotateCamera.
  42917. * It groups all the default supported inputs for ease of use.
  42918. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42919. */
  42920. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42921. /**
  42922. * Instantiates a new ArcRotateCameraInputsManager.
  42923. * @param camera Defines the camera the inputs belong to
  42924. */
  42925. constructor(camera: ArcRotateCamera);
  42926. /**
  42927. * Add mouse wheel input support to the input manager.
  42928. * @returns the current input manager
  42929. */
  42930. addMouseWheel(): ArcRotateCameraInputsManager;
  42931. /**
  42932. * Add pointers input support to the input manager.
  42933. * @returns the current input manager
  42934. */
  42935. addPointers(): ArcRotateCameraInputsManager;
  42936. /**
  42937. * Add keyboard input support to the input manager.
  42938. * @returns the current input manager
  42939. */
  42940. addKeyboard(): ArcRotateCameraInputsManager;
  42941. }
  42942. }
  42943. declare module BABYLON {
  42944. /**
  42945. * This represents an orbital type of camera.
  42946. *
  42947. * 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.
  42948. * 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.
  42949. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42950. */
  42951. export class ArcRotateCamera extends TargetCamera {
  42952. /**
  42953. * Defines the rotation angle of the camera along the longitudinal axis.
  42954. */
  42955. alpha: number;
  42956. /**
  42957. * Defines the rotation angle of the camera along the latitudinal axis.
  42958. */
  42959. beta: number;
  42960. /**
  42961. * Defines the radius of the camera from it s target point.
  42962. */
  42963. radius: number;
  42964. protected _target: Vector3;
  42965. protected _targetHost: Nullable<AbstractMesh>;
  42966. /**
  42967. * Defines the target point of the camera.
  42968. * The camera looks towards it form the radius distance.
  42969. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42970. */
  42971. get target(): Vector3;
  42972. set target(value: Vector3);
  42973. /**
  42974. * Define the current local position of the camera in the scene
  42975. */
  42976. get position(): Vector3;
  42977. set position(newPosition: Vector3);
  42978. protected _upToYMatrix: Matrix;
  42979. protected _YToUpMatrix: Matrix;
  42980. /**
  42981. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42982. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42983. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42984. */
  42985. set upVector(vec: Vector3);
  42986. get upVector(): Vector3;
  42987. /**
  42988. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42989. */
  42990. setMatUp(): void;
  42991. /**
  42992. * Current inertia value on the longitudinal axis.
  42993. * The bigger this number the longer it will take for the camera to stop.
  42994. */
  42995. inertialAlphaOffset: number;
  42996. /**
  42997. * Current inertia value on the latitudinal axis.
  42998. * The bigger this number the longer it will take for the camera to stop.
  42999. */
  43000. inertialBetaOffset: number;
  43001. /**
  43002. * Current inertia value on the radius axis.
  43003. * The bigger this number the longer it will take for the camera to stop.
  43004. */
  43005. inertialRadiusOffset: number;
  43006. /**
  43007. * Minimum allowed angle on the longitudinal axis.
  43008. * This can help limiting how the Camera is able to move in the scene.
  43009. */
  43010. lowerAlphaLimit: Nullable<number>;
  43011. /**
  43012. * Maximum allowed angle on the longitudinal axis.
  43013. * This can help limiting how the Camera is able to move in the scene.
  43014. */
  43015. upperAlphaLimit: Nullable<number>;
  43016. /**
  43017. * Minimum allowed angle on the latitudinal axis.
  43018. * This can help limiting how the Camera is able to move in the scene.
  43019. */
  43020. lowerBetaLimit: number;
  43021. /**
  43022. * Maximum allowed angle on the latitudinal axis.
  43023. * This can help limiting how the Camera is able to move in the scene.
  43024. */
  43025. upperBetaLimit: number;
  43026. /**
  43027. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43028. * This can help limiting how the Camera is able to move in the scene.
  43029. */
  43030. lowerRadiusLimit: Nullable<number>;
  43031. /**
  43032. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43033. * This can help limiting how the Camera is able to move in the scene.
  43034. */
  43035. upperRadiusLimit: Nullable<number>;
  43036. /**
  43037. * Defines the current inertia value used during panning of the camera along the X axis.
  43038. */
  43039. inertialPanningX: number;
  43040. /**
  43041. * Defines the current inertia value used during panning of the camera along the Y axis.
  43042. */
  43043. inertialPanningY: number;
  43044. /**
  43045. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43046. * Basically if your fingers moves away from more than this distance you will be considered
  43047. * in pinch mode.
  43048. */
  43049. pinchToPanMaxDistance: number;
  43050. /**
  43051. * Defines the maximum distance the camera can pan.
  43052. * This could help keeping the cammera always in your scene.
  43053. */
  43054. panningDistanceLimit: Nullable<number>;
  43055. /**
  43056. * Defines the target of the camera before paning.
  43057. */
  43058. panningOriginTarget: Vector3;
  43059. /**
  43060. * Defines the value of the inertia used during panning.
  43061. * 0 would mean stop inertia and one would mean no decelleration at all.
  43062. */
  43063. panningInertia: number;
  43064. /**
  43065. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43066. */
  43067. get angularSensibilityX(): number;
  43068. set angularSensibilityX(value: number);
  43069. /**
  43070. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43071. */
  43072. get angularSensibilityY(): number;
  43073. set angularSensibilityY(value: number);
  43074. /**
  43075. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43076. */
  43077. get pinchPrecision(): number;
  43078. set pinchPrecision(value: number);
  43079. /**
  43080. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43081. * It will be used instead of pinchDeltaPrecision if different from 0.
  43082. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43083. */
  43084. get pinchDeltaPercentage(): number;
  43085. set pinchDeltaPercentage(value: number);
  43086. /**
  43087. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43088. * and pinch delta percentage.
  43089. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43090. * that any object in the plane at the camera's target point will scale
  43091. * perfectly with finger motion.
  43092. */
  43093. get useNaturalPinchZoom(): boolean;
  43094. set useNaturalPinchZoom(value: boolean);
  43095. /**
  43096. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43097. */
  43098. get panningSensibility(): number;
  43099. set panningSensibility(value: number);
  43100. /**
  43101. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43102. */
  43103. get keysUp(): number[];
  43104. set keysUp(value: number[]);
  43105. /**
  43106. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43107. */
  43108. get keysDown(): number[];
  43109. set keysDown(value: number[]);
  43110. /**
  43111. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43112. */
  43113. get keysLeft(): number[];
  43114. set keysLeft(value: number[]);
  43115. /**
  43116. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43117. */
  43118. get keysRight(): number[];
  43119. set keysRight(value: number[]);
  43120. /**
  43121. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43122. */
  43123. get wheelPrecision(): number;
  43124. set wheelPrecision(value: number);
  43125. /**
  43126. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43127. * It will be used instead of pinchDeltaPrecision if different from 0.
  43128. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43129. */
  43130. get wheelDeltaPercentage(): number;
  43131. set wheelDeltaPercentage(value: number);
  43132. /**
  43133. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43134. */
  43135. zoomOnFactor: number;
  43136. /**
  43137. * Defines a screen offset for the camera position.
  43138. */
  43139. targetScreenOffset: Vector2;
  43140. /**
  43141. * Allows the camera to be completely reversed.
  43142. * If false the camera can not arrive upside down.
  43143. */
  43144. allowUpsideDown: boolean;
  43145. /**
  43146. * Define if double tap/click is used to restore the previously saved state of the camera.
  43147. */
  43148. useInputToRestoreState: boolean;
  43149. /** @hidden */
  43150. _viewMatrix: Matrix;
  43151. /** @hidden */
  43152. _useCtrlForPanning: boolean;
  43153. /** @hidden */
  43154. _panningMouseButton: number;
  43155. /**
  43156. * Defines the input associated to the camera.
  43157. */
  43158. inputs: ArcRotateCameraInputsManager;
  43159. /** @hidden */
  43160. _reset: () => void;
  43161. /**
  43162. * Defines the allowed panning axis.
  43163. */
  43164. panningAxis: Vector3;
  43165. protected _localDirection: Vector3;
  43166. protected _transformedDirection: Vector3;
  43167. private _bouncingBehavior;
  43168. /**
  43169. * Gets the bouncing behavior of the camera if it has been enabled.
  43170. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43171. */
  43172. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43173. /**
  43174. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43175. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43176. */
  43177. get useBouncingBehavior(): boolean;
  43178. set useBouncingBehavior(value: boolean);
  43179. private _framingBehavior;
  43180. /**
  43181. * Gets the framing behavior of the camera if it has been enabled.
  43182. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43183. */
  43184. get framingBehavior(): Nullable<FramingBehavior>;
  43185. /**
  43186. * Defines if the framing behavior of the camera is enabled on the camera.
  43187. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43188. */
  43189. get useFramingBehavior(): boolean;
  43190. set useFramingBehavior(value: boolean);
  43191. private _autoRotationBehavior;
  43192. /**
  43193. * Gets the auto rotation behavior of the camera if it has been enabled.
  43194. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43195. */
  43196. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43197. /**
  43198. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43199. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43200. */
  43201. get useAutoRotationBehavior(): boolean;
  43202. set useAutoRotationBehavior(value: boolean);
  43203. /**
  43204. * Observable triggered when the mesh target has been changed on the camera.
  43205. */
  43206. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43207. /**
  43208. * Event raised when the camera is colliding with a mesh.
  43209. */
  43210. onCollide: (collidedMesh: AbstractMesh) => void;
  43211. /**
  43212. * Defines whether the camera should check collision with the objects oh the scene.
  43213. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43214. */
  43215. checkCollisions: boolean;
  43216. /**
  43217. * Defines the collision radius of the camera.
  43218. * This simulates a sphere around the camera.
  43219. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43220. */
  43221. collisionRadius: Vector3;
  43222. protected _collider: Collider;
  43223. protected _previousPosition: Vector3;
  43224. protected _collisionVelocity: Vector3;
  43225. protected _newPosition: Vector3;
  43226. protected _previousAlpha: number;
  43227. protected _previousBeta: number;
  43228. protected _previousRadius: number;
  43229. protected _collisionTriggered: boolean;
  43230. protected _targetBoundingCenter: Nullable<Vector3>;
  43231. private _computationVector;
  43232. /**
  43233. * Instantiates a new ArcRotateCamera in a given scene
  43234. * @param name Defines the name of the camera
  43235. * @param alpha Defines the camera rotation along the logitudinal axis
  43236. * @param beta Defines the camera rotation along the latitudinal axis
  43237. * @param radius Defines the camera distance from its target
  43238. * @param target Defines the camera target
  43239. * @param scene Defines the scene the camera belongs to
  43240. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43241. */
  43242. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43243. /** @hidden */
  43244. _initCache(): void;
  43245. /** @hidden */
  43246. _updateCache(ignoreParentClass?: boolean): void;
  43247. protected _getTargetPosition(): Vector3;
  43248. private _storedAlpha;
  43249. private _storedBeta;
  43250. private _storedRadius;
  43251. private _storedTarget;
  43252. private _storedTargetScreenOffset;
  43253. /**
  43254. * Stores the current state of the camera (alpha, beta, radius and target)
  43255. * @returns the camera itself
  43256. */
  43257. storeState(): Camera;
  43258. /**
  43259. * @hidden
  43260. * Restored camera state. You must call storeState() first
  43261. */
  43262. _restoreStateValues(): boolean;
  43263. /** @hidden */
  43264. _isSynchronizedViewMatrix(): boolean;
  43265. /**
  43266. * Attached controls to the current camera.
  43267. * @param element Defines the element the controls should be listened from
  43268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43269. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43270. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43271. */
  43272. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43273. /**
  43274. * Detach the current controls from the camera.
  43275. * The camera will stop reacting to inputs.
  43276. * @param element Defines the element to stop listening the inputs from
  43277. */
  43278. detachControl(element: HTMLElement): void;
  43279. /** @hidden */
  43280. _checkInputs(): void;
  43281. protected _checkLimits(): void;
  43282. /**
  43283. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43284. */
  43285. rebuildAnglesAndRadius(): void;
  43286. /**
  43287. * Use a position to define the current camera related information like alpha, beta and radius
  43288. * @param position Defines the position to set the camera at
  43289. */
  43290. setPosition(position: Vector3): void;
  43291. /**
  43292. * Defines the target the camera should look at.
  43293. * This will automatically adapt alpha beta and radius to fit within the new target.
  43294. * @param target Defines the new target as a Vector or a mesh
  43295. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43296. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43297. */
  43298. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43299. /** @hidden */
  43300. _getViewMatrix(): Matrix;
  43301. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43302. /**
  43303. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43304. * @param meshes Defines the mesh to zoom on
  43305. * @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)
  43306. */
  43307. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43308. /**
  43309. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43310. * The target will be changed but the radius
  43311. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43312. * @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)
  43313. */
  43314. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43315. min: Vector3;
  43316. max: Vector3;
  43317. distance: number;
  43318. }, doNotUpdateMaxZ?: boolean): void;
  43319. /**
  43320. * @override
  43321. * Override Camera.createRigCamera
  43322. */
  43323. createRigCamera(name: string, cameraIndex: number): Camera;
  43324. /**
  43325. * @hidden
  43326. * @override
  43327. * Override Camera._updateRigCameras
  43328. */
  43329. _updateRigCameras(): void;
  43330. /**
  43331. * Destroy the camera and release the current resources hold by it.
  43332. */
  43333. dispose(): void;
  43334. /**
  43335. * Gets the current object class name.
  43336. * @return the class name
  43337. */
  43338. getClassName(): string;
  43339. }
  43340. }
  43341. declare module BABYLON {
  43342. /**
  43343. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43344. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43345. */
  43346. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43347. /**
  43348. * Gets the name of the behavior.
  43349. */
  43350. get name(): string;
  43351. private _zoomStopsAnimation;
  43352. private _idleRotationSpeed;
  43353. private _idleRotationWaitTime;
  43354. private _idleRotationSpinupTime;
  43355. /**
  43356. * Sets the flag that indicates if user zooming should stop animation.
  43357. */
  43358. set zoomStopsAnimation(flag: boolean);
  43359. /**
  43360. * Gets the flag that indicates if user zooming should stop animation.
  43361. */
  43362. get zoomStopsAnimation(): boolean;
  43363. /**
  43364. * Sets the default speed at which the camera rotates around the model.
  43365. */
  43366. set idleRotationSpeed(speed: number);
  43367. /**
  43368. * Gets the default speed at which the camera rotates around the model.
  43369. */
  43370. get idleRotationSpeed(): number;
  43371. /**
  43372. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43373. */
  43374. set idleRotationWaitTime(time: number);
  43375. /**
  43376. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43377. */
  43378. get idleRotationWaitTime(): number;
  43379. /**
  43380. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43381. */
  43382. set idleRotationSpinupTime(time: number);
  43383. /**
  43384. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43385. */
  43386. get idleRotationSpinupTime(): number;
  43387. /**
  43388. * Gets a value indicating if the camera is currently rotating because of this behavior
  43389. */
  43390. get rotationInProgress(): boolean;
  43391. private _onPrePointerObservableObserver;
  43392. private _onAfterCheckInputsObserver;
  43393. private _attachedCamera;
  43394. private _isPointerDown;
  43395. private _lastFrameTime;
  43396. private _lastInteractionTime;
  43397. private _cameraRotationSpeed;
  43398. /**
  43399. * Initializes the behavior.
  43400. */
  43401. init(): void;
  43402. /**
  43403. * Attaches the behavior to its arc rotate camera.
  43404. * @param camera Defines the camera to attach the behavior to
  43405. */
  43406. attach(camera: ArcRotateCamera): void;
  43407. /**
  43408. * Detaches the behavior from its current arc rotate camera.
  43409. */
  43410. detach(): void;
  43411. /**
  43412. * Returns true if user is scrolling.
  43413. * @return true if user is scrolling.
  43414. */
  43415. private _userIsZooming;
  43416. private _lastFrameRadius;
  43417. private _shouldAnimationStopForInteraction;
  43418. /**
  43419. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43420. */
  43421. private _applyUserInteraction;
  43422. private _userIsMoving;
  43423. }
  43424. }
  43425. declare module BABYLON {
  43426. /**
  43427. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43428. */
  43429. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43430. private ui;
  43431. /**
  43432. * The name of the behavior
  43433. */
  43434. name: string;
  43435. /**
  43436. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43437. */
  43438. distanceAwayFromFace: number;
  43439. /**
  43440. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43441. */
  43442. distanceAwayFromBottomOfFace: number;
  43443. private _faceVectors;
  43444. private _target;
  43445. private _scene;
  43446. private _onRenderObserver;
  43447. private _tmpMatrix;
  43448. private _tmpVector;
  43449. /**
  43450. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43451. * @param ui The transform node that should be attched to the mesh
  43452. */
  43453. constructor(ui: TransformNode);
  43454. /**
  43455. * Initializes the behavior
  43456. */
  43457. init(): void;
  43458. private _closestFace;
  43459. private _zeroVector;
  43460. private _lookAtTmpMatrix;
  43461. private _lookAtToRef;
  43462. /**
  43463. * Attaches the AttachToBoxBehavior to the passed in mesh
  43464. * @param target The mesh that the specified node will be attached to
  43465. */
  43466. attach(target: Mesh): void;
  43467. /**
  43468. * Detaches the behavior from the mesh
  43469. */
  43470. detach(): void;
  43471. }
  43472. }
  43473. declare module BABYLON {
  43474. /**
  43475. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43476. */
  43477. export class FadeInOutBehavior implements Behavior<Mesh> {
  43478. /**
  43479. * Time in milliseconds to delay before fading in (Default: 0)
  43480. */
  43481. delay: number;
  43482. /**
  43483. * Time in milliseconds for the mesh to fade in (Default: 300)
  43484. */
  43485. fadeInTime: number;
  43486. private _millisecondsPerFrame;
  43487. private _hovered;
  43488. private _hoverValue;
  43489. private _ownerNode;
  43490. /**
  43491. * Instatiates the FadeInOutBehavior
  43492. */
  43493. constructor();
  43494. /**
  43495. * The name of the behavior
  43496. */
  43497. get name(): string;
  43498. /**
  43499. * Initializes the behavior
  43500. */
  43501. init(): void;
  43502. /**
  43503. * Attaches the fade behavior on the passed in mesh
  43504. * @param ownerNode The mesh that will be faded in/out once attached
  43505. */
  43506. attach(ownerNode: Mesh): void;
  43507. /**
  43508. * Detaches the behavior from the mesh
  43509. */
  43510. detach(): void;
  43511. /**
  43512. * Triggers the mesh to begin fading in or out
  43513. * @param value if the object should fade in or out (true to fade in)
  43514. */
  43515. fadeIn(value: boolean): void;
  43516. private _update;
  43517. private _setAllVisibility;
  43518. }
  43519. }
  43520. declare module BABYLON {
  43521. /**
  43522. * Class containing a set of static utilities functions for managing Pivots
  43523. * @hidden
  43524. */
  43525. export class PivotTools {
  43526. private static _PivotCached;
  43527. private static _OldPivotPoint;
  43528. private static _PivotTranslation;
  43529. private static _PivotTmpVector;
  43530. private static _PivotPostMultiplyPivotMatrix;
  43531. /** @hidden */
  43532. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43533. /** @hidden */
  43534. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43535. }
  43536. }
  43537. declare module BABYLON {
  43538. /**
  43539. * Class containing static functions to help procedurally build meshes
  43540. */
  43541. export class PlaneBuilder {
  43542. /**
  43543. * Creates a plane mesh
  43544. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43545. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43546. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43548. * * 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
  43549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43550. * @param name defines the name of the mesh
  43551. * @param options defines the options used to create the mesh
  43552. * @param scene defines the hosting scene
  43553. * @returns the plane mesh
  43554. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43555. */
  43556. static CreatePlane(name: string, options: {
  43557. size?: number;
  43558. width?: number;
  43559. height?: number;
  43560. sideOrientation?: number;
  43561. frontUVs?: Vector4;
  43562. backUVs?: Vector4;
  43563. updatable?: boolean;
  43564. sourcePlane?: Plane;
  43565. }, scene?: Nullable<Scene>): Mesh;
  43566. }
  43567. }
  43568. declare module BABYLON {
  43569. /**
  43570. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43571. */
  43572. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43573. private static _AnyMouseID;
  43574. /**
  43575. * Abstract mesh the behavior is set on
  43576. */
  43577. attachedNode: AbstractMesh;
  43578. private _dragPlane;
  43579. private _scene;
  43580. private _pointerObserver;
  43581. private _beforeRenderObserver;
  43582. private static _planeScene;
  43583. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43584. /**
  43585. * 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)
  43586. */
  43587. maxDragAngle: number;
  43588. /**
  43589. * @hidden
  43590. */
  43591. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43592. /**
  43593. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43594. */
  43595. currentDraggingPointerID: number;
  43596. /**
  43597. * The last position where the pointer hit the drag plane in world space
  43598. */
  43599. lastDragPosition: Vector3;
  43600. /**
  43601. * If the behavior is currently in a dragging state
  43602. */
  43603. dragging: boolean;
  43604. /**
  43605. * 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)
  43606. */
  43607. dragDeltaRatio: number;
  43608. /**
  43609. * If the drag plane orientation should be updated during the dragging (Default: true)
  43610. */
  43611. updateDragPlane: boolean;
  43612. private _debugMode;
  43613. private _moving;
  43614. /**
  43615. * Fires each time the attached mesh is dragged with the pointer
  43616. * * delta between last drag position and current drag position in world space
  43617. * * dragDistance along the drag axis
  43618. * * dragPlaneNormal normal of the current drag plane used during the drag
  43619. * * dragPlanePoint in world space where the drag intersects the drag plane
  43620. */
  43621. onDragObservable: Observable<{
  43622. delta: Vector3;
  43623. dragPlanePoint: Vector3;
  43624. dragPlaneNormal: Vector3;
  43625. dragDistance: number;
  43626. pointerId: number;
  43627. }>;
  43628. /**
  43629. * Fires each time a drag begins (eg. mouse down on mesh)
  43630. */
  43631. onDragStartObservable: Observable<{
  43632. dragPlanePoint: Vector3;
  43633. pointerId: number;
  43634. }>;
  43635. /**
  43636. * Fires each time a drag ends (eg. mouse release after drag)
  43637. */
  43638. onDragEndObservable: Observable<{
  43639. dragPlanePoint: Vector3;
  43640. pointerId: number;
  43641. }>;
  43642. /**
  43643. * If the attached mesh should be moved when dragged
  43644. */
  43645. moveAttached: boolean;
  43646. /**
  43647. * If the drag behavior will react to drag events (Default: true)
  43648. */
  43649. enabled: boolean;
  43650. /**
  43651. * If pointer events should start and release the drag (Default: true)
  43652. */
  43653. startAndReleaseDragOnPointerEvents: boolean;
  43654. /**
  43655. * If camera controls should be detached during the drag
  43656. */
  43657. detachCameraControls: boolean;
  43658. /**
  43659. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43660. */
  43661. useObjectOrientationForDragging: boolean;
  43662. private _options;
  43663. /**
  43664. * Gets the options used by the behavior
  43665. */
  43666. get options(): {
  43667. dragAxis?: Vector3;
  43668. dragPlaneNormal?: Vector3;
  43669. };
  43670. /**
  43671. * Sets the options used by the behavior
  43672. */
  43673. set options(options: {
  43674. dragAxis?: Vector3;
  43675. dragPlaneNormal?: Vector3;
  43676. });
  43677. /**
  43678. * Creates a pointer drag behavior that can be attached to a mesh
  43679. * @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)
  43680. */
  43681. constructor(options?: {
  43682. dragAxis?: Vector3;
  43683. dragPlaneNormal?: Vector3;
  43684. });
  43685. /**
  43686. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43687. */
  43688. validateDrag: (targetPosition: Vector3) => boolean;
  43689. /**
  43690. * The name of the behavior
  43691. */
  43692. get name(): string;
  43693. /**
  43694. * Initializes the behavior
  43695. */
  43696. init(): void;
  43697. private _tmpVector;
  43698. private _alternatePickedPoint;
  43699. private _worldDragAxis;
  43700. private _targetPosition;
  43701. private _attachedElement;
  43702. /**
  43703. * Attaches the drag behavior the passed in mesh
  43704. * @param ownerNode The mesh that will be dragged around once attached
  43705. * @param predicate Predicate to use for pick filtering
  43706. */
  43707. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43708. /**
  43709. * Force relase the drag action by code.
  43710. */
  43711. releaseDrag(): void;
  43712. private _startDragRay;
  43713. private _lastPointerRay;
  43714. /**
  43715. * Simulates the start of a pointer drag event on the behavior
  43716. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43717. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43718. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43719. */
  43720. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43721. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43722. private _dragDelta;
  43723. protected _moveDrag(ray: Ray): void;
  43724. private _pickWithRayOnDragPlane;
  43725. private _pointA;
  43726. private _pointC;
  43727. private _localAxis;
  43728. private _lookAt;
  43729. private _updateDragPlanePosition;
  43730. /**
  43731. * Detaches the behavior from the mesh
  43732. */
  43733. detach(): void;
  43734. }
  43735. }
  43736. declare module BABYLON {
  43737. /**
  43738. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43739. */
  43740. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43741. private _dragBehaviorA;
  43742. private _dragBehaviorB;
  43743. private _startDistance;
  43744. private _initialScale;
  43745. private _targetScale;
  43746. private _ownerNode;
  43747. private _sceneRenderObserver;
  43748. /**
  43749. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43750. */
  43751. constructor();
  43752. /**
  43753. * The name of the behavior
  43754. */
  43755. get name(): string;
  43756. /**
  43757. * Initializes the behavior
  43758. */
  43759. init(): void;
  43760. private _getCurrentDistance;
  43761. /**
  43762. * Attaches the scale behavior the passed in mesh
  43763. * @param ownerNode The mesh that will be scaled around once attached
  43764. */
  43765. attach(ownerNode: Mesh): void;
  43766. /**
  43767. * Detaches the behavior from the mesh
  43768. */
  43769. detach(): void;
  43770. }
  43771. }
  43772. declare module BABYLON {
  43773. /**
  43774. * 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
  43775. */
  43776. export class SixDofDragBehavior implements Behavior<Mesh> {
  43777. private static _virtualScene;
  43778. private _ownerNode;
  43779. private _sceneRenderObserver;
  43780. private _scene;
  43781. private _targetPosition;
  43782. private _virtualOriginMesh;
  43783. private _virtualDragMesh;
  43784. private _pointerObserver;
  43785. private _moving;
  43786. private _startingOrientation;
  43787. private _attachedElement;
  43788. /**
  43789. * 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)
  43790. */
  43791. private zDragFactor;
  43792. /**
  43793. * If the object should rotate to face the drag origin
  43794. */
  43795. rotateDraggedObject: boolean;
  43796. /**
  43797. * If the behavior is currently in a dragging state
  43798. */
  43799. dragging: boolean;
  43800. /**
  43801. * 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)
  43802. */
  43803. dragDeltaRatio: number;
  43804. /**
  43805. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43806. */
  43807. currentDraggingPointerID: number;
  43808. /**
  43809. * If camera controls should be detached during the drag
  43810. */
  43811. detachCameraControls: boolean;
  43812. /**
  43813. * Fires each time a drag starts
  43814. */
  43815. onDragStartObservable: Observable<{}>;
  43816. /**
  43817. * Fires each time a drag ends (eg. mouse release after drag)
  43818. */
  43819. onDragEndObservable: Observable<{}>;
  43820. /**
  43821. * 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
  43822. */
  43823. constructor();
  43824. /**
  43825. * The name of the behavior
  43826. */
  43827. get name(): string;
  43828. /**
  43829. * Initializes the behavior
  43830. */
  43831. init(): void;
  43832. /**
  43833. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43834. */
  43835. private get _pointerCamera();
  43836. /**
  43837. * Attaches the scale behavior the passed in mesh
  43838. * @param ownerNode The mesh that will be scaled around once attached
  43839. */
  43840. attach(ownerNode: Mesh): void;
  43841. /**
  43842. * Detaches the behavior from the mesh
  43843. */
  43844. detach(): void;
  43845. }
  43846. }
  43847. declare module BABYLON {
  43848. /**
  43849. * Class used to apply inverse kinematics to bones
  43850. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43851. */
  43852. export class BoneIKController {
  43853. private static _tmpVecs;
  43854. private static _tmpQuat;
  43855. private static _tmpMats;
  43856. /**
  43857. * Gets or sets the target mesh
  43858. */
  43859. targetMesh: AbstractMesh;
  43860. /** Gets or sets the mesh used as pole */
  43861. poleTargetMesh: AbstractMesh;
  43862. /**
  43863. * Gets or sets the bone used as pole
  43864. */
  43865. poleTargetBone: Nullable<Bone>;
  43866. /**
  43867. * Gets or sets the target position
  43868. */
  43869. targetPosition: Vector3;
  43870. /**
  43871. * Gets or sets the pole target position
  43872. */
  43873. poleTargetPosition: Vector3;
  43874. /**
  43875. * Gets or sets the pole target local offset
  43876. */
  43877. poleTargetLocalOffset: Vector3;
  43878. /**
  43879. * Gets or sets the pole angle
  43880. */
  43881. poleAngle: number;
  43882. /**
  43883. * Gets or sets the mesh associated with the controller
  43884. */
  43885. mesh: AbstractMesh;
  43886. /**
  43887. * 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)
  43888. */
  43889. slerpAmount: number;
  43890. private _bone1Quat;
  43891. private _bone1Mat;
  43892. private _bone2Ang;
  43893. private _bone1;
  43894. private _bone2;
  43895. private _bone1Length;
  43896. private _bone2Length;
  43897. private _maxAngle;
  43898. private _maxReach;
  43899. private _rightHandedSystem;
  43900. private _bendAxis;
  43901. private _slerping;
  43902. private _adjustRoll;
  43903. /**
  43904. * Gets or sets maximum allowed angle
  43905. */
  43906. get maxAngle(): number;
  43907. set maxAngle(value: number);
  43908. /**
  43909. * Creates a new BoneIKController
  43910. * @param mesh defines the mesh to control
  43911. * @param bone defines the bone to control
  43912. * @param options defines options to set up the controller
  43913. */
  43914. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43915. targetMesh?: AbstractMesh;
  43916. poleTargetMesh?: AbstractMesh;
  43917. poleTargetBone?: Bone;
  43918. poleTargetLocalOffset?: Vector3;
  43919. poleAngle?: number;
  43920. bendAxis?: Vector3;
  43921. maxAngle?: number;
  43922. slerpAmount?: number;
  43923. });
  43924. private _setMaxAngle;
  43925. /**
  43926. * Force the controller to update the bones
  43927. */
  43928. update(): void;
  43929. }
  43930. }
  43931. declare module BABYLON {
  43932. /**
  43933. * Class used to make a bone look toward a point in space
  43934. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43935. */
  43936. export class BoneLookController {
  43937. private static _tmpVecs;
  43938. private static _tmpQuat;
  43939. private static _tmpMats;
  43940. /**
  43941. * The target Vector3 that the bone will look at
  43942. */
  43943. target: Vector3;
  43944. /**
  43945. * The mesh that the bone is attached to
  43946. */
  43947. mesh: AbstractMesh;
  43948. /**
  43949. * The bone that will be looking to the target
  43950. */
  43951. bone: Bone;
  43952. /**
  43953. * The up axis of the coordinate system that is used when the bone is rotated
  43954. */
  43955. upAxis: Vector3;
  43956. /**
  43957. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43958. */
  43959. upAxisSpace: Space;
  43960. /**
  43961. * Used to make an adjustment to the yaw of the bone
  43962. */
  43963. adjustYaw: number;
  43964. /**
  43965. * Used to make an adjustment to the pitch of the bone
  43966. */
  43967. adjustPitch: number;
  43968. /**
  43969. * Used to make an adjustment to the roll of the bone
  43970. */
  43971. adjustRoll: number;
  43972. /**
  43973. * 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)
  43974. */
  43975. slerpAmount: number;
  43976. private _minYaw;
  43977. private _maxYaw;
  43978. private _minPitch;
  43979. private _maxPitch;
  43980. private _minYawSin;
  43981. private _minYawCos;
  43982. private _maxYawSin;
  43983. private _maxYawCos;
  43984. private _midYawConstraint;
  43985. private _minPitchTan;
  43986. private _maxPitchTan;
  43987. private _boneQuat;
  43988. private _slerping;
  43989. private _transformYawPitch;
  43990. private _transformYawPitchInv;
  43991. private _firstFrameSkipped;
  43992. private _yawRange;
  43993. private _fowardAxis;
  43994. /**
  43995. * Gets or sets the minimum yaw angle that the bone can look to
  43996. */
  43997. get minYaw(): number;
  43998. set minYaw(value: number);
  43999. /**
  44000. * Gets or sets the maximum yaw angle that the bone can look to
  44001. */
  44002. get maxYaw(): number;
  44003. set maxYaw(value: number);
  44004. /**
  44005. * Gets or sets the minimum pitch angle that the bone can look to
  44006. */
  44007. get minPitch(): number;
  44008. set minPitch(value: number);
  44009. /**
  44010. * Gets or sets the maximum pitch angle that the bone can look to
  44011. */
  44012. get maxPitch(): number;
  44013. set maxPitch(value: number);
  44014. /**
  44015. * Create a BoneLookController
  44016. * @param mesh the mesh that the bone belongs to
  44017. * @param bone the bone that will be looking to the target
  44018. * @param target the target Vector3 to look at
  44019. * @param options optional settings:
  44020. * * maxYaw: the maximum angle the bone will yaw to
  44021. * * minYaw: the minimum angle the bone will yaw to
  44022. * * maxPitch: the maximum angle the bone will pitch to
  44023. * * minPitch: the minimum angle the bone will yaw to
  44024. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44025. * * upAxis: the up axis of the coordinate system
  44026. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44027. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44028. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44029. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44030. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44031. * * adjustRoll: used to make an adjustment to the roll of the bone
  44032. **/
  44033. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44034. maxYaw?: number;
  44035. minYaw?: number;
  44036. maxPitch?: number;
  44037. minPitch?: number;
  44038. slerpAmount?: number;
  44039. upAxis?: Vector3;
  44040. upAxisSpace?: Space;
  44041. yawAxis?: Vector3;
  44042. pitchAxis?: Vector3;
  44043. adjustYaw?: number;
  44044. adjustPitch?: number;
  44045. adjustRoll?: number;
  44046. });
  44047. /**
  44048. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44049. */
  44050. update(): void;
  44051. private _getAngleDiff;
  44052. private _getAngleBetween;
  44053. private _isAngleBetween;
  44054. }
  44055. }
  44056. declare module BABYLON {
  44057. /**
  44058. * Manage the gamepad inputs to control an arc rotate camera.
  44059. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44060. */
  44061. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44062. /**
  44063. * Defines the camera the input is attached to.
  44064. */
  44065. camera: ArcRotateCamera;
  44066. /**
  44067. * Defines the gamepad the input is gathering event from.
  44068. */
  44069. gamepad: Nullable<Gamepad>;
  44070. /**
  44071. * Defines the gamepad rotation sensiblity.
  44072. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44073. */
  44074. gamepadRotationSensibility: number;
  44075. /**
  44076. * Defines the gamepad move sensiblity.
  44077. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44078. */
  44079. gamepadMoveSensibility: number;
  44080. private _yAxisScale;
  44081. /**
  44082. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44083. */
  44084. get invertYAxis(): boolean;
  44085. set invertYAxis(value: boolean);
  44086. private _onGamepadConnectedObserver;
  44087. private _onGamepadDisconnectedObserver;
  44088. /**
  44089. * Attach the input controls to a specific dom element to get the input from.
  44090. * @param element Defines the element the controls should be listened from
  44091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44092. */
  44093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44094. /**
  44095. * Detach the current controls from the specified dom element.
  44096. * @param element Defines the element to stop listening the inputs from
  44097. */
  44098. detachControl(element: Nullable<HTMLElement>): void;
  44099. /**
  44100. * Update the current camera state depending on the inputs that have been used this frame.
  44101. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44102. */
  44103. checkInputs(): void;
  44104. /**
  44105. * Gets the class name of the current intput.
  44106. * @returns the class name
  44107. */
  44108. getClassName(): string;
  44109. /**
  44110. * Get the friendly name associated with the input class.
  44111. * @returns the input friendly name
  44112. */
  44113. getSimpleName(): string;
  44114. }
  44115. }
  44116. declare module BABYLON {
  44117. interface ArcRotateCameraInputsManager {
  44118. /**
  44119. * Add orientation input support to the input manager.
  44120. * @returns the current input manager
  44121. */
  44122. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44123. }
  44124. /**
  44125. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44126. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44127. */
  44128. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44129. /**
  44130. * Defines the camera the input is attached to.
  44131. */
  44132. camera: ArcRotateCamera;
  44133. /**
  44134. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44135. */
  44136. alphaCorrection: number;
  44137. /**
  44138. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44139. */
  44140. gammaCorrection: number;
  44141. private _alpha;
  44142. private _gamma;
  44143. private _dirty;
  44144. private _deviceOrientationHandler;
  44145. /**
  44146. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44147. */
  44148. constructor();
  44149. /**
  44150. * Attach the input controls to a specific dom element to get the input from.
  44151. * @param element Defines the element the controls should be listened from
  44152. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44153. */
  44154. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44155. /** @hidden */
  44156. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44157. /**
  44158. * Update the current camera state depending on the inputs that have been used this frame.
  44159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44160. */
  44161. checkInputs(): void;
  44162. /**
  44163. * Detach the current controls from the specified dom element.
  44164. * @param element Defines the element to stop listening the inputs from
  44165. */
  44166. detachControl(element: Nullable<HTMLElement>): void;
  44167. /**
  44168. * Gets the class name of the current intput.
  44169. * @returns the class name
  44170. */
  44171. getClassName(): string;
  44172. /**
  44173. * Get the friendly name associated with the input class.
  44174. * @returns the input friendly name
  44175. */
  44176. getSimpleName(): string;
  44177. }
  44178. }
  44179. declare module BABYLON {
  44180. /**
  44181. * Listen to mouse events to control the camera.
  44182. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44183. */
  44184. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44185. /**
  44186. * Defines the camera the input is attached to.
  44187. */
  44188. camera: FlyCamera;
  44189. /**
  44190. * Defines if touch is enabled. (Default is true.)
  44191. */
  44192. touchEnabled: boolean;
  44193. /**
  44194. * Defines the buttons associated with the input to handle camera rotation.
  44195. */
  44196. buttons: number[];
  44197. /**
  44198. * Assign buttons for Yaw control.
  44199. */
  44200. buttonsYaw: number[];
  44201. /**
  44202. * Assign buttons for Pitch control.
  44203. */
  44204. buttonsPitch: number[];
  44205. /**
  44206. * Assign buttons for Roll control.
  44207. */
  44208. buttonsRoll: number[];
  44209. /**
  44210. * Detect if any button is being pressed while mouse is moved.
  44211. * -1 = Mouse locked.
  44212. * 0 = Left button.
  44213. * 1 = Middle Button.
  44214. * 2 = Right Button.
  44215. */
  44216. activeButton: number;
  44217. /**
  44218. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44219. * Higher values reduce its sensitivity.
  44220. */
  44221. angularSensibility: number;
  44222. private _mousemoveCallback;
  44223. private _observer;
  44224. private _rollObserver;
  44225. private previousPosition;
  44226. private noPreventDefault;
  44227. private element;
  44228. /**
  44229. * Listen to mouse events to control the camera.
  44230. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44231. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44232. */
  44233. constructor(touchEnabled?: boolean);
  44234. /**
  44235. * Attach the mouse control to the HTML DOM element.
  44236. * @param element Defines the element that listens to the input events.
  44237. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44238. */
  44239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44240. /**
  44241. * Detach the current controls from the specified dom element.
  44242. * @param element Defines the element to stop listening the inputs from
  44243. */
  44244. detachControl(element: Nullable<HTMLElement>): void;
  44245. /**
  44246. * Gets the class name of the current input.
  44247. * @returns the class name.
  44248. */
  44249. getClassName(): string;
  44250. /**
  44251. * Get the friendly name associated with the input class.
  44252. * @returns the input's friendly name.
  44253. */
  44254. getSimpleName(): string;
  44255. private _pointerInput;
  44256. private _onMouseMove;
  44257. /**
  44258. * Rotate camera by mouse offset.
  44259. */
  44260. private rotateCamera;
  44261. }
  44262. }
  44263. declare module BABYLON {
  44264. /**
  44265. * Default Inputs manager for the FlyCamera.
  44266. * It groups all the default supported inputs for ease of use.
  44267. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44268. */
  44269. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44270. /**
  44271. * Instantiates a new FlyCameraInputsManager.
  44272. * @param camera Defines the camera the inputs belong to.
  44273. */
  44274. constructor(camera: FlyCamera);
  44275. /**
  44276. * Add keyboard input support to the input manager.
  44277. * @returns the new FlyCameraKeyboardMoveInput().
  44278. */
  44279. addKeyboard(): FlyCameraInputsManager;
  44280. /**
  44281. * Add mouse input support to the input manager.
  44282. * @param touchEnabled Enable touch screen support.
  44283. * @returns the new FlyCameraMouseInput().
  44284. */
  44285. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44286. }
  44287. }
  44288. declare module BABYLON {
  44289. /**
  44290. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44291. * such as in a 3D Space Shooter or a Flight Simulator.
  44292. */
  44293. export class FlyCamera extends TargetCamera {
  44294. /**
  44295. * Define the collision ellipsoid of the camera.
  44296. * This is helpful for simulating a camera body, like a player's body.
  44297. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44298. */
  44299. ellipsoid: Vector3;
  44300. /**
  44301. * Define an offset for the position of the ellipsoid around the camera.
  44302. * This can be helpful if the camera is attached away from the player's body center,
  44303. * such as at its head.
  44304. */
  44305. ellipsoidOffset: Vector3;
  44306. /**
  44307. * Enable or disable collisions of the camera with the rest of the scene objects.
  44308. */
  44309. checkCollisions: boolean;
  44310. /**
  44311. * Enable or disable gravity on the camera.
  44312. */
  44313. applyGravity: boolean;
  44314. /**
  44315. * Define the current direction the camera is moving to.
  44316. */
  44317. cameraDirection: Vector3;
  44318. /**
  44319. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44320. * This overrides and empties cameraRotation.
  44321. */
  44322. rotationQuaternion: Quaternion;
  44323. /**
  44324. * Track Roll to maintain the wanted Rolling when looking around.
  44325. */
  44326. _trackRoll: number;
  44327. /**
  44328. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44329. */
  44330. rollCorrect: number;
  44331. /**
  44332. * Mimic a banked turn, Rolling the camera when Yawing.
  44333. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44334. */
  44335. bankedTurn: boolean;
  44336. /**
  44337. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44338. */
  44339. bankedTurnLimit: number;
  44340. /**
  44341. * Value of 0 disables the banked Roll.
  44342. * Value of 1 is equal to the Yaw angle in radians.
  44343. */
  44344. bankedTurnMultiplier: number;
  44345. /**
  44346. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44347. */
  44348. inputs: FlyCameraInputsManager;
  44349. /**
  44350. * Gets the input sensibility for mouse input.
  44351. * Higher values reduce sensitivity.
  44352. */
  44353. get angularSensibility(): number;
  44354. /**
  44355. * Sets the input sensibility for a mouse input.
  44356. * Higher values reduce sensitivity.
  44357. */
  44358. set angularSensibility(value: number);
  44359. /**
  44360. * Get the keys for camera movement forward.
  44361. */
  44362. get keysForward(): number[];
  44363. /**
  44364. * Set the keys for camera movement forward.
  44365. */
  44366. set keysForward(value: number[]);
  44367. /**
  44368. * Get the keys for camera movement backward.
  44369. */
  44370. get keysBackward(): number[];
  44371. set keysBackward(value: number[]);
  44372. /**
  44373. * Get the keys for camera movement up.
  44374. */
  44375. get keysUp(): number[];
  44376. /**
  44377. * Set the keys for camera movement up.
  44378. */
  44379. set keysUp(value: number[]);
  44380. /**
  44381. * Get the keys for camera movement down.
  44382. */
  44383. get keysDown(): number[];
  44384. /**
  44385. * Set the keys for camera movement down.
  44386. */
  44387. set keysDown(value: number[]);
  44388. /**
  44389. * Get the keys for camera movement left.
  44390. */
  44391. get keysLeft(): number[];
  44392. /**
  44393. * Set the keys for camera movement left.
  44394. */
  44395. set keysLeft(value: number[]);
  44396. /**
  44397. * Set the keys for camera movement right.
  44398. */
  44399. get keysRight(): number[];
  44400. /**
  44401. * Set the keys for camera movement right.
  44402. */
  44403. set keysRight(value: number[]);
  44404. /**
  44405. * Event raised when the camera collides with a mesh in the scene.
  44406. */
  44407. onCollide: (collidedMesh: AbstractMesh) => void;
  44408. private _collider;
  44409. private _needMoveForGravity;
  44410. private _oldPosition;
  44411. private _diffPosition;
  44412. private _newPosition;
  44413. /** @hidden */
  44414. _localDirection: Vector3;
  44415. /** @hidden */
  44416. _transformedDirection: Vector3;
  44417. /**
  44418. * Instantiates a FlyCamera.
  44419. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44420. * such as in a 3D Space Shooter or a Flight Simulator.
  44421. * @param name Define the name of the camera in the scene.
  44422. * @param position Define the starting position of the camera in the scene.
  44423. * @param scene Define the scene the camera belongs to.
  44424. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44425. */
  44426. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44427. /**
  44428. * Attach a control to the HTML DOM element.
  44429. * @param element Defines the element that listens to the input events.
  44430. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44431. */
  44432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44433. /**
  44434. * Detach a control from the HTML DOM element.
  44435. * The camera will stop reacting to that input.
  44436. * @param element Defines the element that listens to the input events.
  44437. */
  44438. detachControl(element: HTMLElement): void;
  44439. private _collisionMask;
  44440. /**
  44441. * Get the mask that the camera ignores in collision events.
  44442. */
  44443. get collisionMask(): number;
  44444. /**
  44445. * Set the mask that the camera ignores in collision events.
  44446. */
  44447. set collisionMask(mask: number);
  44448. /** @hidden */
  44449. _collideWithWorld(displacement: Vector3): void;
  44450. /** @hidden */
  44451. private _onCollisionPositionChange;
  44452. /** @hidden */
  44453. _checkInputs(): void;
  44454. /** @hidden */
  44455. _decideIfNeedsToMove(): boolean;
  44456. /** @hidden */
  44457. _updatePosition(): void;
  44458. /**
  44459. * Restore the Roll to its target value at the rate specified.
  44460. * @param rate - Higher means slower restoring.
  44461. * @hidden
  44462. */
  44463. restoreRoll(rate: number): void;
  44464. /**
  44465. * Destroy the camera and release the current resources held by it.
  44466. */
  44467. dispose(): void;
  44468. /**
  44469. * Get the current object class name.
  44470. * @returns the class name.
  44471. */
  44472. getClassName(): string;
  44473. }
  44474. }
  44475. declare module BABYLON {
  44476. /**
  44477. * Listen to keyboard events to control the camera.
  44478. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44479. */
  44480. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44481. /**
  44482. * Defines the camera the input is attached to.
  44483. */
  44484. camera: FlyCamera;
  44485. /**
  44486. * The list of keyboard keys used to control the forward move of the camera.
  44487. */
  44488. keysForward: number[];
  44489. /**
  44490. * The list of keyboard keys used to control the backward move of the camera.
  44491. */
  44492. keysBackward: number[];
  44493. /**
  44494. * The list of keyboard keys used to control the forward move of the camera.
  44495. */
  44496. keysUp: number[];
  44497. /**
  44498. * The list of keyboard keys used to control the backward move of the camera.
  44499. */
  44500. keysDown: number[];
  44501. /**
  44502. * The list of keyboard keys used to control the right strafe move of the camera.
  44503. */
  44504. keysRight: number[];
  44505. /**
  44506. * The list of keyboard keys used to control the left strafe move of the camera.
  44507. */
  44508. keysLeft: number[];
  44509. private _keys;
  44510. private _onCanvasBlurObserver;
  44511. private _onKeyboardObserver;
  44512. private _engine;
  44513. private _scene;
  44514. /**
  44515. * Attach the input controls to a specific dom element to get the input from.
  44516. * @param element Defines the element the controls should be listened from
  44517. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44518. */
  44519. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44520. /**
  44521. * Detach the current controls from the specified dom element.
  44522. * @param element Defines the element to stop listening the inputs from
  44523. */
  44524. detachControl(element: Nullable<HTMLElement>): void;
  44525. /**
  44526. * Gets the class name of the current intput.
  44527. * @returns the class name
  44528. */
  44529. getClassName(): string;
  44530. /** @hidden */
  44531. _onLostFocus(e: FocusEvent): void;
  44532. /**
  44533. * Get the friendly name associated with the input class.
  44534. * @returns the input friendly name
  44535. */
  44536. getSimpleName(): string;
  44537. /**
  44538. * Update the current camera state depending on the inputs that have been used this frame.
  44539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44540. */
  44541. checkInputs(): void;
  44542. }
  44543. }
  44544. declare module BABYLON {
  44545. /**
  44546. * Manage the mouse wheel inputs to control a follow camera.
  44547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44548. */
  44549. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44550. /**
  44551. * Defines the camera the input is attached to.
  44552. */
  44553. camera: FollowCamera;
  44554. /**
  44555. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44556. */
  44557. axisControlRadius: boolean;
  44558. /**
  44559. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44560. */
  44561. axisControlHeight: boolean;
  44562. /**
  44563. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44564. */
  44565. axisControlRotation: boolean;
  44566. /**
  44567. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44568. * relation to mouseWheel events.
  44569. */
  44570. wheelPrecision: number;
  44571. /**
  44572. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44573. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44574. */
  44575. wheelDeltaPercentage: number;
  44576. private _wheel;
  44577. private _observer;
  44578. /**
  44579. * Attach the input controls to a specific dom element to get the input from.
  44580. * @param element Defines the element the controls should be listened from
  44581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44582. */
  44583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44584. /**
  44585. * Detach the current controls from the specified dom element.
  44586. * @param element Defines the element to stop listening the inputs from
  44587. */
  44588. detachControl(element: Nullable<HTMLElement>): void;
  44589. /**
  44590. * Gets the class name of the current intput.
  44591. * @returns the class name
  44592. */
  44593. getClassName(): string;
  44594. /**
  44595. * Get the friendly name associated with the input class.
  44596. * @returns the input friendly name
  44597. */
  44598. getSimpleName(): string;
  44599. }
  44600. }
  44601. declare module BABYLON {
  44602. /**
  44603. * Manage the pointers inputs to control an follow camera.
  44604. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44605. */
  44606. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44607. /**
  44608. * Defines the camera the input is attached to.
  44609. */
  44610. camera: FollowCamera;
  44611. /**
  44612. * Gets the class name of the current input.
  44613. * @returns the class name
  44614. */
  44615. getClassName(): string;
  44616. /**
  44617. * Defines the pointer angular sensibility along the X axis or how fast is
  44618. * the camera rotating.
  44619. * A negative number will reverse the axis direction.
  44620. */
  44621. angularSensibilityX: number;
  44622. /**
  44623. * Defines the pointer angular sensibility along the Y axis or how fast is
  44624. * the camera rotating.
  44625. * A negative number will reverse the axis direction.
  44626. */
  44627. angularSensibilityY: number;
  44628. /**
  44629. * Defines the pointer pinch precision or how fast is the camera zooming.
  44630. * A negative number will reverse the axis direction.
  44631. */
  44632. pinchPrecision: number;
  44633. /**
  44634. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44635. * from 0.
  44636. * It defines the percentage of current camera.radius to use as delta when
  44637. * pinch zoom is used.
  44638. */
  44639. pinchDeltaPercentage: number;
  44640. /**
  44641. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44642. */
  44643. axisXControlRadius: boolean;
  44644. /**
  44645. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44646. */
  44647. axisXControlHeight: boolean;
  44648. /**
  44649. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44650. */
  44651. axisXControlRotation: boolean;
  44652. /**
  44653. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44654. */
  44655. axisYControlRadius: boolean;
  44656. /**
  44657. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44658. */
  44659. axisYControlHeight: boolean;
  44660. /**
  44661. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44662. */
  44663. axisYControlRotation: boolean;
  44664. /**
  44665. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44666. */
  44667. axisPinchControlRadius: boolean;
  44668. /**
  44669. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44670. */
  44671. axisPinchControlHeight: boolean;
  44672. /**
  44673. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44674. */
  44675. axisPinchControlRotation: boolean;
  44676. /**
  44677. * Log error messages if basic misconfiguration has occurred.
  44678. */
  44679. warningEnable: boolean;
  44680. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44681. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44682. private _warningCounter;
  44683. private _warning;
  44684. }
  44685. }
  44686. declare module BABYLON {
  44687. /**
  44688. * Default Inputs manager for the FollowCamera.
  44689. * It groups all the default supported inputs for ease of use.
  44690. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44691. */
  44692. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44693. /**
  44694. * Instantiates a new FollowCameraInputsManager.
  44695. * @param camera Defines the camera the inputs belong to
  44696. */
  44697. constructor(camera: FollowCamera);
  44698. /**
  44699. * Add keyboard input support to the input manager.
  44700. * @returns the current input manager
  44701. */
  44702. addKeyboard(): FollowCameraInputsManager;
  44703. /**
  44704. * Add mouse wheel input support to the input manager.
  44705. * @returns the current input manager
  44706. */
  44707. addMouseWheel(): FollowCameraInputsManager;
  44708. /**
  44709. * Add pointers input support to the input manager.
  44710. * @returns the current input manager
  44711. */
  44712. addPointers(): FollowCameraInputsManager;
  44713. /**
  44714. * Add orientation input support to the input manager.
  44715. * @returns the current input manager
  44716. */
  44717. addVRDeviceOrientation(): FollowCameraInputsManager;
  44718. }
  44719. }
  44720. declare module BABYLON {
  44721. /**
  44722. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44723. * an arc rotate version arcFollowCamera are available.
  44724. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44725. */
  44726. export class FollowCamera extends TargetCamera {
  44727. /**
  44728. * Distance the follow camera should follow an object at
  44729. */
  44730. radius: number;
  44731. /**
  44732. * Minimum allowed distance of the camera to the axis of rotation
  44733. * (The camera can not get closer).
  44734. * This can help limiting how the Camera is able to move in the scene.
  44735. */
  44736. lowerRadiusLimit: Nullable<number>;
  44737. /**
  44738. * Maximum allowed distance of the camera to the axis of rotation
  44739. * (The camera can not get further).
  44740. * This can help limiting how the Camera is able to move in the scene.
  44741. */
  44742. upperRadiusLimit: Nullable<number>;
  44743. /**
  44744. * Define a rotation offset between the camera and the object it follows
  44745. */
  44746. rotationOffset: number;
  44747. /**
  44748. * Minimum allowed angle to camera position relative to target object.
  44749. * This can help limiting how the Camera is able to move in the scene.
  44750. */
  44751. lowerRotationOffsetLimit: Nullable<number>;
  44752. /**
  44753. * Maximum allowed angle to camera position relative to target object.
  44754. * This can help limiting how the Camera is able to move in the scene.
  44755. */
  44756. upperRotationOffsetLimit: Nullable<number>;
  44757. /**
  44758. * Define a height offset between the camera and the object it follows.
  44759. * It can help following an object from the top (like a car chaing a plane)
  44760. */
  44761. heightOffset: number;
  44762. /**
  44763. * Minimum allowed height of camera position relative to target object.
  44764. * This can help limiting how the Camera is able to move in the scene.
  44765. */
  44766. lowerHeightOffsetLimit: Nullable<number>;
  44767. /**
  44768. * Maximum allowed height of camera position relative to target object.
  44769. * This can help limiting how the Camera is able to move in the scene.
  44770. */
  44771. upperHeightOffsetLimit: Nullable<number>;
  44772. /**
  44773. * Define how fast the camera can accelerate to follow it s target.
  44774. */
  44775. cameraAcceleration: number;
  44776. /**
  44777. * Define the speed limit of the camera following an object.
  44778. */
  44779. maxCameraSpeed: number;
  44780. /**
  44781. * Define the target of the camera.
  44782. */
  44783. lockedTarget: Nullable<AbstractMesh>;
  44784. /**
  44785. * Defines the input associated with the camera.
  44786. */
  44787. inputs: FollowCameraInputsManager;
  44788. /**
  44789. * Instantiates the follow camera.
  44790. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44791. * @param name Define the name of the camera in the scene
  44792. * @param position Define the position of the camera
  44793. * @param scene Define the scene the camera belong to
  44794. * @param lockedTarget Define the target of the camera
  44795. */
  44796. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44797. private _follow;
  44798. /**
  44799. * Attached controls to the current camera.
  44800. * @param element Defines the element the controls should be listened from
  44801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44802. */
  44803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44804. /**
  44805. * Detach the current controls from the camera.
  44806. * The camera will stop reacting to inputs.
  44807. * @param element Defines the element to stop listening the inputs from
  44808. */
  44809. detachControl(element: HTMLElement): void;
  44810. /** @hidden */
  44811. _checkInputs(): void;
  44812. private _checkLimits;
  44813. /**
  44814. * Gets the camera class name.
  44815. * @returns the class name
  44816. */
  44817. getClassName(): string;
  44818. }
  44819. /**
  44820. * Arc Rotate version of the follow camera.
  44821. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44822. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44823. */
  44824. export class ArcFollowCamera extends TargetCamera {
  44825. /** The longitudinal angle of the camera */
  44826. alpha: number;
  44827. /** The latitudinal angle of the camera */
  44828. beta: number;
  44829. /** The radius of the camera from its target */
  44830. radius: number;
  44831. private _cartesianCoordinates;
  44832. /** Define the camera target (the mesh it should follow) */
  44833. private _meshTarget;
  44834. /**
  44835. * Instantiates a new ArcFollowCamera
  44836. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44837. * @param name Define the name of the camera
  44838. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44839. * @param beta Define the rotation angle of the camera around the elevation axis
  44840. * @param radius Define the radius of the camera from its target point
  44841. * @param target Define the target of the camera
  44842. * @param scene Define the scene the camera belongs to
  44843. */
  44844. constructor(name: string,
  44845. /** The longitudinal angle of the camera */
  44846. alpha: number,
  44847. /** The latitudinal angle of the camera */
  44848. beta: number,
  44849. /** The radius of the camera from its target */
  44850. radius: number,
  44851. /** Define the camera target (the mesh it should follow) */
  44852. target: Nullable<AbstractMesh>, scene: Scene);
  44853. private _follow;
  44854. /** @hidden */
  44855. _checkInputs(): void;
  44856. /**
  44857. * Returns the class name of the object.
  44858. * It is mostly used internally for serialization purposes.
  44859. */
  44860. getClassName(): string;
  44861. }
  44862. }
  44863. declare module BABYLON {
  44864. /**
  44865. * Manage the keyboard inputs to control the movement of a follow camera.
  44866. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44867. */
  44868. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44869. /**
  44870. * Defines the camera the input is attached to.
  44871. */
  44872. camera: FollowCamera;
  44873. /**
  44874. * Defines the list of key codes associated with the up action (increase heightOffset)
  44875. */
  44876. keysHeightOffsetIncr: number[];
  44877. /**
  44878. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44879. */
  44880. keysHeightOffsetDecr: number[];
  44881. /**
  44882. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44883. */
  44884. keysHeightOffsetModifierAlt: boolean;
  44885. /**
  44886. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44887. */
  44888. keysHeightOffsetModifierCtrl: boolean;
  44889. /**
  44890. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44891. */
  44892. keysHeightOffsetModifierShift: boolean;
  44893. /**
  44894. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44895. */
  44896. keysRotationOffsetIncr: number[];
  44897. /**
  44898. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44899. */
  44900. keysRotationOffsetDecr: number[];
  44901. /**
  44902. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44903. */
  44904. keysRotationOffsetModifierAlt: boolean;
  44905. /**
  44906. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44907. */
  44908. keysRotationOffsetModifierCtrl: boolean;
  44909. /**
  44910. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44911. */
  44912. keysRotationOffsetModifierShift: boolean;
  44913. /**
  44914. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44915. */
  44916. keysRadiusIncr: number[];
  44917. /**
  44918. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44919. */
  44920. keysRadiusDecr: number[];
  44921. /**
  44922. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44923. */
  44924. keysRadiusModifierAlt: boolean;
  44925. /**
  44926. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44927. */
  44928. keysRadiusModifierCtrl: boolean;
  44929. /**
  44930. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44931. */
  44932. keysRadiusModifierShift: boolean;
  44933. /**
  44934. * Defines the rate of change of heightOffset.
  44935. */
  44936. heightSensibility: number;
  44937. /**
  44938. * Defines the rate of change of rotationOffset.
  44939. */
  44940. rotationSensibility: number;
  44941. /**
  44942. * Defines the rate of change of radius.
  44943. */
  44944. radiusSensibility: number;
  44945. private _keys;
  44946. private _ctrlPressed;
  44947. private _altPressed;
  44948. private _shiftPressed;
  44949. private _onCanvasBlurObserver;
  44950. private _onKeyboardObserver;
  44951. private _engine;
  44952. private _scene;
  44953. /**
  44954. * Attach the input controls to a specific dom element to get the input from.
  44955. * @param element Defines the element the controls should be listened from
  44956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44957. */
  44958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44959. /**
  44960. * Detach the current controls from the specified dom element.
  44961. * @param element Defines the element to stop listening the inputs from
  44962. */
  44963. detachControl(element: Nullable<HTMLElement>): void;
  44964. /**
  44965. * Update the current camera state depending on the inputs that have been used this frame.
  44966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44967. */
  44968. checkInputs(): void;
  44969. /**
  44970. * Gets the class name of the current input.
  44971. * @returns the class name
  44972. */
  44973. getClassName(): string;
  44974. /**
  44975. * Get the friendly name associated with the input class.
  44976. * @returns the input friendly name
  44977. */
  44978. getSimpleName(): string;
  44979. /**
  44980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44981. * allow modification of the heightOffset value.
  44982. */
  44983. private _modifierHeightOffset;
  44984. /**
  44985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44986. * allow modification of the rotationOffset value.
  44987. */
  44988. private _modifierRotationOffset;
  44989. /**
  44990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44991. * allow modification of the radius value.
  44992. */
  44993. private _modifierRadius;
  44994. }
  44995. }
  44996. declare module BABYLON {
  44997. interface FreeCameraInputsManager {
  44998. /**
  44999. * @hidden
  45000. */
  45001. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45002. /**
  45003. * Add orientation input support to the input manager.
  45004. * @returns the current input manager
  45005. */
  45006. addDeviceOrientation(): FreeCameraInputsManager;
  45007. }
  45008. /**
  45009. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45010. * Screen rotation is taken into account.
  45011. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45012. */
  45013. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45014. private _camera;
  45015. private _screenOrientationAngle;
  45016. private _constantTranform;
  45017. private _screenQuaternion;
  45018. private _alpha;
  45019. private _beta;
  45020. private _gamma;
  45021. /**
  45022. * Can be used to detect if a device orientation sensor is available on a device
  45023. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45024. * @returns a promise that will resolve on orientation change
  45025. */
  45026. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45027. /**
  45028. * @hidden
  45029. */
  45030. _onDeviceOrientationChangedObservable: Observable<void>;
  45031. /**
  45032. * Instantiates a new input
  45033. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45034. */
  45035. constructor();
  45036. /**
  45037. * Define the camera controlled by the input.
  45038. */
  45039. get camera(): FreeCamera;
  45040. set camera(camera: FreeCamera);
  45041. /**
  45042. * Attach the input controls to a specific dom element to get the input from.
  45043. * @param element Defines the element the controls should be listened from
  45044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45045. */
  45046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45047. private _orientationChanged;
  45048. private _deviceOrientation;
  45049. /**
  45050. * Detach the current controls from the specified dom element.
  45051. * @param element Defines the element to stop listening the inputs from
  45052. */
  45053. detachControl(element: Nullable<HTMLElement>): void;
  45054. /**
  45055. * Update the current camera state depending on the inputs that have been used this frame.
  45056. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45057. */
  45058. checkInputs(): void;
  45059. /**
  45060. * Gets the class name of the current intput.
  45061. * @returns the class name
  45062. */
  45063. getClassName(): string;
  45064. /**
  45065. * Get the friendly name associated with the input class.
  45066. * @returns the input friendly name
  45067. */
  45068. getSimpleName(): string;
  45069. }
  45070. }
  45071. declare module BABYLON {
  45072. /**
  45073. * Manage the gamepad inputs to control a free camera.
  45074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45075. */
  45076. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45077. /**
  45078. * Define the camera the input is attached to.
  45079. */
  45080. camera: FreeCamera;
  45081. /**
  45082. * Define the Gamepad controlling the input
  45083. */
  45084. gamepad: Nullable<Gamepad>;
  45085. /**
  45086. * Defines the gamepad rotation sensiblity.
  45087. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45088. */
  45089. gamepadAngularSensibility: number;
  45090. /**
  45091. * Defines the gamepad move sensiblity.
  45092. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45093. */
  45094. gamepadMoveSensibility: number;
  45095. private _yAxisScale;
  45096. /**
  45097. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45098. */
  45099. get invertYAxis(): boolean;
  45100. set invertYAxis(value: boolean);
  45101. private _onGamepadConnectedObserver;
  45102. private _onGamepadDisconnectedObserver;
  45103. private _cameraTransform;
  45104. private _deltaTransform;
  45105. private _vector3;
  45106. private _vector2;
  45107. /**
  45108. * Attach the input controls to a specific dom element to get the input from.
  45109. * @param element Defines the element the controls should be listened from
  45110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45111. */
  45112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45113. /**
  45114. * Detach the current controls from the specified dom element.
  45115. * @param element Defines the element to stop listening the inputs from
  45116. */
  45117. detachControl(element: Nullable<HTMLElement>): void;
  45118. /**
  45119. * Update the current camera state depending on the inputs that have been used this frame.
  45120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45121. */
  45122. checkInputs(): void;
  45123. /**
  45124. * Gets the class name of the current intput.
  45125. * @returns the class name
  45126. */
  45127. getClassName(): string;
  45128. /**
  45129. * Get the friendly name associated with the input class.
  45130. * @returns the input friendly name
  45131. */
  45132. getSimpleName(): string;
  45133. }
  45134. }
  45135. declare module BABYLON {
  45136. /**
  45137. * Defines the potential axis of a Joystick
  45138. */
  45139. export enum JoystickAxis {
  45140. /** X axis */
  45141. X = 0,
  45142. /** Y axis */
  45143. Y = 1,
  45144. /** Z axis */
  45145. Z = 2
  45146. }
  45147. /**
  45148. * Represents the different customization options available
  45149. * for VirtualJoystick
  45150. */
  45151. interface VirtualJoystickCustomizations {
  45152. /**
  45153. * Size of the joystick's puck
  45154. */
  45155. puckSize: number;
  45156. /**
  45157. * Size of the joystick's container
  45158. */
  45159. containerSize: number;
  45160. /**
  45161. * Color of the joystick && puck
  45162. */
  45163. color: string;
  45164. /**
  45165. * Image URL for the joystick's puck
  45166. */
  45167. puckImage?: string;
  45168. /**
  45169. * Image URL for the joystick's container
  45170. */
  45171. containerImage?: string;
  45172. /**
  45173. * Defines the unmoving position of the joystick container
  45174. */
  45175. position?: {
  45176. x: number;
  45177. y: number;
  45178. };
  45179. /**
  45180. * Defines whether or not the joystick container is always visible
  45181. */
  45182. alwaysVisible: boolean;
  45183. /**
  45184. * Defines whether or not to limit the movement of the puck to the joystick's container
  45185. */
  45186. limitToContainer: boolean;
  45187. }
  45188. /**
  45189. * Class used to define virtual joystick (used in touch mode)
  45190. */
  45191. export class VirtualJoystick {
  45192. /**
  45193. * Gets or sets a boolean indicating that left and right values must be inverted
  45194. */
  45195. reverseLeftRight: boolean;
  45196. /**
  45197. * Gets or sets a boolean indicating that up and down values must be inverted
  45198. */
  45199. reverseUpDown: boolean;
  45200. /**
  45201. * Gets the offset value for the position (ie. the change of the position value)
  45202. */
  45203. deltaPosition: Vector3;
  45204. /**
  45205. * Gets a boolean indicating if the virtual joystick was pressed
  45206. */
  45207. pressed: boolean;
  45208. /**
  45209. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45210. */
  45211. static Canvas: Nullable<HTMLCanvasElement>;
  45212. /**
  45213. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45214. */
  45215. limitToContainer: boolean;
  45216. private static _globalJoystickIndex;
  45217. private static _alwaysVisibleSticks;
  45218. private static vjCanvasContext;
  45219. private static vjCanvasWidth;
  45220. private static vjCanvasHeight;
  45221. private static halfWidth;
  45222. private static _GetDefaultOptions;
  45223. private _action;
  45224. private _axisTargetedByLeftAndRight;
  45225. private _axisTargetedByUpAndDown;
  45226. private _joystickSensibility;
  45227. private _inversedSensibility;
  45228. private _joystickPointerID;
  45229. private _joystickColor;
  45230. private _joystickPointerPos;
  45231. private _joystickPreviousPointerPos;
  45232. private _joystickPointerStartPos;
  45233. private _deltaJoystickVector;
  45234. private _leftJoystick;
  45235. private _touches;
  45236. private _joystickPosition;
  45237. private _alwaysVisible;
  45238. private _puckImage;
  45239. private _containerImage;
  45240. private _joystickPuckSize;
  45241. private _joystickContainerSize;
  45242. private _clearPuckSize;
  45243. private _clearContainerSize;
  45244. private _clearPuckSizeOffset;
  45245. private _clearContainerSizeOffset;
  45246. private _onPointerDownHandlerRef;
  45247. private _onPointerMoveHandlerRef;
  45248. private _onPointerUpHandlerRef;
  45249. private _onResize;
  45250. /**
  45251. * Creates a new virtual joystick
  45252. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45253. * @param customizations Defines the options we want to customize the VirtualJoystick
  45254. */
  45255. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45256. /**
  45257. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45258. * @param newJoystickSensibility defines the new sensibility
  45259. */
  45260. setJoystickSensibility(newJoystickSensibility: number): void;
  45261. private _onPointerDown;
  45262. private _onPointerMove;
  45263. private _onPointerUp;
  45264. /**
  45265. * Change the color of the virtual joystick
  45266. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45267. */
  45268. setJoystickColor(newColor: string): void;
  45269. /**
  45270. * Size of the joystick's container
  45271. */
  45272. set containerSize(newSize: number);
  45273. get containerSize(): number;
  45274. /**
  45275. * Size of the joystick's puck
  45276. */
  45277. set puckSize(newSize: number);
  45278. get puckSize(): number;
  45279. /**
  45280. * Clears the set position of the joystick
  45281. */
  45282. clearPosition(): void;
  45283. /**
  45284. * Defines whether or not the joystick container is always visible
  45285. */
  45286. set alwaysVisible(value: boolean);
  45287. get alwaysVisible(): boolean;
  45288. /**
  45289. * Sets the constant position of the Joystick container
  45290. * @param x X axis coordinate
  45291. * @param y Y axis coordinate
  45292. */
  45293. setPosition(x: number, y: number): void;
  45294. /**
  45295. * Defines a callback to call when the joystick is touched
  45296. * @param action defines the callback
  45297. */
  45298. setActionOnTouch(action: () => any): void;
  45299. /**
  45300. * Defines which axis you'd like to control for left & right
  45301. * @param axis defines the axis to use
  45302. */
  45303. setAxisForLeftRight(axis: JoystickAxis): void;
  45304. /**
  45305. * Defines which axis you'd like to control for up & down
  45306. * @param axis defines the axis to use
  45307. */
  45308. setAxisForUpDown(axis: JoystickAxis): void;
  45309. /**
  45310. * Clears the canvas from the previous puck / container draw
  45311. */
  45312. private _clearPreviousDraw;
  45313. /**
  45314. * Loads `urlPath` to be used for the container's image
  45315. * @param urlPath defines the urlPath of an image to use
  45316. */
  45317. setContainerImage(urlPath: string): void;
  45318. /**
  45319. * Loads `urlPath` to be used for the puck's image
  45320. * @param urlPath defines the urlPath of an image to use
  45321. */
  45322. setPuckImage(urlPath: string): void;
  45323. /**
  45324. * Draws the Virtual Joystick's container
  45325. */
  45326. private _drawContainer;
  45327. /**
  45328. * Draws the Virtual Joystick's puck
  45329. */
  45330. private _drawPuck;
  45331. private _drawVirtualJoystick;
  45332. /**
  45333. * Release internal HTML canvas
  45334. */
  45335. releaseCanvas(): void;
  45336. }
  45337. }
  45338. declare module BABYLON {
  45339. interface FreeCameraInputsManager {
  45340. /**
  45341. * Add virtual joystick input support to the input manager.
  45342. * @returns the current input manager
  45343. */
  45344. addVirtualJoystick(): FreeCameraInputsManager;
  45345. }
  45346. /**
  45347. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45348. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45349. */
  45350. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45351. /**
  45352. * Defines the camera the input is attached to.
  45353. */
  45354. camera: FreeCamera;
  45355. private _leftjoystick;
  45356. private _rightjoystick;
  45357. /**
  45358. * Gets the left stick of the virtual joystick.
  45359. * @returns The virtual Joystick
  45360. */
  45361. getLeftJoystick(): VirtualJoystick;
  45362. /**
  45363. * Gets the right stick of the virtual joystick.
  45364. * @returns The virtual Joystick
  45365. */
  45366. getRightJoystick(): VirtualJoystick;
  45367. /**
  45368. * Update the current camera state depending on the inputs that have been used this frame.
  45369. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45370. */
  45371. checkInputs(): void;
  45372. /**
  45373. * Attach the input controls to a specific dom element to get the input from.
  45374. * @param element Defines the element the controls should be listened from
  45375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45376. */
  45377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45378. /**
  45379. * Detach the current controls from the specified dom element.
  45380. * @param element Defines the element to stop listening the inputs from
  45381. */
  45382. detachControl(element: Nullable<HTMLElement>): void;
  45383. /**
  45384. * Gets the class name of the current intput.
  45385. * @returns the class name
  45386. */
  45387. getClassName(): string;
  45388. /**
  45389. * Get the friendly name associated with the input class.
  45390. * @returns the input friendly name
  45391. */
  45392. getSimpleName(): string;
  45393. }
  45394. }
  45395. declare module BABYLON {
  45396. /**
  45397. * This represents a FPS type of camera controlled by touch.
  45398. * This is like a universal camera minus the Gamepad controls.
  45399. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45400. */
  45401. export class TouchCamera extends FreeCamera {
  45402. /**
  45403. * Defines the touch sensibility for rotation.
  45404. * The higher the faster.
  45405. */
  45406. get touchAngularSensibility(): number;
  45407. set touchAngularSensibility(value: number);
  45408. /**
  45409. * Defines the touch sensibility for move.
  45410. * The higher the faster.
  45411. */
  45412. get touchMoveSensibility(): number;
  45413. set touchMoveSensibility(value: number);
  45414. /**
  45415. * Instantiates a new touch camera.
  45416. * This represents a FPS type of camera controlled by touch.
  45417. * This is like a universal camera minus the Gamepad controls.
  45418. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45419. * @param name Define the name of the camera in the scene
  45420. * @param position Define the start position of the camera in the scene
  45421. * @param scene Define the scene the camera belongs to
  45422. */
  45423. constructor(name: string, position: Vector3, scene: Scene);
  45424. /**
  45425. * Gets the current object class name.
  45426. * @return the class name
  45427. */
  45428. getClassName(): string;
  45429. /** @hidden */
  45430. _setupInputs(): void;
  45431. }
  45432. }
  45433. declare module BABYLON {
  45434. /**
  45435. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45436. * being tilted forward or back and left or right.
  45437. */
  45438. export class DeviceOrientationCamera extends FreeCamera {
  45439. private _initialQuaternion;
  45440. private _quaternionCache;
  45441. private _tmpDragQuaternion;
  45442. private _disablePointerInputWhenUsingDeviceOrientation;
  45443. /**
  45444. * Creates a new device orientation camera
  45445. * @param name The name of the camera
  45446. * @param position The start position camera
  45447. * @param scene The scene the camera belongs to
  45448. */
  45449. constructor(name: string, position: Vector3, scene: Scene);
  45450. /**
  45451. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45452. */
  45453. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45454. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45455. private _dragFactor;
  45456. /**
  45457. * Enabled turning on the y axis when the orientation sensor is active
  45458. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45459. */
  45460. enableHorizontalDragging(dragFactor?: number): void;
  45461. /**
  45462. * Gets the current instance class name ("DeviceOrientationCamera").
  45463. * This helps avoiding instanceof at run time.
  45464. * @returns the class name
  45465. */
  45466. getClassName(): string;
  45467. /**
  45468. * @hidden
  45469. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45470. */
  45471. _checkInputs(): void;
  45472. /**
  45473. * Reset the camera to its default orientation on the specified axis only.
  45474. * @param axis The axis to reset
  45475. */
  45476. resetToCurrentRotation(axis?: Axis): void;
  45477. }
  45478. }
  45479. declare module BABYLON {
  45480. /**
  45481. * Defines supported buttons for XBox360 compatible gamepads
  45482. */
  45483. export enum Xbox360Button {
  45484. /** A */
  45485. A = 0,
  45486. /** B */
  45487. B = 1,
  45488. /** X */
  45489. X = 2,
  45490. /** Y */
  45491. Y = 3,
  45492. /** Left button */
  45493. LB = 4,
  45494. /** Right button */
  45495. RB = 5,
  45496. /** Back */
  45497. Back = 8,
  45498. /** Start */
  45499. Start = 9,
  45500. /** Left stick */
  45501. LeftStick = 10,
  45502. /** Right stick */
  45503. RightStick = 11
  45504. }
  45505. /** Defines values for XBox360 DPad */
  45506. export enum Xbox360Dpad {
  45507. /** Up */
  45508. Up = 12,
  45509. /** Down */
  45510. Down = 13,
  45511. /** Left */
  45512. Left = 14,
  45513. /** Right */
  45514. Right = 15
  45515. }
  45516. /**
  45517. * Defines a XBox360 gamepad
  45518. */
  45519. export class Xbox360Pad extends Gamepad {
  45520. private _leftTrigger;
  45521. private _rightTrigger;
  45522. private _onlefttriggerchanged;
  45523. private _onrighttriggerchanged;
  45524. private _onbuttondown;
  45525. private _onbuttonup;
  45526. private _ondpaddown;
  45527. private _ondpadup;
  45528. /** Observable raised when a button is pressed */
  45529. onButtonDownObservable: Observable<Xbox360Button>;
  45530. /** Observable raised when a button is released */
  45531. onButtonUpObservable: Observable<Xbox360Button>;
  45532. /** Observable raised when a pad is pressed */
  45533. onPadDownObservable: Observable<Xbox360Dpad>;
  45534. /** Observable raised when a pad is released */
  45535. onPadUpObservable: Observable<Xbox360Dpad>;
  45536. private _buttonA;
  45537. private _buttonB;
  45538. private _buttonX;
  45539. private _buttonY;
  45540. private _buttonBack;
  45541. private _buttonStart;
  45542. private _buttonLB;
  45543. private _buttonRB;
  45544. private _buttonLeftStick;
  45545. private _buttonRightStick;
  45546. private _dPadUp;
  45547. private _dPadDown;
  45548. private _dPadLeft;
  45549. private _dPadRight;
  45550. private _isXboxOnePad;
  45551. /**
  45552. * Creates a new XBox360 gamepad object
  45553. * @param id defines the id of this gamepad
  45554. * @param index defines its index
  45555. * @param gamepad defines the internal HTML gamepad object
  45556. * @param xboxOne defines if it is a XBox One gamepad
  45557. */
  45558. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45559. /**
  45560. * Defines the callback to call when left trigger is pressed
  45561. * @param callback defines the callback to use
  45562. */
  45563. onlefttriggerchanged(callback: (value: number) => void): void;
  45564. /**
  45565. * Defines the callback to call when right trigger is pressed
  45566. * @param callback defines the callback to use
  45567. */
  45568. onrighttriggerchanged(callback: (value: number) => void): void;
  45569. /**
  45570. * Gets the left trigger value
  45571. */
  45572. get leftTrigger(): number;
  45573. /**
  45574. * Sets the left trigger value
  45575. */
  45576. set leftTrigger(newValue: number);
  45577. /**
  45578. * Gets the right trigger value
  45579. */
  45580. get rightTrigger(): number;
  45581. /**
  45582. * Sets the right trigger value
  45583. */
  45584. set rightTrigger(newValue: number);
  45585. /**
  45586. * Defines the callback to call when a button is pressed
  45587. * @param callback defines the callback to use
  45588. */
  45589. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45590. /**
  45591. * Defines the callback to call when a button is released
  45592. * @param callback defines the callback to use
  45593. */
  45594. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45595. /**
  45596. * Defines the callback to call when a pad is pressed
  45597. * @param callback defines the callback to use
  45598. */
  45599. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45600. /**
  45601. * Defines the callback to call when a pad is released
  45602. * @param callback defines the callback to use
  45603. */
  45604. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45605. private _setButtonValue;
  45606. private _setDPadValue;
  45607. /**
  45608. * Gets the value of the `A` button
  45609. */
  45610. get buttonA(): number;
  45611. /**
  45612. * Sets the value of the `A` button
  45613. */
  45614. set buttonA(value: number);
  45615. /**
  45616. * Gets the value of the `B` button
  45617. */
  45618. get buttonB(): number;
  45619. /**
  45620. * Sets the value of the `B` button
  45621. */
  45622. set buttonB(value: number);
  45623. /**
  45624. * Gets the value of the `X` button
  45625. */
  45626. get buttonX(): number;
  45627. /**
  45628. * Sets the value of the `X` button
  45629. */
  45630. set buttonX(value: number);
  45631. /**
  45632. * Gets the value of the `Y` button
  45633. */
  45634. get buttonY(): number;
  45635. /**
  45636. * Sets the value of the `Y` button
  45637. */
  45638. set buttonY(value: number);
  45639. /**
  45640. * Gets the value of the `Start` button
  45641. */
  45642. get buttonStart(): number;
  45643. /**
  45644. * Sets the value of the `Start` button
  45645. */
  45646. set buttonStart(value: number);
  45647. /**
  45648. * Gets the value of the `Back` button
  45649. */
  45650. get buttonBack(): number;
  45651. /**
  45652. * Sets the value of the `Back` button
  45653. */
  45654. set buttonBack(value: number);
  45655. /**
  45656. * Gets the value of the `Left` button
  45657. */
  45658. get buttonLB(): number;
  45659. /**
  45660. * Sets the value of the `Left` button
  45661. */
  45662. set buttonLB(value: number);
  45663. /**
  45664. * Gets the value of the `Right` button
  45665. */
  45666. get buttonRB(): number;
  45667. /**
  45668. * Sets the value of the `Right` button
  45669. */
  45670. set buttonRB(value: number);
  45671. /**
  45672. * Gets the value of the Left joystick
  45673. */
  45674. get buttonLeftStick(): number;
  45675. /**
  45676. * Sets the value of the Left joystick
  45677. */
  45678. set buttonLeftStick(value: number);
  45679. /**
  45680. * Gets the value of the Right joystick
  45681. */
  45682. get buttonRightStick(): number;
  45683. /**
  45684. * Sets the value of the Right joystick
  45685. */
  45686. set buttonRightStick(value: number);
  45687. /**
  45688. * Gets the value of D-pad up
  45689. */
  45690. get dPadUp(): number;
  45691. /**
  45692. * Sets the value of D-pad up
  45693. */
  45694. set dPadUp(value: number);
  45695. /**
  45696. * Gets the value of D-pad down
  45697. */
  45698. get dPadDown(): number;
  45699. /**
  45700. * Sets the value of D-pad down
  45701. */
  45702. set dPadDown(value: number);
  45703. /**
  45704. * Gets the value of D-pad left
  45705. */
  45706. get dPadLeft(): number;
  45707. /**
  45708. * Sets the value of D-pad left
  45709. */
  45710. set dPadLeft(value: number);
  45711. /**
  45712. * Gets the value of D-pad right
  45713. */
  45714. get dPadRight(): number;
  45715. /**
  45716. * Sets the value of D-pad right
  45717. */
  45718. set dPadRight(value: number);
  45719. /**
  45720. * Force the gamepad to synchronize with device values
  45721. */
  45722. update(): void;
  45723. /**
  45724. * Disposes the gamepad
  45725. */
  45726. dispose(): void;
  45727. }
  45728. }
  45729. declare module BABYLON {
  45730. /**
  45731. * Defines supported buttons for DualShock compatible gamepads
  45732. */
  45733. export enum DualShockButton {
  45734. /** Cross */
  45735. Cross = 0,
  45736. /** Circle */
  45737. Circle = 1,
  45738. /** Square */
  45739. Square = 2,
  45740. /** Triangle */
  45741. Triangle = 3,
  45742. /** L1 */
  45743. L1 = 4,
  45744. /** R1 */
  45745. R1 = 5,
  45746. /** Share */
  45747. Share = 8,
  45748. /** Options */
  45749. Options = 9,
  45750. /** Left stick */
  45751. LeftStick = 10,
  45752. /** Right stick */
  45753. RightStick = 11
  45754. }
  45755. /** Defines values for DualShock DPad */
  45756. export enum DualShockDpad {
  45757. /** Up */
  45758. Up = 12,
  45759. /** Down */
  45760. Down = 13,
  45761. /** Left */
  45762. Left = 14,
  45763. /** Right */
  45764. Right = 15
  45765. }
  45766. /**
  45767. * Defines a DualShock gamepad
  45768. */
  45769. export class DualShockPad extends Gamepad {
  45770. private _leftTrigger;
  45771. private _rightTrigger;
  45772. private _onlefttriggerchanged;
  45773. private _onrighttriggerchanged;
  45774. private _onbuttondown;
  45775. private _onbuttonup;
  45776. private _ondpaddown;
  45777. private _ondpadup;
  45778. /** Observable raised when a button is pressed */
  45779. onButtonDownObservable: Observable<DualShockButton>;
  45780. /** Observable raised when a button is released */
  45781. onButtonUpObservable: Observable<DualShockButton>;
  45782. /** Observable raised when a pad is pressed */
  45783. onPadDownObservable: Observable<DualShockDpad>;
  45784. /** Observable raised when a pad is released */
  45785. onPadUpObservable: Observable<DualShockDpad>;
  45786. private _buttonCross;
  45787. private _buttonCircle;
  45788. private _buttonSquare;
  45789. private _buttonTriangle;
  45790. private _buttonShare;
  45791. private _buttonOptions;
  45792. private _buttonL1;
  45793. private _buttonR1;
  45794. private _buttonLeftStick;
  45795. private _buttonRightStick;
  45796. private _dPadUp;
  45797. private _dPadDown;
  45798. private _dPadLeft;
  45799. private _dPadRight;
  45800. /**
  45801. * Creates a new DualShock gamepad object
  45802. * @param id defines the id of this gamepad
  45803. * @param index defines its index
  45804. * @param gamepad defines the internal HTML gamepad object
  45805. */
  45806. constructor(id: string, index: number, gamepad: any);
  45807. /**
  45808. * Defines the callback to call when left trigger is pressed
  45809. * @param callback defines the callback to use
  45810. */
  45811. onlefttriggerchanged(callback: (value: number) => void): void;
  45812. /**
  45813. * Defines the callback to call when right trigger is pressed
  45814. * @param callback defines the callback to use
  45815. */
  45816. onrighttriggerchanged(callback: (value: number) => void): void;
  45817. /**
  45818. * Gets the left trigger value
  45819. */
  45820. get leftTrigger(): number;
  45821. /**
  45822. * Sets the left trigger value
  45823. */
  45824. set leftTrigger(newValue: number);
  45825. /**
  45826. * Gets the right trigger value
  45827. */
  45828. get rightTrigger(): number;
  45829. /**
  45830. * Sets the right trigger value
  45831. */
  45832. set rightTrigger(newValue: number);
  45833. /**
  45834. * Defines the callback to call when a button is pressed
  45835. * @param callback defines the callback to use
  45836. */
  45837. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45838. /**
  45839. * Defines the callback to call when a button is released
  45840. * @param callback defines the callback to use
  45841. */
  45842. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45843. /**
  45844. * Defines the callback to call when a pad is pressed
  45845. * @param callback defines the callback to use
  45846. */
  45847. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45848. /**
  45849. * Defines the callback to call when a pad is released
  45850. * @param callback defines the callback to use
  45851. */
  45852. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45853. private _setButtonValue;
  45854. private _setDPadValue;
  45855. /**
  45856. * Gets the value of the `Cross` button
  45857. */
  45858. get buttonCross(): number;
  45859. /**
  45860. * Sets the value of the `Cross` button
  45861. */
  45862. set buttonCross(value: number);
  45863. /**
  45864. * Gets the value of the `Circle` button
  45865. */
  45866. get buttonCircle(): number;
  45867. /**
  45868. * Sets the value of the `Circle` button
  45869. */
  45870. set buttonCircle(value: number);
  45871. /**
  45872. * Gets the value of the `Square` button
  45873. */
  45874. get buttonSquare(): number;
  45875. /**
  45876. * Sets the value of the `Square` button
  45877. */
  45878. set buttonSquare(value: number);
  45879. /**
  45880. * Gets the value of the `Triangle` button
  45881. */
  45882. get buttonTriangle(): number;
  45883. /**
  45884. * Sets the value of the `Triangle` button
  45885. */
  45886. set buttonTriangle(value: number);
  45887. /**
  45888. * Gets the value of the `Options` button
  45889. */
  45890. get buttonOptions(): number;
  45891. /**
  45892. * Sets the value of the `Options` button
  45893. */
  45894. set buttonOptions(value: number);
  45895. /**
  45896. * Gets the value of the `Share` button
  45897. */
  45898. get buttonShare(): number;
  45899. /**
  45900. * Sets the value of the `Share` button
  45901. */
  45902. set buttonShare(value: number);
  45903. /**
  45904. * Gets the value of the `L1` button
  45905. */
  45906. get buttonL1(): number;
  45907. /**
  45908. * Sets the value of the `L1` button
  45909. */
  45910. set buttonL1(value: number);
  45911. /**
  45912. * Gets the value of the `R1` button
  45913. */
  45914. get buttonR1(): number;
  45915. /**
  45916. * Sets the value of the `R1` button
  45917. */
  45918. set buttonR1(value: number);
  45919. /**
  45920. * Gets the value of the Left joystick
  45921. */
  45922. get buttonLeftStick(): number;
  45923. /**
  45924. * Sets the value of the Left joystick
  45925. */
  45926. set buttonLeftStick(value: number);
  45927. /**
  45928. * Gets the value of the Right joystick
  45929. */
  45930. get buttonRightStick(): number;
  45931. /**
  45932. * Sets the value of the Right joystick
  45933. */
  45934. set buttonRightStick(value: number);
  45935. /**
  45936. * Gets the value of D-pad up
  45937. */
  45938. get dPadUp(): number;
  45939. /**
  45940. * Sets the value of D-pad up
  45941. */
  45942. set dPadUp(value: number);
  45943. /**
  45944. * Gets the value of D-pad down
  45945. */
  45946. get dPadDown(): number;
  45947. /**
  45948. * Sets the value of D-pad down
  45949. */
  45950. set dPadDown(value: number);
  45951. /**
  45952. * Gets the value of D-pad left
  45953. */
  45954. get dPadLeft(): number;
  45955. /**
  45956. * Sets the value of D-pad left
  45957. */
  45958. set dPadLeft(value: number);
  45959. /**
  45960. * Gets the value of D-pad right
  45961. */
  45962. get dPadRight(): number;
  45963. /**
  45964. * Sets the value of D-pad right
  45965. */
  45966. set dPadRight(value: number);
  45967. /**
  45968. * Force the gamepad to synchronize with device values
  45969. */
  45970. update(): void;
  45971. /**
  45972. * Disposes the gamepad
  45973. */
  45974. dispose(): void;
  45975. }
  45976. }
  45977. declare module BABYLON {
  45978. /**
  45979. * Manager for handling gamepads
  45980. */
  45981. export class GamepadManager {
  45982. private _scene?;
  45983. private _babylonGamepads;
  45984. private _oneGamepadConnected;
  45985. /** @hidden */
  45986. _isMonitoring: boolean;
  45987. private _gamepadEventSupported;
  45988. private _gamepadSupport?;
  45989. /**
  45990. * observable to be triggered when the gamepad controller has been connected
  45991. */
  45992. onGamepadConnectedObservable: Observable<Gamepad>;
  45993. /**
  45994. * observable to be triggered when the gamepad controller has been disconnected
  45995. */
  45996. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45997. private _onGamepadConnectedEvent;
  45998. private _onGamepadDisconnectedEvent;
  45999. /**
  46000. * Initializes the gamepad manager
  46001. * @param _scene BabylonJS scene
  46002. */
  46003. constructor(_scene?: Scene | undefined);
  46004. /**
  46005. * The gamepads in the game pad manager
  46006. */
  46007. get gamepads(): Gamepad[];
  46008. /**
  46009. * Get the gamepad controllers based on type
  46010. * @param type The type of gamepad controller
  46011. * @returns Nullable gamepad
  46012. */
  46013. getGamepadByType(type?: number): Nullable<Gamepad>;
  46014. /**
  46015. * Disposes the gamepad manager
  46016. */
  46017. dispose(): void;
  46018. private _addNewGamepad;
  46019. private _startMonitoringGamepads;
  46020. private _stopMonitoringGamepads;
  46021. /** @hidden */
  46022. _checkGamepadsStatus(): void;
  46023. private _updateGamepadObjects;
  46024. }
  46025. }
  46026. declare module BABYLON {
  46027. interface Scene {
  46028. /** @hidden */
  46029. _gamepadManager: Nullable<GamepadManager>;
  46030. /**
  46031. * Gets the gamepad manager associated with the scene
  46032. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46033. */
  46034. gamepadManager: GamepadManager;
  46035. }
  46036. /**
  46037. * Interface representing a free camera inputs manager
  46038. */
  46039. interface FreeCameraInputsManager {
  46040. /**
  46041. * Adds gamepad input support to the FreeCameraInputsManager.
  46042. * @returns the FreeCameraInputsManager
  46043. */
  46044. addGamepad(): FreeCameraInputsManager;
  46045. }
  46046. /**
  46047. * Interface representing an arc rotate camera inputs manager
  46048. */
  46049. interface ArcRotateCameraInputsManager {
  46050. /**
  46051. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46052. * @returns the camera inputs manager
  46053. */
  46054. addGamepad(): ArcRotateCameraInputsManager;
  46055. }
  46056. /**
  46057. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46058. */
  46059. export class GamepadSystemSceneComponent implements ISceneComponent {
  46060. /**
  46061. * The component name helpfull to identify the component in the list of scene components.
  46062. */
  46063. readonly name: string;
  46064. /**
  46065. * The scene the component belongs to.
  46066. */
  46067. scene: Scene;
  46068. /**
  46069. * Creates a new instance of the component for the given scene
  46070. * @param scene Defines the scene to register the component in
  46071. */
  46072. constructor(scene: Scene);
  46073. /**
  46074. * Registers the component in a given scene
  46075. */
  46076. register(): void;
  46077. /**
  46078. * Rebuilds the elements related to this component in case of
  46079. * context lost for instance.
  46080. */
  46081. rebuild(): void;
  46082. /**
  46083. * Disposes the component and the associated ressources
  46084. */
  46085. dispose(): void;
  46086. private _beforeCameraUpdate;
  46087. }
  46088. }
  46089. declare module BABYLON {
  46090. /**
  46091. * 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,
  46092. * which still works and will still be found in many Playgrounds.
  46093. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46094. */
  46095. export class UniversalCamera extends TouchCamera {
  46096. /**
  46097. * Defines the gamepad rotation sensiblity.
  46098. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46099. */
  46100. get gamepadAngularSensibility(): number;
  46101. set gamepadAngularSensibility(value: number);
  46102. /**
  46103. * Defines the gamepad move sensiblity.
  46104. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46105. */
  46106. get gamepadMoveSensibility(): number;
  46107. set gamepadMoveSensibility(value: number);
  46108. /**
  46109. * 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,
  46110. * which still works and will still be found in many Playgrounds.
  46111. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46112. * @param name Define the name of the camera in the scene
  46113. * @param position Define the start position of the camera in the scene
  46114. * @param scene Define the scene the camera belongs to
  46115. */
  46116. constructor(name: string, position: Vector3, scene: Scene);
  46117. /**
  46118. * Gets the current object class name.
  46119. * @return the class name
  46120. */
  46121. getClassName(): string;
  46122. }
  46123. }
  46124. declare module BABYLON {
  46125. /**
  46126. * This represents a FPS type of camera. This is only here for back compat purpose.
  46127. * Please use the UniversalCamera instead as both are identical.
  46128. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46129. */
  46130. export class GamepadCamera extends UniversalCamera {
  46131. /**
  46132. * Instantiates a new Gamepad Camera
  46133. * This represents a FPS type of camera. This is only here for back compat purpose.
  46134. * Please use the UniversalCamera instead as both are identical.
  46135. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46136. * @param name Define the name of the camera in the scene
  46137. * @param position Define the start position of the camera in the scene
  46138. * @param scene Define the scene the camera belongs to
  46139. */
  46140. constructor(name: string, position: Vector3, scene: Scene);
  46141. /**
  46142. * Gets the current object class name.
  46143. * @return the class name
  46144. */
  46145. getClassName(): string;
  46146. }
  46147. }
  46148. declare module BABYLON {
  46149. /** @hidden */
  46150. export var passPixelShader: {
  46151. name: string;
  46152. shader: string;
  46153. };
  46154. }
  46155. declare module BABYLON {
  46156. /** @hidden */
  46157. export var passCubePixelShader: {
  46158. name: string;
  46159. shader: string;
  46160. };
  46161. }
  46162. declare module BABYLON {
  46163. /**
  46164. * PassPostProcess which produces an output the same as it's input
  46165. */
  46166. export class PassPostProcess extends PostProcess {
  46167. /**
  46168. * Gets a string identifying the name of the class
  46169. * @returns "PassPostProcess" string
  46170. */
  46171. getClassName(): string;
  46172. /**
  46173. * Creates the PassPostProcess
  46174. * @param name The name of the effect.
  46175. * @param options The required width/height ratio to downsize to before computing the render pass.
  46176. * @param camera The camera to apply the render pass to.
  46177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46178. * @param engine The engine which the post process will be applied. (default: current engine)
  46179. * @param reusable If the post process can be reused on the same frame. (default: false)
  46180. * @param textureType The type of texture to be used when performing the post processing.
  46181. * @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)
  46182. */
  46183. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46184. /** @hidden */
  46185. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46186. }
  46187. /**
  46188. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46189. */
  46190. export class PassCubePostProcess extends PostProcess {
  46191. private _face;
  46192. /**
  46193. * Gets or sets the cube face to display.
  46194. * * 0 is +X
  46195. * * 1 is -X
  46196. * * 2 is +Y
  46197. * * 3 is -Y
  46198. * * 4 is +Z
  46199. * * 5 is -Z
  46200. */
  46201. get face(): number;
  46202. set face(value: number);
  46203. /**
  46204. * Gets a string identifying the name of the class
  46205. * @returns "PassCubePostProcess" string
  46206. */
  46207. getClassName(): string;
  46208. /**
  46209. * Creates the PassCubePostProcess
  46210. * @param name The name of the effect.
  46211. * @param options The required width/height ratio to downsize to before computing the render pass.
  46212. * @param camera The camera to apply the render pass to.
  46213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46214. * @param engine The engine which the post process will be applied. (default: current engine)
  46215. * @param reusable If the post process can be reused on the same frame. (default: false)
  46216. * @param textureType The type of texture to be used when performing the post processing.
  46217. * @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)
  46218. */
  46219. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46220. /** @hidden */
  46221. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46222. }
  46223. }
  46224. declare module BABYLON {
  46225. /** @hidden */
  46226. export var anaglyphPixelShader: {
  46227. name: string;
  46228. shader: string;
  46229. };
  46230. }
  46231. declare module BABYLON {
  46232. /**
  46233. * Postprocess used to generate anaglyphic rendering
  46234. */
  46235. export class AnaglyphPostProcess extends PostProcess {
  46236. private _passedProcess;
  46237. /**
  46238. * Gets a string identifying the name of the class
  46239. * @returns "AnaglyphPostProcess" string
  46240. */
  46241. getClassName(): string;
  46242. /**
  46243. * Creates a new AnaglyphPostProcess
  46244. * @param name defines postprocess name
  46245. * @param options defines creation options or target ratio scale
  46246. * @param rigCameras defines cameras using this postprocess
  46247. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46248. * @param engine defines hosting engine
  46249. * @param reusable defines if the postprocess will be reused multiple times per frame
  46250. */
  46251. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46252. }
  46253. }
  46254. declare module BABYLON {
  46255. /**
  46256. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46257. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46258. */
  46259. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46260. /**
  46261. * Creates a new AnaglyphArcRotateCamera
  46262. * @param name defines camera name
  46263. * @param alpha defines alpha angle (in radians)
  46264. * @param beta defines beta angle (in radians)
  46265. * @param radius defines radius
  46266. * @param target defines camera target
  46267. * @param interaxialDistance defines distance between each color axis
  46268. * @param scene defines the hosting scene
  46269. */
  46270. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46271. /**
  46272. * Gets camera class name
  46273. * @returns AnaglyphArcRotateCamera
  46274. */
  46275. getClassName(): string;
  46276. }
  46277. }
  46278. declare module BABYLON {
  46279. /**
  46280. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46281. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46282. */
  46283. export class AnaglyphFreeCamera extends FreeCamera {
  46284. /**
  46285. * Creates a new AnaglyphFreeCamera
  46286. * @param name defines camera name
  46287. * @param position defines initial position
  46288. * @param interaxialDistance defines distance between each color axis
  46289. * @param scene defines the hosting scene
  46290. */
  46291. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46292. /**
  46293. * Gets camera class name
  46294. * @returns AnaglyphFreeCamera
  46295. */
  46296. getClassName(): string;
  46297. }
  46298. }
  46299. declare module BABYLON {
  46300. /**
  46301. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46302. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46303. */
  46304. export class AnaglyphGamepadCamera extends GamepadCamera {
  46305. /**
  46306. * Creates a new AnaglyphGamepadCamera
  46307. * @param name defines camera name
  46308. * @param position defines initial position
  46309. * @param interaxialDistance defines distance between each color axis
  46310. * @param scene defines the hosting scene
  46311. */
  46312. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46313. /**
  46314. * Gets camera class name
  46315. * @returns AnaglyphGamepadCamera
  46316. */
  46317. getClassName(): string;
  46318. }
  46319. }
  46320. declare module BABYLON {
  46321. /**
  46322. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46323. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46324. */
  46325. export class AnaglyphUniversalCamera extends UniversalCamera {
  46326. /**
  46327. * Creates a new AnaglyphUniversalCamera
  46328. * @param name defines camera name
  46329. * @param position defines initial position
  46330. * @param interaxialDistance defines distance between each color axis
  46331. * @param scene defines the hosting scene
  46332. */
  46333. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46334. /**
  46335. * Gets camera class name
  46336. * @returns AnaglyphUniversalCamera
  46337. */
  46338. getClassName(): string;
  46339. }
  46340. }
  46341. declare module BABYLON {
  46342. /**
  46343. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46344. * @see https://doc.babylonjs.com/features/cameras
  46345. */
  46346. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46347. /**
  46348. * Creates a new StereoscopicArcRotateCamera
  46349. * @param name defines camera name
  46350. * @param alpha defines alpha angle (in radians)
  46351. * @param beta defines beta angle (in radians)
  46352. * @param radius defines radius
  46353. * @param target defines camera target
  46354. * @param interaxialDistance defines distance between each color axis
  46355. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46356. * @param scene defines the hosting scene
  46357. */
  46358. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46359. /**
  46360. * Gets camera class name
  46361. * @returns StereoscopicArcRotateCamera
  46362. */
  46363. getClassName(): string;
  46364. }
  46365. }
  46366. declare module BABYLON {
  46367. /**
  46368. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46369. * @see https://doc.babylonjs.com/features/cameras
  46370. */
  46371. export class StereoscopicFreeCamera extends FreeCamera {
  46372. /**
  46373. * Creates a new StereoscopicFreeCamera
  46374. * @param name defines camera name
  46375. * @param position defines initial position
  46376. * @param interaxialDistance defines distance between each color axis
  46377. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46378. * @param scene defines the hosting scene
  46379. */
  46380. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46381. /**
  46382. * Gets camera class name
  46383. * @returns StereoscopicFreeCamera
  46384. */
  46385. getClassName(): string;
  46386. }
  46387. }
  46388. declare module BABYLON {
  46389. /**
  46390. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46391. * @see https://doc.babylonjs.com/features/cameras
  46392. */
  46393. export class StereoscopicGamepadCamera extends GamepadCamera {
  46394. /**
  46395. * Creates a new StereoscopicGamepadCamera
  46396. * @param name defines camera name
  46397. * @param position defines initial position
  46398. * @param interaxialDistance defines distance between each color axis
  46399. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46400. * @param scene defines the hosting scene
  46401. */
  46402. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46403. /**
  46404. * Gets camera class name
  46405. * @returns StereoscopicGamepadCamera
  46406. */
  46407. getClassName(): string;
  46408. }
  46409. }
  46410. declare module BABYLON {
  46411. /**
  46412. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46413. * @see https://doc.babylonjs.com/features/cameras
  46414. */
  46415. export class StereoscopicUniversalCamera extends UniversalCamera {
  46416. /**
  46417. * Creates a new StereoscopicUniversalCamera
  46418. * @param name defines camera name
  46419. * @param position defines initial position
  46420. * @param interaxialDistance defines distance between each color axis
  46421. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46422. * @param scene defines the hosting scene
  46423. */
  46424. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46425. /**
  46426. * Gets camera class name
  46427. * @returns StereoscopicUniversalCamera
  46428. */
  46429. getClassName(): string;
  46430. }
  46431. }
  46432. declare module BABYLON {
  46433. /**
  46434. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46435. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46436. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46437. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46438. */
  46439. export class VirtualJoysticksCamera extends FreeCamera {
  46440. /**
  46441. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46442. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46443. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46444. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46445. * @param name Define the name of the camera in the scene
  46446. * @param position Define the start position of the camera in the scene
  46447. * @param scene Define the scene the camera belongs to
  46448. */
  46449. constructor(name: string, position: Vector3, scene: Scene);
  46450. /**
  46451. * Gets the current object class name.
  46452. * @return the class name
  46453. */
  46454. getClassName(): string;
  46455. }
  46456. }
  46457. declare module BABYLON {
  46458. /**
  46459. * This represents all the required metrics to create a VR camera.
  46460. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46461. */
  46462. export class VRCameraMetrics {
  46463. /**
  46464. * Define the horizontal resolution off the screen.
  46465. */
  46466. hResolution: number;
  46467. /**
  46468. * Define the vertical resolution off the screen.
  46469. */
  46470. vResolution: number;
  46471. /**
  46472. * Define the horizontal screen size.
  46473. */
  46474. hScreenSize: number;
  46475. /**
  46476. * Define the vertical screen size.
  46477. */
  46478. vScreenSize: number;
  46479. /**
  46480. * Define the vertical screen center position.
  46481. */
  46482. vScreenCenter: number;
  46483. /**
  46484. * Define the distance of the eyes to the screen.
  46485. */
  46486. eyeToScreenDistance: number;
  46487. /**
  46488. * Define the distance between both lenses
  46489. */
  46490. lensSeparationDistance: number;
  46491. /**
  46492. * Define the distance between both viewer's eyes.
  46493. */
  46494. interpupillaryDistance: number;
  46495. /**
  46496. * Define the distortion factor of the VR postprocess.
  46497. * Please, touch with care.
  46498. */
  46499. distortionK: number[];
  46500. /**
  46501. * Define the chromatic aberration correction factors for the VR post process.
  46502. */
  46503. chromaAbCorrection: number[];
  46504. /**
  46505. * Define the scale factor of the post process.
  46506. * The smaller the better but the slower.
  46507. */
  46508. postProcessScaleFactor: number;
  46509. /**
  46510. * Define an offset for the lens center.
  46511. */
  46512. lensCenterOffset: number;
  46513. /**
  46514. * Define if the current vr camera should compensate the distortion of the lense or not.
  46515. */
  46516. compensateDistortion: boolean;
  46517. /**
  46518. * Defines if multiview should be enabled when rendering (Default: false)
  46519. */
  46520. multiviewEnabled: boolean;
  46521. /**
  46522. * Gets the rendering aspect ratio based on the provided resolutions.
  46523. */
  46524. get aspectRatio(): number;
  46525. /**
  46526. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46527. */
  46528. get aspectRatioFov(): number;
  46529. /**
  46530. * @hidden
  46531. */
  46532. get leftHMatrix(): Matrix;
  46533. /**
  46534. * @hidden
  46535. */
  46536. get rightHMatrix(): Matrix;
  46537. /**
  46538. * @hidden
  46539. */
  46540. get leftPreViewMatrix(): Matrix;
  46541. /**
  46542. * @hidden
  46543. */
  46544. get rightPreViewMatrix(): Matrix;
  46545. /**
  46546. * Get the default VRMetrics based on the most generic setup.
  46547. * @returns the default vr metrics
  46548. */
  46549. static GetDefault(): VRCameraMetrics;
  46550. }
  46551. }
  46552. declare module BABYLON {
  46553. /** @hidden */
  46554. export var vrDistortionCorrectionPixelShader: {
  46555. name: string;
  46556. shader: string;
  46557. };
  46558. }
  46559. declare module BABYLON {
  46560. /**
  46561. * VRDistortionCorrectionPostProcess used for mobile VR
  46562. */
  46563. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46564. private _isRightEye;
  46565. private _distortionFactors;
  46566. private _postProcessScaleFactor;
  46567. private _lensCenterOffset;
  46568. private _scaleIn;
  46569. private _scaleFactor;
  46570. private _lensCenter;
  46571. /**
  46572. * Gets a string identifying the name of the class
  46573. * @returns "VRDistortionCorrectionPostProcess" string
  46574. */
  46575. getClassName(): string;
  46576. /**
  46577. * Initializes the VRDistortionCorrectionPostProcess
  46578. * @param name The name of the effect.
  46579. * @param camera The camera to apply the render pass to.
  46580. * @param isRightEye If this is for the right eye distortion
  46581. * @param vrMetrics All the required metrics for the VR camera
  46582. */
  46583. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46584. }
  46585. }
  46586. declare module BABYLON {
  46587. /**
  46588. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46589. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46590. */
  46591. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46592. /**
  46593. * Creates a new VRDeviceOrientationArcRotateCamera
  46594. * @param name defines camera name
  46595. * @param alpha defines the camera rotation along the logitudinal axis
  46596. * @param beta defines the camera rotation along the latitudinal axis
  46597. * @param radius defines the camera distance from its target
  46598. * @param target defines the camera target
  46599. * @param scene defines the scene the camera belongs to
  46600. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46601. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46602. */
  46603. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46604. /**
  46605. * Gets camera class name
  46606. * @returns VRDeviceOrientationArcRotateCamera
  46607. */
  46608. getClassName(): string;
  46609. }
  46610. }
  46611. declare module BABYLON {
  46612. /**
  46613. * Camera used to simulate VR rendering (based on FreeCamera)
  46614. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46615. */
  46616. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46617. /**
  46618. * Creates a new VRDeviceOrientationFreeCamera
  46619. * @param name defines camera name
  46620. * @param position defines the start position of the camera
  46621. * @param scene defines the scene the camera belongs to
  46622. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46623. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46624. */
  46625. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46626. /**
  46627. * Gets camera class name
  46628. * @returns VRDeviceOrientationFreeCamera
  46629. */
  46630. getClassName(): string;
  46631. }
  46632. }
  46633. declare module BABYLON {
  46634. /**
  46635. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46636. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46637. */
  46638. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46639. /**
  46640. * Creates a new VRDeviceOrientationGamepadCamera
  46641. * @param name defines camera name
  46642. * @param position defines the start position of the camera
  46643. * @param scene defines the scene the camera belongs to
  46644. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46645. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46646. */
  46647. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46648. /**
  46649. * Gets camera class name
  46650. * @returns VRDeviceOrientationGamepadCamera
  46651. */
  46652. getClassName(): string;
  46653. }
  46654. }
  46655. declare module BABYLON {
  46656. /**
  46657. * A class extending Texture allowing drawing on a texture
  46658. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46659. */
  46660. export class DynamicTexture extends Texture {
  46661. private _generateMipMaps;
  46662. private _canvas;
  46663. private _context;
  46664. /**
  46665. * Creates a DynamicTexture
  46666. * @param name defines the name of the texture
  46667. * @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
  46668. * @param scene defines the scene where you want the texture
  46669. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46670. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46671. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46672. */
  46673. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46674. /**
  46675. * Get the current class name of the texture useful for serialization or dynamic coding.
  46676. * @returns "DynamicTexture"
  46677. */
  46678. getClassName(): string;
  46679. /**
  46680. * Gets the current state of canRescale
  46681. */
  46682. get canRescale(): boolean;
  46683. private _recreate;
  46684. /**
  46685. * Scales the texture
  46686. * @param ratio the scale factor to apply to both width and height
  46687. */
  46688. scale(ratio: number): void;
  46689. /**
  46690. * Resizes the texture
  46691. * @param width the new width
  46692. * @param height the new height
  46693. */
  46694. scaleTo(width: number, height: number): void;
  46695. /**
  46696. * Gets the context of the canvas used by the texture
  46697. * @returns the canvas context of the dynamic texture
  46698. */
  46699. getContext(): CanvasRenderingContext2D;
  46700. /**
  46701. * Clears the texture
  46702. */
  46703. clear(): void;
  46704. /**
  46705. * Updates the texture
  46706. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46707. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46708. */
  46709. update(invertY?: boolean, premulAlpha?: boolean): void;
  46710. /**
  46711. * Draws text onto the texture
  46712. * @param text defines the text to be drawn
  46713. * @param x defines the placement of the text from the left
  46714. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46715. * @param font defines the font to be used with font-style, font-size, font-name
  46716. * @param color defines the color used for the text
  46717. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46718. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46719. * @param update defines whether texture is immediately update (default is true)
  46720. */
  46721. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46722. /**
  46723. * Clones the texture
  46724. * @returns the clone of the texture.
  46725. */
  46726. clone(): DynamicTexture;
  46727. /**
  46728. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46729. * @returns a serialized dynamic texture object
  46730. */
  46731. serialize(): any;
  46732. private _IsCanvasElement;
  46733. /** @hidden */
  46734. _rebuild(): void;
  46735. }
  46736. }
  46737. declare module BABYLON {
  46738. /**
  46739. * Class containing static functions to help procedurally build meshes
  46740. */
  46741. export class GroundBuilder {
  46742. /**
  46743. * Creates a ground mesh
  46744. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46745. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46747. * @param name defines the name of the mesh
  46748. * @param options defines the options used to create the mesh
  46749. * @param scene defines the hosting scene
  46750. * @returns the ground mesh
  46751. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46752. */
  46753. static CreateGround(name: string, options: {
  46754. width?: number;
  46755. height?: number;
  46756. subdivisions?: number;
  46757. subdivisionsX?: number;
  46758. subdivisionsY?: number;
  46759. updatable?: boolean;
  46760. }, scene: any): Mesh;
  46761. /**
  46762. * Creates a tiled ground mesh
  46763. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46764. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46765. * * 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
  46766. * * 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
  46767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46768. * @param name defines the name of the mesh
  46769. * @param options defines the options used to create the mesh
  46770. * @param scene defines the hosting scene
  46771. * @returns the tiled ground mesh
  46772. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46773. */
  46774. static CreateTiledGround(name: string, options: {
  46775. xmin: number;
  46776. zmin: number;
  46777. xmax: number;
  46778. zmax: number;
  46779. subdivisions?: {
  46780. w: number;
  46781. h: number;
  46782. };
  46783. precision?: {
  46784. w: number;
  46785. h: number;
  46786. };
  46787. updatable?: boolean;
  46788. }, scene?: Nullable<Scene>): Mesh;
  46789. /**
  46790. * Creates a ground mesh from a height map
  46791. * * The parameter `url` sets the URL of the height map image resource.
  46792. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46793. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46794. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46795. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46796. * * 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.
  46797. * * 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).
  46798. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46800. * @param name defines the name of the mesh
  46801. * @param url defines the url to the height map
  46802. * @param options defines the options used to create the mesh
  46803. * @param scene defines the hosting scene
  46804. * @returns the ground mesh
  46805. * @see https://doc.babylonjs.com/babylon101/height_map
  46806. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46807. */
  46808. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46809. width?: number;
  46810. height?: number;
  46811. subdivisions?: number;
  46812. minHeight?: number;
  46813. maxHeight?: number;
  46814. colorFilter?: Color3;
  46815. alphaFilter?: number;
  46816. updatable?: boolean;
  46817. onReady?: (mesh: GroundMesh) => void;
  46818. }, scene?: Nullable<Scene>): GroundMesh;
  46819. }
  46820. }
  46821. declare module BABYLON {
  46822. /**
  46823. * Class containing static functions to help procedurally build meshes
  46824. */
  46825. export class TorusBuilder {
  46826. /**
  46827. * Creates a torus mesh
  46828. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46829. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46830. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46832. * * 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
  46833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46834. * @param name defines the name of the mesh
  46835. * @param options defines the options used to create the mesh
  46836. * @param scene defines the hosting scene
  46837. * @returns the torus mesh
  46838. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46839. */
  46840. static CreateTorus(name: string, options: {
  46841. diameter?: number;
  46842. thickness?: number;
  46843. tessellation?: number;
  46844. updatable?: boolean;
  46845. sideOrientation?: number;
  46846. frontUVs?: Vector4;
  46847. backUVs?: Vector4;
  46848. }, scene: any): Mesh;
  46849. }
  46850. }
  46851. declare module BABYLON {
  46852. /**
  46853. * Class containing static functions to help procedurally build meshes
  46854. */
  46855. export class CylinderBuilder {
  46856. /**
  46857. * Creates a cylinder or a cone mesh
  46858. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46859. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46860. * * 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.
  46861. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46862. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46863. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46864. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46865. * * 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).
  46866. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46867. * * 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).
  46868. * * 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
  46869. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46870. * * 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
  46871. * * 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.
  46872. * * If `enclose` is false, a ring surface is one element.
  46873. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46874. * * 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
  46875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46876. * * 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
  46877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46878. * @param name defines the name of the mesh
  46879. * @param options defines the options used to create the mesh
  46880. * @param scene defines the hosting scene
  46881. * @returns the cylinder mesh
  46882. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46883. */
  46884. static CreateCylinder(name: string, options: {
  46885. height?: number;
  46886. diameterTop?: number;
  46887. diameterBottom?: number;
  46888. diameter?: number;
  46889. tessellation?: number;
  46890. subdivisions?: number;
  46891. arc?: number;
  46892. faceColors?: Color4[];
  46893. faceUV?: Vector4[];
  46894. updatable?: boolean;
  46895. hasRings?: boolean;
  46896. enclose?: boolean;
  46897. cap?: number;
  46898. sideOrientation?: number;
  46899. frontUVs?: Vector4;
  46900. backUVs?: Vector4;
  46901. }, scene: any): Mesh;
  46902. }
  46903. }
  46904. declare module BABYLON {
  46905. /**
  46906. * States of the webXR experience
  46907. */
  46908. export enum WebXRState {
  46909. /**
  46910. * Transitioning to being in XR mode
  46911. */
  46912. ENTERING_XR = 0,
  46913. /**
  46914. * Transitioning to non XR mode
  46915. */
  46916. EXITING_XR = 1,
  46917. /**
  46918. * In XR mode and presenting
  46919. */
  46920. IN_XR = 2,
  46921. /**
  46922. * Not entered XR mode
  46923. */
  46924. NOT_IN_XR = 3
  46925. }
  46926. /**
  46927. * Abstraction of the XR render target
  46928. */
  46929. export interface WebXRRenderTarget extends IDisposable {
  46930. /**
  46931. * xrpresent context of the canvas which can be used to display/mirror xr content
  46932. */
  46933. canvasContext: WebGLRenderingContext;
  46934. /**
  46935. * xr layer for the canvas
  46936. */
  46937. xrLayer: Nullable<XRWebGLLayer>;
  46938. /**
  46939. * Initializes the xr layer for the session
  46940. * @param xrSession xr session
  46941. * @returns a promise that will resolve once the XR Layer has been created
  46942. */
  46943. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46944. }
  46945. }
  46946. declare module BABYLON {
  46947. /**
  46948. * COnfiguration object for WebXR output canvas
  46949. */
  46950. export class WebXRManagedOutputCanvasOptions {
  46951. /**
  46952. * An optional canvas in case you wish to create it yourself and provide it here.
  46953. * If not provided, a new canvas will be created
  46954. */
  46955. canvasElement?: HTMLCanvasElement;
  46956. /**
  46957. * Options for this XR Layer output
  46958. */
  46959. canvasOptions?: XRWebGLLayerOptions;
  46960. /**
  46961. * CSS styling for a newly created canvas (if not provided)
  46962. */
  46963. newCanvasCssStyle?: string;
  46964. /**
  46965. * Get the default values of the configuration object
  46966. * @param engine defines the engine to use (can be null)
  46967. * @returns default values of this configuration object
  46968. */
  46969. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46970. }
  46971. /**
  46972. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46973. */
  46974. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46975. private _options;
  46976. private _canvas;
  46977. private _engine;
  46978. private _originalCanvasSize;
  46979. /**
  46980. * Rendering context of the canvas which can be used to display/mirror xr content
  46981. */
  46982. canvasContext: WebGLRenderingContext;
  46983. /**
  46984. * xr layer for the canvas
  46985. */
  46986. xrLayer: Nullable<XRWebGLLayer>;
  46987. /**
  46988. * Obseervers registered here will be triggered when the xr layer was initialized
  46989. */
  46990. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46991. /**
  46992. * Initializes the canvas to be added/removed upon entering/exiting xr
  46993. * @param _xrSessionManager The XR Session manager
  46994. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46995. */
  46996. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46997. /**
  46998. * Disposes of the object
  46999. */
  47000. dispose(): void;
  47001. /**
  47002. * Initializes the xr layer for the session
  47003. * @param xrSession xr session
  47004. * @returns a promise that will resolve once the XR Layer has been created
  47005. */
  47006. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47007. private _addCanvas;
  47008. private _removeCanvas;
  47009. private _setCanvasSize;
  47010. private _setManagedOutputCanvas;
  47011. }
  47012. }
  47013. declare module BABYLON {
  47014. /**
  47015. * Manages an XRSession to work with Babylon's engine
  47016. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47017. */
  47018. export class WebXRSessionManager implements IDisposable {
  47019. /** The scene which the session should be created for */
  47020. scene: Scene;
  47021. private _referenceSpace;
  47022. private _rttProvider;
  47023. private _sessionEnded;
  47024. private _xrNavigator;
  47025. private baseLayer;
  47026. /**
  47027. * The base reference space from which the session started. good if you want to reset your
  47028. * reference space
  47029. */
  47030. baseReferenceSpace: XRReferenceSpace;
  47031. /**
  47032. * Current XR frame
  47033. */
  47034. currentFrame: Nullable<XRFrame>;
  47035. /** WebXR timestamp updated every frame */
  47036. currentTimestamp: number;
  47037. /**
  47038. * Used just in case of a failure to initialize an immersive session.
  47039. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47040. */
  47041. defaultHeightCompensation: number;
  47042. /**
  47043. * Fires every time a new xrFrame arrives which can be used to update the camera
  47044. */
  47045. onXRFrameObservable: Observable<XRFrame>;
  47046. /**
  47047. * Fires when the reference space changed
  47048. */
  47049. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47050. /**
  47051. * Fires when the xr session is ended either by the device or manually done
  47052. */
  47053. onXRSessionEnded: Observable<any>;
  47054. /**
  47055. * Fires when the xr session is ended either by the device or manually done
  47056. */
  47057. onXRSessionInit: Observable<XRSession>;
  47058. /**
  47059. * Underlying xr session
  47060. */
  47061. session: XRSession;
  47062. /**
  47063. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47064. * or get the offset the player is currently at.
  47065. */
  47066. viewerReferenceSpace: XRReferenceSpace;
  47067. /**
  47068. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47069. * @param scene The scene which the session should be created for
  47070. */
  47071. constructor(
  47072. /** The scene which the session should be created for */
  47073. scene: Scene);
  47074. /**
  47075. * The current reference space used in this session. This reference space can constantly change!
  47076. * It is mainly used to offset the camera's position.
  47077. */
  47078. get referenceSpace(): XRReferenceSpace;
  47079. /**
  47080. * Set a new reference space and triggers the observable
  47081. */
  47082. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47083. /**
  47084. * Disposes of the session manager
  47085. */
  47086. dispose(): void;
  47087. /**
  47088. * Stops the xrSession and restores the render loop
  47089. * @returns Promise which resolves after it exits XR
  47090. */
  47091. exitXRAsync(): Promise<void>;
  47092. /**
  47093. * Gets the correct render target texture to be rendered this frame for this eye
  47094. * @param eye the eye for which to get the render target
  47095. * @returns the render target for the specified eye
  47096. */
  47097. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47098. /**
  47099. * Creates a WebXRRenderTarget object for the XR session
  47100. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47101. * @param options optional options to provide when creating a new render target
  47102. * @returns a WebXR render target to which the session can render
  47103. */
  47104. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47105. /**
  47106. * Initializes the manager
  47107. * After initialization enterXR can be called to start an XR session
  47108. * @returns Promise which resolves after it is initialized
  47109. */
  47110. initializeAsync(): Promise<void>;
  47111. /**
  47112. * Initializes an xr session
  47113. * @param xrSessionMode mode to initialize
  47114. * @param xrSessionInit defines optional and required values to pass to the session builder
  47115. * @returns a promise which will resolve once the session has been initialized
  47116. */
  47117. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47118. /**
  47119. * Checks if a session would be supported for the creation options specified
  47120. * @param sessionMode session mode to check if supported eg. immersive-vr
  47121. * @returns A Promise that resolves to true if supported and false if not
  47122. */
  47123. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47124. /**
  47125. * Resets the reference space to the one started the session
  47126. */
  47127. resetReferenceSpace(): void;
  47128. /**
  47129. * Starts rendering to the xr layer
  47130. */
  47131. runXRRenderLoop(): void;
  47132. /**
  47133. * Sets the reference space on the xr session
  47134. * @param referenceSpaceType space to set
  47135. * @returns a promise that will resolve once the reference space has been set
  47136. */
  47137. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47138. /**
  47139. * Updates the render state of the session
  47140. * @param state state to set
  47141. * @returns a promise that resolves once the render state has been updated
  47142. */
  47143. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47144. /**
  47145. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47146. * @param sessionMode defines the session to test
  47147. * @returns a promise with boolean as final value
  47148. */
  47149. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47150. private _createRenderTargetTexture;
  47151. }
  47152. }
  47153. declare module BABYLON {
  47154. /**
  47155. * WebXR Camera which holds the views for the xrSession
  47156. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47157. */
  47158. export class WebXRCamera extends FreeCamera {
  47159. private _xrSessionManager;
  47160. private _firstFrame;
  47161. private _referenceQuaternion;
  47162. private _referencedPosition;
  47163. private _xrInvPositionCache;
  47164. private _xrInvQuaternionCache;
  47165. /**
  47166. * Observable raised before camera teleportation
  47167. */
  47168. onBeforeCameraTeleport: Observable<Vector3>;
  47169. /**
  47170. * Observable raised after camera teleportation
  47171. */
  47172. onAfterCameraTeleport: Observable<Vector3>;
  47173. /**
  47174. * Should position compensation execute on first frame.
  47175. * This is used when copying the position from a native (non XR) camera
  47176. */
  47177. compensateOnFirstFrame: boolean;
  47178. /**
  47179. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47180. * @param name the name of the camera
  47181. * @param scene the scene to add the camera to
  47182. * @param _xrSessionManager a constructed xr session manager
  47183. */
  47184. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47185. /**
  47186. * Return the user's height, unrelated to the current ground.
  47187. * This will be the y position of this camera, when ground level is 0.
  47188. */
  47189. get realWorldHeight(): number;
  47190. /** @hidden */
  47191. _updateForDualEyeDebugging(): void;
  47192. /**
  47193. * Sets this camera's transformation based on a non-vr camera
  47194. * @param otherCamera the non-vr camera to copy the transformation from
  47195. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47196. */
  47197. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47198. /**
  47199. * Gets the current instance class name ("WebXRCamera").
  47200. * @returns the class name
  47201. */
  47202. getClassName(): string;
  47203. private _rotate180;
  47204. private _updateFromXRSession;
  47205. private _updateNumberOfRigCameras;
  47206. private _updateReferenceSpace;
  47207. private _updateReferenceSpaceOffset;
  47208. }
  47209. }
  47210. declare module BABYLON {
  47211. /**
  47212. * Defining the interface required for a (webxr) feature
  47213. */
  47214. export interface IWebXRFeature extends IDisposable {
  47215. /**
  47216. * Is this feature attached
  47217. */
  47218. attached: boolean;
  47219. /**
  47220. * Should auto-attach be disabled?
  47221. */
  47222. disableAutoAttach: boolean;
  47223. /**
  47224. * Attach the feature to the session
  47225. * Will usually be called by the features manager
  47226. *
  47227. * @param force should attachment be forced (even when already attached)
  47228. * @returns true if successful.
  47229. */
  47230. attach(force?: boolean): boolean;
  47231. /**
  47232. * Detach the feature from the session
  47233. * Will usually be called by the features manager
  47234. *
  47235. * @returns true if successful.
  47236. */
  47237. detach(): boolean;
  47238. /**
  47239. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47240. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47241. *
  47242. * @returns whether or not the feature is compatible in this environment
  47243. */
  47244. isCompatible(): boolean;
  47245. /**
  47246. * Was this feature disposed;
  47247. */
  47248. isDisposed: boolean;
  47249. /**
  47250. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47251. */
  47252. xrNativeFeatureName?: string;
  47253. /**
  47254. * A list of (Babylon WebXR) features this feature depends on
  47255. */
  47256. dependsOn?: string[];
  47257. }
  47258. /**
  47259. * A list of the currently available features without referencing them
  47260. */
  47261. export class WebXRFeatureName {
  47262. /**
  47263. * The name of the anchor system feature
  47264. */
  47265. static readonly ANCHOR_SYSTEM: string;
  47266. /**
  47267. * The name of the background remover feature
  47268. */
  47269. static readonly BACKGROUND_REMOVER: string;
  47270. /**
  47271. * The name of the hit test feature
  47272. */
  47273. static readonly HIT_TEST: string;
  47274. /**
  47275. * physics impostors for xr controllers feature
  47276. */
  47277. static readonly PHYSICS_CONTROLLERS: string;
  47278. /**
  47279. * The name of the plane detection feature
  47280. */
  47281. static readonly PLANE_DETECTION: string;
  47282. /**
  47283. * The name of the pointer selection feature
  47284. */
  47285. static readonly POINTER_SELECTION: string;
  47286. /**
  47287. * The name of the teleportation feature
  47288. */
  47289. static readonly TELEPORTATION: string;
  47290. /**
  47291. * The name of the feature points feature.
  47292. */
  47293. static readonly FEATURE_POINTS: string;
  47294. /**
  47295. * The name of the hand tracking feature.
  47296. */
  47297. static readonly HAND_TRACKING: string;
  47298. }
  47299. /**
  47300. * Defining the constructor of a feature. Used to register the modules.
  47301. */
  47302. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47303. /**
  47304. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47305. * It is mainly used in AR sessions.
  47306. *
  47307. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47308. */
  47309. export class WebXRFeaturesManager implements IDisposable {
  47310. private _xrSessionManager;
  47311. private static readonly _AvailableFeatures;
  47312. private _features;
  47313. /**
  47314. * constructs a new features manages.
  47315. *
  47316. * @param _xrSessionManager an instance of WebXRSessionManager
  47317. */
  47318. constructor(_xrSessionManager: WebXRSessionManager);
  47319. /**
  47320. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47321. * Mainly used internally.
  47322. *
  47323. * @param featureName the name of the feature to register
  47324. * @param constructorFunction the function used to construct the module
  47325. * @param version the (babylon) version of the module
  47326. * @param stable is that a stable version of this module
  47327. */
  47328. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47329. /**
  47330. * Returns a constructor of a specific feature.
  47331. *
  47332. * @param featureName the name of the feature to construct
  47333. * @param version the version of the feature to load
  47334. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47335. * @param options optional options provided to the module.
  47336. * @returns a function that, when called, will return a new instance of this feature
  47337. */
  47338. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47339. /**
  47340. * Can be used to return the list of features currently registered
  47341. *
  47342. * @returns an Array of available features
  47343. */
  47344. static GetAvailableFeatures(): string[];
  47345. /**
  47346. * Gets the versions available for a specific feature
  47347. * @param featureName the name of the feature
  47348. * @returns an array with the available versions
  47349. */
  47350. static GetAvailableVersions(featureName: string): string[];
  47351. /**
  47352. * Return the latest unstable version of this feature
  47353. * @param featureName the name of the feature to search
  47354. * @returns the version number. if not found will return -1
  47355. */
  47356. static GetLatestVersionOfFeature(featureName: string): number;
  47357. /**
  47358. * Return the latest stable version of this feature
  47359. * @param featureName the name of the feature to search
  47360. * @returns the version number. if not found will return -1
  47361. */
  47362. static GetStableVersionOfFeature(featureName: string): number;
  47363. /**
  47364. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47365. * Can be used during a session to start a feature
  47366. * @param featureName the name of feature to attach
  47367. */
  47368. attachFeature(featureName: string): void;
  47369. /**
  47370. * Can be used inside a session or when the session ends to detach a specific feature
  47371. * @param featureName the name of the feature to detach
  47372. */
  47373. detachFeature(featureName: string): void;
  47374. /**
  47375. * Used to disable an already-enabled feature
  47376. * The feature will be disposed and will be recreated once enabled.
  47377. * @param featureName the feature to disable
  47378. * @returns true if disable was successful
  47379. */
  47380. disableFeature(featureName: string | {
  47381. Name: string;
  47382. }): boolean;
  47383. /**
  47384. * dispose this features manager
  47385. */
  47386. dispose(): void;
  47387. /**
  47388. * 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.
  47389. * 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.
  47390. *
  47391. * @param featureName the name of the feature to load or the class of the feature
  47392. * @param version optional version to load. if not provided the latest version will be enabled
  47393. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47394. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47395. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47396. * @returns a new constructed feature or throws an error if feature not found.
  47397. */
  47398. enableFeature(featureName: string | {
  47399. Name: string;
  47400. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47401. /**
  47402. * get the implementation of an enabled feature.
  47403. * @param featureName the name of the feature to load
  47404. * @returns the feature class, if found
  47405. */
  47406. getEnabledFeature(featureName: string): IWebXRFeature;
  47407. /**
  47408. * Get the list of enabled features
  47409. * @returns an array of enabled features
  47410. */
  47411. getEnabledFeatures(): string[];
  47412. /**
  47413. * This function will exten the session creation configuration object with enabled features.
  47414. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47415. * according to the defined "required" variable, provided during enableFeature call
  47416. * @param xrSessionInit the xr Session init object to extend
  47417. *
  47418. * @returns an extended XRSessionInit object
  47419. */
  47420. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47421. }
  47422. }
  47423. declare module BABYLON {
  47424. /**
  47425. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47426. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47427. */
  47428. export class WebXRExperienceHelper implements IDisposable {
  47429. private scene;
  47430. private _nonVRCamera;
  47431. private _originalSceneAutoClear;
  47432. private _supported;
  47433. /**
  47434. * Camera used to render xr content
  47435. */
  47436. camera: WebXRCamera;
  47437. /** A features manager for this xr session */
  47438. featuresManager: WebXRFeaturesManager;
  47439. /**
  47440. * Observers registered here will be triggered after the camera's initial transformation is set
  47441. * This can be used to set a different ground level or an extra rotation.
  47442. *
  47443. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47444. * to the position set after this observable is done executing.
  47445. */
  47446. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47447. /**
  47448. * Fires when the state of the experience helper has changed
  47449. */
  47450. onStateChangedObservable: Observable<WebXRState>;
  47451. /** Session manager used to keep track of xr session */
  47452. sessionManager: WebXRSessionManager;
  47453. /**
  47454. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47455. */
  47456. state: WebXRState;
  47457. /**
  47458. * Creates a WebXRExperienceHelper
  47459. * @param scene The scene the helper should be created in
  47460. */
  47461. private constructor();
  47462. /**
  47463. * Creates the experience helper
  47464. * @param scene the scene to attach the experience helper to
  47465. * @returns a promise for the experience helper
  47466. */
  47467. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47468. /**
  47469. * Disposes of the experience helper
  47470. */
  47471. dispose(): void;
  47472. /**
  47473. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47474. * @param sessionMode options for the XR session
  47475. * @param referenceSpaceType frame of reference of the XR session
  47476. * @param renderTarget the output canvas that will be used to enter XR mode
  47477. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47478. * @returns promise that resolves after xr mode has entered
  47479. */
  47480. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47481. /**
  47482. * Exits XR mode and returns the scene to its original state
  47483. * @returns promise that resolves after xr mode has exited
  47484. */
  47485. exitXRAsync(): Promise<void>;
  47486. private _nonXRToXRCamera;
  47487. private _setState;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. /**
  47492. * X-Y values for axes in WebXR
  47493. */
  47494. export interface IWebXRMotionControllerAxesValue {
  47495. /**
  47496. * The value of the x axis
  47497. */
  47498. x: number;
  47499. /**
  47500. * The value of the y-axis
  47501. */
  47502. y: number;
  47503. }
  47504. /**
  47505. * changed / previous values for the values of this component
  47506. */
  47507. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47508. /**
  47509. * current (this frame) value
  47510. */
  47511. current: T;
  47512. /**
  47513. * previous (last change) value
  47514. */
  47515. previous: T;
  47516. }
  47517. /**
  47518. * Represents changes in the component between current frame and last values recorded
  47519. */
  47520. export interface IWebXRMotionControllerComponentChanges {
  47521. /**
  47522. * will be populated with previous and current values if axes changed
  47523. */
  47524. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47525. /**
  47526. * will be populated with previous and current values if pressed changed
  47527. */
  47528. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47529. /**
  47530. * will be populated with previous and current values if touched changed
  47531. */
  47532. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47533. /**
  47534. * will be populated with previous and current values if value changed
  47535. */
  47536. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47537. }
  47538. /**
  47539. * This class represents a single component (for example button or thumbstick) of a motion controller
  47540. */
  47541. export class WebXRControllerComponent implements IDisposable {
  47542. /**
  47543. * the id of this component
  47544. */
  47545. id: string;
  47546. /**
  47547. * the type of the component
  47548. */
  47549. type: MotionControllerComponentType;
  47550. private _buttonIndex;
  47551. private _axesIndices;
  47552. private _axes;
  47553. private _changes;
  47554. private _currentValue;
  47555. private _hasChanges;
  47556. private _pressed;
  47557. private _touched;
  47558. /**
  47559. * button component type
  47560. */
  47561. static BUTTON_TYPE: MotionControllerComponentType;
  47562. /**
  47563. * squeeze component type
  47564. */
  47565. static SQUEEZE_TYPE: MotionControllerComponentType;
  47566. /**
  47567. * Thumbstick component type
  47568. */
  47569. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47570. /**
  47571. * Touchpad component type
  47572. */
  47573. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47574. /**
  47575. * trigger component type
  47576. */
  47577. static TRIGGER_TYPE: MotionControllerComponentType;
  47578. /**
  47579. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47580. * the axes data changes
  47581. */
  47582. onAxisValueChangedObservable: Observable<{
  47583. x: number;
  47584. y: number;
  47585. }>;
  47586. /**
  47587. * Observers registered here will be triggered when the state of a button changes
  47588. * State change is either pressed / touched / value
  47589. */
  47590. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47591. /**
  47592. * Creates a new component for a motion controller.
  47593. * It is created by the motion controller itself
  47594. *
  47595. * @param id the id of this component
  47596. * @param type the type of the component
  47597. * @param _buttonIndex index in the buttons array of the gamepad
  47598. * @param _axesIndices indices of the values in the axes array of the gamepad
  47599. */
  47600. constructor(
  47601. /**
  47602. * the id of this component
  47603. */
  47604. id: string,
  47605. /**
  47606. * the type of the component
  47607. */
  47608. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47609. /**
  47610. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47611. */
  47612. get axes(): IWebXRMotionControllerAxesValue;
  47613. /**
  47614. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47615. */
  47616. get changes(): IWebXRMotionControllerComponentChanges;
  47617. /**
  47618. * Return whether or not the component changed the last frame
  47619. */
  47620. get hasChanges(): boolean;
  47621. /**
  47622. * is the button currently pressed
  47623. */
  47624. get pressed(): boolean;
  47625. /**
  47626. * is the button currently touched
  47627. */
  47628. get touched(): boolean;
  47629. /**
  47630. * Get the current value of this component
  47631. */
  47632. get value(): number;
  47633. /**
  47634. * Dispose this component
  47635. */
  47636. dispose(): void;
  47637. /**
  47638. * Are there axes correlating to this component
  47639. * @return true is axes data is available
  47640. */
  47641. isAxes(): boolean;
  47642. /**
  47643. * Is this component a button (hence - pressable)
  47644. * @returns true if can be pressed
  47645. */
  47646. isButton(): boolean;
  47647. /**
  47648. * update this component using the gamepad object it is in. Called on every frame
  47649. * @param nativeController the native gamepad controller object
  47650. */
  47651. update(nativeController: IMinimalMotionControllerObject): void;
  47652. }
  47653. }
  47654. declare module BABYLON {
  47655. /**
  47656. * Interface used to represent data loading progression
  47657. */
  47658. export interface ISceneLoaderProgressEvent {
  47659. /**
  47660. * Defines if data length to load can be evaluated
  47661. */
  47662. readonly lengthComputable: boolean;
  47663. /**
  47664. * Defines the loaded data length
  47665. */
  47666. readonly loaded: number;
  47667. /**
  47668. * Defines the data length to load
  47669. */
  47670. readonly total: number;
  47671. }
  47672. /**
  47673. * Interface used by SceneLoader plugins to define supported file extensions
  47674. */
  47675. export interface ISceneLoaderPluginExtensions {
  47676. /**
  47677. * Defines the list of supported extensions
  47678. */
  47679. [extension: string]: {
  47680. isBinary: boolean;
  47681. };
  47682. }
  47683. /**
  47684. * Interface used by SceneLoader plugin factory
  47685. */
  47686. export interface ISceneLoaderPluginFactory {
  47687. /**
  47688. * Defines the name of the factory
  47689. */
  47690. name: string;
  47691. /**
  47692. * Function called to create a new plugin
  47693. * @return the new plugin
  47694. */
  47695. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47696. /**
  47697. * The callback that returns true if the data can be directly loaded.
  47698. * @param data string containing the file data
  47699. * @returns if the data can be loaded directly
  47700. */
  47701. canDirectLoad?(data: string): boolean;
  47702. }
  47703. /**
  47704. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47705. */
  47706. export interface ISceneLoaderPluginBase {
  47707. /**
  47708. * The friendly name of this plugin.
  47709. */
  47710. name: string;
  47711. /**
  47712. * The file extensions supported by this plugin.
  47713. */
  47714. extensions: string | ISceneLoaderPluginExtensions;
  47715. /**
  47716. * The callback called when loading from a url.
  47717. * @param scene scene loading this url
  47718. * @param url url to load
  47719. * @param onSuccess callback called when the file successfully loads
  47720. * @param onProgress callback called while file is loading (if the server supports this mode)
  47721. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47722. * @param onError callback called when the file fails to load
  47723. * @returns a file request object
  47724. */
  47725. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47726. /**
  47727. * The callback called when loading from a file object.
  47728. * @param scene scene loading this file
  47729. * @param file defines the file to load
  47730. * @param onSuccess defines the callback to call when data is loaded
  47731. * @param onProgress defines the callback to call during loading process
  47732. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47733. * @param onError defines the callback to call when an error occurs
  47734. * @returns a file request object
  47735. */
  47736. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47737. /**
  47738. * The callback that returns true if the data can be directly loaded.
  47739. * @param data string containing the file data
  47740. * @returns if the data can be loaded directly
  47741. */
  47742. canDirectLoad?(data: string): boolean;
  47743. /**
  47744. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47745. * @param scene scene loading this data
  47746. * @param data string containing the data
  47747. * @returns data to pass to the plugin
  47748. */
  47749. directLoad?(scene: Scene, data: string): any;
  47750. /**
  47751. * The callback that allows custom handling of the root url based on the response url.
  47752. * @param rootUrl the original root url
  47753. * @param responseURL the response url if available
  47754. * @returns the new root url
  47755. */
  47756. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47757. }
  47758. /**
  47759. * Interface used to define a SceneLoader plugin
  47760. */
  47761. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47762. /**
  47763. * Import meshes into a scene.
  47764. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47765. * @param scene The scene to import into
  47766. * @param data The data to import
  47767. * @param rootUrl The root url for scene and resources
  47768. * @param meshes The meshes array to import into
  47769. * @param particleSystems The particle systems array to import into
  47770. * @param skeletons The skeletons array to import into
  47771. * @param onError The callback when import fails
  47772. * @returns True if successful or false otherwise
  47773. */
  47774. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47775. /**
  47776. * Load into a scene.
  47777. * @param scene The scene to load into
  47778. * @param data The data to import
  47779. * @param rootUrl The root url for scene and resources
  47780. * @param onError The callback when import fails
  47781. * @returns True if successful or false otherwise
  47782. */
  47783. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47784. /**
  47785. * Load into an asset container.
  47786. * @param scene The scene to load into
  47787. * @param data The data to import
  47788. * @param rootUrl The root url for scene and resources
  47789. * @param onError The callback when import fails
  47790. * @returns The loaded asset container
  47791. */
  47792. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47793. }
  47794. /**
  47795. * Interface used to define an async SceneLoader plugin
  47796. */
  47797. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47798. /**
  47799. * Import meshes into a scene.
  47800. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47801. * @param scene The scene to import into
  47802. * @param data The data to import
  47803. * @param rootUrl The root url for scene and resources
  47804. * @param onProgress The callback when the load progresses
  47805. * @param fileName Defines the name of the file to load
  47806. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47807. */
  47808. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47809. meshes: AbstractMesh[];
  47810. particleSystems: IParticleSystem[];
  47811. skeletons: Skeleton[];
  47812. animationGroups: AnimationGroup[];
  47813. }>;
  47814. /**
  47815. * Load into a scene.
  47816. * @param scene The scene to load into
  47817. * @param data The data to import
  47818. * @param rootUrl The root url for scene and resources
  47819. * @param onProgress The callback when the load progresses
  47820. * @param fileName Defines the name of the file to load
  47821. * @returns Nothing
  47822. */
  47823. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47824. /**
  47825. * Load into an asset container.
  47826. * @param scene The scene to load into
  47827. * @param data The data to import
  47828. * @param rootUrl The root url for scene and resources
  47829. * @param onProgress The callback when the load progresses
  47830. * @param fileName Defines the name of the file to load
  47831. * @returns The loaded asset container
  47832. */
  47833. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47834. }
  47835. /**
  47836. * Mode that determines how to handle old animation groups before loading new ones.
  47837. */
  47838. export enum SceneLoaderAnimationGroupLoadingMode {
  47839. /**
  47840. * Reset all old animations to initial state then dispose them.
  47841. */
  47842. Clean = 0,
  47843. /**
  47844. * Stop all old animations.
  47845. */
  47846. Stop = 1,
  47847. /**
  47848. * Restart old animations from first frame.
  47849. */
  47850. Sync = 2,
  47851. /**
  47852. * Old animations remains untouched.
  47853. */
  47854. NoSync = 3
  47855. }
  47856. /**
  47857. * Defines a plugin registered by the SceneLoader
  47858. */
  47859. interface IRegisteredPlugin {
  47860. /**
  47861. * Defines the plugin to use
  47862. */
  47863. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47864. /**
  47865. * Defines if the plugin supports binary data
  47866. */
  47867. isBinary: boolean;
  47868. }
  47869. /**
  47870. * Class used to load scene from various file formats using registered plugins
  47871. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47872. */
  47873. export class SceneLoader {
  47874. /**
  47875. * No logging while loading
  47876. */
  47877. static readonly NO_LOGGING: number;
  47878. /**
  47879. * Minimal logging while loading
  47880. */
  47881. static readonly MINIMAL_LOGGING: number;
  47882. /**
  47883. * Summary logging while loading
  47884. */
  47885. static readonly SUMMARY_LOGGING: number;
  47886. /**
  47887. * Detailled logging while loading
  47888. */
  47889. static readonly DETAILED_LOGGING: number;
  47890. /**
  47891. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47892. */
  47893. static get ForceFullSceneLoadingForIncremental(): boolean;
  47894. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47895. /**
  47896. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47897. */
  47898. static get ShowLoadingScreen(): boolean;
  47899. static set ShowLoadingScreen(value: boolean);
  47900. /**
  47901. * Defines the current logging level (while loading the scene)
  47902. * @ignorenaming
  47903. */
  47904. static get loggingLevel(): number;
  47905. static set loggingLevel(value: number);
  47906. /**
  47907. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47908. */
  47909. static get CleanBoneMatrixWeights(): boolean;
  47910. static set CleanBoneMatrixWeights(value: boolean);
  47911. /**
  47912. * Event raised when a plugin is used to load a scene
  47913. */
  47914. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47915. private static _registeredPlugins;
  47916. private static _showingLoadingScreen;
  47917. /**
  47918. * Gets the default plugin (used to load Babylon files)
  47919. * @returns the .babylon plugin
  47920. */
  47921. static GetDefaultPlugin(): IRegisteredPlugin;
  47922. private static _GetPluginForExtension;
  47923. private static _GetPluginForDirectLoad;
  47924. private static _GetPluginForFilename;
  47925. private static _GetDirectLoad;
  47926. private static _LoadData;
  47927. private static _GetFileInfo;
  47928. /**
  47929. * Gets a plugin that can load the given extension
  47930. * @param extension defines the extension to load
  47931. * @returns a plugin or null if none works
  47932. */
  47933. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47934. /**
  47935. * Gets a boolean indicating that the given extension can be loaded
  47936. * @param extension defines the extension to load
  47937. * @returns true if the extension is supported
  47938. */
  47939. static IsPluginForExtensionAvailable(extension: string): boolean;
  47940. /**
  47941. * Adds a new plugin to the list of registered plugins
  47942. * @param plugin defines the plugin to add
  47943. */
  47944. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47945. /**
  47946. * Import meshes into a scene
  47947. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47948. * @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)
  47949. * @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)
  47950. * @param scene the instance of BABYLON.Scene to append to
  47951. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  47952. * @param onProgress a callback with a progress event for each file being loaded
  47953. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47954. * @param pluginExtension the extension used to determine the plugin
  47955. * @returns The loaded plugin
  47956. */
  47957. 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>;
  47958. /**
  47959. * Import meshes into a scene
  47960. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47961. * @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)
  47962. * @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)
  47963. * @param scene the instance of BABYLON.Scene to append to
  47964. * @param onProgress a callback with a progress event for each file being loaded
  47965. * @param pluginExtension the extension used to determine the plugin
  47966. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47967. */
  47968. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47969. meshes: AbstractMesh[];
  47970. particleSystems: IParticleSystem[];
  47971. skeletons: Skeleton[];
  47972. animationGroups: AnimationGroup[];
  47973. }>;
  47974. /**
  47975. * Load a scene
  47976. * @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)
  47977. * @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)
  47978. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47979. * @param onSuccess a callback with the scene when import succeeds
  47980. * @param onProgress a callback with a progress event for each file being loaded
  47981. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47982. * @param pluginExtension the extension used to determine the plugin
  47983. * @returns The loaded plugin
  47984. */
  47985. 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>;
  47986. /**
  47987. * Load a scene
  47988. * @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)
  47989. * @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)
  47990. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47991. * @param onProgress a callback with a progress event for each file being loaded
  47992. * @param pluginExtension the extension used to determine the plugin
  47993. * @returns The loaded scene
  47994. */
  47995. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47996. /**
  47997. * Append a scene
  47998. * @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)
  47999. * @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)
  48000. * @param scene is the instance of BABYLON.Scene to append to
  48001. * @param onSuccess a callback with the scene when import succeeds
  48002. * @param onProgress a callback with a progress event for each file being loaded
  48003. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48004. * @param pluginExtension the extension used to determine the plugin
  48005. * @returns The loaded plugin
  48006. */
  48007. 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>;
  48008. /**
  48009. * Append a scene
  48010. * @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)
  48011. * @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)
  48012. * @param scene is the instance of BABYLON.Scene to append to
  48013. * @param onProgress a callback with a progress event for each file being loaded
  48014. * @param pluginExtension the extension used to determine the plugin
  48015. * @returns The given scene
  48016. */
  48017. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48018. /**
  48019. * Load a scene into an asset container
  48020. * @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)
  48021. * @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)
  48022. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48023. * @param onSuccess a callback with the scene when import succeeds
  48024. * @param onProgress a callback with a progress event for each file being loaded
  48025. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48026. * @param pluginExtension the extension used to determine the plugin
  48027. * @returns The loaded plugin
  48028. */
  48029. 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>;
  48030. /**
  48031. * Load a scene into an asset container
  48032. * @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)
  48033. * @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)
  48034. * @param scene is the instance of Scene to append to
  48035. * @param onProgress a callback with a progress event for each file being loaded
  48036. * @param pluginExtension the extension used to determine the plugin
  48037. * @returns The loaded asset container
  48038. */
  48039. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48040. /**
  48041. * Import animations from a file into a scene
  48042. * @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)
  48043. * @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)
  48044. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48045. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48046. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48047. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48048. * @param onSuccess a callback with the scene when import succeeds
  48049. * @param onProgress a callback with a progress event for each file being loaded
  48050. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48051. * @param pluginExtension the extension used to determine the plugin
  48052. */
  48053. 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;
  48054. /**
  48055. * Import animations from a file into a scene
  48056. * @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)
  48057. * @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)
  48058. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48059. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48060. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48061. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48062. * @param onSuccess a callback with the scene when import succeeds
  48063. * @param onProgress a callback with a progress event for each file being loaded
  48064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48065. * @param pluginExtension the extension used to determine the plugin
  48066. * @returns the updated scene with imported animations
  48067. */
  48068. 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>;
  48069. }
  48070. }
  48071. declare module BABYLON {
  48072. /**
  48073. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48074. */
  48075. export type MotionControllerHandedness = "none" | "left" | "right";
  48076. /**
  48077. * The type of components available in motion controllers.
  48078. * This is not the name of the component.
  48079. */
  48080. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48081. /**
  48082. * The state of a controller component
  48083. */
  48084. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48085. /**
  48086. * The schema of motion controller layout.
  48087. * No object will be initialized using this interface
  48088. * This is used just to define the profile.
  48089. */
  48090. export interface IMotionControllerLayout {
  48091. /**
  48092. * Path to load the assets. Usually relative to the base path
  48093. */
  48094. assetPath: string;
  48095. /**
  48096. * Available components (unsorted)
  48097. */
  48098. components: {
  48099. /**
  48100. * A map of component Ids
  48101. */
  48102. [componentId: string]: {
  48103. /**
  48104. * The type of input the component outputs
  48105. */
  48106. type: MotionControllerComponentType;
  48107. /**
  48108. * The indices of this component in the gamepad object
  48109. */
  48110. gamepadIndices: {
  48111. /**
  48112. * Index of button
  48113. */
  48114. button?: number;
  48115. /**
  48116. * If available, index of x-axis
  48117. */
  48118. xAxis?: number;
  48119. /**
  48120. * If available, index of y-axis
  48121. */
  48122. yAxis?: number;
  48123. };
  48124. /**
  48125. * The mesh's root node name
  48126. */
  48127. rootNodeName: string;
  48128. /**
  48129. * Animation definitions for this model
  48130. */
  48131. visualResponses: {
  48132. [stateKey: string]: {
  48133. /**
  48134. * What property will be animated
  48135. */
  48136. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48137. /**
  48138. * What states influence this visual response
  48139. */
  48140. states: MotionControllerComponentStateType[];
  48141. /**
  48142. * Type of animation - movement or visibility
  48143. */
  48144. valueNodeProperty: "transform" | "visibility";
  48145. /**
  48146. * Base node name to move. Its position will be calculated according to the min and max nodes
  48147. */
  48148. valueNodeName?: string;
  48149. /**
  48150. * Minimum movement node
  48151. */
  48152. minNodeName?: string;
  48153. /**
  48154. * Max movement node
  48155. */
  48156. maxNodeName?: string;
  48157. };
  48158. };
  48159. /**
  48160. * If touch enabled, what is the name of node to display user feedback
  48161. */
  48162. touchPointNodeName?: string;
  48163. };
  48164. };
  48165. /**
  48166. * Is it xr standard mapping or not
  48167. */
  48168. gamepadMapping: "" | "xr-standard";
  48169. /**
  48170. * Base root node of this entire model
  48171. */
  48172. rootNodeName: string;
  48173. /**
  48174. * Defines the main button component id
  48175. */
  48176. selectComponentId: string;
  48177. }
  48178. /**
  48179. * A definition for the layout map in the input profile
  48180. */
  48181. export interface IMotionControllerLayoutMap {
  48182. /**
  48183. * Layouts with handedness type as a key
  48184. */
  48185. [handedness: string]: IMotionControllerLayout;
  48186. }
  48187. /**
  48188. * The XR Input profile schema
  48189. * Profiles can be found here:
  48190. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48191. */
  48192. export interface IMotionControllerProfile {
  48193. /**
  48194. * fallback profiles for this profileId
  48195. */
  48196. fallbackProfileIds: string[];
  48197. /**
  48198. * The layout map, with handedness as key
  48199. */
  48200. layouts: IMotionControllerLayoutMap;
  48201. /**
  48202. * The id of this profile
  48203. * correlates to the profile(s) in the xrInput.profiles array
  48204. */
  48205. profileId: string;
  48206. }
  48207. /**
  48208. * A helper-interface for the 3 meshes needed for controller button animation
  48209. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48210. */
  48211. export interface IMotionControllerButtonMeshMap {
  48212. /**
  48213. * the mesh that defines the pressed value mesh position.
  48214. * This is used to find the max-position of this button
  48215. */
  48216. pressedMesh: AbstractMesh;
  48217. /**
  48218. * the mesh that defines the unpressed value mesh position.
  48219. * This is used to find the min (or initial) position of this button
  48220. */
  48221. unpressedMesh: AbstractMesh;
  48222. /**
  48223. * The mesh that will be changed when value changes
  48224. */
  48225. valueMesh: AbstractMesh;
  48226. }
  48227. /**
  48228. * A helper-interface for the 3 meshes needed for controller axis animation.
  48229. * This will be expanded when touchpad animations are fully supported
  48230. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48231. */
  48232. export interface IMotionControllerMeshMap {
  48233. /**
  48234. * the mesh that defines the maximum value mesh position.
  48235. */
  48236. maxMesh?: AbstractMesh;
  48237. /**
  48238. * the mesh that defines the minimum value mesh position.
  48239. */
  48240. minMesh?: AbstractMesh;
  48241. /**
  48242. * The mesh that will be changed when axis value changes
  48243. */
  48244. valueMesh?: AbstractMesh;
  48245. }
  48246. /**
  48247. * The elements needed for change-detection of the gamepad objects in motion controllers
  48248. */
  48249. export interface IMinimalMotionControllerObject {
  48250. /**
  48251. * Available axes of this controller
  48252. */
  48253. axes: number[];
  48254. /**
  48255. * An array of available buttons
  48256. */
  48257. buttons: Array<{
  48258. /**
  48259. * Value of the button/trigger
  48260. */
  48261. value: number;
  48262. /**
  48263. * If the button/trigger is currently touched
  48264. */
  48265. touched: boolean;
  48266. /**
  48267. * If the button/trigger is currently pressed
  48268. */
  48269. pressed: boolean;
  48270. }>;
  48271. /**
  48272. * EXPERIMENTAL haptic support.
  48273. */
  48274. hapticActuators?: Array<{
  48275. pulse: (value: number, duration: number) => Promise<boolean>;
  48276. }>;
  48277. }
  48278. /**
  48279. * An Abstract Motion controller
  48280. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48281. * Each component has an observable to check for changes in value and state
  48282. */
  48283. export abstract class WebXRAbstractMotionController implements IDisposable {
  48284. protected scene: Scene;
  48285. protected layout: IMotionControllerLayout;
  48286. /**
  48287. * The gamepad object correlating to this controller
  48288. */
  48289. gamepadObject: IMinimalMotionControllerObject;
  48290. /**
  48291. * handedness (left/right/none) of this controller
  48292. */
  48293. handedness: MotionControllerHandedness;
  48294. private _initComponent;
  48295. private _modelReady;
  48296. /**
  48297. * A map of components (WebXRControllerComponent) in this motion controller
  48298. * Components have a ComponentType and can also have both button and axis definitions
  48299. */
  48300. readonly components: {
  48301. [id: string]: WebXRControllerComponent;
  48302. };
  48303. /**
  48304. * Disable the model's animation. Can be set at any time.
  48305. */
  48306. disableAnimation: boolean;
  48307. /**
  48308. * Observers registered here will be triggered when the model of this controller is done loading
  48309. */
  48310. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48311. /**
  48312. * The profile id of this motion controller
  48313. */
  48314. abstract profileId: string;
  48315. /**
  48316. * The root mesh of the model. It is null if the model was not yet initialized
  48317. */
  48318. rootMesh: Nullable<AbstractMesh>;
  48319. /**
  48320. * constructs a new abstract motion controller
  48321. * @param scene the scene to which the model of the controller will be added
  48322. * @param layout The profile layout to load
  48323. * @param gamepadObject The gamepad object correlating to this controller
  48324. * @param handedness handedness (left/right/none) of this controller
  48325. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48326. */
  48327. constructor(scene: Scene, layout: IMotionControllerLayout,
  48328. /**
  48329. * The gamepad object correlating to this controller
  48330. */
  48331. gamepadObject: IMinimalMotionControllerObject,
  48332. /**
  48333. * handedness (left/right/none) of this controller
  48334. */
  48335. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48336. /**
  48337. * Dispose this controller, the model mesh and all its components
  48338. */
  48339. dispose(): void;
  48340. /**
  48341. * Returns all components of specific type
  48342. * @param type the type to search for
  48343. * @return an array of components with this type
  48344. */
  48345. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48346. /**
  48347. * get a component based an its component id as defined in layout.components
  48348. * @param id the id of the component
  48349. * @returns the component correlates to the id or undefined if not found
  48350. */
  48351. getComponent(id: string): WebXRControllerComponent;
  48352. /**
  48353. * Get the list of components available in this motion controller
  48354. * @returns an array of strings correlating to available components
  48355. */
  48356. getComponentIds(): string[];
  48357. /**
  48358. * Get the first component of specific type
  48359. * @param type type of component to find
  48360. * @return a controller component or null if not found
  48361. */
  48362. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48363. /**
  48364. * Get the main (Select) component of this controller as defined in the layout
  48365. * @returns the main component of this controller
  48366. */
  48367. getMainComponent(): WebXRControllerComponent;
  48368. /**
  48369. * Loads the model correlating to this controller
  48370. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48371. * @returns A promise fulfilled with the result of the model loading
  48372. */
  48373. loadModel(): Promise<boolean>;
  48374. /**
  48375. * Update this model using the current XRFrame
  48376. * @param xrFrame the current xr frame to use and update the model
  48377. */
  48378. updateFromXRFrame(xrFrame: XRFrame): void;
  48379. /**
  48380. * Backwards compatibility due to a deeply-integrated typo
  48381. */
  48382. get handness(): XREye;
  48383. /**
  48384. * Pulse (vibrate) this controller
  48385. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48386. * Consecutive calls to this function will cancel the last pulse call
  48387. *
  48388. * @param value the strength of the pulse in 0.0...1.0 range
  48389. * @param duration Duration of the pulse in milliseconds
  48390. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48391. * @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
  48392. */
  48393. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48394. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48395. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48396. /**
  48397. * Moves the axis on the controller mesh based on its current state
  48398. * @param axis the index of the axis
  48399. * @param axisValue the value of the axis which determines the meshes new position
  48400. * @hidden
  48401. */
  48402. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48403. /**
  48404. * Update the model itself with the current frame data
  48405. * @param xrFrame the frame to use for updating the model mesh
  48406. */
  48407. protected updateModel(xrFrame: XRFrame): void;
  48408. /**
  48409. * Get the filename and path for this controller's model
  48410. * @returns a map of filename and path
  48411. */
  48412. protected abstract _getFilenameAndPath(): {
  48413. filename: string;
  48414. path: string;
  48415. };
  48416. /**
  48417. * This function is called before the mesh is loaded. It checks for loading constraints.
  48418. * For example, this function can check if the GLB loader is available
  48419. * If this function returns false, the generic controller will be loaded instead
  48420. * @returns Is the client ready to load the mesh
  48421. */
  48422. protected abstract _getModelLoadingConstraints(): boolean;
  48423. /**
  48424. * This function will be called after the model was successfully loaded and can be used
  48425. * for mesh transformations before it is available for the user
  48426. * @param meshes the loaded meshes
  48427. */
  48428. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48429. /**
  48430. * Set the root mesh for this controller. Important for the WebXR controller class
  48431. * @param meshes the loaded meshes
  48432. */
  48433. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48434. /**
  48435. * A function executed each frame that updates the mesh (if needed)
  48436. * @param xrFrame the current xrFrame
  48437. */
  48438. protected abstract _updateModel(xrFrame: XRFrame): void;
  48439. private _getGenericFilenameAndPath;
  48440. private _getGenericParentMesh;
  48441. }
  48442. }
  48443. declare module BABYLON {
  48444. /**
  48445. * A generic trigger-only motion controller for WebXR
  48446. */
  48447. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48448. /**
  48449. * Static version of the profile id of this controller
  48450. */
  48451. static ProfileId: string;
  48452. profileId: string;
  48453. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48454. protected _getFilenameAndPath(): {
  48455. filename: string;
  48456. path: string;
  48457. };
  48458. protected _getModelLoadingConstraints(): boolean;
  48459. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48460. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48461. protected _updateModel(): void;
  48462. }
  48463. }
  48464. declare module BABYLON {
  48465. /**
  48466. * Class containing static functions to help procedurally build meshes
  48467. */
  48468. export class SphereBuilder {
  48469. /**
  48470. * Creates a sphere mesh
  48471. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48472. * * 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`)
  48473. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48474. * * 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
  48475. * * 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)
  48476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48477. * * 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
  48478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48479. * @param name defines the name of the mesh
  48480. * @param options defines the options used to create the mesh
  48481. * @param scene defines the hosting scene
  48482. * @returns the sphere mesh
  48483. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48484. */
  48485. static CreateSphere(name: string, options: {
  48486. segments?: number;
  48487. diameter?: number;
  48488. diameterX?: number;
  48489. diameterY?: number;
  48490. diameterZ?: number;
  48491. arc?: number;
  48492. slice?: number;
  48493. sideOrientation?: number;
  48494. frontUVs?: Vector4;
  48495. backUVs?: Vector4;
  48496. updatable?: boolean;
  48497. }, scene?: Nullable<Scene>): Mesh;
  48498. }
  48499. }
  48500. declare module BABYLON {
  48501. /**
  48502. * A profiled motion controller has its profile loaded from an online repository.
  48503. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48504. */
  48505. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48506. private _repositoryUrl;
  48507. private _buttonMeshMapping;
  48508. private _touchDots;
  48509. /**
  48510. * The profile ID of this controller. Will be populated when the controller initializes.
  48511. */
  48512. profileId: string;
  48513. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48514. dispose(): void;
  48515. protected _getFilenameAndPath(): {
  48516. filename: string;
  48517. path: string;
  48518. };
  48519. protected _getModelLoadingConstraints(): boolean;
  48520. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48521. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48522. protected _updateModel(_xrFrame: XRFrame): void;
  48523. }
  48524. }
  48525. declare module BABYLON {
  48526. /**
  48527. * A construction function type to create a new controller based on an xrInput object
  48528. */
  48529. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48530. /**
  48531. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48532. *
  48533. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48534. * it should be replaced with auto-loaded controllers.
  48535. *
  48536. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48537. */
  48538. export class WebXRMotionControllerManager {
  48539. private static _AvailableControllers;
  48540. private static _Fallbacks;
  48541. private static _ProfileLoadingPromises;
  48542. private static _ProfilesList;
  48543. /**
  48544. * The base URL of the online controller repository. Can be changed at any time.
  48545. */
  48546. static BaseRepositoryUrl: string;
  48547. /**
  48548. * Which repository gets priority - local or online
  48549. */
  48550. static PrioritizeOnlineRepository: boolean;
  48551. /**
  48552. * Use the online repository, or use only locally-defined controllers
  48553. */
  48554. static UseOnlineRepository: boolean;
  48555. /**
  48556. * Clear the cache used for profile loading and reload when requested again
  48557. */
  48558. static ClearProfilesCache(): void;
  48559. /**
  48560. * Register the default fallbacks.
  48561. * This function is called automatically when this file is imported.
  48562. */
  48563. static DefaultFallbacks(): void;
  48564. /**
  48565. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48566. * @param profileId the profile to which a fallback needs to be found
  48567. * @return an array with corresponding fallback profiles
  48568. */
  48569. static FindFallbackWithProfileId(profileId: string): string[];
  48570. /**
  48571. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48572. * The order of search:
  48573. *
  48574. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48575. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48576. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48577. * 4) return the generic trigger controller if none were found
  48578. *
  48579. * @param xrInput the xrInput to which a new controller is initialized
  48580. * @param scene the scene to which the model will be added
  48581. * @param forceProfile force a certain profile for this controller
  48582. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48583. */
  48584. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48585. /**
  48586. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48587. *
  48588. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48589. *
  48590. * @param type the profile type to register
  48591. * @param constructFunction the function to be called when loading this profile
  48592. */
  48593. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48594. /**
  48595. * Register a fallback to a specific profile.
  48596. * @param profileId the profileId that will receive the fallbacks
  48597. * @param fallbacks A list of fallback profiles
  48598. */
  48599. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48600. /**
  48601. * Will update the list of profiles available in the repository
  48602. * @return a promise that resolves to a map of profiles available online
  48603. */
  48604. static UpdateProfilesList(): Promise<{
  48605. [profile: string]: string;
  48606. }>;
  48607. private static _LoadProfileFromRepository;
  48608. private static _LoadProfilesFromAvailableControllers;
  48609. }
  48610. }
  48611. declare module BABYLON {
  48612. /**
  48613. * Configuration options for the WebXR controller creation
  48614. */
  48615. export interface IWebXRControllerOptions {
  48616. /**
  48617. * Should the controller mesh be animated when a user interacts with it
  48618. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48619. */
  48620. disableMotionControllerAnimation?: boolean;
  48621. /**
  48622. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48623. */
  48624. doNotLoadControllerMesh?: boolean;
  48625. /**
  48626. * Force a specific controller type for this controller.
  48627. * This can be used when creating your own profile or when testing different controllers
  48628. */
  48629. forceControllerProfile?: string;
  48630. /**
  48631. * Defines a rendering group ID for meshes that will be loaded.
  48632. * This is for the default controllers only.
  48633. */
  48634. renderingGroupId?: number;
  48635. }
  48636. /**
  48637. * Represents an XR controller
  48638. */
  48639. export class WebXRInputSource {
  48640. private _scene;
  48641. /** The underlying input source for the controller */
  48642. inputSource: XRInputSource;
  48643. private _options;
  48644. private _tmpVector;
  48645. private _uniqueId;
  48646. private _disposed;
  48647. /**
  48648. * 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
  48649. */
  48650. grip?: AbstractMesh;
  48651. /**
  48652. * If available, this is the gamepad object related to this controller.
  48653. * Using this object it is possible to get click events and trackpad changes of the
  48654. * webxr controller that is currently being used.
  48655. */
  48656. motionController?: WebXRAbstractMotionController;
  48657. /**
  48658. * Event that fires when the controller is removed/disposed.
  48659. * The object provided as event data is this controller, after associated assets were disposed.
  48660. * uniqueId is still available.
  48661. */
  48662. onDisposeObservable: Observable<WebXRInputSource>;
  48663. /**
  48664. * Will be triggered when the mesh associated with the motion controller is done loading.
  48665. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48666. * A shortened version of controller -> motion controller -> on mesh loaded.
  48667. */
  48668. onMeshLoadedObservable: Observable<AbstractMesh>;
  48669. /**
  48670. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48671. */
  48672. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48673. /**
  48674. * Pointer which can be used to select objects or attach a visible laser to
  48675. */
  48676. pointer: AbstractMesh;
  48677. /**
  48678. * Creates the input source object
  48679. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48680. * @param _scene the scene which the controller should be associated to
  48681. * @param inputSource the underlying input source for the controller
  48682. * @param _options options for this controller creation
  48683. */
  48684. constructor(_scene: Scene,
  48685. /** The underlying input source for the controller */
  48686. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48687. /**
  48688. * Get this controllers unique id
  48689. */
  48690. get uniqueId(): string;
  48691. /**
  48692. * Disposes of the object
  48693. */
  48694. dispose(): void;
  48695. /**
  48696. * Gets a world space ray coming from the pointer or grip
  48697. * @param result the resulting ray
  48698. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48699. */
  48700. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48701. /**
  48702. * Updates the controller pose based on the given XRFrame
  48703. * @param xrFrame xr frame to update the pose with
  48704. * @param referenceSpace reference space to use
  48705. */
  48706. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48707. }
  48708. }
  48709. declare module BABYLON {
  48710. /**
  48711. * The schema for initialization options of the XR Input class
  48712. */
  48713. export interface IWebXRInputOptions {
  48714. /**
  48715. * If set to true no model will be automatically loaded
  48716. */
  48717. doNotLoadControllerMeshes?: boolean;
  48718. /**
  48719. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48720. * If not found, the xr input profile data will be used.
  48721. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48722. */
  48723. forceInputProfile?: string;
  48724. /**
  48725. * Do not send a request to the controller repository to load the profile.
  48726. *
  48727. * Instead, use the controllers available in babylon itself.
  48728. */
  48729. disableOnlineControllerRepository?: boolean;
  48730. /**
  48731. * A custom URL for the controllers repository
  48732. */
  48733. customControllersRepositoryURL?: string;
  48734. /**
  48735. * Should the controller model's components not move according to the user input
  48736. */
  48737. disableControllerAnimation?: boolean;
  48738. /**
  48739. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48740. */
  48741. controllerOptions?: IWebXRControllerOptions;
  48742. }
  48743. /**
  48744. * XR input used to track XR inputs such as controllers/rays
  48745. */
  48746. export class WebXRInput implements IDisposable {
  48747. /**
  48748. * the xr session manager for this session
  48749. */
  48750. xrSessionManager: WebXRSessionManager;
  48751. /**
  48752. * the WebXR camera for this session. Mainly used for teleportation
  48753. */
  48754. xrCamera: WebXRCamera;
  48755. private readonly options;
  48756. /**
  48757. * XR controllers being tracked
  48758. */
  48759. controllers: Array<WebXRInputSource>;
  48760. private _frameObserver;
  48761. private _sessionEndedObserver;
  48762. private _sessionInitObserver;
  48763. /**
  48764. * Event when a controller has been connected/added
  48765. */
  48766. onControllerAddedObservable: Observable<WebXRInputSource>;
  48767. /**
  48768. * Event when a controller has been removed/disconnected
  48769. */
  48770. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48771. /**
  48772. * Initializes the WebXRInput
  48773. * @param xrSessionManager the xr session manager for this session
  48774. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48775. * @param options = initialization options for this xr input
  48776. */
  48777. constructor(
  48778. /**
  48779. * the xr session manager for this session
  48780. */
  48781. xrSessionManager: WebXRSessionManager,
  48782. /**
  48783. * the WebXR camera for this session. Mainly used for teleportation
  48784. */
  48785. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48786. private _onInputSourcesChange;
  48787. private _addAndRemoveControllers;
  48788. /**
  48789. * Disposes of the object
  48790. */
  48791. dispose(): void;
  48792. }
  48793. }
  48794. declare module BABYLON {
  48795. /**
  48796. * This is the base class for all WebXR features.
  48797. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48798. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48799. */
  48800. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48801. protected _xrSessionManager: WebXRSessionManager;
  48802. private _attached;
  48803. private _removeOnDetach;
  48804. /**
  48805. * Is this feature disposed?
  48806. */
  48807. isDisposed: boolean;
  48808. /**
  48809. * Should auto-attach be disabled?
  48810. */
  48811. disableAutoAttach: boolean;
  48812. /**
  48813. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48814. */
  48815. xrNativeFeatureName: string;
  48816. /**
  48817. * Construct a new (abstract) WebXR feature
  48818. * @param _xrSessionManager the xr session manager for this feature
  48819. */
  48820. constructor(_xrSessionManager: WebXRSessionManager);
  48821. /**
  48822. * Is this feature attached
  48823. */
  48824. get attached(): boolean;
  48825. /**
  48826. * attach this feature
  48827. *
  48828. * @param force should attachment be forced (even when already attached)
  48829. * @returns true if successful, false is failed or already attached
  48830. */
  48831. attach(force?: boolean): boolean;
  48832. /**
  48833. * detach this feature.
  48834. *
  48835. * @returns true if successful, false if failed or already detached
  48836. */
  48837. detach(): boolean;
  48838. /**
  48839. * Dispose this feature and all of the resources attached
  48840. */
  48841. dispose(): void;
  48842. /**
  48843. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48844. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48845. *
  48846. * @returns whether or not the feature is compatible in this environment
  48847. */
  48848. isCompatible(): boolean;
  48849. /**
  48850. * This is used to register callbacks that will automatically be removed when detach is called.
  48851. * @param observable the observable to which the observer will be attached
  48852. * @param callback the callback to register
  48853. */
  48854. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48855. /**
  48856. * Code in this function will be executed on each xrFrame received from the browser.
  48857. * This function will not execute after the feature is detached.
  48858. * @param _xrFrame the current frame
  48859. */
  48860. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48861. }
  48862. }
  48863. declare module BABYLON {
  48864. /**
  48865. * Renders a layer on top of an existing scene
  48866. */
  48867. export class UtilityLayerRenderer implements IDisposable {
  48868. /** the original scene that will be rendered on top of */
  48869. originalScene: Scene;
  48870. private _pointerCaptures;
  48871. private _lastPointerEvents;
  48872. private static _DefaultUtilityLayer;
  48873. private static _DefaultKeepDepthUtilityLayer;
  48874. private _sharedGizmoLight;
  48875. private _renderCamera;
  48876. /**
  48877. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48878. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48879. * @returns the camera that is used when rendering the utility layer
  48880. */
  48881. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48882. /**
  48883. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48884. * @param cam the camera that should be used when rendering the utility layer
  48885. */
  48886. setRenderCamera(cam: Nullable<Camera>): void;
  48887. /**
  48888. * @hidden
  48889. * Light which used by gizmos to get light shading
  48890. */
  48891. _getSharedGizmoLight(): HemisphericLight;
  48892. /**
  48893. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48894. */
  48895. pickUtilitySceneFirst: boolean;
  48896. /**
  48897. * 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)
  48898. */
  48899. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48900. /**
  48901. * 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)
  48902. */
  48903. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48904. /**
  48905. * The scene that is rendered on top of the original scene
  48906. */
  48907. utilityLayerScene: Scene;
  48908. /**
  48909. * If the utility layer should automatically be rendered on top of existing scene
  48910. */
  48911. shouldRender: boolean;
  48912. /**
  48913. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48914. */
  48915. onlyCheckPointerDownEvents: boolean;
  48916. /**
  48917. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48918. */
  48919. processAllEvents: boolean;
  48920. /**
  48921. * Observable raised when the pointer move from the utility layer scene to the main scene
  48922. */
  48923. onPointerOutObservable: Observable<number>;
  48924. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48925. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48926. private _afterRenderObserver;
  48927. private _sceneDisposeObserver;
  48928. private _originalPointerObserver;
  48929. /**
  48930. * Instantiates a UtilityLayerRenderer
  48931. * @param originalScene the original scene that will be rendered on top of
  48932. * @param handleEvents boolean indicating if the utility layer should handle events
  48933. */
  48934. constructor(
  48935. /** the original scene that will be rendered on top of */
  48936. originalScene: Scene, handleEvents?: boolean);
  48937. private _notifyObservers;
  48938. /**
  48939. * Renders the utility layers scene on top of the original scene
  48940. */
  48941. render(): void;
  48942. /**
  48943. * Disposes of the renderer
  48944. */
  48945. dispose(): void;
  48946. private _updateCamera;
  48947. }
  48948. }
  48949. declare module BABYLON {
  48950. /**
  48951. * Options interface for the pointer selection module
  48952. */
  48953. export interface IWebXRControllerPointerSelectionOptions {
  48954. /**
  48955. * if provided, this scene will be used to render meshes.
  48956. */
  48957. customUtilityLayerScene?: Scene;
  48958. /**
  48959. * 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)
  48960. * If not disabled, the last picked point will be used to execute a pointer up event
  48961. * If disabled, pointer up event will be triggered right after the pointer down event.
  48962. * Used in screen and gaze target ray mode only
  48963. */
  48964. disablePointerUpOnTouchOut: boolean;
  48965. /**
  48966. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48967. */
  48968. forceGazeMode: boolean;
  48969. /**
  48970. * 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
  48971. * to start a new countdown to the pointer down event.
  48972. * Defaults to 1.
  48973. */
  48974. gazeModePointerMovedFactor?: number;
  48975. /**
  48976. * Different button type to use instead of the main component
  48977. */
  48978. overrideButtonId?: string;
  48979. /**
  48980. * use this rendering group id for the meshes (optional)
  48981. */
  48982. renderingGroupId?: number;
  48983. /**
  48984. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48985. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48986. * 3000 means 3 seconds between pointing at something and selecting it
  48987. */
  48988. timeToSelect?: number;
  48989. /**
  48990. * Should meshes created here be added to a utility layer or the main scene
  48991. */
  48992. useUtilityLayer?: boolean;
  48993. /**
  48994. * Optional WebXR camera to be used for gaze selection
  48995. */
  48996. gazeCamera?: WebXRCamera;
  48997. /**
  48998. * the xr input to use with this pointer selection
  48999. */
  49000. xrInput: WebXRInput;
  49001. }
  49002. /**
  49003. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49004. */
  49005. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49006. private readonly _options;
  49007. private static _idCounter;
  49008. private _attachController;
  49009. private _controllers;
  49010. private _scene;
  49011. private _tmpVectorForPickCompare;
  49012. /**
  49013. * The module's name
  49014. */
  49015. static readonly Name: string;
  49016. /**
  49017. * The (Babylon) version of this module.
  49018. * This is an integer representing the implementation version.
  49019. * This number does not correspond to the WebXR specs version
  49020. */
  49021. static readonly Version: number;
  49022. /**
  49023. * Disable lighting on the laser pointer (so it will always be visible)
  49024. */
  49025. disablePointerLighting: boolean;
  49026. /**
  49027. * Disable lighting on the selection mesh (so it will always be visible)
  49028. */
  49029. disableSelectionMeshLighting: boolean;
  49030. /**
  49031. * Should the laser pointer be displayed
  49032. */
  49033. displayLaserPointer: boolean;
  49034. /**
  49035. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49036. */
  49037. displaySelectionMesh: boolean;
  49038. /**
  49039. * This color will be set to the laser pointer when selection is triggered
  49040. */
  49041. laserPointerPickedColor: Color3;
  49042. /**
  49043. * Default color of the laser pointer
  49044. */
  49045. laserPointerDefaultColor: Color3;
  49046. /**
  49047. * default color of the selection ring
  49048. */
  49049. selectionMeshDefaultColor: Color3;
  49050. /**
  49051. * This color will be applied to the selection ring when selection is triggered
  49052. */
  49053. selectionMeshPickedColor: Color3;
  49054. /**
  49055. * Optional filter to be used for ray selection. This predicate shares behavior with
  49056. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49057. */
  49058. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49059. /**
  49060. * constructs a new background remover module
  49061. * @param _xrSessionManager the session manager for this module
  49062. * @param _options read-only options to be used in this module
  49063. */
  49064. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49065. /**
  49066. * attach this feature
  49067. * Will usually be called by the features manager
  49068. *
  49069. * @returns true if successful.
  49070. */
  49071. attach(): boolean;
  49072. /**
  49073. * detach this feature.
  49074. * Will usually be called by the features manager
  49075. *
  49076. * @returns true if successful.
  49077. */
  49078. detach(): boolean;
  49079. /**
  49080. * Will get the mesh under a specific pointer.
  49081. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49082. * @param controllerId the controllerId to check
  49083. * @returns The mesh under pointer or null if no mesh is under the pointer
  49084. */
  49085. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49086. /**
  49087. * Get the xr controller that correlates to the pointer id in the pointer event
  49088. *
  49089. * @param id the pointer id to search for
  49090. * @returns the controller that correlates to this id or null if not found
  49091. */
  49092. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49093. protected _onXRFrame(_xrFrame: XRFrame): void;
  49094. private _attachGazeMode;
  49095. private _attachScreenRayMode;
  49096. private _attachTrackedPointerRayMode;
  49097. private _convertNormalToDirectionOfRay;
  49098. private _detachController;
  49099. private _generateNewMeshPair;
  49100. private _pickingMoved;
  49101. private _updatePointerDistance;
  49102. /** @hidden */
  49103. get lasterPointerDefaultColor(): Color3;
  49104. }
  49105. }
  49106. declare module BABYLON {
  49107. /**
  49108. * Button which can be used to enter a different mode of XR
  49109. */
  49110. export class WebXREnterExitUIButton {
  49111. /** button element */
  49112. element: HTMLElement;
  49113. /** XR initialization options for the button */
  49114. sessionMode: XRSessionMode;
  49115. /** Reference space type */
  49116. referenceSpaceType: XRReferenceSpaceType;
  49117. /**
  49118. * Creates a WebXREnterExitUIButton
  49119. * @param element button element
  49120. * @param sessionMode XR initialization session mode
  49121. * @param referenceSpaceType the type of reference space to be used
  49122. */
  49123. constructor(
  49124. /** button element */
  49125. element: HTMLElement,
  49126. /** XR initialization options for the button */
  49127. sessionMode: XRSessionMode,
  49128. /** Reference space type */
  49129. referenceSpaceType: XRReferenceSpaceType);
  49130. /**
  49131. * Extendable function which can be used to update the button's visuals when the state changes
  49132. * @param activeButton the current active button in the UI
  49133. */
  49134. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49135. }
  49136. /**
  49137. * Options to create the webXR UI
  49138. */
  49139. export class WebXREnterExitUIOptions {
  49140. /**
  49141. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49142. */
  49143. customButtons?: Array<WebXREnterExitUIButton>;
  49144. /**
  49145. * A reference space type to use when creating the default button.
  49146. * Default is local-floor
  49147. */
  49148. referenceSpaceType?: XRReferenceSpaceType;
  49149. /**
  49150. * Context to enter xr with
  49151. */
  49152. renderTarget?: Nullable<WebXRRenderTarget>;
  49153. /**
  49154. * A session mode to use when creating the default button.
  49155. * Default is immersive-vr
  49156. */
  49157. sessionMode?: XRSessionMode;
  49158. /**
  49159. * A list of optional features to init the session with
  49160. */
  49161. optionalFeatures?: string[];
  49162. /**
  49163. * A list of optional features to init the session with
  49164. */
  49165. requiredFeatures?: string[];
  49166. }
  49167. /**
  49168. * UI to allow the user to enter/exit XR mode
  49169. */
  49170. export class WebXREnterExitUI implements IDisposable {
  49171. private scene;
  49172. /** version of the options passed to this UI */
  49173. options: WebXREnterExitUIOptions;
  49174. private _activeButton;
  49175. private _buttons;
  49176. /**
  49177. * The HTML Div Element to which buttons are added.
  49178. */
  49179. readonly overlay: HTMLDivElement;
  49180. /**
  49181. * Fired every time the active button is changed.
  49182. *
  49183. * When xr is entered via a button that launches xr that button will be the callback parameter
  49184. *
  49185. * When exiting xr the callback parameter will be null)
  49186. */
  49187. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49188. /**
  49189. *
  49190. * @param scene babylon scene object to use
  49191. * @param options (read-only) version of the options passed to this UI
  49192. */
  49193. private constructor();
  49194. /**
  49195. * Creates UI to allow the user to enter/exit XR mode
  49196. * @param scene the scene to add the ui to
  49197. * @param helper the xr experience helper to enter/exit xr with
  49198. * @param options options to configure the UI
  49199. * @returns the created ui
  49200. */
  49201. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49202. /**
  49203. * Disposes of the XR UI component
  49204. */
  49205. dispose(): void;
  49206. private _updateButtons;
  49207. }
  49208. }
  49209. declare module BABYLON {
  49210. /**
  49211. * Class containing static functions to help procedurally build meshes
  49212. */
  49213. export class LinesBuilder {
  49214. /**
  49215. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49216. * * 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
  49217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49218. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49219. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49220. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49222. * * 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
  49223. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49226. * @param name defines the name of the new line system
  49227. * @param options defines the options used to create the line system
  49228. * @param scene defines the hosting scene
  49229. * @returns a new line system mesh
  49230. */
  49231. static CreateLineSystem(name: string, options: {
  49232. lines: Vector3[][];
  49233. updatable?: boolean;
  49234. instance?: Nullable<LinesMesh>;
  49235. colors?: Nullable<Color4[][]>;
  49236. useVertexAlpha?: boolean;
  49237. }, scene: Nullable<Scene>): LinesMesh;
  49238. /**
  49239. * Creates a line mesh
  49240. * 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
  49241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49242. * * The parameter `points` is an array successive Vector3
  49243. * * 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
  49244. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49246. * * When updating an instance, remember that only point positions can change, not the number of points
  49247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49249. * @param name defines the name of the new line system
  49250. * @param options defines the options used to create the line system
  49251. * @param scene defines the hosting scene
  49252. * @returns a new line mesh
  49253. */
  49254. static CreateLines(name: string, options: {
  49255. points: Vector3[];
  49256. updatable?: boolean;
  49257. instance?: Nullable<LinesMesh>;
  49258. colors?: Color4[];
  49259. useVertexAlpha?: boolean;
  49260. }, scene?: Nullable<Scene>): LinesMesh;
  49261. /**
  49262. * Creates a dashed line mesh
  49263. * * 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
  49264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49265. * * The parameter `points` is an array successive Vector3
  49266. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49267. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49268. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49269. * * 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
  49270. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49271. * * When updating an instance, remember that only point positions can change, not the number of points
  49272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49273. * @param name defines the name of the mesh
  49274. * @param options defines the options used to create the mesh
  49275. * @param scene defines the hosting scene
  49276. * @returns the dashed line mesh
  49277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49278. */
  49279. static CreateDashedLines(name: string, options: {
  49280. points: Vector3[];
  49281. dashSize?: number;
  49282. gapSize?: number;
  49283. dashNb?: number;
  49284. updatable?: boolean;
  49285. instance?: LinesMesh;
  49286. useVertexAlpha?: boolean;
  49287. }, scene?: Nullable<Scene>): LinesMesh;
  49288. }
  49289. }
  49290. declare module BABYLON {
  49291. /**
  49292. * Construction options for a timer
  49293. */
  49294. export interface ITimerOptions<T> {
  49295. /**
  49296. * Time-to-end
  49297. */
  49298. timeout: number;
  49299. /**
  49300. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49301. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49302. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49303. */
  49304. contextObservable: Observable<T>;
  49305. /**
  49306. * Optional parameters when adding an observer to the observable
  49307. */
  49308. observableParameters?: {
  49309. mask?: number;
  49310. insertFirst?: boolean;
  49311. scope?: any;
  49312. };
  49313. /**
  49314. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49315. */
  49316. breakCondition?: (data?: ITimerData<T>) => boolean;
  49317. /**
  49318. * Will be triggered when the time condition has met
  49319. */
  49320. onEnded?: (data: ITimerData<any>) => void;
  49321. /**
  49322. * Will be triggered when the break condition has met (prematurely ended)
  49323. */
  49324. onAborted?: (data: ITimerData<any>) => void;
  49325. /**
  49326. * Optional function to execute on each tick (or count)
  49327. */
  49328. onTick?: (data: ITimerData<any>) => void;
  49329. }
  49330. /**
  49331. * An interface defining the data sent by the timer
  49332. */
  49333. export interface ITimerData<T> {
  49334. /**
  49335. * When did it start
  49336. */
  49337. startTime: number;
  49338. /**
  49339. * Time now
  49340. */
  49341. currentTime: number;
  49342. /**
  49343. * Time passed since started
  49344. */
  49345. deltaTime: number;
  49346. /**
  49347. * How much is completed, in [0.0...1.0].
  49348. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49349. */
  49350. completeRate: number;
  49351. /**
  49352. * What the registered observable sent in the last count
  49353. */
  49354. payload: T;
  49355. }
  49356. /**
  49357. * The current state of the timer
  49358. */
  49359. export enum TimerState {
  49360. /**
  49361. * Timer initialized, not yet started
  49362. */
  49363. INIT = 0,
  49364. /**
  49365. * Timer started and counting
  49366. */
  49367. STARTED = 1,
  49368. /**
  49369. * Timer ended (whether aborted or time reached)
  49370. */
  49371. ENDED = 2
  49372. }
  49373. /**
  49374. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49375. *
  49376. * @param options options with which to initialize this timer
  49377. */
  49378. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49379. /**
  49380. * An advanced implementation of a timer class
  49381. */
  49382. export class AdvancedTimer<T = any> implements IDisposable {
  49383. /**
  49384. * Will notify each time the timer calculates the remaining time
  49385. */
  49386. onEachCountObservable: Observable<ITimerData<T>>;
  49387. /**
  49388. * Will trigger when the timer was aborted due to the break condition
  49389. */
  49390. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49391. /**
  49392. * Will trigger when the timer ended successfully
  49393. */
  49394. onTimerEndedObservable: Observable<ITimerData<T>>;
  49395. /**
  49396. * Will trigger when the timer state has changed
  49397. */
  49398. onStateChangedObservable: Observable<TimerState>;
  49399. private _observer;
  49400. private _contextObservable;
  49401. private _observableParameters;
  49402. private _startTime;
  49403. private _timer;
  49404. private _state;
  49405. private _breakCondition;
  49406. private _timeToEnd;
  49407. private _breakOnNextTick;
  49408. /**
  49409. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49410. * @param options construction options for this advanced timer
  49411. */
  49412. constructor(options: ITimerOptions<T>);
  49413. /**
  49414. * set a breaking condition for this timer. Default is to never break during count
  49415. * @param predicate the new break condition. Returns true to break, false otherwise
  49416. */
  49417. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49418. /**
  49419. * Reset ALL associated observables in this advanced timer
  49420. */
  49421. clearObservables(): void;
  49422. /**
  49423. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49424. *
  49425. * @param timeToEnd how much time to measure until timer ended
  49426. */
  49427. start(timeToEnd?: number): void;
  49428. /**
  49429. * Will force a stop on the next tick.
  49430. */
  49431. stop(): void;
  49432. /**
  49433. * Dispose this timer, clearing all resources
  49434. */
  49435. dispose(): void;
  49436. private _setState;
  49437. private _tick;
  49438. private _stop;
  49439. }
  49440. }
  49441. declare module BABYLON {
  49442. /**
  49443. * The options container for the teleportation module
  49444. */
  49445. export interface IWebXRTeleportationOptions {
  49446. /**
  49447. * if provided, this scene will be used to render meshes.
  49448. */
  49449. customUtilityLayerScene?: Scene;
  49450. /**
  49451. * Values to configure the default target mesh
  49452. */
  49453. defaultTargetMeshOptions?: {
  49454. /**
  49455. * Fill color of the teleportation area
  49456. */
  49457. teleportationFillColor?: string;
  49458. /**
  49459. * Border color for the teleportation area
  49460. */
  49461. teleportationBorderColor?: string;
  49462. /**
  49463. * Disable the mesh's animation sequence
  49464. */
  49465. disableAnimation?: boolean;
  49466. /**
  49467. * Disable lighting on the material or the ring and arrow
  49468. */
  49469. disableLighting?: boolean;
  49470. /**
  49471. * Override the default material of the torus and arrow
  49472. */
  49473. torusArrowMaterial?: Material;
  49474. };
  49475. /**
  49476. * A list of meshes to use as floor meshes.
  49477. * Meshes can be added and removed after initializing the feature using the
  49478. * addFloorMesh and removeFloorMesh functions
  49479. * If empty, rotation will still work
  49480. */
  49481. floorMeshes?: AbstractMesh[];
  49482. /**
  49483. * use this rendering group id for the meshes (optional)
  49484. */
  49485. renderingGroupId?: number;
  49486. /**
  49487. * Should teleportation move only to snap points
  49488. */
  49489. snapPointsOnly?: boolean;
  49490. /**
  49491. * An array of points to which the teleportation will snap to.
  49492. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49493. */
  49494. snapPositions?: Vector3[];
  49495. /**
  49496. * How close should the teleportation ray be in order to snap to position.
  49497. * Default to 0.8 units (meters)
  49498. */
  49499. snapToPositionRadius?: number;
  49500. /**
  49501. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49502. * If you want to support rotation, make sure your mesh has a direction indicator.
  49503. *
  49504. * When left untouched, the default mesh will be initialized.
  49505. */
  49506. teleportationTargetMesh?: AbstractMesh;
  49507. /**
  49508. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49509. */
  49510. timeToTeleport?: number;
  49511. /**
  49512. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49513. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49514. */
  49515. useMainComponentOnly?: boolean;
  49516. /**
  49517. * Should meshes created here be added to a utility layer or the main scene
  49518. */
  49519. useUtilityLayer?: boolean;
  49520. /**
  49521. * Babylon XR Input class for controller
  49522. */
  49523. xrInput: WebXRInput;
  49524. /**
  49525. * Meshes that the teleportation ray cannot go through
  49526. */
  49527. pickBlockerMeshes?: AbstractMesh[];
  49528. }
  49529. /**
  49530. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49531. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49532. * the input of the attached controllers.
  49533. */
  49534. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49535. private _options;
  49536. private _controllers;
  49537. private _currentTeleportationControllerId;
  49538. private _floorMeshes;
  49539. private _quadraticBezierCurve;
  49540. private _selectionFeature;
  49541. private _snapToPositions;
  49542. private _snappedToPoint;
  49543. private _teleportationRingMaterial?;
  49544. private _tmpRay;
  49545. private _tmpVector;
  49546. private _tmpQuaternion;
  49547. /**
  49548. * The module's name
  49549. */
  49550. static readonly Name: string;
  49551. /**
  49552. * The (Babylon) version of this module.
  49553. * This is an integer representing the implementation version.
  49554. * This number does not correspond to the webxr specs version
  49555. */
  49556. static readonly Version: number;
  49557. /**
  49558. * Is movement backwards enabled
  49559. */
  49560. backwardsMovementEnabled: boolean;
  49561. /**
  49562. * Distance to travel when moving backwards
  49563. */
  49564. backwardsTeleportationDistance: number;
  49565. /**
  49566. * The distance from the user to the inspection point in the direction of the controller
  49567. * A higher number will allow the user to move further
  49568. * defaults to 5 (meters, in xr units)
  49569. */
  49570. parabolicCheckRadius: number;
  49571. /**
  49572. * Should the module support parabolic ray on top of direct ray
  49573. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49574. * Very helpful when moving between floors / different heights
  49575. */
  49576. parabolicRayEnabled: boolean;
  49577. /**
  49578. * How much rotation should be applied when rotating right and left
  49579. */
  49580. rotationAngle: number;
  49581. /**
  49582. * Is rotation enabled when moving forward?
  49583. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49584. */
  49585. rotationEnabled: boolean;
  49586. /**
  49587. * constructs a new anchor system
  49588. * @param _xrSessionManager an instance of WebXRSessionManager
  49589. * @param _options configuration object for this feature
  49590. */
  49591. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49592. /**
  49593. * Get the snapPointsOnly flag
  49594. */
  49595. get snapPointsOnly(): boolean;
  49596. /**
  49597. * Sets the snapPointsOnly flag
  49598. * @param snapToPoints should teleportation be exclusively to snap points
  49599. */
  49600. set snapPointsOnly(snapToPoints: boolean);
  49601. /**
  49602. * Add a new mesh to the floor meshes array
  49603. * @param mesh the mesh to use as floor mesh
  49604. */
  49605. addFloorMesh(mesh: AbstractMesh): void;
  49606. /**
  49607. * Add a new snap-to point to fix teleportation to this position
  49608. * @param newSnapPoint The new Snap-To point
  49609. */
  49610. addSnapPoint(newSnapPoint: Vector3): void;
  49611. attach(): boolean;
  49612. detach(): boolean;
  49613. dispose(): void;
  49614. /**
  49615. * Remove a mesh from the floor meshes array
  49616. * @param mesh the mesh to remove
  49617. */
  49618. removeFloorMesh(mesh: AbstractMesh): void;
  49619. /**
  49620. * Remove a mesh from the floor meshes array using its name
  49621. * @param name the mesh name to remove
  49622. */
  49623. removeFloorMeshByName(name: string): void;
  49624. /**
  49625. * 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
  49626. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49627. * @returns was the point found and removed or not
  49628. */
  49629. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49630. /**
  49631. * This function sets a selection feature that will be disabled when
  49632. * the forward ray is shown and will be reattached when hidden.
  49633. * This is used to remove the selection rays when moving.
  49634. * @param selectionFeature the feature to disable when forward movement is enabled
  49635. */
  49636. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49637. protected _onXRFrame(_xrFrame: XRFrame): void;
  49638. private _attachController;
  49639. private _createDefaultTargetMesh;
  49640. private _detachController;
  49641. private _findClosestSnapPointWithRadius;
  49642. private _setTargetMeshPosition;
  49643. private _setTargetMeshVisibility;
  49644. private _showParabolicPath;
  49645. private _teleportForward;
  49646. }
  49647. }
  49648. declare module BABYLON {
  49649. /**
  49650. * Options for the default xr helper
  49651. */
  49652. export class WebXRDefaultExperienceOptions {
  49653. /**
  49654. * Enable or disable default UI to enter XR
  49655. */
  49656. disableDefaultUI?: boolean;
  49657. /**
  49658. * Should teleportation not initialize. defaults to false.
  49659. */
  49660. disableTeleportation?: boolean;
  49661. /**
  49662. * Floor meshes that will be used for teleport
  49663. */
  49664. floorMeshes?: Array<AbstractMesh>;
  49665. /**
  49666. * If set to true, the first frame will not be used to reset position
  49667. * The first frame is mainly used when copying transformation from the old camera
  49668. * Mainly used in AR
  49669. */
  49670. ignoreNativeCameraTransformation?: boolean;
  49671. /**
  49672. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49673. */
  49674. inputOptions?: IWebXRInputOptions;
  49675. /**
  49676. * optional configuration for the output canvas
  49677. */
  49678. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49679. /**
  49680. * optional UI options. This can be used among other to change session mode and reference space type
  49681. */
  49682. uiOptions?: WebXREnterExitUIOptions;
  49683. /**
  49684. * When loading teleportation and pointer select, use stable versions instead of latest.
  49685. */
  49686. useStablePlugins?: boolean;
  49687. /**
  49688. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49689. */
  49690. renderingGroupId?: number;
  49691. /**
  49692. * A list of optional features to init the session with
  49693. * If set to true, all features we support will be added
  49694. */
  49695. optionalFeatures?: boolean | string[];
  49696. }
  49697. /**
  49698. * Default experience which provides a similar setup to the previous webVRExperience
  49699. */
  49700. export class WebXRDefaultExperience {
  49701. /**
  49702. * Base experience
  49703. */
  49704. baseExperience: WebXRExperienceHelper;
  49705. /**
  49706. * Enables ui for entering/exiting xr
  49707. */
  49708. enterExitUI: WebXREnterExitUI;
  49709. /**
  49710. * Input experience extension
  49711. */
  49712. input: WebXRInput;
  49713. /**
  49714. * Enables laser pointer and selection
  49715. */
  49716. pointerSelection: WebXRControllerPointerSelection;
  49717. /**
  49718. * Default target xr should render to
  49719. */
  49720. renderTarget: WebXRRenderTarget;
  49721. /**
  49722. * Enables teleportation
  49723. */
  49724. teleportation: WebXRMotionControllerTeleportation;
  49725. private constructor();
  49726. /**
  49727. * Creates the default xr experience
  49728. * @param scene scene
  49729. * @param options options for basic configuration
  49730. * @returns resulting WebXRDefaultExperience
  49731. */
  49732. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49733. /**
  49734. * DIsposes of the experience helper
  49735. */
  49736. dispose(): void;
  49737. }
  49738. }
  49739. declare module BABYLON {
  49740. /**
  49741. * Options to modify the vr teleportation behavior.
  49742. */
  49743. export interface VRTeleportationOptions {
  49744. /**
  49745. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49746. */
  49747. floorMeshName?: string;
  49748. /**
  49749. * A list of meshes to be used as the teleportation floor. (default: empty)
  49750. */
  49751. floorMeshes?: Mesh[];
  49752. /**
  49753. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49754. */
  49755. teleportationMode?: number;
  49756. /**
  49757. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49758. */
  49759. teleportationTime?: number;
  49760. /**
  49761. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49762. */
  49763. teleportationSpeed?: number;
  49764. /**
  49765. * The easing function used in the animation or null for Linear. (default CircleEase)
  49766. */
  49767. easingFunction?: EasingFunction;
  49768. }
  49769. /**
  49770. * Options to modify the vr experience helper's behavior.
  49771. */
  49772. export interface VRExperienceHelperOptions extends WebVROptions {
  49773. /**
  49774. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49775. */
  49776. createDeviceOrientationCamera?: boolean;
  49777. /**
  49778. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49779. */
  49780. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49781. /**
  49782. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49783. */
  49784. laserToggle?: boolean;
  49785. /**
  49786. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49787. */
  49788. floorMeshes?: Mesh[];
  49789. /**
  49790. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49791. */
  49792. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49793. /**
  49794. * Defines if WebXR should be used instead of WebVR (if available)
  49795. */
  49796. useXR?: boolean;
  49797. }
  49798. /**
  49799. * Event containing information after VR has been entered
  49800. */
  49801. export class OnAfterEnteringVRObservableEvent {
  49802. /**
  49803. * If entering vr was successful
  49804. */
  49805. success: boolean;
  49806. }
  49807. /**
  49808. * Helps to quickly add VR support to an existing scene.
  49809. * See https://doc.babylonjs.com/how_to/webvr_helper
  49810. */
  49811. export class VRExperienceHelper {
  49812. /** Options to modify the vr experience helper's behavior. */
  49813. webVROptions: VRExperienceHelperOptions;
  49814. private _scene;
  49815. private _position;
  49816. private _btnVR;
  49817. private _btnVRDisplayed;
  49818. private _webVRsupported;
  49819. private _webVRready;
  49820. private _webVRrequesting;
  49821. private _webVRpresenting;
  49822. private _hasEnteredVR;
  49823. private _fullscreenVRpresenting;
  49824. private _inputElement;
  49825. private _webVRCamera;
  49826. private _vrDeviceOrientationCamera;
  49827. private _deviceOrientationCamera;
  49828. private _existingCamera;
  49829. private _onKeyDown;
  49830. private _onVrDisplayPresentChange;
  49831. private _onVRDisplayChanged;
  49832. private _onVRRequestPresentStart;
  49833. private _onVRRequestPresentComplete;
  49834. /**
  49835. * 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)
  49836. */
  49837. enableGazeEvenWhenNoPointerLock: boolean;
  49838. /**
  49839. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49840. */
  49841. exitVROnDoubleTap: boolean;
  49842. /**
  49843. * Observable raised right before entering VR.
  49844. */
  49845. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49846. /**
  49847. * Observable raised when entering VR has completed.
  49848. */
  49849. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49850. /**
  49851. * Observable raised when exiting VR.
  49852. */
  49853. onExitingVRObservable: Observable<VRExperienceHelper>;
  49854. /**
  49855. * Observable raised when controller mesh is loaded.
  49856. */
  49857. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49858. /** Return this.onEnteringVRObservable
  49859. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49860. */
  49861. get onEnteringVR(): Observable<VRExperienceHelper>;
  49862. /** Return this.onExitingVRObservable
  49863. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49864. */
  49865. get onExitingVR(): Observable<VRExperienceHelper>;
  49866. /** Return this.onControllerMeshLoadedObservable
  49867. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49868. */
  49869. get onControllerMeshLoaded(): Observable<WebVRController>;
  49870. private _rayLength;
  49871. private _useCustomVRButton;
  49872. private _teleportationRequested;
  49873. private _teleportActive;
  49874. private _floorMeshName;
  49875. private _floorMeshesCollection;
  49876. private _teleportationMode;
  49877. private _teleportationTime;
  49878. private _teleportationSpeed;
  49879. private _teleportationEasing;
  49880. private _rotationAllowed;
  49881. private _teleportBackwardsVector;
  49882. private _teleportationTarget;
  49883. private _isDefaultTeleportationTarget;
  49884. private _postProcessMove;
  49885. private _teleportationFillColor;
  49886. private _teleportationBorderColor;
  49887. private _rotationAngle;
  49888. private _haloCenter;
  49889. private _cameraGazer;
  49890. private _padSensibilityUp;
  49891. private _padSensibilityDown;
  49892. private _leftController;
  49893. private _rightController;
  49894. private _gazeColor;
  49895. private _laserColor;
  49896. private _pickedLaserColor;
  49897. private _pickedGazeColor;
  49898. /**
  49899. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49900. */
  49901. onNewMeshSelected: Observable<AbstractMesh>;
  49902. /**
  49903. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49904. * This observable will provide the mesh and the controller used to select the mesh
  49905. */
  49906. onMeshSelectedWithController: Observable<{
  49907. mesh: AbstractMesh;
  49908. controller: WebVRController;
  49909. }>;
  49910. /**
  49911. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49912. */
  49913. onNewMeshPicked: Observable<PickingInfo>;
  49914. private _circleEase;
  49915. /**
  49916. * Observable raised before camera teleportation
  49917. */
  49918. onBeforeCameraTeleport: Observable<Vector3>;
  49919. /**
  49920. * Observable raised after camera teleportation
  49921. */
  49922. onAfterCameraTeleport: Observable<Vector3>;
  49923. /**
  49924. * Observable raised when current selected mesh gets unselected
  49925. */
  49926. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49927. private _raySelectionPredicate;
  49928. /**
  49929. * To be optionaly changed by user to define custom ray selection
  49930. */
  49931. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49932. /**
  49933. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49934. */
  49935. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49936. /**
  49937. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49938. */
  49939. teleportationEnabled: boolean;
  49940. private _defaultHeight;
  49941. private _teleportationInitialized;
  49942. private _interactionsEnabled;
  49943. private _interactionsRequested;
  49944. private _displayGaze;
  49945. private _displayLaserPointer;
  49946. /**
  49947. * The mesh used to display where the user is going to teleport.
  49948. */
  49949. get teleportationTarget(): Mesh;
  49950. /**
  49951. * Sets the mesh to be used to display where the user is going to teleport.
  49952. */
  49953. set teleportationTarget(value: Mesh);
  49954. /**
  49955. * 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
  49956. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49957. * See https://doc.babylonjs.com/resources/baking_transformations
  49958. */
  49959. get gazeTrackerMesh(): Mesh;
  49960. set gazeTrackerMesh(value: Mesh);
  49961. /**
  49962. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49963. */
  49964. updateGazeTrackerScale: boolean;
  49965. /**
  49966. * If the gaze trackers color should be updated when selecting meshes
  49967. */
  49968. updateGazeTrackerColor: boolean;
  49969. /**
  49970. * If the controller laser color should be updated when selecting meshes
  49971. */
  49972. updateControllerLaserColor: boolean;
  49973. /**
  49974. * The gaze tracking mesh corresponding to the left controller
  49975. */
  49976. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49977. /**
  49978. * The gaze tracking mesh corresponding to the right controller
  49979. */
  49980. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49981. /**
  49982. * If the ray of the gaze should be displayed.
  49983. */
  49984. get displayGaze(): boolean;
  49985. /**
  49986. * Sets if the ray of the gaze should be displayed.
  49987. */
  49988. set displayGaze(value: boolean);
  49989. /**
  49990. * If the ray of the LaserPointer should be displayed.
  49991. */
  49992. get displayLaserPointer(): boolean;
  49993. /**
  49994. * Sets if the ray of the LaserPointer should be displayed.
  49995. */
  49996. set displayLaserPointer(value: boolean);
  49997. /**
  49998. * The deviceOrientationCamera used as the camera when not in VR.
  49999. */
  50000. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50001. /**
  50002. * Based on the current WebVR support, returns the current VR camera used.
  50003. */
  50004. get currentVRCamera(): Nullable<Camera>;
  50005. /**
  50006. * The webVRCamera which is used when in VR.
  50007. */
  50008. get webVRCamera(): WebVRFreeCamera;
  50009. /**
  50010. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50011. */
  50012. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50013. /**
  50014. * The html button that is used to trigger entering into VR.
  50015. */
  50016. get vrButton(): Nullable<HTMLButtonElement>;
  50017. private get _teleportationRequestInitiated();
  50018. /**
  50019. * Defines whether or not Pointer lock should be requested when switching to
  50020. * full screen.
  50021. */
  50022. requestPointerLockOnFullScreen: boolean;
  50023. /**
  50024. * If asking to force XR, this will be populated with the default xr experience
  50025. */
  50026. xr: WebXRDefaultExperience;
  50027. /**
  50028. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50029. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50030. */
  50031. xrTestDone: boolean;
  50032. /**
  50033. * Instantiates a VRExperienceHelper.
  50034. * Helps to quickly add VR support to an existing scene.
  50035. * @param scene The scene the VRExperienceHelper belongs to.
  50036. * @param webVROptions Options to modify the vr experience helper's behavior.
  50037. */
  50038. constructor(scene: Scene,
  50039. /** Options to modify the vr experience helper's behavior. */
  50040. webVROptions?: VRExperienceHelperOptions);
  50041. private completeVRInit;
  50042. private _onDefaultMeshLoaded;
  50043. private _onResize;
  50044. private _onFullscreenChange;
  50045. /**
  50046. * Gets a value indicating if we are currently in VR mode.
  50047. */
  50048. get isInVRMode(): boolean;
  50049. private onVrDisplayPresentChange;
  50050. private onVRDisplayChanged;
  50051. private moveButtonToBottomRight;
  50052. private displayVRButton;
  50053. private updateButtonVisibility;
  50054. private _cachedAngularSensibility;
  50055. /**
  50056. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50057. * Otherwise, will use the fullscreen API.
  50058. */
  50059. enterVR(): void;
  50060. /**
  50061. * Attempt to exit VR, or fullscreen.
  50062. */
  50063. exitVR(): void;
  50064. /**
  50065. * The position of the vr experience helper.
  50066. */
  50067. get position(): Vector3;
  50068. /**
  50069. * Sets the position of the vr experience helper.
  50070. */
  50071. set position(value: Vector3);
  50072. /**
  50073. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50074. */
  50075. enableInteractions(): void;
  50076. private get _noControllerIsActive();
  50077. private beforeRender;
  50078. private _isTeleportationFloor;
  50079. /**
  50080. * Adds a floor mesh to be used for teleportation.
  50081. * @param floorMesh the mesh to be used for teleportation.
  50082. */
  50083. addFloorMesh(floorMesh: Mesh): void;
  50084. /**
  50085. * Removes a floor mesh from being used for teleportation.
  50086. * @param floorMesh the mesh to be removed.
  50087. */
  50088. removeFloorMesh(floorMesh: Mesh): void;
  50089. /**
  50090. * Enables interactions and teleportation using the VR controllers and gaze.
  50091. * @param vrTeleportationOptions options to modify teleportation behavior.
  50092. */
  50093. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50094. private _onNewGamepadConnected;
  50095. private _tryEnableInteractionOnController;
  50096. private _onNewGamepadDisconnected;
  50097. private _enableInteractionOnController;
  50098. private _checkTeleportWithRay;
  50099. private _checkRotate;
  50100. private _checkTeleportBackwards;
  50101. private _enableTeleportationOnController;
  50102. private _createTeleportationCircles;
  50103. private _displayTeleportationTarget;
  50104. private _hideTeleportationTarget;
  50105. private _rotateCamera;
  50106. private _moveTeleportationSelectorTo;
  50107. private _workingVector;
  50108. private _workingQuaternion;
  50109. private _workingMatrix;
  50110. /**
  50111. * Time Constant Teleportation Mode
  50112. */
  50113. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50114. /**
  50115. * Speed Constant Teleportation Mode
  50116. */
  50117. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50118. /**
  50119. * Teleports the users feet to the desired location
  50120. * @param location The location where the user's feet should be placed
  50121. */
  50122. teleportCamera(location: Vector3): void;
  50123. private _convertNormalToDirectionOfRay;
  50124. private _castRayAndSelectObject;
  50125. private _notifySelectedMeshUnselected;
  50126. /**
  50127. * Permanently set new colors for the laser pointer
  50128. * @param color the new laser color
  50129. * @param pickedColor the new laser color when picked mesh detected
  50130. */
  50131. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50132. /**
  50133. * Set lighting enabled / disabled on the laser pointer of both controllers
  50134. * @param enabled should the lighting be enabled on the laser pointer
  50135. */
  50136. setLaserLightingState(enabled?: boolean): void;
  50137. /**
  50138. * Permanently set new colors for the gaze pointer
  50139. * @param color the new gaze color
  50140. * @param pickedColor the new gaze color when picked mesh detected
  50141. */
  50142. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50143. /**
  50144. * Sets the color of the laser ray from the vr controllers.
  50145. * @param color new color for the ray.
  50146. */
  50147. changeLaserColor(color: Color3): void;
  50148. /**
  50149. * Sets the color of the ray from the vr headsets gaze.
  50150. * @param color new color for the ray.
  50151. */
  50152. changeGazeColor(color: Color3): void;
  50153. /**
  50154. * Exits VR and disposes of the vr experience helper
  50155. */
  50156. dispose(): void;
  50157. /**
  50158. * Gets the name of the VRExperienceHelper class
  50159. * @returns "VRExperienceHelper"
  50160. */
  50161. getClassName(): string;
  50162. }
  50163. }
  50164. declare module BABYLON {
  50165. /**
  50166. * Contains an array of blocks representing the octree
  50167. */
  50168. export interface IOctreeContainer<T> {
  50169. /**
  50170. * Blocks within the octree
  50171. */
  50172. blocks: Array<OctreeBlock<T>>;
  50173. }
  50174. /**
  50175. * Class used to store a cell in an octree
  50176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50177. */
  50178. export class OctreeBlock<T> {
  50179. /**
  50180. * Gets the content of the current block
  50181. */
  50182. entries: T[];
  50183. /**
  50184. * Gets the list of block children
  50185. */
  50186. blocks: Array<OctreeBlock<T>>;
  50187. private _depth;
  50188. private _maxDepth;
  50189. private _capacity;
  50190. private _minPoint;
  50191. private _maxPoint;
  50192. private _boundingVectors;
  50193. private _creationFunc;
  50194. /**
  50195. * Creates a new block
  50196. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50197. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50198. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50199. * @param depth defines the current depth of this block in the octree
  50200. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50201. * @param creationFunc defines a callback to call when an element is added to the block
  50202. */
  50203. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50204. /**
  50205. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50206. */
  50207. get capacity(): number;
  50208. /**
  50209. * Gets the minimum vector (in world space) of the block's bounding box
  50210. */
  50211. get minPoint(): Vector3;
  50212. /**
  50213. * Gets the maximum vector (in world space) of the block's bounding box
  50214. */
  50215. get maxPoint(): Vector3;
  50216. /**
  50217. * Add a new element to this block
  50218. * @param entry defines the element to add
  50219. */
  50220. addEntry(entry: T): void;
  50221. /**
  50222. * Remove an element from this block
  50223. * @param entry defines the element to remove
  50224. */
  50225. removeEntry(entry: T): void;
  50226. /**
  50227. * Add an array of elements to this block
  50228. * @param entries defines the array of elements to add
  50229. */
  50230. addEntries(entries: T[]): void;
  50231. /**
  50232. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50233. * @param frustumPlanes defines the frustum planes to test
  50234. * @param selection defines the array to store current content if selection is positive
  50235. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50236. */
  50237. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50238. /**
  50239. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50240. * @param sphereCenter defines the bounding sphere center
  50241. * @param sphereRadius defines the bounding sphere radius
  50242. * @param selection defines the array to store current content if selection is positive
  50243. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50244. */
  50245. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50246. /**
  50247. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50248. * @param ray defines the ray to test with
  50249. * @param selection defines the array to store current content if selection is positive
  50250. */
  50251. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50252. /**
  50253. * Subdivide the content into child blocks (this block will then be empty)
  50254. */
  50255. createInnerBlocks(): void;
  50256. /**
  50257. * @hidden
  50258. */
  50259. 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;
  50260. }
  50261. }
  50262. declare module BABYLON {
  50263. /**
  50264. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50265. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50266. */
  50267. export class Octree<T> {
  50268. /** 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.) */
  50269. maxDepth: number;
  50270. /**
  50271. * Blocks within the octree containing objects
  50272. */
  50273. blocks: Array<OctreeBlock<T>>;
  50274. /**
  50275. * Content stored in the octree
  50276. */
  50277. dynamicContent: T[];
  50278. private _maxBlockCapacity;
  50279. private _selectionContent;
  50280. private _creationFunc;
  50281. /**
  50282. * Creates a octree
  50283. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50284. * @param creationFunc function to be used to instatiate the octree
  50285. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50286. * @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.)
  50287. */
  50288. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50289. /** 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.) */
  50290. maxDepth?: number);
  50291. /**
  50292. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50293. * @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);
  50294. * @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);
  50295. * @param entries meshes to be added to the octree blocks
  50296. */
  50297. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50298. /**
  50299. * Adds a mesh to the octree
  50300. * @param entry Mesh to add to the octree
  50301. */
  50302. addMesh(entry: T): void;
  50303. /**
  50304. * Remove an element from the octree
  50305. * @param entry defines the element to remove
  50306. */
  50307. removeMesh(entry: T): void;
  50308. /**
  50309. * Selects an array of meshes within the frustum
  50310. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50311. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50312. * @returns array of meshes within the frustum
  50313. */
  50314. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50315. /**
  50316. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50317. * @param sphereCenter defines the bounding sphere center
  50318. * @param sphereRadius defines the bounding sphere radius
  50319. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50320. * @returns an array of objects that intersect the sphere
  50321. */
  50322. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50323. /**
  50324. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50325. * @param ray defines the ray to test with
  50326. * @returns array of intersected objects
  50327. */
  50328. intersectsRay(ray: Ray): SmartArray<T>;
  50329. /**
  50330. * Adds a mesh into the octree block if it intersects the block
  50331. */
  50332. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50333. /**
  50334. * Adds a submesh into the octree block if it intersects the block
  50335. */
  50336. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50337. }
  50338. }
  50339. declare module BABYLON {
  50340. interface Scene {
  50341. /**
  50342. * @hidden
  50343. * Backing Filed
  50344. */
  50345. _selectionOctree: Octree<AbstractMesh>;
  50346. /**
  50347. * Gets the octree used to boost mesh selection (picking)
  50348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50349. */
  50350. selectionOctree: Octree<AbstractMesh>;
  50351. /**
  50352. * Creates or updates the octree used to boost selection (picking)
  50353. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50354. * @param maxCapacity defines the maximum capacity per leaf
  50355. * @param maxDepth defines the maximum depth of the octree
  50356. * @returns an octree of AbstractMesh
  50357. */
  50358. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50359. }
  50360. interface AbstractMesh {
  50361. /**
  50362. * @hidden
  50363. * Backing Field
  50364. */
  50365. _submeshesOctree: Octree<SubMesh>;
  50366. /**
  50367. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50368. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50369. * @param maxCapacity defines the maximum size of each block (64 by default)
  50370. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50371. * @returns the new octree
  50372. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50373. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50374. */
  50375. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50376. }
  50377. /**
  50378. * Defines the octree scene component responsible to manage any octrees
  50379. * in a given scene.
  50380. */
  50381. export class OctreeSceneComponent {
  50382. /**
  50383. * The component name help to identify the component in the list of scene components.
  50384. */
  50385. readonly name: string;
  50386. /**
  50387. * The scene the component belongs to.
  50388. */
  50389. scene: Scene;
  50390. /**
  50391. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50392. */
  50393. readonly checksIsEnabled: boolean;
  50394. /**
  50395. * Creates a new instance of the component for the given scene
  50396. * @param scene Defines the scene to register the component in
  50397. */
  50398. constructor(scene: Scene);
  50399. /**
  50400. * Registers the component in a given scene
  50401. */
  50402. register(): void;
  50403. /**
  50404. * Return the list of active meshes
  50405. * @returns the list of active meshes
  50406. */
  50407. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50408. /**
  50409. * Return the list of active sub meshes
  50410. * @param mesh The mesh to get the candidates sub meshes from
  50411. * @returns the list of active sub meshes
  50412. */
  50413. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50414. private _tempRay;
  50415. /**
  50416. * Return the list of sub meshes intersecting with a given local ray
  50417. * @param mesh defines the mesh to find the submesh for
  50418. * @param localRay defines the ray in local space
  50419. * @returns the list of intersecting sub meshes
  50420. */
  50421. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50422. /**
  50423. * Return the list of sub meshes colliding with a collider
  50424. * @param mesh defines the mesh to find the submesh for
  50425. * @param collider defines the collider to evaluate the collision against
  50426. * @returns the list of colliding sub meshes
  50427. */
  50428. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50429. /**
  50430. * Rebuilds the elements related to this component in case of
  50431. * context lost for instance.
  50432. */
  50433. rebuild(): void;
  50434. /**
  50435. * Disposes the component and the associated ressources.
  50436. */
  50437. dispose(): void;
  50438. }
  50439. }
  50440. declare module BABYLON {
  50441. /**
  50442. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50443. */
  50444. export class Gizmo implements IDisposable {
  50445. /** The utility layer the gizmo will be added to */
  50446. gizmoLayer: UtilityLayerRenderer;
  50447. /**
  50448. * The root mesh of the gizmo
  50449. */
  50450. _rootMesh: Mesh;
  50451. private _attachedMesh;
  50452. private _attachedNode;
  50453. /**
  50454. * Ratio for the scale of the gizmo (Default: 1)
  50455. */
  50456. protected _scaleRatio: number;
  50457. /**
  50458. * boolean updated by pointermove when a gizmo mesh is hovered
  50459. */
  50460. protected _isHovered: boolean;
  50461. /**
  50462. * Ratio for the scale of the gizmo (Default: 1)
  50463. */
  50464. set scaleRatio(value: number);
  50465. get scaleRatio(): number;
  50466. /**
  50467. * True when the mouse pointer is hovered a gizmo mesh
  50468. */
  50469. get isHovered(): boolean;
  50470. /**
  50471. * If a custom mesh has been set (Default: false)
  50472. */
  50473. protected _customMeshSet: boolean;
  50474. /**
  50475. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50476. * * When set, interactions will be enabled
  50477. */
  50478. get attachedMesh(): Nullable<AbstractMesh>;
  50479. set attachedMesh(value: Nullable<AbstractMesh>);
  50480. /**
  50481. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50482. * * When set, interactions will be enabled
  50483. */
  50484. get attachedNode(): Nullable<Node>;
  50485. set attachedNode(value: Nullable<Node>);
  50486. /**
  50487. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50488. * @param mesh The mesh to replace the default mesh of the gizmo
  50489. */
  50490. setCustomMesh(mesh: Mesh): void;
  50491. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50492. /**
  50493. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50494. */
  50495. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50496. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50497. /**
  50498. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50499. */
  50500. updateGizmoPositionToMatchAttachedMesh: boolean;
  50501. /**
  50502. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50503. */
  50504. updateScale: boolean;
  50505. protected _interactionsEnabled: boolean;
  50506. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50507. private _beforeRenderObserver;
  50508. private _tempQuaternion;
  50509. private _tempVector;
  50510. private _tempVector2;
  50511. private _tempMatrix1;
  50512. private _tempMatrix2;
  50513. private _rightHandtoLeftHandMatrix;
  50514. /**
  50515. * Creates a gizmo
  50516. * @param gizmoLayer The utility layer the gizmo will be added to
  50517. */
  50518. constructor(
  50519. /** The utility layer the gizmo will be added to */
  50520. gizmoLayer?: UtilityLayerRenderer);
  50521. /**
  50522. * Updates the gizmo to match the attached mesh's position/rotation
  50523. */
  50524. protected _update(): void;
  50525. /**
  50526. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50527. * @param value Node, TransformNode or mesh
  50528. */
  50529. protected _matrixChanged(): void;
  50530. /**
  50531. * Disposes of the gizmo
  50532. */
  50533. dispose(): void;
  50534. }
  50535. }
  50536. declare module BABYLON {
  50537. /**
  50538. * Single plane drag gizmo
  50539. */
  50540. export class PlaneDragGizmo extends Gizmo {
  50541. /**
  50542. * Drag behavior responsible for the gizmos dragging interactions
  50543. */
  50544. dragBehavior: PointerDragBehavior;
  50545. private _pointerObserver;
  50546. /**
  50547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50548. */
  50549. snapDistance: number;
  50550. /**
  50551. * Event that fires each time the gizmo snaps to a new location.
  50552. * * snapDistance is the the change in distance
  50553. */
  50554. onSnapObservable: Observable<{
  50555. snapDistance: number;
  50556. }>;
  50557. private _plane;
  50558. private _coloredMaterial;
  50559. private _hoverMaterial;
  50560. private _isEnabled;
  50561. private _parent;
  50562. /** @hidden */
  50563. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50564. /** @hidden */
  50565. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50566. /**
  50567. * Creates a PlaneDragGizmo
  50568. * @param gizmoLayer The utility layer the gizmo will be added to
  50569. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50570. * @param color The color of the gizmo
  50571. */
  50572. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50573. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50574. /**
  50575. * If the gizmo is enabled
  50576. */
  50577. set isEnabled(value: boolean);
  50578. get isEnabled(): boolean;
  50579. /**
  50580. * Disposes of the gizmo
  50581. */
  50582. dispose(): void;
  50583. }
  50584. }
  50585. declare module BABYLON {
  50586. /**
  50587. * Gizmo that enables dragging a mesh along 3 axis
  50588. */
  50589. export class PositionGizmo extends Gizmo {
  50590. /**
  50591. * Internal gizmo used for interactions on the x axis
  50592. */
  50593. xGizmo: AxisDragGizmo;
  50594. /**
  50595. * Internal gizmo used for interactions on the y axis
  50596. */
  50597. yGizmo: AxisDragGizmo;
  50598. /**
  50599. * Internal gizmo used for interactions on the z axis
  50600. */
  50601. zGizmo: AxisDragGizmo;
  50602. /**
  50603. * Internal gizmo used for interactions on the yz plane
  50604. */
  50605. xPlaneGizmo: PlaneDragGizmo;
  50606. /**
  50607. * Internal gizmo used for interactions on the xz plane
  50608. */
  50609. yPlaneGizmo: PlaneDragGizmo;
  50610. /**
  50611. * Internal gizmo used for interactions on the xy plane
  50612. */
  50613. zPlaneGizmo: PlaneDragGizmo;
  50614. /**
  50615. * private variables
  50616. */
  50617. private _meshAttached;
  50618. private _nodeAttached;
  50619. private _snapDistance;
  50620. /** Fires an event when any of it's sub gizmos are dragged */
  50621. onDragStartObservable: Observable<unknown>;
  50622. /** Fires an event when any of it's sub gizmos are released from dragging */
  50623. onDragEndObservable: Observable<unknown>;
  50624. /**
  50625. * If set to true, planar drag is enabled
  50626. */
  50627. private _planarGizmoEnabled;
  50628. get attachedMesh(): Nullable<AbstractMesh>;
  50629. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50630. get attachedNode(): Nullable<Node>;
  50631. set attachedNode(node: Nullable<Node>);
  50632. /**
  50633. * True when the mouse pointer is hovering a gizmo mesh
  50634. */
  50635. get isHovered(): boolean;
  50636. /**
  50637. * Creates a PositionGizmo
  50638. * @param gizmoLayer The utility layer the gizmo will be added to
  50639. @param thickness display gizmo axis thickness
  50640. */
  50641. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50642. /**
  50643. * If the planar drag gizmo is enabled
  50644. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50645. */
  50646. set planarGizmoEnabled(value: boolean);
  50647. get planarGizmoEnabled(): boolean;
  50648. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50649. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50650. /**
  50651. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50652. */
  50653. set snapDistance(value: number);
  50654. get snapDistance(): number;
  50655. /**
  50656. * Ratio for the scale of the gizmo (Default: 1)
  50657. */
  50658. set scaleRatio(value: number);
  50659. get scaleRatio(): number;
  50660. /**
  50661. * Disposes of the gizmo
  50662. */
  50663. dispose(): void;
  50664. /**
  50665. * CustomMeshes are not supported by this gizmo
  50666. * @param mesh The mesh to replace the default mesh of the gizmo
  50667. */
  50668. setCustomMesh(mesh: Mesh): void;
  50669. }
  50670. }
  50671. declare module BABYLON {
  50672. /**
  50673. * Single axis drag gizmo
  50674. */
  50675. export class AxisDragGizmo extends Gizmo {
  50676. /**
  50677. * Drag behavior responsible for the gizmos dragging interactions
  50678. */
  50679. dragBehavior: PointerDragBehavior;
  50680. private _pointerObserver;
  50681. /**
  50682. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50683. */
  50684. snapDistance: number;
  50685. /**
  50686. * Event that fires each time the gizmo snaps to a new location.
  50687. * * snapDistance is the the change in distance
  50688. */
  50689. onSnapObservable: Observable<{
  50690. snapDistance: number;
  50691. }>;
  50692. private _isEnabled;
  50693. private _parent;
  50694. private _arrow;
  50695. private _coloredMaterial;
  50696. private _hoverMaterial;
  50697. /** @hidden */
  50698. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50699. /** @hidden */
  50700. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50701. /**
  50702. * Creates an AxisDragGizmo
  50703. * @param gizmoLayer The utility layer the gizmo will be added to
  50704. * @param dragAxis The axis which the gizmo will be able to drag on
  50705. * @param color The color of the gizmo
  50706. * @param thickness display gizmo axis thickness
  50707. */
  50708. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50709. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50710. /**
  50711. * If the gizmo is enabled
  50712. */
  50713. set isEnabled(value: boolean);
  50714. get isEnabled(): boolean;
  50715. /**
  50716. * Disposes of the gizmo
  50717. */
  50718. dispose(): void;
  50719. }
  50720. }
  50721. declare module BABYLON.Debug {
  50722. /**
  50723. * The Axes viewer will show 3 axes in a specific point in space
  50724. */
  50725. export class AxesViewer {
  50726. private _xAxis;
  50727. private _yAxis;
  50728. private _zAxis;
  50729. private _scaleLinesFactor;
  50730. private _instanced;
  50731. /**
  50732. * Gets the hosting scene
  50733. */
  50734. scene: Nullable<Scene>;
  50735. /**
  50736. * Gets or sets a number used to scale line length
  50737. */
  50738. scaleLines: number;
  50739. /** Gets the node hierarchy used to render x-axis */
  50740. get xAxis(): TransformNode;
  50741. /** Gets the node hierarchy used to render y-axis */
  50742. get yAxis(): TransformNode;
  50743. /** Gets the node hierarchy used to render z-axis */
  50744. get zAxis(): TransformNode;
  50745. /**
  50746. * Creates a new AxesViewer
  50747. * @param scene defines the hosting scene
  50748. * @param scaleLines defines a number used to scale line length (1 by default)
  50749. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50750. * @param xAxis defines the node hierarchy used to render the x-axis
  50751. * @param yAxis defines the node hierarchy used to render the y-axis
  50752. * @param zAxis defines the node hierarchy used to render the z-axis
  50753. */
  50754. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50755. /**
  50756. * Force the viewer to update
  50757. * @param position defines the position of the viewer
  50758. * @param xaxis defines the x axis of the viewer
  50759. * @param yaxis defines the y axis of the viewer
  50760. * @param zaxis defines the z axis of the viewer
  50761. */
  50762. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50763. /**
  50764. * Creates an instance of this axes viewer.
  50765. * @returns a new axes viewer with instanced meshes
  50766. */
  50767. createInstance(): AxesViewer;
  50768. /** Releases resources */
  50769. dispose(): void;
  50770. private static _SetRenderingGroupId;
  50771. }
  50772. }
  50773. declare module BABYLON.Debug {
  50774. /**
  50775. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50776. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50777. */
  50778. export class BoneAxesViewer extends AxesViewer {
  50779. /**
  50780. * Gets or sets the target mesh where to display the axes viewer
  50781. */
  50782. mesh: Nullable<Mesh>;
  50783. /**
  50784. * Gets or sets the target bone where to display the axes viewer
  50785. */
  50786. bone: Nullable<Bone>;
  50787. /** Gets current position */
  50788. pos: Vector3;
  50789. /** Gets direction of X axis */
  50790. xaxis: Vector3;
  50791. /** Gets direction of Y axis */
  50792. yaxis: Vector3;
  50793. /** Gets direction of Z axis */
  50794. zaxis: Vector3;
  50795. /**
  50796. * Creates a new BoneAxesViewer
  50797. * @param scene defines the hosting scene
  50798. * @param bone defines the target bone
  50799. * @param mesh defines the target mesh
  50800. * @param scaleLines defines a scaling factor for line length (1 by default)
  50801. */
  50802. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50803. /**
  50804. * Force the viewer to update
  50805. */
  50806. update(): void;
  50807. /** Releases resources */
  50808. dispose(): void;
  50809. }
  50810. }
  50811. declare module BABYLON {
  50812. /**
  50813. * Interface used to define scene explorer extensibility option
  50814. */
  50815. export interface IExplorerExtensibilityOption {
  50816. /**
  50817. * Define the option label
  50818. */
  50819. label: string;
  50820. /**
  50821. * Defines the action to execute on click
  50822. */
  50823. action: (entity: any) => void;
  50824. }
  50825. /**
  50826. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50827. */
  50828. export interface IExplorerExtensibilityGroup {
  50829. /**
  50830. * Defines a predicate to test if a given type mut be extended
  50831. */
  50832. predicate: (entity: any) => boolean;
  50833. /**
  50834. * Gets the list of options added to a type
  50835. */
  50836. entries: IExplorerExtensibilityOption[];
  50837. }
  50838. /**
  50839. * Interface used to define the options to use to create the Inspector
  50840. */
  50841. export interface IInspectorOptions {
  50842. /**
  50843. * Display in overlay mode (default: false)
  50844. */
  50845. overlay?: boolean;
  50846. /**
  50847. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50848. */
  50849. globalRoot?: HTMLElement;
  50850. /**
  50851. * Display the Scene explorer
  50852. */
  50853. showExplorer?: boolean;
  50854. /**
  50855. * Display the property inspector
  50856. */
  50857. showInspector?: boolean;
  50858. /**
  50859. * Display in embed mode (both panes on the right)
  50860. */
  50861. embedMode?: boolean;
  50862. /**
  50863. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50864. */
  50865. handleResize?: boolean;
  50866. /**
  50867. * Allow the panes to popup (default: true)
  50868. */
  50869. enablePopup?: boolean;
  50870. /**
  50871. * Allow the panes to be closed by users (default: true)
  50872. */
  50873. enableClose?: boolean;
  50874. /**
  50875. * Optional list of extensibility entries
  50876. */
  50877. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50878. /**
  50879. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50880. */
  50881. inspectorURL?: string;
  50882. /**
  50883. * Optional initial tab (default to DebugLayerTab.Properties)
  50884. */
  50885. initialTab?: DebugLayerTab;
  50886. }
  50887. interface Scene {
  50888. /**
  50889. * @hidden
  50890. * Backing field
  50891. */
  50892. _debugLayer: DebugLayer;
  50893. /**
  50894. * Gets the debug layer (aka Inspector) associated with the scene
  50895. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50896. */
  50897. debugLayer: DebugLayer;
  50898. }
  50899. /**
  50900. * Enum of inspector action tab
  50901. */
  50902. export enum DebugLayerTab {
  50903. /**
  50904. * Properties tag (default)
  50905. */
  50906. Properties = 0,
  50907. /**
  50908. * Debug tab
  50909. */
  50910. Debug = 1,
  50911. /**
  50912. * Statistics tab
  50913. */
  50914. Statistics = 2,
  50915. /**
  50916. * Tools tab
  50917. */
  50918. Tools = 3,
  50919. /**
  50920. * Settings tab
  50921. */
  50922. Settings = 4
  50923. }
  50924. /**
  50925. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50926. * what is happening in your scene
  50927. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50928. */
  50929. export class DebugLayer {
  50930. /**
  50931. * Define the url to get the inspector script from.
  50932. * By default it uses the babylonjs CDN.
  50933. * @ignoreNaming
  50934. */
  50935. static InspectorURL: string;
  50936. private _scene;
  50937. private BJSINSPECTOR;
  50938. private _onPropertyChangedObservable?;
  50939. /**
  50940. * Observable triggered when a property is changed through the inspector.
  50941. */
  50942. get onPropertyChangedObservable(): any;
  50943. /**
  50944. * Instantiates a new debug layer.
  50945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50946. * what is happening in your scene
  50947. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50948. * @param scene Defines the scene to inspect
  50949. */
  50950. constructor(scene: Scene);
  50951. /** Creates the inspector window. */
  50952. private _createInspector;
  50953. /**
  50954. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50955. * @param entity defines the entity to select
  50956. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50957. */
  50958. select(entity: any, lineContainerTitles?: string | string[]): void;
  50959. /** Get the inspector from bundle or global */
  50960. private _getGlobalInspector;
  50961. /**
  50962. * Get if the inspector is visible or not.
  50963. * @returns true if visible otherwise, false
  50964. */
  50965. isVisible(): boolean;
  50966. /**
  50967. * Hide the inspector and close its window.
  50968. */
  50969. hide(): void;
  50970. /**
  50971. * Update the scene in the inspector
  50972. */
  50973. setAsActiveScene(): void;
  50974. /**
  50975. * Launch the debugLayer.
  50976. * @param config Define the configuration of the inspector
  50977. * @return a promise fulfilled when the debug layer is visible
  50978. */
  50979. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. /**
  50984. * Class containing static functions to help procedurally build meshes
  50985. */
  50986. export class BoxBuilder {
  50987. /**
  50988. * Creates a box mesh
  50989. * * The parameter `size` sets the size (float) of each box side (default 1)
  50990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50991. * * 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)
  50992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50994. * * 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
  50995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50997. * @param name defines the name of the mesh
  50998. * @param options defines the options used to create the mesh
  50999. * @param scene defines the hosting scene
  51000. * @returns the box mesh
  51001. */
  51002. static CreateBox(name: string, options: {
  51003. size?: number;
  51004. width?: number;
  51005. height?: number;
  51006. depth?: number;
  51007. faceUV?: Vector4[];
  51008. faceColors?: Color4[];
  51009. sideOrientation?: number;
  51010. frontUVs?: Vector4;
  51011. backUVs?: Vector4;
  51012. wrap?: boolean;
  51013. topBaseAt?: number;
  51014. bottomBaseAt?: number;
  51015. updatable?: boolean;
  51016. }, scene?: Nullable<Scene>): Mesh;
  51017. }
  51018. }
  51019. declare module BABYLON.Debug {
  51020. /**
  51021. * Used to show the physics impostor around the specific mesh
  51022. */
  51023. export class PhysicsViewer {
  51024. /** @hidden */
  51025. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51026. /** @hidden */
  51027. protected _meshes: Array<Nullable<AbstractMesh>>;
  51028. /** @hidden */
  51029. protected _scene: Nullable<Scene>;
  51030. /** @hidden */
  51031. protected _numMeshes: number;
  51032. /** @hidden */
  51033. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51034. private _renderFunction;
  51035. private _utilityLayer;
  51036. private _debugBoxMesh;
  51037. private _debugSphereMesh;
  51038. private _debugCylinderMesh;
  51039. private _debugMaterial;
  51040. private _debugMeshMeshes;
  51041. /**
  51042. * Creates a new PhysicsViewer
  51043. * @param scene defines the hosting scene
  51044. */
  51045. constructor(scene: Scene);
  51046. /** @hidden */
  51047. protected _updateDebugMeshes(): void;
  51048. /**
  51049. * Renders a specified physic impostor
  51050. * @param impostor defines the impostor to render
  51051. * @param targetMesh defines the mesh represented by the impostor
  51052. * @returns the new debug mesh used to render the impostor
  51053. */
  51054. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51055. /**
  51056. * Hides a specified physic impostor
  51057. * @param impostor defines the impostor to hide
  51058. */
  51059. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51060. private _getDebugMaterial;
  51061. private _getDebugBoxMesh;
  51062. private _getDebugSphereMesh;
  51063. private _getDebugCylinderMesh;
  51064. private _getDebugMeshMesh;
  51065. private _getDebugMesh;
  51066. /** Releases all resources */
  51067. dispose(): void;
  51068. }
  51069. }
  51070. declare module BABYLON {
  51071. /**
  51072. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51073. * in order to better appreciate the issue one might have.
  51074. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51075. */
  51076. export class RayHelper {
  51077. /**
  51078. * Defines the ray we are currently tryin to visualize.
  51079. */
  51080. ray: Nullable<Ray>;
  51081. private _renderPoints;
  51082. private _renderLine;
  51083. private _renderFunction;
  51084. private _scene;
  51085. private _onAfterRenderObserver;
  51086. private _onAfterStepObserver;
  51087. private _attachedToMesh;
  51088. private _meshSpaceDirection;
  51089. private _meshSpaceOrigin;
  51090. /**
  51091. * Helper function to create a colored helper in a scene in one line.
  51092. * @param ray Defines the ray we are currently tryin to visualize
  51093. * @param scene Defines the scene the ray is used in
  51094. * @param color Defines the color we want to see the ray in
  51095. * @returns The newly created ray helper.
  51096. */
  51097. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51098. /**
  51099. * Instantiate a new ray helper.
  51100. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51101. * in order to better appreciate the issue one might have.
  51102. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51103. * @param ray Defines the ray we are currently tryin to visualize
  51104. */
  51105. constructor(ray: Ray);
  51106. /**
  51107. * Shows the ray we are willing to debug.
  51108. * @param scene Defines the scene the ray needs to be rendered in
  51109. * @param color Defines the color the ray needs to be rendered in
  51110. */
  51111. show(scene: Scene, color?: Color3): void;
  51112. /**
  51113. * Hides the ray we are debugging.
  51114. */
  51115. hide(): void;
  51116. private _render;
  51117. /**
  51118. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51119. * @param mesh Defines the mesh we want the helper attached to
  51120. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51121. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51122. * @param length Defines the length of the ray
  51123. */
  51124. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51125. /**
  51126. * Detach the ray helper from the mesh it has previously been attached to.
  51127. */
  51128. detachFromMesh(): void;
  51129. private _updateToMesh;
  51130. /**
  51131. * Dispose the helper and release its associated resources.
  51132. */
  51133. dispose(): void;
  51134. }
  51135. }
  51136. declare module BABYLON {
  51137. /**
  51138. * Defines the options associated with the creation of a SkeletonViewer.
  51139. */
  51140. export interface ISkeletonViewerOptions {
  51141. /** Should the system pause animations before building the Viewer? */
  51142. pauseAnimations: boolean;
  51143. /** Should the system return the skeleton to rest before building? */
  51144. returnToRest: boolean;
  51145. /** public Display Mode of the Viewer */
  51146. displayMode: number;
  51147. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51148. displayOptions: ISkeletonViewerDisplayOptions;
  51149. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51150. computeBonesUsingShaders: boolean;
  51151. /** Flag ignore non weighted bones */
  51152. useAllBones: boolean;
  51153. }
  51154. /**
  51155. * Defines how to display the various bone meshes for the viewer.
  51156. */
  51157. export interface ISkeletonViewerDisplayOptions {
  51158. /** How far down to start tapering the bone spurs */
  51159. midStep?: number;
  51160. /** How big is the midStep? */
  51161. midStepFactor?: number;
  51162. /** Base for the Sphere Size */
  51163. sphereBaseSize?: number;
  51164. /** The ratio of the sphere to the longest bone in units */
  51165. sphereScaleUnit?: number;
  51166. /** Ratio for the Sphere Size */
  51167. sphereFactor?: number;
  51168. /** Whether to show local axes or not */
  51169. showLocalAxes?: boolean;
  51170. /** Length of each local axis */
  51171. localAxesSize?: number;
  51172. }
  51173. /**
  51174. * Defines the constructor options for the BoneWeight Shader.
  51175. */
  51176. export interface IBoneWeightShaderOptions {
  51177. /** Skeleton to Map */
  51178. skeleton: Skeleton;
  51179. /** Colors for Uninfluenced bones */
  51180. colorBase?: Color3;
  51181. /** Colors for 0.0-0.25 Weight bones */
  51182. colorZero?: Color3;
  51183. /** Color for 0.25-0.5 Weight Influence */
  51184. colorQuarter?: Color3;
  51185. /** Color for 0.5-0.75 Weight Influence */
  51186. colorHalf?: Color3;
  51187. /** Color for 0.75-1 Weight Influence */
  51188. colorFull?: Color3;
  51189. /** Color for Zero Weight Influence */
  51190. targetBoneIndex?: number;
  51191. }
  51192. /**
  51193. * Simple structure of the gradient steps for the Color Map.
  51194. */
  51195. export interface ISkeletonMapShaderColorMapKnot {
  51196. /** Color of the Knot */
  51197. color: Color3;
  51198. /** Location of the Knot */
  51199. location: number;
  51200. }
  51201. /**
  51202. * Defines the constructor options for the SkeletonMap Shader.
  51203. */
  51204. export interface ISkeletonMapShaderOptions {
  51205. /** Skeleton to Map */
  51206. skeleton: Skeleton;
  51207. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51208. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51209. }
  51210. }
  51211. declare module BABYLON {
  51212. /**
  51213. * Class containing static functions to help procedurally build meshes
  51214. */
  51215. export class RibbonBuilder {
  51216. /**
  51217. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51218. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51219. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51220. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51221. * * 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
  51222. * * 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
  51223. * * 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
  51224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51225. * * 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
  51226. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51227. * * 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
  51228. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51229. * * 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
  51230. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51232. * @param name defines the name of the mesh
  51233. * @param options defines the options used to create the mesh
  51234. * @param scene defines the hosting scene
  51235. * @returns the ribbon mesh
  51236. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51238. */
  51239. static CreateRibbon(name: string, options: {
  51240. pathArray: Vector3[][];
  51241. closeArray?: boolean;
  51242. closePath?: boolean;
  51243. offset?: number;
  51244. updatable?: boolean;
  51245. sideOrientation?: number;
  51246. frontUVs?: Vector4;
  51247. backUVs?: Vector4;
  51248. instance?: Mesh;
  51249. invertUV?: boolean;
  51250. uvs?: Vector2[];
  51251. colors?: Color4[];
  51252. }, scene?: Nullable<Scene>): Mesh;
  51253. }
  51254. }
  51255. declare module BABYLON {
  51256. /**
  51257. * Class containing static functions to help procedurally build meshes
  51258. */
  51259. export class ShapeBuilder {
  51260. /**
  51261. * 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.
  51262. * * 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.
  51263. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51264. * * 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.
  51265. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51266. * * 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
  51267. * * 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
  51268. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51270. * * 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
  51271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51273. * @param name defines the name of the mesh
  51274. * @param options defines the options used to create the mesh
  51275. * @param scene defines the hosting scene
  51276. * @returns the extruded shape mesh
  51277. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51279. */
  51280. static ExtrudeShape(name: string, options: {
  51281. shape: Vector3[];
  51282. path: Vector3[];
  51283. scale?: number;
  51284. rotation?: number;
  51285. cap?: number;
  51286. updatable?: boolean;
  51287. sideOrientation?: number;
  51288. frontUVs?: Vector4;
  51289. backUVs?: Vector4;
  51290. instance?: Mesh;
  51291. invertUV?: boolean;
  51292. }, scene?: Nullable<Scene>): Mesh;
  51293. /**
  51294. * Creates an custom extruded shape mesh.
  51295. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51296. * * 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.
  51297. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51298. * * 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
  51299. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51300. * * 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
  51301. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51302. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51303. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51304. * * 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
  51305. * * 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
  51306. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51308. * * 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
  51309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51311. * @param name defines the name of the mesh
  51312. * @param options defines the options used to create the mesh
  51313. * @param scene defines the hosting scene
  51314. * @returns the custom extruded shape mesh
  51315. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51316. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51318. */
  51319. static ExtrudeShapeCustom(name: string, options: {
  51320. shape: Vector3[];
  51321. path: Vector3[];
  51322. scaleFunction?: any;
  51323. rotationFunction?: any;
  51324. ribbonCloseArray?: boolean;
  51325. ribbonClosePath?: boolean;
  51326. cap?: number;
  51327. updatable?: boolean;
  51328. sideOrientation?: number;
  51329. frontUVs?: Vector4;
  51330. backUVs?: Vector4;
  51331. instance?: Mesh;
  51332. invertUV?: boolean;
  51333. }, scene?: Nullable<Scene>): Mesh;
  51334. private static _ExtrudeShapeGeneric;
  51335. }
  51336. }
  51337. declare module BABYLON.Debug {
  51338. /**
  51339. * Class used to render a debug view of a given skeleton
  51340. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51341. */
  51342. export class SkeletonViewer {
  51343. /** defines the skeleton to render */
  51344. skeleton: Skeleton;
  51345. /** defines the mesh attached to the skeleton */
  51346. mesh: AbstractMesh;
  51347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51348. autoUpdateBonesMatrices: boolean;
  51349. /** defines the rendering group id to use with the viewer */
  51350. renderingGroupId: number;
  51351. /** is the options for the viewer */
  51352. options: Partial<ISkeletonViewerOptions>;
  51353. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51354. static readonly DISPLAY_LINES: number;
  51355. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51356. static readonly DISPLAY_SPHERES: number;
  51357. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51358. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51359. /** public static method to create a BoneWeight Shader
  51360. * @param options The constructor options
  51361. * @param scene The scene that the shader is scoped to
  51362. * @returns The created ShaderMaterial
  51363. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51364. */
  51365. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51366. /** public static method to create a BoneWeight Shader
  51367. * @param options The constructor options
  51368. * @param scene The scene that the shader is scoped to
  51369. * @returns The created ShaderMaterial
  51370. */
  51371. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51372. /** private static method to create a BoneWeight Shader
  51373. * @param size The size of the buffer to create (usually the bone count)
  51374. * @param colorMap The gradient data to generate
  51375. * @param scene The scene that the shader is scoped to
  51376. * @returns an Array of floats from the color gradient values
  51377. */
  51378. private static _CreateBoneMapColorBuffer;
  51379. /** If SkeletonViewer scene scope. */
  51380. private _scene;
  51381. /** Gets or sets the color used to render the skeleton */
  51382. color: Color3;
  51383. /** Array of the points of the skeleton fo the line view. */
  51384. private _debugLines;
  51385. /** The SkeletonViewers Mesh. */
  51386. private _debugMesh;
  51387. /** The local axes Meshes. */
  51388. private _localAxes;
  51389. /** If SkeletonViewer is enabled. */
  51390. private _isEnabled;
  51391. /** If SkeletonViewer is ready. */
  51392. private _ready;
  51393. /** SkeletonViewer render observable. */
  51394. private _obs;
  51395. /** The Utility Layer to render the gizmos in. */
  51396. private _utilityLayer;
  51397. private _boneIndices;
  51398. /** Gets the Scene. */
  51399. get scene(): Scene;
  51400. /** Gets the utilityLayer. */
  51401. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51402. /** Checks Ready Status. */
  51403. get isReady(): Boolean;
  51404. /** Sets Ready Status. */
  51405. set ready(value: boolean);
  51406. /** Gets the debugMesh */
  51407. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51408. /** Sets the debugMesh */
  51409. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51410. /** Gets the displayMode */
  51411. get displayMode(): number;
  51412. /** Sets the displayMode */
  51413. set displayMode(value: number);
  51414. /**
  51415. * Creates a new SkeletonViewer
  51416. * @param skeleton defines the skeleton to render
  51417. * @param mesh defines the mesh attached to the skeleton
  51418. * @param scene defines the hosting scene
  51419. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51420. * @param renderingGroupId defines the rendering group id to use with the viewer
  51421. * @param options All of the extra constructor options for the SkeletonViewer
  51422. */
  51423. constructor(
  51424. /** defines the skeleton to render */
  51425. skeleton: Skeleton,
  51426. /** defines the mesh attached to the skeleton */
  51427. mesh: AbstractMesh,
  51428. /** The Scene scope*/
  51429. scene: Scene,
  51430. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51431. autoUpdateBonesMatrices?: boolean,
  51432. /** defines the rendering group id to use with the viewer */
  51433. renderingGroupId?: number,
  51434. /** is the options for the viewer */
  51435. options?: Partial<ISkeletonViewerOptions>);
  51436. /** The Dynamic bindings for the update functions */
  51437. private _bindObs;
  51438. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51439. update(): void;
  51440. /** Gets or sets a boolean indicating if the viewer is enabled */
  51441. set isEnabled(value: boolean);
  51442. get isEnabled(): boolean;
  51443. private _getBonePosition;
  51444. private _getLinesForBonesWithLength;
  51445. private _getLinesForBonesNoLength;
  51446. /** function to revert the mesh and scene back to the initial state. */
  51447. private _revert;
  51448. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  51449. private _getAbsoluteBindPoseToRef;
  51450. /** function to build and bind sphere joint points and spur bone representations. */
  51451. private _buildSpheresAndSpurs;
  51452. private _buildLocalAxes;
  51453. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51454. private _displayLinesUpdate;
  51455. /** Changes the displayMode of the skeleton viewer
  51456. * @param mode The displayMode numerical value
  51457. */
  51458. changeDisplayMode(mode: number): void;
  51459. /** Sets a display option of the skeleton viewer
  51460. *
  51461. * | Option | Type | Default | Description |
  51462. * | --------------- | ------- | ------- | ----------- |
  51463. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51464. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51465. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51466. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51467. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  51468. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  51469. *
  51470. * @param option String of the option name
  51471. * @param value The numerical option value
  51472. */
  51473. changeDisplayOptions(option: string, value: number): void;
  51474. /** Release associated resources */
  51475. dispose(): void;
  51476. }
  51477. }
  51478. declare module BABYLON {
  51479. /**
  51480. * Enum for Device Types
  51481. */
  51482. export enum DeviceType {
  51483. /** Generic */
  51484. Generic = 0,
  51485. /** Keyboard */
  51486. Keyboard = 1,
  51487. /** Mouse */
  51488. Mouse = 2,
  51489. /** Touch Pointers */
  51490. Touch = 3,
  51491. /** PS4 Dual Shock */
  51492. DualShock = 4,
  51493. /** Xbox */
  51494. Xbox = 5,
  51495. /** Switch Controller */
  51496. Switch = 6
  51497. }
  51498. /**
  51499. * Enum for All Pointers (Touch/Mouse)
  51500. */
  51501. export enum PointerInput {
  51502. /** Horizontal Axis */
  51503. Horizontal = 0,
  51504. /** Vertical Axis */
  51505. Vertical = 1,
  51506. /** Left Click or Touch */
  51507. LeftClick = 2,
  51508. /** Middle Click */
  51509. MiddleClick = 3,
  51510. /** Right Click */
  51511. RightClick = 4,
  51512. /** Browser Back */
  51513. BrowserBack = 5,
  51514. /** Browser Forward */
  51515. BrowserForward = 6
  51516. }
  51517. /**
  51518. * Enum for Dual Shock Gamepad
  51519. */
  51520. export enum DualShockInput {
  51521. /** Cross */
  51522. Cross = 0,
  51523. /** Circle */
  51524. Circle = 1,
  51525. /** Square */
  51526. Square = 2,
  51527. /** Triangle */
  51528. Triangle = 3,
  51529. /** L1 */
  51530. L1 = 4,
  51531. /** R1 */
  51532. R1 = 5,
  51533. /** L2 */
  51534. L2 = 6,
  51535. /** R2 */
  51536. R2 = 7,
  51537. /** Share */
  51538. Share = 8,
  51539. /** Options */
  51540. Options = 9,
  51541. /** L3 */
  51542. L3 = 10,
  51543. /** R3 */
  51544. R3 = 11,
  51545. /** DPadUp */
  51546. DPadUp = 12,
  51547. /** DPadDown */
  51548. DPadDown = 13,
  51549. /** DPadLeft */
  51550. DPadLeft = 14,
  51551. /** DRight */
  51552. DPadRight = 15,
  51553. /** Home */
  51554. Home = 16,
  51555. /** TouchPad */
  51556. TouchPad = 17,
  51557. /** LStickXAxis */
  51558. LStickXAxis = 18,
  51559. /** LStickYAxis */
  51560. LStickYAxis = 19,
  51561. /** RStickXAxis */
  51562. RStickXAxis = 20,
  51563. /** RStickYAxis */
  51564. RStickYAxis = 21
  51565. }
  51566. /**
  51567. * Enum for Xbox Gamepad
  51568. */
  51569. export enum XboxInput {
  51570. /** A */
  51571. A = 0,
  51572. /** B */
  51573. B = 1,
  51574. /** X */
  51575. X = 2,
  51576. /** Y */
  51577. Y = 3,
  51578. /** LB */
  51579. LB = 4,
  51580. /** RB */
  51581. RB = 5,
  51582. /** LT */
  51583. LT = 6,
  51584. /** RT */
  51585. RT = 7,
  51586. /** Back */
  51587. Back = 8,
  51588. /** Start */
  51589. Start = 9,
  51590. /** LS */
  51591. LS = 10,
  51592. /** RS */
  51593. RS = 11,
  51594. /** DPadUp */
  51595. DPadUp = 12,
  51596. /** DPadDown */
  51597. DPadDown = 13,
  51598. /** DPadLeft */
  51599. DPadLeft = 14,
  51600. /** DRight */
  51601. DPadRight = 15,
  51602. /** Home */
  51603. Home = 16,
  51604. /** LStickXAxis */
  51605. LStickXAxis = 17,
  51606. /** LStickYAxis */
  51607. LStickYAxis = 18,
  51608. /** RStickXAxis */
  51609. RStickXAxis = 19,
  51610. /** RStickYAxis */
  51611. RStickYAxis = 20
  51612. }
  51613. /**
  51614. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51615. */
  51616. export enum SwitchInput {
  51617. /** B */
  51618. B = 0,
  51619. /** A */
  51620. A = 1,
  51621. /** Y */
  51622. Y = 2,
  51623. /** X */
  51624. X = 3,
  51625. /** L */
  51626. L = 4,
  51627. /** R */
  51628. R = 5,
  51629. /** ZL */
  51630. ZL = 6,
  51631. /** ZR */
  51632. ZR = 7,
  51633. /** Minus */
  51634. Minus = 8,
  51635. /** Plus */
  51636. Plus = 9,
  51637. /** LS */
  51638. LS = 10,
  51639. /** RS */
  51640. RS = 11,
  51641. /** DPadUp */
  51642. DPadUp = 12,
  51643. /** DPadDown */
  51644. DPadDown = 13,
  51645. /** DPadLeft */
  51646. DPadLeft = 14,
  51647. /** DRight */
  51648. DPadRight = 15,
  51649. /** Home */
  51650. Home = 16,
  51651. /** Capture */
  51652. Capture = 17,
  51653. /** LStickXAxis */
  51654. LStickXAxis = 18,
  51655. /** LStickYAxis */
  51656. LStickYAxis = 19,
  51657. /** RStickXAxis */
  51658. RStickXAxis = 20,
  51659. /** RStickYAxis */
  51660. RStickYAxis = 21
  51661. }
  51662. }
  51663. declare module BABYLON {
  51664. /**
  51665. * This class will take all inputs from Keyboard, Pointer, and
  51666. * any Gamepads and provide a polling system that all devices
  51667. * will use. This class assumes that there will only be one
  51668. * pointer device and one keyboard.
  51669. */
  51670. export class DeviceInputSystem implements IDisposable {
  51671. /**
  51672. * Callback to be triggered when a device is connected
  51673. */
  51674. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51675. /**
  51676. * Callback to be triggered when a device is disconnected
  51677. */
  51678. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51679. /**
  51680. * Callback to be triggered when event driven input is updated
  51681. */
  51682. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51683. private _inputs;
  51684. private _gamepads;
  51685. private _keyboardActive;
  51686. private _pointerActive;
  51687. private _elementToAttachTo;
  51688. private _keyboardDownEvent;
  51689. private _keyboardUpEvent;
  51690. private _pointerMoveEvent;
  51691. private _pointerDownEvent;
  51692. private _pointerUpEvent;
  51693. private _gamepadConnectedEvent;
  51694. private _gamepadDisconnectedEvent;
  51695. private static _MAX_KEYCODES;
  51696. private static _MAX_POINTER_INPUTS;
  51697. private constructor();
  51698. /**
  51699. * Creates a new DeviceInputSystem instance
  51700. * @param engine Engine to pull input element from
  51701. * @returns The new instance
  51702. */
  51703. static Create(engine: Engine): DeviceInputSystem;
  51704. /**
  51705. * Checks for current device input value, given an id and input index
  51706. * @param deviceName Id of connected device
  51707. * @param inputIndex Index of device input
  51708. * @returns Current value of input
  51709. */
  51710. /**
  51711. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51712. * @param deviceType Enum specifiying device type
  51713. * @param deviceSlot "Slot" or index that device is referenced in
  51714. * @param inputIndex Id of input to be checked
  51715. * @returns Current value of input
  51716. */
  51717. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51718. /**
  51719. * Dispose of all the eventlisteners
  51720. */
  51721. dispose(): void;
  51722. /**
  51723. * Add device and inputs to device array
  51724. * @param deviceType Enum specifiying device type
  51725. * @param deviceSlot "Slot" or index that device is referenced in
  51726. * @param numberOfInputs Number of input entries to create for given device
  51727. */
  51728. private _registerDevice;
  51729. /**
  51730. * Given a specific device name, remove that device from the device map
  51731. * @param deviceType Enum specifiying device type
  51732. * @param deviceSlot "Slot" or index that device is referenced in
  51733. */
  51734. private _unregisterDevice;
  51735. /**
  51736. * Handle all actions that come from keyboard interaction
  51737. */
  51738. private _handleKeyActions;
  51739. /**
  51740. * Handle all actions that come from pointer interaction
  51741. */
  51742. private _handlePointerActions;
  51743. /**
  51744. * Handle all actions that come from gamepad interaction
  51745. */
  51746. private _handleGamepadActions;
  51747. /**
  51748. * Update all non-event based devices with each frame
  51749. * @param deviceType Enum specifiying device type
  51750. * @param deviceSlot "Slot" or index that device is referenced in
  51751. * @param inputIndex Id of input to be checked
  51752. */
  51753. private _updateDevice;
  51754. /**
  51755. * Gets DeviceType from the device name
  51756. * @param deviceName Name of Device from DeviceInputSystem
  51757. * @returns DeviceType enum value
  51758. */
  51759. private _getGamepadDeviceType;
  51760. }
  51761. }
  51762. declare module BABYLON {
  51763. /**
  51764. * Type to handle enforcement of inputs
  51765. */
  51766. 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;
  51767. }
  51768. declare module BABYLON {
  51769. /**
  51770. * Class that handles all input for a specific device
  51771. */
  51772. export class DeviceSource<T extends DeviceType> {
  51773. /** Type of device */
  51774. readonly deviceType: DeviceType;
  51775. /** "Slot" or index that device is referenced in */
  51776. readonly deviceSlot: number;
  51777. /**
  51778. * Observable to handle device input changes per device
  51779. */
  51780. readonly onInputChangedObservable: Observable<{
  51781. inputIndex: DeviceInput<T>;
  51782. previousState: Nullable<number>;
  51783. currentState: Nullable<number>;
  51784. }>;
  51785. private readonly _deviceInputSystem;
  51786. /**
  51787. * Default Constructor
  51788. * @param deviceInputSystem Reference to DeviceInputSystem
  51789. * @param deviceType Type of device
  51790. * @param deviceSlot "Slot" or index that device is referenced in
  51791. */
  51792. constructor(deviceInputSystem: DeviceInputSystem,
  51793. /** Type of device */
  51794. deviceType: DeviceType,
  51795. /** "Slot" or index that device is referenced in */
  51796. deviceSlot?: number);
  51797. /**
  51798. * Get input for specific input
  51799. * @param inputIndex index of specific input on device
  51800. * @returns Input value from DeviceInputSystem
  51801. */
  51802. getInput(inputIndex: DeviceInput<T>): number;
  51803. }
  51804. /**
  51805. * Class to keep track of devices
  51806. */
  51807. export class DeviceSourceManager implements IDisposable {
  51808. /**
  51809. * Observable to be triggered when before a device is connected
  51810. */
  51811. readonly onBeforeDeviceConnectedObservable: Observable<{
  51812. deviceType: DeviceType;
  51813. deviceSlot: number;
  51814. }>;
  51815. /**
  51816. * Observable to be triggered when before a device is disconnected
  51817. */
  51818. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51819. deviceType: DeviceType;
  51820. deviceSlot: number;
  51821. }>;
  51822. /**
  51823. * Observable to be triggered when after a device is connected
  51824. */
  51825. readonly onAfterDeviceConnectedObservable: Observable<{
  51826. deviceType: DeviceType;
  51827. deviceSlot: number;
  51828. }>;
  51829. /**
  51830. * Observable to be triggered when after a device is disconnected
  51831. */
  51832. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51833. deviceType: DeviceType;
  51834. deviceSlot: number;
  51835. }>;
  51836. private readonly _devices;
  51837. private readonly _firstDevice;
  51838. private readonly _deviceInputSystem;
  51839. /**
  51840. * Default Constructor
  51841. * @param engine engine to pull input element from
  51842. */
  51843. constructor(engine: Engine);
  51844. /**
  51845. * Gets a DeviceSource, given a type and slot
  51846. * @param deviceType Enum specifying device type
  51847. * @param deviceSlot "Slot" or index that device is referenced in
  51848. * @returns DeviceSource object
  51849. */
  51850. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51851. /**
  51852. * Gets an array of DeviceSource objects for a given device type
  51853. * @param deviceType Enum specifying device type
  51854. * @returns Array of DeviceSource objects
  51855. */
  51856. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51857. /**
  51858. * Dispose of DeviceInputSystem and other parts
  51859. */
  51860. dispose(): void;
  51861. /**
  51862. * Function to add device name to device list
  51863. * @param deviceType Enum specifying device type
  51864. * @param deviceSlot "Slot" or index that device is referenced in
  51865. */
  51866. private _addDevice;
  51867. /**
  51868. * Function to remove device name to device list
  51869. * @param deviceType Enum specifying device type
  51870. * @param deviceSlot "Slot" or index that device is referenced in
  51871. */
  51872. private _removeDevice;
  51873. /**
  51874. * Updates array storing first connected device of each type
  51875. * @param type Type of Device
  51876. */
  51877. private _updateFirstDevices;
  51878. }
  51879. }
  51880. declare module BABYLON {
  51881. /**
  51882. * Options to create the null engine
  51883. */
  51884. export class NullEngineOptions {
  51885. /**
  51886. * Render width (Default: 512)
  51887. */
  51888. renderWidth: number;
  51889. /**
  51890. * Render height (Default: 256)
  51891. */
  51892. renderHeight: number;
  51893. /**
  51894. * Texture size (Default: 512)
  51895. */
  51896. textureSize: number;
  51897. /**
  51898. * If delta time between frames should be constant
  51899. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51900. */
  51901. deterministicLockstep: boolean;
  51902. /**
  51903. * Maximum about of steps between frames (Default: 4)
  51904. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51905. */
  51906. lockstepMaxSteps: number;
  51907. /**
  51908. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51909. */
  51910. useHighPrecisionMatrix?: boolean;
  51911. }
  51912. /**
  51913. * The null engine class provides support for headless version of babylon.js.
  51914. * This can be used in server side scenario or for testing purposes
  51915. */
  51916. export class NullEngine extends Engine {
  51917. private _options;
  51918. /**
  51919. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51920. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51921. * @returns true if engine is in deterministic lock step mode
  51922. */
  51923. isDeterministicLockStep(): boolean;
  51924. /**
  51925. * Gets the max steps when engine is running in deterministic lock step
  51926. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51927. * @returns the max steps
  51928. */
  51929. getLockstepMaxSteps(): number;
  51930. /**
  51931. * Gets the current hardware scaling level.
  51932. * By default the hardware scaling level is computed from the window device ratio.
  51933. * 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.
  51934. * @returns a number indicating the current hardware scaling level
  51935. */
  51936. getHardwareScalingLevel(): number;
  51937. constructor(options?: NullEngineOptions);
  51938. /**
  51939. * Creates a vertex buffer
  51940. * @param vertices the data for the vertex buffer
  51941. * @returns the new WebGL static buffer
  51942. */
  51943. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51944. /**
  51945. * Creates a new index buffer
  51946. * @param indices defines the content of the index buffer
  51947. * @param updatable defines if the index buffer must be updatable
  51948. * @returns a new webGL buffer
  51949. */
  51950. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51951. /**
  51952. * Clear the current render buffer or the current render target (if any is set up)
  51953. * @param color defines the color to use
  51954. * @param backBuffer defines if the back buffer must be cleared
  51955. * @param depth defines if the depth buffer must be cleared
  51956. * @param stencil defines if the stencil buffer must be cleared
  51957. */
  51958. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51959. /**
  51960. * Gets the current render width
  51961. * @param useScreen defines if screen size must be used (or the current render target if any)
  51962. * @returns a number defining the current render width
  51963. */
  51964. getRenderWidth(useScreen?: boolean): number;
  51965. /**
  51966. * Gets the current render height
  51967. * @param useScreen defines if screen size must be used (or the current render target if any)
  51968. * @returns a number defining the current render height
  51969. */
  51970. getRenderHeight(useScreen?: boolean): number;
  51971. /**
  51972. * Set the WebGL's viewport
  51973. * @param viewport defines the viewport element to be used
  51974. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51975. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51976. */
  51977. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51978. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51979. /**
  51980. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51981. * @param pipelineContext defines the pipeline context to use
  51982. * @param uniformsNames defines the list of uniform names
  51983. * @returns an array of webGL uniform locations
  51984. */
  51985. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51986. /**
  51987. * Gets the lsit of active attributes for a given webGL program
  51988. * @param pipelineContext defines the pipeline context to use
  51989. * @param attributesNames defines the list of attribute names to get
  51990. * @returns an array of indices indicating the offset of each attribute
  51991. */
  51992. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51993. /**
  51994. * Binds an effect to the webGL context
  51995. * @param effect defines the effect to bind
  51996. */
  51997. bindSamplers(effect: Effect): void;
  51998. /**
  51999. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52000. * @param effect defines the effect to activate
  52001. */
  52002. enableEffect(effect: Effect): void;
  52003. /**
  52004. * Set various states to the webGL context
  52005. * @param culling defines backface culling state
  52006. * @param zOffset defines the value to apply to zOffset (0 by default)
  52007. * @param force defines if states must be applied even if cache is up to date
  52008. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52009. */
  52010. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52011. /**
  52012. * Set the value of an uniform to an array of int32
  52013. * @param uniform defines the webGL uniform location where to store the value
  52014. * @param array defines the array of int32 to store
  52015. * @returns true if value was set
  52016. */
  52017. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52018. /**
  52019. * Set the value of an uniform to an array of int32 (stored as vec2)
  52020. * @param uniform defines the webGL uniform location where to store the value
  52021. * @param array defines the array of int32 to store
  52022. * @returns true if value was set
  52023. */
  52024. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52025. /**
  52026. * Set the value of an uniform to an array of int32 (stored as vec3)
  52027. * @param uniform defines the webGL uniform location where to store the value
  52028. * @param array defines the array of int32 to store
  52029. * @returns true if value was set
  52030. */
  52031. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52032. /**
  52033. * Set the value of an uniform to an array of int32 (stored as vec4)
  52034. * @param uniform defines the webGL uniform location where to store the value
  52035. * @param array defines the array of int32 to store
  52036. * @returns true if value was set
  52037. */
  52038. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52039. /**
  52040. * Set the value of an uniform to an array of float32
  52041. * @param uniform defines the webGL uniform location where to store the value
  52042. * @param array defines the array of float32 to store
  52043. * @returns true if value was set
  52044. */
  52045. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52046. /**
  52047. * Set the value of an uniform to an array of float32 (stored as vec2)
  52048. * @param uniform defines the webGL uniform location where to store the value
  52049. * @param array defines the array of float32 to store
  52050. * @returns true if value was set
  52051. */
  52052. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52053. /**
  52054. * Set the value of an uniform to an array of float32 (stored as vec3)
  52055. * @param uniform defines the webGL uniform location where to store the value
  52056. * @param array defines the array of float32 to store
  52057. * @returns true if value was set
  52058. */
  52059. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52060. /**
  52061. * Set the value of an uniform to an array of float32 (stored as vec4)
  52062. * @param uniform defines the webGL uniform location where to store the value
  52063. * @param array defines the array of float32 to store
  52064. * @returns true if value was set
  52065. */
  52066. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52067. /**
  52068. * Set the value of an uniform to an array of number
  52069. * @param uniform defines the webGL uniform location where to store the value
  52070. * @param array defines the array of number to store
  52071. * @returns true if value was set
  52072. */
  52073. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  52074. /**
  52075. * Set the value of an uniform to an array of number (stored as vec2)
  52076. * @param uniform defines the webGL uniform location where to store the value
  52077. * @param array defines the array of number to store
  52078. * @returns true if value was set
  52079. */
  52080. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  52081. /**
  52082. * Set the value of an uniform to an array of number (stored as vec3)
  52083. * @param uniform defines the webGL uniform location where to store the value
  52084. * @param array defines the array of number to store
  52085. * @returns true if value was set
  52086. */
  52087. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  52088. /**
  52089. * Set the value of an uniform to an array of number (stored as vec4)
  52090. * @param uniform defines the webGL uniform location where to store the value
  52091. * @param array defines the array of number to store
  52092. * @returns true if value was set
  52093. */
  52094. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  52095. /**
  52096. * Set the value of an uniform to an array of float32 (stored as matrices)
  52097. * @param uniform defines the webGL uniform location where to store the value
  52098. * @param matrices defines the array of float32 to store
  52099. * @returns true if value was set
  52100. */
  52101. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  52102. /**
  52103. * Set the value of an uniform to a matrix (3x3)
  52104. * @param uniform defines the webGL uniform location where to store the value
  52105. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52106. * @returns true if value was set
  52107. */
  52108. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52109. /**
  52110. * Set the value of an uniform to a matrix (2x2)
  52111. * @param uniform defines the webGL uniform location where to store the value
  52112. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52113. * @returns true if value was set
  52114. */
  52115. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52116. /**
  52117. * Set the value of an uniform to a number (float)
  52118. * @param uniform defines the webGL uniform location where to store the value
  52119. * @param value defines the float number to store
  52120. * @returns true if value was set
  52121. */
  52122. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  52123. /**
  52124. * Set the value of an uniform to a vec2
  52125. * @param uniform defines the webGL uniform location where to store the value
  52126. * @param x defines the 1st component of the value
  52127. * @param y defines the 2nd component of the value
  52128. * @returns true if value was set
  52129. */
  52130. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  52131. /**
  52132. * Set the value of an uniform to a vec3
  52133. * @param uniform defines the webGL uniform location where to store the value
  52134. * @param x defines the 1st component of the value
  52135. * @param y defines the 2nd component of the value
  52136. * @param z defines the 3rd component of the value
  52137. * @returns true if value was set
  52138. */
  52139. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  52140. /**
  52141. * Set the value of an uniform to a boolean
  52142. * @param uniform defines the webGL uniform location where to store the value
  52143. * @param bool defines the boolean to store
  52144. * @returns true if value was set
  52145. */
  52146. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  52147. /**
  52148. * Set the value of an uniform to a vec4
  52149. * @param uniform defines the webGL uniform location where to store the value
  52150. * @param x defines the 1st component of the value
  52151. * @param y defines the 2nd component of the value
  52152. * @param z defines the 3rd component of the value
  52153. * @param w defines the 4th component of the value
  52154. * @returns true if value was set
  52155. */
  52156. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  52157. /**
  52158. * Sets the current alpha mode
  52159. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52160. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52161. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52162. */
  52163. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52164. /**
  52165. * Bind webGl buffers directly to the webGL context
  52166. * @param vertexBuffers defines the vertex buffer to bind
  52167. * @param indexBuffer defines the index buffer to bind
  52168. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52169. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52170. * @param effect defines the effect associated with the vertex buffer
  52171. */
  52172. bindBuffers(vertexBuffers: {
  52173. [key: string]: VertexBuffer;
  52174. }, indexBuffer: DataBuffer, effect: Effect): void;
  52175. /**
  52176. * Force the entire cache to be cleared
  52177. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52178. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52179. */
  52180. wipeCaches(bruteForce?: boolean): void;
  52181. /**
  52182. * Send a draw order
  52183. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52184. * @param indexStart defines the starting index
  52185. * @param indexCount defines the number of index to draw
  52186. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52187. */
  52188. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52189. /**
  52190. * Draw a list of indexed primitives
  52191. * @param fillMode defines the primitive to use
  52192. * @param indexStart defines the starting index
  52193. * @param indexCount defines the number of index to draw
  52194. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52195. */
  52196. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52197. /**
  52198. * Draw a list of unindexed primitives
  52199. * @param fillMode defines the primitive to use
  52200. * @param verticesStart defines the index of first vertex to draw
  52201. * @param verticesCount defines the count of vertices to draw
  52202. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52203. */
  52204. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52205. /** @hidden */
  52206. _createTexture(): WebGLTexture;
  52207. /** @hidden */
  52208. _releaseTexture(texture: InternalTexture): void;
  52209. /**
  52210. * Usually called from Texture.ts.
  52211. * Passed information to create a WebGLTexture
  52212. * @param urlArg defines a value which contains one of the following:
  52213. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52214. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52215. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52216. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52217. * @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)
  52218. * @param scene needed for loading to the correct scene
  52219. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52220. * @param onLoad optional callback to be called upon successful completion
  52221. * @param onError optional callback to be called upon failure
  52222. * @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
  52223. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52224. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52225. * @param forcedExtension defines the extension to use to pick the right loader
  52226. * @param mimeType defines an optional mime type
  52227. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52228. */
  52229. 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;
  52230. /**
  52231. * Creates a new render target texture
  52232. * @param size defines the size of the texture
  52233. * @param options defines the options used to create the texture
  52234. * @returns a new render target texture stored in an InternalTexture
  52235. */
  52236. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52237. /**
  52238. * Update the sampling mode of a given texture
  52239. * @param samplingMode defines the required sampling mode
  52240. * @param texture defines the texture to update
  52241. */
  52242. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52243. /**
  52244. * Binds the frame buffer to the specified texture.
  52245. * @param texture The texture to render to or null for the default canvas
  52246. * @param faceIndex The face of the texture to render to in case of cube texture
  52247. * @param requiredWidth The width of the target to render to
  52248. * @param requiredHeight The height of the target to render to
  52249. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52250. * @param lodLevel defines le lod level to bind to the frame buffer
  52251. */
  52252. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52253. /**
  52254. * Unbind the current render target texture from the webGL context
  52255. * @param texture defines the render target texture to unbind
  52256. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52257. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52258. */
  52259. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52260. /**
  52261. * Creates a dynamic vertex buffer
  52262. * @param vertices the data for the dynamic vertex buffer
  52263. * @returns the new WebGL dynamic buffer
  52264. */
  52265. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52266. /**
  52267. * Update the content of a dynamic texture
  52268. * @param texture defines the texture to update
  52269. * @param canvas defines the canvas containing the source
  52270. * @param invertY defines if data must be stored with Y axis inverted
  52271. * @param premulAlpha defines if alpha is stored as premultiplied
  52272. * @param format defines the format of the data
  52273. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52274. */
  52275. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52276. /**
  52277. * Gets a boolean indicating if all created effects are ready
  52278. * @returns true if all effects are ready
  52279. */
  52280. areAllEffectsReady(): boolean;
  52281. /**
  52282. * @hidden
  52283. * Get the current error code of the webGL context
  52284. * @returns the error code
  52285. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52286. */
  52287. getError(): number;
  52288. /** @hidden */
  52289. _getUnpackAlignement(): number;
  52290. /** @hidden */
  52291. _unpackFlipY(value: boolean): void;
  52292. /**
  52293. * Update a dynamic index buffer
  52294. * @param indexBuffer defines the target index buffer
  52295. * @param indices defines the data to update
  52296. * @param offset defines the offset in the target index buffer where update should start
  52297. */
  52298. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52299. /**
  52300. * Updates a dynamic vertex buffer.
  52301. * @param vertexBuffer the vertex buffer to update
  52302. * @param vertices the data used to update the vertex buffer
  52303. * @param byteOffset the byte offset of the data (optional)
  52304. * @param byteLength the byte length of the data (optional)
  52305. */
  52306. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52307. /** @hidden */
  52308. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52309. /** @hidden */
  52310. _bindTexture(channel: number, texture: InternalTexture): void;
  52311. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52312. /**
  52313. * 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
  52314. */
  52315. releaseEffects(): void;
  52316. displayLoadingUI(): void;
  52317. hideLoadingUI(): 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. * @hidden
  52331. **/
  52332. export class _TimeToken {
  52333. _startTimeQuery: Nullable<WebGLQuery>;
  52334. _endTimeQuery: Nullable<WebGLQuery>;
  52335. _timeElapsedQuery: Nullable<WebGLQuery>;
  52336. _timeElapsedQueryEnded: boolean;
  52337. }
  52338. }
  52339. declare module BABYLON {
  52340. /** @hidden */
  52341. export class _OcclusionDataStorage {
  52342. /** @hidden */
  52343. occlusionInternalRetryCounter: number;
  52344. /** @hidden */
  52345. isOcclusionQueryInProgress: boolean;
  52346. /** @hidden */
  52347. isOccluded: boolean;
  52348. /** @hidden */
  52349. occlusionRetryCount: number;
  52350. /** @hidden */
  52351. occlusionType: number;
  52352. /** @hidden */
  52353. occlusionQueryAlgorithmType: number;
  52354. }
  52355. interface Engine {
  52356. /**
  52357. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52358. * @return the new query
  52359. */
  52360. createQuery(): WebGLQuery;
  52361. /**
  52362. * Delete and release a webGL query
  52363. * @param query defines the query to delete
  52364. * @return the current engine
  52365. */
  52366. deleteQuery(query: WebGLQuery): Engine;
  52367. /**
  52368. * Check if a given query has resolved and got its value
  52369. * @param query defines the query to check
  52370. * @returns true if the query got its value
  52371. */
  52372. isQueryResultAvailable(query: WebGLQuery): boolean;
  52373. /**
  52374. * Gets the value of a given query
  52375. * @param query defines the query to check
  52376. * @returns the value of the query
  52377. */
  52378. getQueryResult(query: WebGLQuery): number;
  52379. /**
  52380. * Initiates an occlusion query
  52381. * @param algorithmType defines the algorithm to use
  52382. * @param query defines the query to use
  52383. * @returns the current engine
  52384. * @see https://doc.babylonjs.com/features/occlusionquery
  52385. */
  52386. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52387. /**
  52388. * Ends an occlusion query
  52389. * @see https://doc.babylonjs.com/features/occlusionquery
  52390. * @param algorithmType defines the algorithm to use
  52391. * @returns the current engine
  52392. */
  52393. endOcclusionQuery(algorithmType: number): Engine;
  52394. /**
  52395. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52396. * Please note that only one query can be issued at a time
  52397. * @returns a time token used to track the time span
  52398. */
  52399. startTimeQuery(): Nullable<_TimeToken>;
  52400. /**
  52401. * Ends a time query
  52402. * @param token defines the token used to measure the time span
  52403. * @returns the time spent (in ns)
  52404. */
  52405. endTimeQuery(token: _TimeToken): int;
  52406. /** @hidden */
  52407. _currentNonTimestampToken: Nullable<_TimeToken>;
  52408. /** @hidden */
  52409. _createTimeQuery(): WebGLQuery;
  52410. /** @hidden */
  52411. _deleteTimeQuery(query: WebGLQuery): void;
  52412. /** @hidden */
  52413. _getGlAlgorithmType(algorithmType: number): number;
  52414. /** @hidden */
  52415. _getTimeQueryResult(query: WebGLQuery): any;
  52416. /** @hidden */
  52417. _getTimeQueryAvailability(query: WebGLQuery): any;
  52418. }
  52419. interface AbstractMesh {
  52420. /**
  52421. * Backing filed
  52422. * @hidden
  52423. */
  52424. __occlusionDataStorage: _OcclusionDataStorage;
  52425. /**
  52426. * Access property
  52427. * @hidden
  52428. */
  52429. _occlusionDataStorage: _OcclusionDataStorage;
  52430. /**
  52431. * 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.
  52432. * The default value is -1 which means don't break the query and wait till the result
  52433. * @see https://doc.babylonjs.com/features/occlusionquery
  52434. */
  52435. occlusionRetryCount: number;
  52436. /**
  52437. * 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:
  52438. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52439. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52440. * * 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.
  52441. * @see https://doc.babylonjs.com/features/occlusionquery
  52442. */
  52443. occlusionType: number;
  52444. /**
  52445. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52446. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52447. * * 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.
  52448. * @see https://doc.babylonjs.com/features/occlusionquery
  52449. */
  52450. occlusionQueryAlgorithmType: number;
  52451. /**
  52452. * 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
  52453. * @see https://doc.babylonjs.com/features/occlusionquery
  52454. */
  52455. isOccluded: boolean;
  52456. /**
  52457. * Flag to check the progress status of the query
  52458. * @see https://doc.babylonjs.com/features/occlusionquery
  52459. */
  52460. isOcclusionQueryInProgress: boolean;
  52461. }
  52462. }
  52463. declare module BABYLON {
  52464. /** @hidden */
  52465. export var _forceTransformFeedbackToBundle: boolean;
  52466. interface Engine {
  52467. /**
  52468. * Creates a webGL transform feedback object
  52469. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52470. * @returns the webGL transform feedback object
  52471. */
  52472. createTransformFeedback(): WebGLTransformFeedback;
  52473. /**
  52474. * Delete a webGL transform feedback object
  52475. * @param value defines the webGL transform feedback object to delete
  52476. */
  52477. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52478. /**
  52479. * Bind a webGL transform feedback object to the webgl context
  52480. * @param value defines the webGL transform feedback object to bind
  52481. */
  52482. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52483. /**
  52484. * Begins a transform feedback operation
  52485. * @param usePoints defines if points or triangles must be used
  52486. */
  52487. beginTransformFeedback(usePoints: boolean): void;
  52488. /**
  52489. * Ends a transform feedback operation
  52490. */
  52491. endTransformFeedback(): void;
  52492. /**
  52493. * Specify the varyings to use with transform feedback
  52494. * @param program defines the associated webGL program
  52495. * @param value defines the list of strings representing the varying names
  52496. */
  52497. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52498. /**
  52499. * Bind a webGL buffer for a transform feedback operation
  52500. * @param value defines the webGL buffer to bind
  52501. */
  52502. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /**
  52507. * Class used to define an additional view for the engine
  52508. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52509. */
  52510. export class EngineView {
  52511. /** Defines the canvas where to render the view */
  52512. target: HTMLCanvasElement;
  52513. /** Defines an optional camera used to render the view (will use active camera else) */
  52514. camera?: Camera;
  52515. }
  52516. interface Engine {
  52517. /**
  52518. * Gets or sets the HTML element to use for attaching events
  52519. */
  52520. inputElement: Nullable<HTMLElement>;
  52521. /**
  52522. * Gets the current engine view
  52523. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52524. */
  52525. activeView: Nullable<EngineView>;
  52526. /** Gets or sets the list of views */
  52527. views: EngineView[];
  52528. /**
  52529. * Register a new child canvas
  52530. * @param canvas defines the canvas to register
  52531. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52532. * @returns the associated view
  52533. */
  52534. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52535. /**
  52536. * Remove a registered child canvas
  52537. * @param canvas defines the canvas to remove
  52538. * @returns the current engine
  52539. */
  52540. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52541. }
  52542. }
  52543. declare module BABYLON {
  52544. interface Engine {
  52545. /** @hidden */
  52546. _excludedCompressedTextures: string[];
  52547. /** @hidden */
  52548. _textureFormatInUse: string;
  52549. /**
  52550. * Gets the list of texture formats supported
  52551. */
  52552. readonly texturesSupported: Array<string>;
  52553. /**
  52554. * Gets the texture format in use
  52555. */
  52556. readonly textureFormatInUse: Nullable<string>;
  52557. /**
  52558. * Set the compressed texture extensions or file names to skip.
  52559. *
  52560. * @param skippedFiles defines the list of those texture files you want to skip
  52561. * Example: [".dds", ".env", "myfile.png"]
  52562. */
  52563. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52564. /**
  52565. * Set the compressed texture format to use, based on the formats you have, and the formats
  52566. * supported by the hardware / browser.
  52567. *
  52568. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52569. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52570. * to API arguments needed to compressed textures. This puts the burden on the container
  52571. * generator to house the arcane code for determining these for current & future formats.
  52572. *
  52573. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52574. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52575. *
  52576. * Note: The result of this call is not taken into account when a texture is base64.
  52577. *
  52578. * @param formatsAvailable defines the list of those format families you have created
  52579. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52580. *
  52581. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52582. * @returns The extension selected.
  52583. */
  52584. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52585. }
  52586. }
  52587. declare module BABYLON {
  52588. /**
  52589. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52590. */
  52591. export interface CubeMapInfo {
  52592. /**
  52593. * The pixel array for the front face.
  52594. * This is stored in format, left to right, up to down format.
  52595. */
  52596. front: Nullable<ArrayBufferView>;
  52597. /**
  52598. * The pixel array for the back face.
  52599. * This is stored in format, left to right, up to down format.
  52600. */
  52601. back: Nullable<ArrayBufferView>;
  52602. /**
  52603. * The pixel array for the left face.
  52604. * This is stored in format, left to right, up to down format.
  52605. */
  52606. left: Nullable<ArrayBufferView>;
  52607. /**
  52608. * The pixel array for the right face.
  52609. * This is stored in format, left to right, up to down format.
  52610. */
  52611. right: Nullable<ArrayBufferView>;
  52612. /**
  52613. * The pixel array for the up face.
  52614. * This is stored in format, left to right, up to down format.
  52615. */
  52616. up: Nullable<ArrayBufferView>;
  52617. /**
  52618. * The pixel array for the down face.
  52619. * This is stored in format, left to right, up to down format.
  52620. */
  52621. down: Nullable<ArrayBufferView>;
  52622. /**
  52623. * The size of the cubemap stored.
  52624. *
  52625. * Each faces will be size * size pixels.
  52626. */
  52627. size: number;
  52628. /**
  52629. * The format of the texture.
  52630. *
  52631. * RGBA, RGB.
  52632. */
  52633. format: number;
  52634. /**
  52635. * The type of the texture data.
  52636. *
  52637. * UNSIGNED_INT, FLOAT.
  52638. */
  52639. type: number;
  52640. /**
  52641. * Specifies whether the texture is in gamma space.
  52642. */
  52643. gammaSpace: boolean;
  52644. }
  52645. /**
  52646. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52647. */
  52648. export class PanoramaToCubeMapTools {
  52649. private static FACE_LEFT;
  52650. private static FACE_RIGHT;
  52651. private static FACE_FRONT;
  52652. private static FACE_BACK;
  52653. private static FACE_DOWN;
  52654. private static FACE_UP;
  52655. /**
  52656. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52657. *
  52658. * @param float32Array The source data.
  52659. * @param inputWidth The width of the input panorama.
  52660. * @param inputHeight The height of the input panorama.
  52661. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52662. * @return The cubemap data
  52663. */
  52664. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52665. private static CreateCubemapTexture;
  52666. private static CalcProjectionSpherical;
  52667. }
  52668. }
  52669. declare module BABYLON {
  52670. /**
  52671. * Helper class dealing with the extraction of spherical polynomial dataArray
  52672. * from a cube map.
  52673. */
  52674. export class CubeMapToSphericalPolynomialTools {
  52675. private static FileFaces;
  52676. /**
  52677. * Converts a texture to the according Spherical Polynomial data.
  52678. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52679. *
  52680. * @param texture The texture to extract the information from.
  52681. * @return The Spherical Polynomial data.
  52682. */
  52683. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52684. /**
  52685. * Converts a cubemap to the according Spherical Polynomial data.
  52686. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52687. *
  52688. * @param cubeInfo The Cube map to extract the information from.
  52689. * @return The Spherical Polynomial data.
  52690. */
  52691. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52692. }
  52693. }
  52694. declare module BABYLON {
  52695. interface BaseTexture {
  52696. /**
  52697. * Get the polynomial representation of the texture data.
  52698. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52699. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52700. */
  52701. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52702. }
  52703. }
  52704. declare module BABYLON {
  52705. /** @hidden */
  52706. export var rgbdEncodePixelShader: {
  52707. name: string;
  52708. shader: string;
  52709. };
  52710. }
  52711. declare module BABYLON {
  52712. /** @hidden */
  52713. export var rgbdDecodePixelShader: {
  52714. name: string;
  52715. shader: string;
  52716. };
  52717. }
  52718. declare module BABYLON {
  52719. /**
  52720. * Raw texture data and descriptor sufficient for WebGL texture upload
  52721. */
  52722. export interface EnvironmentTextureInfo {
  52723. /**
  52724. * Version of the environment map
  52725. */
  52726. version: number;
  52727. /**
  52728. * Width of image
  52729. */
  52730. width: number;
  52731. /**
  52732. * Irradiance information stored in the file.
  52733. */
  52734. irradiance: any;
  52735. /**
  52736. * Specular information stored in the file.
  52737. */
  52738. specular: any;
  52739. }
  52740. /**
  52741. * Defines One Image in the file. It requires only the position in the file
  52742. * as well as the length.
  52743. */
  52744. interface BufferImageData {
  52745. /**
  52746. * Length of the image data.
  52747. */
  52748. length: number;
  52749. /**
  52750. * Position of the data from the null terminator delimiting the end of the JSON.
  52751. */
  52752. position: number;
  52753. }
  52754. /**
  52755. * Defines the specular data enclosed in the file.
  52756. * This corresponds to the version 1 of the data.
  52757. */
  52758. export interface EnvironmentTextureSpecularInfoV1 {
  52759. /**
  52760. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52761. */
  52762. specularDataPosition?: number;
  52763. /**
  52764. * This contains all the images data needed to reconstruct the cubemap.
  52765. */
  52766. mipmaps: Array<BufferImageData>;
  52767. /**
  52768. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52769. */
  52770. lodGenerationScale: number;
  52771. }
  52772. /**
  52773. * Sets of helpers addressing the serialization and deserialization of environment texture
  52774. * stored in a BabylonJS env file.
  52775. * Those files are usually stored as .env files.
  52776. */
  52777. export class EnvironmentTextureTools {
  52778. /**
  52779. * Magic number identifying the env file.
  52780. */
  52781. private static _MagicBytes;
  52782. /**
  52783. * Gets the environment info from an env file.
  52784. * @param data The array buffer containing the .env bytes.
  52785. * @returns the environment file info (the json header) if successfully parsed.
  52786. */
  52787. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52788. /**
  52789. * Creates an environment texture from a loaded cube texture.
  52790. * @param texture defines the cube texture to convert in env file
  52791. * @return a promise containing the environment data if succesfull.
  52792. */
  52793. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52794. /**
  52795. * Creates a JSON representation of the spherical data.
  52796. * @param texture defines the texture containing the polynomials
  52797. * @return the JSON representation of the spherical info
  52798. */
  52799. private static _CreateEnvTextureIrradiance;
  52800. /**
  52801. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52802. * @param data the image data
  52803. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52804. * @return the views described by info providing access to the underlying buffer
  52805. */
  52806. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52807. /**
  52808. * Uploads the texture info contained in the env file to the GPU.
  52809. * @param texture defines the internal texture to upload to
  52810. * @param data defines the data to load
  52811. * @param info defines the texture info retrieved through the GetEnvInfo method
  52812. * @returns a promise
  52813. */
  52814. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52815. private static _OnImageReadyAsync;
  52816. /**
  52817. * Uploads the levels of image data to the GPU.
  52818. * @param texture defines the internal texture to upload to
  52819. * @param imageData defines the array buffer views of image data [mipmap][face]
  52820. * @returns a promise
  52821. */
  52822. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52823. /**
  52824. * Uploads spherical polynomials information to the texture.
  52825. * @param texture defines the texture we are trying to upload the information to
  52826. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52827. */
  52828. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52829. /** @hidden */
  52830. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52831. }
  52832. }
  52833. declare module BABYLON {
  52834. /**
  52835. * Class used to inline functions in shader code
  52836. */
  52837. export class ShaderCodeInliner {
  52838. private static readonly _RegexpFindFunctionNameAndType;
  52839. private _sourceCode;
  52840. private _functionDescr;
  52841. private _numMaxIterations;
  52842. /** Gets or sets the token used to mark the functions to inline */
  52843. inlineToken: string;
  52844. /** Gets or sets the debug mode */
  52845. debug: boolean;
  52846. /** Gets the code after the inlining process */
  52847. get code(): string;
  52848. /**
  52849. * Initializes the inliner
  52850. * @param sourceCode shader code source to inline
  52851. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52852. */
  52853. constructor(sourceCode: string, numMaxIterations?: number);
  52854. /**
  52855. * Start the processing of the shader code
  52856. */
  52857. processCode(): void;
  52858. private _collectFunctions;
  52859. private _processInlining;
  52860. private _extractBetweenMarkers;
  52861. private _skipWhitespaces;
  52862. private _removeComments;
  52863. private _replaceFunctionCallsByCode;
  52864. private _findBackward;
  52865. private _escapeRegExp;
  52866. private _replaceNames;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Container for accessors for natively-stored mesh data buffers.
  52872. */
  52873. class NativeDataBuffer extends DataBuffer {
  52874. /**
  52875. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52876. */
  52877. nativeIndexBuffer?: any;
  52878. /**
  52879. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52880. */
  52881. nativeVertexBuffer?: any;
  52882. }
  52883. /** @hidden */
  52884. class NativeTexture extends InternalTexture {
  52885. getInternalTexture(): InternalTexture;
  52886. getViewCount(): number;
  52887. }
  52888. /** @hidden */
  52889. export class NativeEngine extends Engine {
  52890. private readonly _native;
  52891. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52892. private readonly INVALID_HANDLE;
  52893. private _boundBuffersVertexArray;
  52894. private _currentDepthTest;
  52895. getHardwareScalingLevel(): number;
  52896. constructor();
  52897. dispose(): void;
  52898. /**
  52899. * Can be used to override the current requestAnimationFrame requester.
  52900. * @hidden
  52901. */
  52902. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52903. /**
  52904. * Override default engine behavior.
  52905. * @param color
  52906. * @param backBuffer
  52907. * @param depth
  52908. * @param stencil
  52909. */
  52910. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52911. /**
  52912. * Gets host document
  52913. * @returns the host document object
  52914. */
  52915. getHostDocument(): Nullable<Document>;
  52916. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52917. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52918. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52919. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52920. [key: string]: VertexBuffer;
  52921. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52922. bindBuffers(vertexBuffers: {
  52923. [key: string]: VertexBuffer;
  52924. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52925. recordVertexArrayObject(vertexBuffers: {
  52926. [key: string]: VertexBuffer;
  52927. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52928. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52929. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52931. /**
  52932. * Draw a list of indexed primitives
  52933. * @param fillMode defines the primitive to use
  52934. * @param indexStart defines the starting index
  52935. * @param indexCount defines the number of index to draw
  52936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52937. */
  52938. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52939. /**
  52940. * Draw a list of unindexed primitives
  52941. * @param fillMode defines the primitive to use
  52942. * @param verticesStart defines the index of first vertex to draw
  52943. * @param verticesCount defines the count of vertices to draw
  52944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52945. */
  52946. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52947. createPipelineContext(): IPipelineContext;
  52948. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52949. /** @hidden */
  52950. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52951. /** @hidden */
  52952. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52953. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52954. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52955. protected _setProgram(program: WebGLProgram): void;
  52956. _releaseEffect(effect: Effect): void;
  52957. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52958. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52959. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52960. bindSamplers(effect: Effect): void;
  52961. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52962. getRenderWidth(useScreen?: boolean): number;
  52963. getRenderHeight(useScreen?: boolean): number;
  52964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52966. /**
  52967. * Set the z offset to apply to current rendering
  52968. * @param value defines the offset to apply
  52969. */
  52970. setZOffset(value: number): void;
  52971. /**
  52972. * Gets the current value of the zOffset
  52973. * @returns the current zOffset state
  52974. */
  52975. getZOffset(): number;
  52976. /**
  52977. * Enable or disable depth buffering
  52978. * @param enable defines the state to set
  52979. */
  52980. setDepthBuffer(enable: boolean): void;
  52981. /**
  52982. * Gets a boolean indicating if depth writing is enabled
  52983. * @returns the current depth writing state
  52984. */
  52985. getDepthWrite(): boolean;
  52986. setDepthFunctionToGreater(): void;
  52987. setDepthFunctionToGreaterOrEqual(): void;
  52988. setDepthFunctionToLess(): void;
  52989. setDepthFunctionToLessOrEqual(): void;
  52990. /**
  52991. * Enable or disable depth writing
  52992. * @param enable defines the state to set
  52993. */
  52994. setDepthWrite(enable: boolean): void;
  52995. /**
  52996. * Enable or disable color writing
  52997. * @param enable defines the state to set
  52998. */
  52999. setColorWrite(enable: boolean): void;
  53000. /**
  53001. * Gets a boolean indicating if color writing is enabled
  53002. * @returns the current color writing state
  53003. */
  53004. getColorWrite(): boolean;
  53005. /**
  53006. * Sets alpha constants used by some alpha blending modes
  53007. * @param r defines the red component
  53008. * @param g defines the green component
  53009. * @param b defines the blue component
  53010. * @param a defines the alpha component
  53011. */
  53012. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53013. /**
  53014. * Sets the current alpha mode
  53015. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53016. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53017. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53018. */
  53019. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53020. /**
  53021. * Gets the current alpha mode
  53022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53023. * @returns the current alpha mode
  53024. */
  53025. getAlphaMode(): number;
  53026. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  53027. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53028. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53029. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53030. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53031. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53032. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53033. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53034. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53035. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  53036. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  53037. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  53038. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  53039. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  53040. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53041. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53042. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  53043. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  53044. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  53045. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  53046. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  53047. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  53048. wipeCaches(bruteForce?: boolean): void;
  53049. _createTexture(): WebGLTexture;
  53050. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53051. /**
  53052. * Usually called from Texture.ts.
  53053. * Passed information to create a WebGLTexture
  53054. * @param url defines a value which contains one of the following:
  53055. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53056. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53057. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53058. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53059. * @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)
  53060. * @param scene needed for loading to the correct scene
  53061. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53062. * @param onLoad optional callback to be called upon successful completion
  53063. * @param onError optional callback to be called upon failure
  53064. * @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
  53065. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53066. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53067. * @param forcedExtension defines the extension to use to pick the right loader
  53068. * @param mimeType defines an optional mime type
  53069. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53070. */
  53071. 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;
  53072. /**
  53073. * Creates a cube texture
  53074. * @param rootUrl defines the url where the files to load is located
  53075. * @param scene defines the current scene
  53076. * @param files defines the list of files to load (1 per face)
  53077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53078. * @param onLoad defines an optional callback raised when the texture is loaded
  53079. * @param onError defines an optional callback raised if there is an issue to load the texture
  53080. * @param format defines the format of the data
  53081. * @param forcedExtension defines the extension to use to pick the right loader
  53082. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53083. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53084. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53085. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53086. * @returns the cube texture as an InternalTexture
  53087. */
  53088. 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;
  53089. private _getSamplingFilter;
  53090. private static _GetNativeTextureFormat;
  53091. createRenderTargetTexture(size: number | {
  53092. width: number;
  53093. height: number;
  53094. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53095. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53096. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53097. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53098. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53099. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53100. /**
  53101. * Updates a dynamic vertex buffer.
  53102. * @param vertexBuffer the vertex buffer to update
  53103. * @param data the data used to update the vertex buffer
  53104. * @param byteOffset the byte offset of the data (optional)
  53105. * @param byteLength the byte length of the data (optional)
  53106. */
  53107. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53108. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53109. private _updateAnisotropicLevel;
  53110. private _getAddressMode;
  53111. /** @hidden */
  53112. _bindTexture(channel: number, texture: InternalTexture): void;
  53113. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53114. releaseEffects(): void;
  53115. /** @hidden */
  53116. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53117. /** @hidden */
  53118. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53119. /** @hidden */
  53120. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53121. /** @hidden */
  53122. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53123. }
  53124. }
  53125. declare module BABYLON {
  53126. /**
  53127. * Gather the list of clipboard event types as constants.
  53128. */
  53129. export class ClipboardEventTypes {
  53130. /**
  53131. * The clipboard event is fired when a copy command is active (pressed).
  53132. */
  53133. static readonly COPY: number;
  53134. /**
  53135. * The clipboard event is fired when a cut command is active (pressed).
  53136. */
  53137. static readonly CUT: number;
  53138. /**
  53139. * The clipboard event is fired when a paste command is active (pressed).
  53140. */
  53141. static readonly PASTE: number;
  53142. }
  53143. /**
  53144. * This class is used to store clipboard related info for the onClipboardObservable event.
  53145. */
  53146. export class ClipboardInfo {
  53147. /**
  53148. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53149. */
  53150. type: number;
  53151. /**
  53152. * Defines the related dom event
  53153. */
  53154. event: ClipboardEvent;
  53155. /**
  53156. *Creates an instance of ClipboardInfo.
  53157. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53158. * @param event Defines the related dom event
  53159. */
  53160. constructor(
  53161. /**
  53162. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53163. */
  53164. type: number,
  53165. /**
  53166. * Defines the related dom event
  53167. */
  53168. event: ClipboardEvent);
  53169. /**
  53170. * Get the clipboard event's type from the keycode.
  53171. * @param keyCode Defines the keyCode for the current keyboard event.
  53172. * @return {number}
  53173. */
  53174. static GetTypeFromCharacter(keyCode: number): number;
  53175. }
  53176. }
  53177. declare module BABYLON {
  53178. /**
  53179. * Google Daydream controller
  53180. */
  53181. export class DaydreamController extends WebVRController {
  53182. /**
  53183. * Base Url for the controller model.
  53184. */
  53185. static MODEL_BASE_URL: string;
  53186. /**
  53187. * File name for the controller model.
  53188. */
  53189. static MODEL_FILENAME: string;
  53190. /**
  53191. * Gamepad Id prefix used to identify Daydream Controller.
  53192. */
  53193. static readonly GAMEPAD_ID_PREFIX: string;
  53194. /**
  53195. * Creates a new DaydreamController from a gamepad
  53196. * @param vrGamepad the gamepad that the controller should be created from
  53197. */
  53198. constructor(vrGamepad: any);
  53199. /**
  53200. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53201. * @param scene scene in which to add meshes
  53202. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53203. */
  53204. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53205. /**
  53206. * Called once for each button that changed state since the last frame
  53207. * @param buttonIdx Which button index changed
  53208. * @param state New state of the button
  53209. * @param changes Which properties on the state changed since last frame
  53210. */
  53211. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Gear VR Controller
  53217. */
  53218. export class GearVRController extends WebVRController {
  53219. /**
  53220. * Base Url for the controller model.
  53221. */
  53222. static MODEL_BASE_URL: string;
  53223. /**
  53224. * File name for the controller model.
  53225. */
  53226. static MODEL_FILENAME: string;
  53227. /**
  53228. * Gamepad Id prefix used to identify this controller.
  53229. */
  53230. static readonly GAMEPAD_ID_PREFIX: string;
  53231. private readonly _buttonIndexToObservableNameMap;
  53232. /**
  53233. * Creates a new GearVRController from a gamepad
  53234. * @param vrGamepad the gamepad that the controller should be created from
  53235. */
  53236. constructor(vrGamepad: any);
  53237. /**
  53238. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53239. * @param scene scene in which to add meshes
  53240. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53241. */
  53242. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53243. /**
  53244. * Called once for each button that changed state since the last frame
  53245. * @param buttonIdx Which button index changed
  53246. * @param state New state of the button
  53247. * @param changes Which properties on the state changed since last frame
  53248. */
  53249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53250. }
  53251. }
  53252. declare module BABYLON {
  53253. /**
  53254. * Generic Controller
  53255. */
  53256. export class GenericController extends WebVRController {
  53257. /**
  53258. * Base Url for the controller model.
  53259. */
  53260. static readonly MODEL_BASE_URL: string;
  53261. /**
  53262. * File name for the controller model.
  53263. */
  53264. static readonly MODEL_FILENAME: string;
  53265. /**
  53266. * Creates a new GenericController from a gamepad
  53267. * @param vrGamepad the gamepad that the controller should be created from
  53268. */
  53269. constructor(vrGamepad: any);
  53270. /**
  53271. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53272. * @param scene scene in which to add meshes
  53273. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53274. */
  53275. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53276. /**
  53277. * Called once for each button that changed state since the last frame
  53278. * @param buttonIdx Which button index changed
  53279. * @param state New state of the button
  53280. * @param changes Which properties on the state changed since last frame
  53281. */
  53282. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53283. }
  53284. }
  53285. declare module BABYLON {
  53286. /**
  53287. * Oculus Touch Controller
  53288. */
  53289. export class OculusTouchController extends WebVRController {
  53290. /**
  53291. * Base Url for the controller model.
  53292. */
  53293. static MODEL_BASE_URL: string;
  53294. /**
  53295. * File name for the left controller model.
  53296. */
  53297. static MODEL_LEFT_FILENAME: string;
  53298. /**
  53299. * File name for the right controller model.
  53300. */
  53301. static MODEL_RIGHT_FILENAME: string;
  53302. /**
  53303. * Base Url for the Quest controller model.
  53304. */
  53305. static QUEST_MODEL_BASE_URL: string;
  53306. /**
  53307. * @hidden
  53308. * If the controllers are running on a device that needs the updated Quest controller models
  53309. */
  53310. static _IsQuest: boolean;
  53311. /**
  53312. * Fired when the secondary trigger on this controller is modified
  53313. */
  53314. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53315. /**
  53316. * Fired when the thumb rest on this controller is modified
  53317. */
  53318. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53319. /**
  53320. * Creates a new OculusTouchController from a gamepad
  53321. * @param vrGamepad the gamepad that the controller should be created from
  53322. */
  53323. constructor(vrGamepad: any);
  53324. /**
  53325. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53326. * @param scene scene in which to add meshes
  53327. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53328. */
  53329. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53330. /**
  53331. * Fired when the A button on this controller is modified
  53332. */
  53333. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53334. /**
  53335. * Fired when the B button on this controller is modified
  53336. */
  53337. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53338. /**
  53339. * Fired when the X button on this controller is modified
  53340. */
  53341. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53342. /**
  53343. * Fired when the Y button on this controller is modified
  53344. */
  53345. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53346. /**
  53347. * Called once for each button that changed state since the last frame
  53348. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53349. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53350. * 2) secondary trigger (same)
  53351. * 3) A (right) X (left), touch, pressed = value
  53352. * 4) B / Y
  53353. * 5) thumb rest
  53354. * @param buttonIdx Which button index changed
  53355. * @param state New state of the button
  53356. * @param changes Which properties on the state changed since last frame
  53357. */
  53358. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53359. }
  53360. }
  53361. declare module BABYLON {
  53362. /**
  53363. * Vive Controller
  53364. */
  53365. export class ViveController extends WebVRController {
  53366. /**
  53367. * Base Url for the controller model.
  53368. */
  53369. static MODEL_BASE_URL: string;
  53370. /**
  53371. * File name for the controller model.
  53372. */
  53373. static MODEL_FILENAME: string;
  53374. /**
  53375. * Creates a new ViveController from a gamepad
  53376. * @param vrGamepad the gamepad that the controller should be created from
  53377. */
  53378. constructor(vrGamepad: any);
  53379. /**
  53380. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53381. * @param scene scene in which to add meshes
  53382. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53383. */
  53384. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53385. /**
  53386. * Fired when the left button on this controller is modified
  53387. */
  53388. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53389. /**
  53390. * Fired when the right button on this controller is modified
  53391. */
  53392. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53393. /**
  53394. * Fired when the menu button on this controller is modified
  53395. */
  53396. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53397. /**
  53398. * Called once for each button that changed state since the last frame
  53399. * Vive mapping:
  53400. * 0: touchpad
  53401. * 1: trigger
  53402. * 2: left AND right buttons
  53403. * 3: menu button
  53404. * @param buttonIdx Which button index changed
  53405. * @param state New state of the button
  53406. * @param changes Which properties on the state changed since last frame
  53407. */
  53408. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53409. }
  53410. }
  53411. declare module BABYLON {
  53412. /**
  53413. * Defines the WindowsMotionController object that the state of the windows motion controller
  53414. */
  53415. export class WindowsMotionController extends WebVRController {
  53416. /**
  53417. * The base url used to load the left and right controller models
  53418. */
  53419. static MODEL_BASE_URL: string;
  53420. /**
  53421. * The name of the left controller model file
  53422. */
  53423. static MODEL_LEFT_FILENAME: string;
  53424. /**
  53425. * The name of the right controller model file
  53426. */
  53427. static MODEL_RIGHT_FILENAME: string;
  53428. /**
  53429. * The controller name prefix for this controller type
  53430. */
  53431. static readonly GAMEPAD_ID_PREFIX: string;
  53432. /**
  53433. * The controller id pattern for this controller type
  53434. */
  53435. private static readonly GAMEPAD_ID_PATTERN;
  53436. private _loadedMeshInfo;
  53437. protected readonly _mapping: {
  53438. buttons: string[];
  53439. buttonMeshNames: {
  53440. trigger: string;
  53441. menu: string;
  53442. grip: string;
  53443. thumbstick: string;
  53444. trackpad: string;
  53445. };
  53446. buttonObservableNames: {
  53447. trigger: string;
  53448. menu: string;
  53449. grip: string;
  53450. thumbstick: string;
  53451. trackpad: string;
  53452. };
  53453. axisMeshNames: string[];
  53454. pointingPoseMeshName: string;
  53455. };
  53456. /**
  53457. * Fired when the trackpad on this controller is clicked
  53458. */
  53459. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53460. /**
  53461. * Fired when the trackpad on this controller is modified
  53462. */
  53463. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53464. /**
  53465. * The current x and y values of this controller's trackpad
  53466. */
  53467. trackpad: StickValues;
  53468. /**
  53469. * Creates a new WindowsMotionController from a gamepad
  53470. * @param vrGamepad the gamepad that the controller should be created from
  53471. */
  53472. constructor(vrGamepad: any);
  53473. /**
  53474. * Fired when the trigger on this controller is modified
  53475. */
  53476. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53477. /**
  53478. * Fired when the menu button on this controller is modified
  53479. */
  53480. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53481. /**
  53482. * Fired when the grip button on this controller is modified
  53483. */
  53484. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53485. /**
  53486. * Fired when the thumbstick button on this controller is modified
  53487. */
  53488. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53489. /**
  53490. * Fired when the touchpad button on this controller is modified
  53491. */
  53492. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53493. /**
  53494. * Fired when the touchpad values on this controller are modified
  53495. */
  53496. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53497. protected _updateTrackpad(): void;
  53498. /**
  53499. * Called once per frame by the engine.
  53500. */
  53501. update(): void;
  53502. /**
  53503. * Called once for each button that changed state since the last frame
  53504. * @param buttonIdx Which button index changed
  53505. * @param state New state of the button
  53506. * @param changes Which properties on the state changed since last frame
  53507. */
  53508. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53509. /**
  53510. * Moves the buttons on the controller mesh based on their current state
  53511. * @param buttonName the name of the button to move
  53512. * @param buttonValue the value of the button which determines the buttons new position
  53513. */
  53514. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53515. /**
  53516. * Moves the axis on the controller mesh based on its current state
  53517. * @param axis the index of the axis
  53518. * @param axisValue the value of the axis which determines the meshes new position
  53519. * @hidden
  53520. */
  53521. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53522. /**
  53523. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53524. * @param scene scene in which to add meshes
  53525. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53526. */
  53527. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53528. /**
  53529. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53530. * can be transformed by button presses and axes values, based on this._mapping.
  53531. *
  53532. * @param scene scene in which the meshes exist
  53533. * @param meshes list of meshes that make up the controller model to process
  53534. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53535. */
  53536. private processModel;
  53537. private createMeshInfo;
  53538. /**
  53539. * Gets the ray of the controller in the direction the controller is pointing
  53540. * @param length the length the resulting ray should be
  53541. * @returns a ray in the direction the controller is pointing
  53542. */
  53543. getForwardRay(length?: number): Ray;
  53544. /**
  53545. * Disposes of the controller
  53546. */
  53547. dispose(): void;
  53548. }
  53549. /**
  53550. * This class represents a new windows motion controller in XR.
  53551. */
  53552. export class XRWindowsMotionController extends WindowsMotionController {
  53553. /**
  53554. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53555. */
  53556. protected readonly _mapping: {
  53557. buttons: string[];
  53558. buttonMeshNames: {
  53559. trigger: string;
  53560. menu: string;
  53561. grip: string;
  53562. thumbstick: string;
  53563. trackpad: string;
  53564. };
  53565. buttonObservableNames: {
  53566. trigger: string;
  53567. menu: string;
  53568. grip: string;
  53569. thumbstick: string;
  53570. trackpad: string;
  53571. };
  53572. axisMeshNames: string[];
  53573. pointingPoseMeshName: string;
  53574. };
  53575. /**
  53576. * Construct a new XR-Based windows motion controller
  53577. *
  53578. * @param gamepadInfo the gamepad object from the browser
  53579. */
  53580. constructor(gamepadInfo: any);
  53581. /**
  53582. * holds the thumbstick values (X,Y)
  53583. */
  53584. thumbstickValues: StickValues;
  53585. /**
  53586. * Fired when the thumbstick on this controller is clicked
  53587. */
  53588. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53589. /**
  53590. * Fired when the thumbstick on this controller is modified
  53591. */
  53592. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53593. /**
  53594. * Fired when the touchpad button on this controller is modified
  53595. */
  53596. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53597. /**
  53598. * Fired when the touchpad values on this controller are modified
  53599. */
  53600. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53601. /**
  53602. * Fired when the thumbstick button on this controller is modified
  53603. * here to prevent breaking changes
  53604. */
  53605. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53606. /**
  53607. * updating the thumbstick(!) and not the trackpad.
  53608. * This is named this way due to the difference between WebVR and XR and to avoid
  53609. * changing the parent class.
  53610. */
  53611. protected _updateTrackpad(): void;
  53612. /**
  53613. * Disposes the class with joy
  53614. */
  53615. dispose(): void;
  53616. }
  53617. }
  53618. declare module BABYLON {
  53619. /**
  53620. * Class containing static functions to help procedurally build meshes
  53621. */
  53622. export class PolyhedronBuilder {
  53623. /**
  53624. * Creates a polyhedron mesh
  53625. * * 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
  53626. * * The parameter `size` (positive float, default 1) sets the polygon size
  53627. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53628. * * 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`
  53629. * * 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
  53630. * * 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)`)
  53631. * * 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
  53632. * * 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
  53633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53634. * * 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
  53635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53636. * @param name defines the name of the mesh
  53637. * @param options defines the options used to create the mesh
  53638. * @param scene defines the hosting scene
  53639. * @returns the polyhedron mesh
  53640. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53641. */
  53642. static CreatePolyhedron(name: string, options: {
  53643. type?: number;
  53644. size?: number;
  53645. sizeX?: number;
  53646. sizeY?: number;
  53647. sizeZ?: number;
  53648. custom?: any;
  53649. faceUV?: Vector4[];
  53650. faceColors?: Color4[];
  53651. flat?: boolean;
  53652. updatable?: boolean;
  53653. sideOrientation?: number;
  53654. frontUVs?: Vector4;
  53655. backUVs?: Vector4;
  53656. }, scene?: Nullable<Scene>): Mesh;
  53657. }
  53658. }
  53659. declare module BABYLON {
  53660. /**
  53661. * Gizmo that enables scaling a mesh along 3 axis
  53662. */
  53663. export class ScaleGizmo extends Gizmo {
  53664. /**
  53665. * Internal gizmo used for interactions on the x axis
  53666. */
  53667. xGizmo: AxisScaleGizmo;
  53668. /**
  53669. * Internal gizmo used for interactions on the y axis
  53670. */
  53671. yGizmo: AxisScaleGizmo;
  53672. /**
  53673. * Internal gizmo used for interactions on the z axis
  53674. */
  53675. zGizmo: AxisScaleGizmo;
  53676. /**
  53677. * Internal gizmo used to scale all axis equally
  53678. */
  53679. uniformScaleGizmo: AxisScaleGizmo;
  53680. private _meshAttached;
  53681. private _nodeAttached;
  53682. private _snapDistance;
  53683. private _uniformScalingMesh;
  53684. private _octahedron;
  53685. private _sensitivity;
  53686. /** Fires an event when any of it's sub gizmos are dragged */
  53687. onDragStartObservable: Observable<unknown>;
  53688. /** Fires an event when any of it's sub gizmos are released from dragging */
  53689. onDragEndObservable: Observable<unknown>;
  53690. get attachedMesh(): Nullable<AbstractMesh>;
  53691. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53692. get attachedNode(): Nullable<Node>;
  53693. set attachedNode(node: Nullable<Node>);
  53694. /**
  53695. * True when the mouse pointer is hovering a gizmo mesh
  53696. */
  53697. get isHovered(): boolean;
  53698. /**
  53699. * Creates a ScaleGizmo
  53700. * @param gizmoLayer The utility layer the gizmo will be added to
  53701. * @param thickness display gizmo axis thickness
  53702. */
  53703. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53704. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53705. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53706. /**
  53707. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53708. */
  53709. set snapDistance(value: number);
  53710. get snapDistance(): number;
  53711. /**
  53712. * Ratio for the scale of the gizmo (Default: 1)
  53713. */
  53714. set scaleRatio(value: number);
  53715. get scaleRatio(): number;
  53716. /**
  53717. * Sensitivity factor for dragging (Default: 1)
  53718. */
  53719. set sensitivity(value: number);
  53720. get sensitivity(): number;
  53721. /**
  53722. * Disposes of the gizmo
  53723. */
  53724. dispose(): void;
  53725. }
  53726. }
  53727. declare module BABYLON {
  53728. /**
  53729. * Single axis scale gizmo
  53730. */
  53731. export class AxisScaleGizmo extends Gizmo {
  53732. /**
  53733. * Drag behavior responsible for the gizmos dragging interactions
  53734. */
  53735. dragBehavior: PointerDragBehavior;
  53736. private _pointerObserver;
  53737. /**
  53738. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53739. */
  53740. snapDistance: number;
  53741. /**
  53742. * Event that fires each time the gizmo snaps to a new location.
  53743. * * snapDistance is the the change in distance
  53744. */
  53745. onSnapObservable: Observable<{
  53746. snapDistance: number;
  53747. }>;
  53748. /**
  53749. * If the scaling operation should be done on all axis (default: false)
  53750. */
  53751. uniformScaling: boolean;
  53752. /**
  53753. * Custom sensitivity value for the drag strength
  53754. */
  53755. sensitivity: number;
  53756. private _isEnabled;
  53757. private _parent;
  53758. private _arrow;
  53759. private _coloredMaterial;
  53760. private _hoverMaterial;
  53761. /**
  53762. * Creates an AxisScaleGizmo
  53763. * @param gizmoLayer The utility layer the gizmo will be added to
  53764. * @param dragAxis The axis which the gizmo will be able to scale on
  53765. * @param color The color of the gizmo
  53766. * @param thickness display gizmo axis thickness
  53767. */
  53768. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53769. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53770. /**
  53771. * If the gizmo is enabled
  53772. */
  53773. set isEnabled(value: boolean);
  53774. get isEnabled(): boolean;
  53775. /**
  53776. * Disposes of the gizmo
  53777. */
  53778. dispose(): void;
  53779. /**
  53780. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53781. * @param mesh The mesh to replace the default mesh of the gizmo
  53782. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53783. */
  53784. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53785. }
  53786. }
  53787. declare module BABYLON {
  53788. /**
  53789. * Bounding box gizmo
  53790. */
  53791. export class BoundingBoxGizmo extends Gizmo {
  53792. private _lineBoundingBox;
  53793. private _rotateSpheresParent;
  53794. private _scaleBoxesParent;
  53795. private _boundingDimensions;
  53796. private _renderObserver;
  53797. private _pointerObserver;
  53798. private _scaleDragSpeed;
  53799. private _tmpQuaternion;
  53800. private _tmpVector;
  53801. private _tmpRotationMatrix;
  53802. /**
  53803. * 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)
  53804. */
  53805. ignoreChildren: boolean;
  53806. /**
  53807. * 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)
  53808. */
  53809. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53810. /**
  53811. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53812. */
  53813. rotationSphereSize: number;
  53814. /**
  53815. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53816. */
  53817. scaleBoxSize: number;
  53818. /**
  53819. * 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)
  53820. */
  53821. fixedDragMeshScreenSize: boolean;
  53822. /**
  53823. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53824. */
  53825. fixedDragMeshScreenSizeDistanceFactor: number;
  53826. /**
  53827. * Fired when a rotation sphere or scale box is dragged
  53828. */
  53829. onDragStartObservable: Observable<{}>;
  53830. /**
  53831. * Fired when a scale box is dragged
  53832. */
  53833. onScaleBoxDragObservable: Observable<{}>;
  53834. /**
  53835. * Fired when a scale box drag is ended
  53836. */
  53837. onScaleBoxDragEndObservable: Observable<{}>;
  53838. /**
  53839. * Fired when a rotation sphere is dragged
  53840. */
  53841. onRotationSphereDragObservable: Observable<{}>;
  53842. /**
  53843. * Fired when a rotation sphere drag is ended
  53844. */
  53845. onRotationSphereDragEndObservable: Observable<{}>;
  53846. /**
  53847. * 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)
  53848. */
  53849. scalePivot: Nullable<Vector3>;
  53850. /**
  53851. * Mesh used as a pivot to rotate the attached node
  53852. */
  53853. private _anchorMesh;
  53854. private _existingMeshScale;
  53855. private _dragMesh;
  53856. private pointerDragBehavior;
  53857. private coloredMaterial;
  53858. private hoverColoredMaterial;
  53859. /**
  53860. * Sets the color of the bounding box gizmo
  53861. * @param color the color to set
  53862. */
  53863. setColor(color: Color3): void;
  53864. /**
  53865. * Creates an BoundingBoxGizmo
  53866. * @param gizmoLayer The utility layer the gizmo will be added to
  53867. * @param color The color of the gizmo
  53868. */
  53869. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53870. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53871. private _selectNode;
  53872. /**
  53873. * Updates the bounding box information for the Gizmo
  53874. */
  53875. updateBoundingBox(): void;
  53876. private _updateRotationSpheres;
  53877. private _updateScaleBoxes;
  53878. /**
  53879. * Enables rotation on the specified axis and disables rotation on the others
  53880. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53881. */
  53882. setEnabledRotationAxis(axis: string): void;
  53883. /**
  53884. * Enables/disables scaling
  53885. * @param enable if scaling should be enabled
  53886. * @param homogeneousScaling defines if scaling should only be homogeneous
  53887. */
  53888. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53889. private _updateDummy;
  53890. /**
  53891. * Enables a pointer drag behavior on the bounding box of the gizmo
  53892. */
  53893. enableDragBehavior(): void;
  53894. /**
  53895. * Disposes of the gizmo
  53896. */
  53897. dispose(): void;
  53898. /**
  53899. * 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)
  53900. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53901. * @returns the bounding box mesh with the passed in mesh as a child
  53902. */
  53903. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53904. /**
  53905. * CustomMeshes are not supported by this gizmo
  53906. * @param mesh The mesh to replace the default mesh of the gizmo
  53907. */
  53908. setCustomMesh(mesh: Mesh): void;
  53909. }
  53910. }
  53911. declare module BABYLON {
  53912. /**
  53913. * Single plane rotation gizmo
  53914. */
  53915. export class PlaneRotationGizmo extends Gizmo {
  53916. /**
  53917. * Drag behavior responsible for the gizmos dragging interactions
  53918. */
  53919. dragBehavior: PointerDragBehavior;
  53920. private _pointerObserver;
  53921. /**
  53922. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53923. */
  53924. snapDistance: number;
  53925. /**
  53926. * Event that fires each time the gizmo snaps to a new location.
  53927. * * snapDistance is the the change in distance
  53928. */
  53929. onSnapObservable: Observable<{
  53930. snapDistance: number;
  53931. }>;
  53932. private _isEnabled;
  53933. private _parent;
  53934. /**
  53935. * Creates a PlaneRotationGizmo
  53936. * @param gizmoLayer The utility layer the gizmo will be added to
  53937. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53938. * @param color The color of the gizmo
  53939. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53940. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53941. * @param thickness display gizmo axis thickness
  53942. */
  53943. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53944. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53945. /**
  53946. * If the gizmo is enabled
  53947. */
  53948. set isEnabled(value: boolean);
  53949. get isEnabled(): boolean;
  53950. /**
  53951. * Disposes of the gizmo
  53952. */
  53953. dispose(): void;
  53954. }
  53955. }
  53956. declare module BABYLON {
  53957. /**
  53958. * Gizmo that enables rotating a mesh along 3 axis
  53959. */
  53960. export class RotationGizmo extends Gizmo {
  53961. /**
  53962. * Internal gizmo used for interactions on the x axis
  53963. */
  53964. xGizmo: PlaneRotationGizmo;
  53965. /**
  53966. * Internal gizmo used for interactions on the y axis
  53967. */
  53968. yGizmo: PlaneRotationGizmo;
  53969. /**
  53970. * Internal gizmo used for interactions on the z axis
  53971. */
  53972. zGizmo: PlaneRotationGizmo;
  53973. /** Fires an event when any of it's sub gizmos are dragged */
  53974. onDragStartObservable: Observable<unknown>;
  53975. /** Fires an event when any of it's sub gizmos are released from dragging */
  53976. onDragEndObservable: Observable<unknown>;
  53977. private _meshAttached;
  53978. private _nodeAttached;
  53979. get attachedMesh(): Nullable<AbstractMesh>;
  53980. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53981. get attachedNode(): Nullable<Node>;
  53982. set attachedNode(node: Nullable<Node>);
  53983. /**
  53984. * True when the mouse pointer is hovering a gizmo mesh
  53985. */
  53986. get isHovered(): boolean;
  53987. /**
  53988. * Creates a RotationGizmo
  53989. * @param gizmoLayer The utility layer the gizmo will be added to
  53990. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53991. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53992. * @param thickness display gizmo axis thickness
  53993. */
  53994. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53995. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53996. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53997. /**
  53998. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53999. */
  54000. set snapDistance(value: number);
  54001. get snapDistance(): number;
  54002. /**
  54003. * Ratio for the scale of the gizmo (Default: 1)
  54004. */
  54005. set scaleRatio(value: number);
  54006. get scaleRatio(): number;
  54007. /**
  54008. * Disposes of the gizmo
  54009. */
  54010. dispose(): void;
  54011. /**
  54012. * CustomMeshes are not supported by this gizmo
  54013. * @param mesh The mesh to replace the default mesh of the gizmo
  54014. */
  54015. setCustomMesh(mesh: Mesh): void;
  54016. }
  54017. }
  54018. declare module BABYLON {
  54019. /**
  54020. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54021. */
  54022. export class GizmoManager implements IDisposable {
  54023. private scene;
  54024. /**
  54025. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54026. */
  54027. gizmos: {
  54028. positionGizmo: Nullable<PositionGizmo>;
  54029. rotationGizmo: Nullable<RotationGizmo>;
  54030. scaleGizmo: Nullable<ScaleGizmo>;
  54031. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54032. };
  54033. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54034. clearGizmoOnEmptyPointerEvent: boolean;
  54035. /** Fires an event when the manager is attached to a mesh */
  54036. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54037. /** Fires an event when the manager is attached to a node */
  54038. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54039. private _gizmosEnabled;
  54040. private _pointerObserver;
  54041. private _attachedMesh;
  54042. private _attachedNode;
  54043. private _boundingBoxColor;
  54044. private _defaultUtilityLayer;
  54045. private _defaultKeepDepthUtilityLayer;
  54046. private _thickness;
  54047. /**
  54048. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54049. */
  54050. boundingBoxDragBehavior: SixDofDragBehavior;
  54051. /**
  54052. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54053. */
  54054. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54055. /**
  54056. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54057. */
  54058. attachableNodes: Nullable<Array<Node>>;
  54059. /**
  54060. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54061. */
  54062. usePointerToAttachGizmos: boolean;
  54063. /**
  54064. * Utility layer that the bounding box gizmo belongs to
  54065. */
  54066. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54067. /**
  54068. * Utility layer that all gizmos besides bounding box belong to
  54069. */
  54070. get utilityLayer(): UtilityLayerRenderer;
  54071. /**
  54072. * True when the mouse pointer is hovering a gizmo mesh
  54073. */
  54074. get isHovered(): boolean;
  54075. /**
  54076. * Instatiates a gizmo manager
  54077. * @param scene the scene to overlay the gizmos on top of
  54078. * @param thickness display gizmo axis thickness
  54079. */
  54080. constructor(scene: Scene, thickness?: number);
  54081. /**
  54082. * Attaches a set of gizmos to the specified mesh
  54083. * @param mesh The mesh the gizmo's should be attached to
  54084. */
  54085. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54086. /**
  54087. * Attaches a set of gizmos to the specified node
  54088. * @param node The node the gizmo's should be attached to
  54089. */
  54090. attachToNode(node: Nullable<Node>): void;
  54091. /**
  54092. * If the position gizmo is enabled
  54093. */
  54094. set positionGizmoEnabled(value: boolean);
  54095. get positionGizmoEnabled(): boolean;
  54096. /**
  54097. * If the rotation gizmo is enabled
  54098. */
  54099. set rotationGizmoEnabled(value: boolean);
  54100. get rotationGizmoEnabled(): boolean;
  54101. /**
  54102. * If the scale gizmo is enabled
  54103. */
  54104. set scaleGizmoEnabled(value: boolean);
  54105. get scaleGizmoEnabled(): boolean;
  54106. /**
  54107. * If the boundingBox gizmo is enabled
  54108. */
  54109. set boundingBoxGizmoEnabled(value: boolean);
  54110. get boundingBoxGizmoEnabled(): boolean;
  54111. /**
  54112. * Disposes of the gizmo manager
  54113. */
  54114. dispose(): void;
  54115. }
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * A directional light is defined by a direction (what a surprise!).
  54120. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54121. * 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.
  54122. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54123. */
  54124. export class DirectionalLight extends ShadowLight {
  54125. private _shadowFrustumSize;
  54126. /**
  54127. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54128. */
  54129. get shadowFrustumSize(): number;
  54130. /**
  54131. * Specifies a fix frustum size for the shadow generation.
  54132. */
  54133. set shadowFrustumSize(value: number);
  54134. private _shadowOrthoScale;
  54135. /**
  54136. * Gets the shadow projection scale against the optimal computed one.
  54137. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54138. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54139. */
  54140. get shadowOrthoScale(): number;
  54141. /**
  54142. * Sets the shadow projection scale against the optimal computed one.
  54143. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54144. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54145. */
  54146. set shadowOrthoScale(value: number);
  54147. /**
  54148. * Automatically compute the projection matrix to best fit (including all the casters)
  54149. * on each frame.
  54150. */
  54151. autoUpdateExtends: boolean;
  54152. /**
  54153. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54154. * on each frame. autoUpdateExtends must be set to true for this to work
  54155. */
  54156. autoCalcShadowZBounds: boolean;
  54157. private _orthoLeft;
  54158. private _orthoRight;
  54159. private _orthoTop;
  54160. private _orthoBottom;
  54161. /**
  54162. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54163. * The directional light is emitted from everywhere in the given direction.
  54164. * It can cast shadows.
  54165. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54166. * @param name The friendly name of the light
  54167. * @param direction The direction of the light
  54168. * @param scene The scene the light belongs to
  54169. */
  54170. constructor(name: string, direction: Vector3, scene: Scene);
  54171. /**
  54172. * Returns the string "DirectionalLight".
  54173. * @return The class name
  54174. */
  54175. getClassName(): string;
  54176. /**
  54177. * Returns the integer 1.
  54178. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54179. */
  54180. getTypeID(): number;
  54181. /**
  54182. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54183. * Returns the DirectionalLight Shadow projection matrix.
  54184. */
  54185. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54186. /**
  54187. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54188. * Returns the DirectionalLight Shadow projection matrix.
  54189. */
  54190. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54191. /**
  54192. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54193. * Returns the DirectionalLight Shadow projection matrix.
  54194. */
  54195. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54196. protected _buildUniformLayout(): void;
  54197. /**
  54198. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54199. * @param effect The effect to update
  54200. * @param lightIndex The index of the light in the effect to update
  54201. * @returns The directional light
  54202. */
  54203. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54204. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54205. /**
  54206. * Gets the minZ used for shadow according to both the scene and the light.
  54207. *
  54208. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54209. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54210. * @param activeCamera The camera we are returning the min for
  54211. * @returns the depth min z
  54212. */
  54213. getDepthMinZ(activeCamera: Camera): number;
  54214. /**
  54215. * Gets the maxZ used for shadow according to both the scene and the light.
  54216. *
  54217. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54218. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54219. * @param activeCamera The camera we are returning the max for
  54220. * @returns the depth max z
  54221. */
  54222. getDepthMaxZ(activeCamera: Camera): number;
  54223. /**
  54224. * Prepares the list of defines specific to the light type.
  54225. * @param defines the list of defines
  54226. * @param lightIndex defines the index of the light for the effect
  54227. */
  54228. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54229. }
  54230. }
  54231. declare module BABYLON {
  54232. /**
  54233. * Class containing static functions to help procedurally build meshes
  54234. */
  54235. export class HemisphereBuilder {
  54236. /**
  54237. * Creates a hemisphere mesh
  54238. * @param name defines the name of the mesh
  54239. * @param options defines the options used to create the mesh
  54240. * @param scene defines the hosting scene
  54241. * @returns the hemisphere mesh
  54242. */
  54243. static CreateHemisphere(name: string, options: {
  54244. segments?: number;
  54245. diameter?: number;
  54246. sideOrientation?: number;
  54247. }, scene: any): Mesh;
  54248. }
  54249. }
  54250. declare module BABYLON {
  54251. /**
  54252. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54253. * These values define a cone of light starting from the position, emitting toward the direction.
  54254. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54255. * and the exponent defines the speed of the decay of the light with distance (reach).
  54256. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54257. */
  54258. export class SpotLight extends ShadowLight {
  54259. private _angle;
  54260. private _innerAngle;
  54261. private _cosHalfAngle;
  54262. private _lightAngleScale;
  54263. private _lightAngleOffset;
  54264. /**
  54265. * Gets the cone angle of the spot light in Radians.
  54266. */
  54267. get angle(): number;
  54268. /**
  54269. * Sets the cone angle of the spot light in Radians.
  54270. */
  54271. set angle(value: number);
  54272. /**
  54273. * Only used in gltf falloff mode, this defines the angle where
  54274. * the directional falloff will start before cutting at angle which could be seen
  54275. * as outer angle.
  54276. */
  54277. get innerAngle(): number;
  54278. /**
  54279. * Only used in gltf falloff mode, this defines the angle where
  54280. * the directional falloff will start before cutting at angle which could be seen
  54281. * as outer angle.
  54282. */
  54283. set innerAngle(value: number);
  54284. private _shadowAngleScale;
  54285. /**
  54286. * Allows scaling the angle of the light for shadow generation only.
  54287. */
  54288. get shadowAngleScale(): number;
  54289. /**
  54290. * Allows scaling the angle of the light for shadow generation only.
  54291. */
  54292. set shadowAngleScale(value: number);
  54293. /**
  54294. * The light decay speed with the distance from the emission spot.
  54295. */
  54296. exponent: number;
  54297. private _projectionTextureMatrix;
  54298. /**
  54299. * Allows reading the projecton texture
  54300. */
  54301. get projectionTextureMatrix(): Matrix;
  54302. protected _projectionTextureLightNear: number;
  54303. /**
  54304. * Gets the near clip of the Spotlight for texture projection.
  54305. */
  54306. get projectionTextureLightNear(): number;
  54307. /**
  54308. * Sets the near clip of the Spotlight for texture projection.
  54309. */
  54310. set projectionTextureLightNear(value: number);
  54311. protected _projectionTextureLightFar: number;
  54312. /**
  54313. * Gets the far clip of the Spotlight for texture projection.
  54314. */
  54315. get projectionTextureLightFar(): number;
  54316. /**
  54317. * Sets the far clip of the Spotlight for texture projection.
  54318. */
  54319. set projectionTextureLightFar(value: number);
  54320. protected _projectionTextureUpDirection: Vector3;
  54321. /**
  54322. * Gets the Up vector of the Spotlight for texture projection.
  54323. */
  54324. get projectionTextureUpDirection(): Vector3;
  54325. /**
  54326. * Sets the Up vector of the Spotlight for texture projection.
  54327. */
  54328. set projectionTextureUpDirection(value: Vector3);
  54329. private _projectionTexture;
  54330. /**
  54331. * Gets the projection texture of the light.
  54332. */
  54333. get projectionTexture(): Nullable<BaseTexture>;
  54334. /**
  54335. * Sets the projection texture of the light.
  54336. */
  54337. set projectionTexture(value: Nullable<BaseTexture>);
  54338. private _projectionTextureViewLightDirty;
  54339. private _projectionTextureProjectionLightDirty;
  54340. private _projectionTextureDirty;
  54341. private _projectionTextureViewTargetVector;
  54342. private _projectionTextureViewLightMatrix;
  54343. private _projectionTextureProjectionLightMatrix;
  54344. private _projectionTextureScalingMatrix;
  54345. /**
  54346. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54347. * It can cast shadows.
  54348. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54349. * @param name The light friendly name
  54350. * @param position The position of the spot light in the scene
  54351. * @param direction The direction of the light in the scene
  54352. * @param angle The cone angle of the light in Radians
  54353. * @param exponent The light decay speed with the distance from the emission spot
  54354. * @param scene The scene the lights belongs to
  54355. */
  54356. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54357. /**
  54358. * Returns the string "SpotLight".
  54359. * @returns the class name
  54360. */
  54361. getClassName(): string;
  54362. /**
  54363. * Returns the integer 2.
  54364. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54365. */
  54366. getTypeID(): number;
  54367. /**
  54368. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54369. */
  54370. protected _setDirection(value: Vector3): void;
  54371. /**
  54372. * Overrides the position setter to recompute the projection texture view light Matrix.
  54373. */
  54374. protected _setPosition(value: Vector3): void;
  54375. /**
  54376. * 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.
  54377. * Returns the SpotLight.
  54378. */
  54379. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54380. protected _computeProjectionTextureViewLightMatrix(): void;
  54381. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54382. /**
  54383. * Main function for light texture projection matrix computing.
  54384. */
  54385. protected _computeProjectionTextureMatrix(): void;
  54386. protected _buildUniformLayout(): void;
  54387. private _computeAngleValues;
  54388. /**
  54389. * Sets the passed Effect "effect" with the Light textures.
  54390. * @param effect The effect to update
  54391. * @param lightIndex The index of the light in the effect to update
  54392. * @returns The light
  54393. */
  54394. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54395. /**
  54396. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54397. * @param effect The effect to update
  54398. * @param lightIndex The index of the light in the effect to update
  54399. * @returns The spot light
  54400. */
  54401. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54402. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54403. /**
  54404. * Disposes the light and the associated resources.
  54405. */
  54406. dispose(): void;
  54407. /**
  54408. * Prepares the list of defines specific to the light type.
  54409. * @param defines the list of defines
  54410. * @param lightIndex defines the index of the light for the effect
  54411. */
  54412. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54413. }
  54414. }
  54415. declare module BABYLON {
  54416. /**
  54417. * Gizmo that enables viewing a light
  54418. */
  54419. export class LightGizmo extends Gizmo {
  54420. private _lightMesh;
  54421. private _material;
  54422. private _cachedPosition;
  54423. private _cachedForward;
  54424. private _attachedMeshParent;
  54425. private _pointerObserver;
  54426. /**
  54427. * Event that fires each time the gizmo is clicked
  54428. */
  54429. onClickedObservable: Observable<Light>;
  54430. /**
  54431. * Creates a LightGizmo
  54432. * @param gizmoLayer The utility layer the gizmo will be added to
  54433. */
  54434. constructor(gizmoLayer?: UtilityLayerRenderer);
  54435. private _light;
  54436. /**
  54437. * The light that the gizmo is attached to
  54438. */
  54439. set light(light: Nullable<Light>);
  54440. get light(): Nullable<Light>;
  54441. /**
  54442. * Gets the material used to render the light gizmo
  54443. */
  54444. get material(): StandardMaterial;
  54445. /**
  54446. * @hidden
  54447. * Updates the gizmo to match the attached mesh's position/rotation
  54448. */
  54449. protected _update(): void;
  54450. private static _Scale;
  54451. /**
  54452. * Creates the lines for a light mesh
  54453. */
  54454. private static _CreateLightLines;
  54455. /**
  54456. * Disposes of the light gizmo
  54457. */
  54458. dispose(): void;
  54459. private static _CreateHemisphericLightMesh;
  54460. private static _CreatePointLightMesh;
  54461. private static _CreateSpotLightMesh;
  54462. private static _CreateDirectionalLightMesh;
  54463. }
  54464. }
  54465. declare module BABYLON {
  54466. /**
  54467. * Gizmo that enables viewing a camera
  54468. */
  54469. export class CameraGizmo extends Gizmo {
  54470. private _cameraMesh;
  54471. private _cameraLinesMesh;
  54472. private _material;
  54473. private _pointerObserver;
  54474. /**
  54475. * Event that fires each time the gizmo is clicked
  54476. */
  54477. onClickedObservable: Observable<Camera>;
  54478. /**
  54479. * Creates a CameraGizmo
  54480. * @param gizmoLayer The utility layer the gizmo will be added to
  54481. */
  54482. constructor(gizmoLayer?: UtilityLayerRenderer);
  54483. private _camera;
  54484. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54485. get displayFrustum(): boolean;
  54486. set displayFrustum(value: boolean);
  54487. /**
  54488. * The camera that the gizmo is attached to
  54489. */
  54490. set camera(camera: Nullable<Camera>);
  54491. get camera(): Nullable<Camera>;
  54492. /**
  54493. * Gets the material used to render the camera gizmo
  54494. */
  54495. get material(): StandardMaterial;
  54496. /**
  54497. * @hidden
  54498. * Updates the gizmo to match the attached mesh's position/rotation
  54499. */
  54500. protected _update(): void;
  54501. private static _Scale;
  54502. private _invProjection;
  54503. /**
  54504. * Disposes of the camera gizmo
  54505. */
  54506. dispose(): void;
  54507. private static _CreateCameraMesh;
  54508. private static _CreateCameraFrustum;
  54509. }
  54510. }
  54511. declare module BABYLON {
  54512. /** @hidden */
  54513. export var backgroundFragmentDeclaration: {
  54514. name: string;
  54515. shader: string;
  54516. };
  54517. }
  54518. declare module BABYLON {
  54519. /** @hidden */
  54520. export var backgroundUboDeclaration: {
  54521. name: string;
  54522. shader: string;
  54523. };
  54524. }
  54525. declare module BABYLON {
  54526. /** @hidden */
  54527. export var backgroundPixelShader: {
  54528. name: string;
  54529. shader: string;
  54530. };
  54531. }
  54532. declare module BABYLON {
  54533. /** @hidden */
  54534. export var backgroundVertexDeclaration: {
  54535. name: string;
  54536. shader: string;
  54537. };
  54538. }
  54539. declare module BABYLON {
  54540. /** @hidden */
  54541. export var backgroundVertexShader: {
  54542. name: string;
  54543. shader: string;
  54544. };
  54545. }
  54546. declare module BABYLON {
  54547. /**
  54548. * Background material used to create an efficient environement around your scene.
  54549. */
  54550. export class BackgroundMaterial extends PushMaterial {
  54551. /**
  54552. * Standard reflectance value at parallel view angle.
  54553. */
  54554. static StandardReflectance0: number;
  54555. /**
  54556. * Standard reflectance value at grazing angle.
  54557. */
  54558. static StandardReflectance90: number;
  54559. protected _primaryColor: Color3;
  54560. /**
  54561. * Key light Color (multiply against the environement texture)
  54562. */
  54563. primaryColor: Color3;
  54564. protected __perceptualColor: Nullable<Color3>;
  54565. /**
  54566. * Experimental Internal Use Only.
  54567. *
  54568. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54569. * This acts as a helper to set the primary color to a more "human friendly" value.
  54570. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54571. * output color as close as possible from the chosen value.
  54572. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54573. * part of lighting setup.)
  54574. */
  54575. get _perceptualColor(): Nullable<Color3>;
  54576. set _perceptualColor(value: Nullable<Color3>);
  54577. protected _primaryColorShadowLevel: float;
  54578. /**
  54579. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54580. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54581. */
  54582. get primaryColorShadowLevel(): float;
  54583. set primaryColorShadowLevel(value: float);
  54584. protected _primaryColorHighlightLevel: float;
  54585. /**
  54586. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54587. * The primary color is used at the level chosen to define what the white area would look.
  54588. */
  54589. get primaryColorHighlightLevel(): float;
  54590. set primaryColorHighlightLevel(value: float);
  54591. protected _reflectionTexture: Nullable<BaseTexture>;
  54592. /**
  54593. * Reflection Texture used in the material.
  54594. * Should be author in a specific way for the best result (refer to the documentation).
  54595. */
  54596. reflectionTexture: Nullable<BaseTexture>;
  54597. protected _reflectionBlur: float;
  54598. /**
  54599. * Reflection Texture level of blur.
  54600. *
  54601. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54602. * texture twice.
  54603. */
  54604. reflectionBlur: float;
  54605. protected _diffuseTexture: Nullable<BaseTexture>;
  54606. /**
  54607. * Diffuse Texture used in the material.
  54608. * Should be author in a specific way for the best result (refer to the documentation).
  54609. */
  54610. diffuseTexture: Nullable<BaseTexture>;
  54611. protected _shadowLights: Nullable<IShadowLight[]>;
  54612. /**
  54613. * Specify the list of lights casting shadow on the material.
  54614. * All scene shadow lights will be included if null.
  54615. */
  54616. shadowLights: Nullable<IShadowLight[]>;
  54617. protected _shadowLevel: float;
  54618. /**
  54619. * Helps adjusting the shadow to a softer level if required.
  54620. * 0 means black shadows and 1 means no shadows.
  54621. */
  54622. shadowLevel: float;
  54623. protected _sceneCenter: Vector3;
  54624. /**
  54625. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54626. * It is usually zero but might be interesting to modify according to your setup.
  54627. */
  54628. sceneCenter: Vector3;
  54629. protected _opacityFresnel: boolean;
  54630. /**
  54631. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54632. * This helps ensuring a nice transition when the camera goes under the ground.
  54633. */
  54634. opacityFresnel: boolean;
  54635. protected _reflectionFresnel: boolean;
  54636. /**
  54637. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54638. * This helps adding a mirror texture on the ground.
  54639. */
  54640. reflectionFresnel: boolean;
  54641. protected _reflectionFalloffDistance: number;
  54642. /**
  54643. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54644. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54645. */
  54646. reflectionFalloffDistance: number;
  54647. protected _reflectionAmount: number;
  54648. /**
  54649. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54650. */
  54651. reflectionAmount: number;
  54652. protected _reflectionReflectance0: number;
  54653. /**
  54654. * This specifies the weight of the reflection at grazing angle.
  54655. */
  54656. reflectionReflectance0: number;
  54657. protected _reflectionReflectance90: number;
  54658. /**
  54659. * This specifies the weight of the reflection at a perpendicular point of view.
  54660. */
  54661. reflectionReflectance90: number;
  54662. /**
  54663. * Sets the reflection reflectance fresnel values according to the default standard
  54664. * empirically know to work well :-)
  54665. */
  54666. set reflectionStandardFresnelWeight(value: number);
  54667. protected _useRGBColor: boolean;
  54668. /**
  54669. * Helps to directly use the maps channels instead of their level.
  54670. */
  54671. useRGBColor: boolean;
  54672. protected _enableNoise: boolean;
  54673. /**
  54674. * This helps reducing the banding effect that could occur on the background.
  54675. */
  54676. enableNoise: boolean;
  54677. /**
  54678. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54679. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54680. * Recommended to be keep at 1.0 except for special cases.
  54681. */
  54682. get fovMultiplier(): number;
  54683. set fovMultiplier(value: number);
  54684. private _fovMultiplier;
  54685. /**
  54686. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54687. */
  54688. useEquirectangularFOV: boolean;
  54689. private _maxSimultaneousLights;
  54690. /**
  54691. * Number of Simultaneous lights allowed on the material.
  54692. */
  54693. maxSimultaneousLights: int;
  54694. private _shadowOnly;
  54695. /**
  54696. * Make the material only render shadows
  54697. */
  54698. shadowOnly: boolean;
  54699. /**
  54700. * Default configuration related to image processing available in the Background Material.
  54701. */
  54702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54703. /**
  54704. * Keep track of the image processing observer to allow dispose and replace.
  54705. */
  54706. private _imageProcessingObserver;
  54707. /**
  54708. * Attaches a new image processing configuration to the PBR Material.
  54709. * @param configuration (if null the scene configuration will be use)
  54710. */
  54711. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54712. /**
  54713. * Gets the image processing configuration used either in this material.
  54714. */
  54715. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54716. /**
  54717. * Sets the Default image processing configuration used either in the this material.
  54718. *
  54719. * If sets to null, the scene one is in use.
  54720. */
  54721. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54722. /**
  54723. * Gets wether the color curves effect is enabled.
  54724. */
  54725. get cameraColorCurvesEnabled(): boolean;
  54726. /**
  54727. * Sets wether the color curves effect is enabled.
  54728. */
  54729. set cameraColorCurvesEnabled(value: boolean);
  54730. /**
  54731. * Gets wether the color grading effect is enabled.
  54732. */
  54733. get cameraColorGradingEnabled(): boolean;
  54734. /**
  54735. * Gets wether the color grading effect is enabled.
  54736. */
  54737. set cameraColorGradingEnabled(value: boolean);
  54738. /**
  54739. * Gets wether tonemapping is enabled or not.
  54740. */
  54741. get cameraToneMappingEnabled(): boolean;
  54742. /**
  54743. * Sets wether tonemapping is enabled or not
  54744. */
  54745. set cameraToneMappingEnabled(value: boolean);
  54746. /**
  54747. * The camera exposure used on this material.
  54748. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54749. * This corresponds to a photographic exposure.
  54750. */
  54751. get cameraExposure(): float;
  54752. /**
  54753. * The camera exposure used on this material.
  54754. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54755. * This corresponds to a photographic exposure.
  54756. */
  54757. set cameraExposure(value: float);
  54758. /**
  54759. * Gets The camera contrast used on this material.
  54760. */
  54761. get cameraContrast(): float;
  54762. /**
  54763. * Sets The camera contrast used on this material.
  54764. */
  54765. set cameraContrast(value: float);
  54766. /**
  54767. * Gets the Color Grading 2D Lookup Texture.
  54768. */
  54769. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54770. /**
  54771. * Sets the Color Grading 2D Lookup Texture.
  54772. */
  54773. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54774. /**
  54775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54777. * 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;
  54778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54779. */
  54780. get cameraColorCurves(): Nullable<ColorCurves>;
  54781. /**
  54782. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54783. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54784. * 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;
  54785. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54786. */
  54787. set cameraColorCurves(value: Nullable<ColorCurves>);
  54788. /**
  54789. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54790. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54791. */
  54792. switchToBGR: boolean;
  54793. private _renderTargets;
  54794. private _reflectionControls;
  54795. private _white;
  54796. private _primaryShadowColor;
  54797. private _primaryHighlightColor;
  54798. /**
  54799. * Instantiates a Background Material in the given scene
  54800. * @param name The friendly name of the material
  54801. * @param scene The scene to add the material to
  54802. */
  54803. constructor(name: string, scene: Scene);
  54804. /**
  54805. * Gets a boolean indicating that current material needs to register RTT
  54806. */
  54807. get hasRenderTargetTextures(): boolean;
  54808. /**
  54809. * The entire material has been created in order to prevent overdraw.
  54810. * @returns false
  54811. */
  54812. needAlphaTesting(): boolean;
  54813. /**
  54814. * The entire material has been created in order to prevent overdraw.
  54815. * @returns true if blending is enable
  54816. */
  54817. needAlphaBlending(): boolean;
  54818. /**
  54819. * Checks wether the material is ready to be rendered for a given mesh.
  54820. * @param mesh The mesh to render
  54821. * @param subMesh The submesh to check against
  54822. * @param useInstances Specify wether or not the material is used with instances
  54823. * @returns true if all the dependencies are ready (Textures, Effects...)
  54824. */
  54825. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54826. /**
  54827. * Compute the primary color according to the chosen perceptual color.
  54828. */
  54829. private _computePrimaryColorFromPerceptualColor;
  54830. /**
  54831. * Compute the highlights and shadow colors according to their chosen levels.
  54832. */
  54833. private _computePrimaryColors;
  54834. /**
  54835. * Build the uniform buffer used in the material.
  54836. */
  54837. buildUniformLayout(): void;
  54838. /**
  54839. * Unbind the material.
  54840. */
  54841. unbind(): void;
  54842. /**
  54843. * Bind only the world matrix to the material.
  54844. * @param world The world matrix to bind.
  54845. */
  54846. bindOnlyWorldMatrix(world: Matrix): void;
  54847. /**
  54848. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54849. * @param world The world matrix to bind.
  54850. * @param subMesh The submesh to bind for.
  54851. */
  54852. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54853. /**
  54854. * Checks to see if a texture is used in the material.
  54855. * @param texture - Base texture to use.
  54856. * @returns - Boolean specifying if a texture is used in the material.
  54857. */
  54858. hasTexture(texture: BaseTexture): boolean;
  54859. /**
  54860. * Dispose the material.
  54861. * @param forceDisposeEffect Force disposal of the associated effect.
  54862. * @param forceDisposeTextures Force disposal of the associated textures.
  54863. */
  54864. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54865. /**
  54866. * Clones the material.
  54867. * @param name The cloned name.
  54868. * @returns The cloned material.
  54869. */
  54870. clone(name: string): BackgroundMaterial;
  54871. /**
  54872. * Serializes the current material to its JSON representation.
  54873. * @returns The JSON representation.
  54874. */
  54875. serialize(): any;
  54876. /**
  54877. * Gets the class name of the material
  54878. * @returns "BackgroundMaterial"
  54879. */
  54880. getClassName(): string;
  54881. /**
  54882. * Parse a JSON input to create back a background material.
  54883. * @param source The JSON data to parse
  54884. * @param scene The scene to create the parsed material in
  54885. * @param rootUrl The root url of the assets the material depends upon
  54886. * @returns the instantiated BackgroundMaterial.
  54887. */
  54888. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54889. }
  54890. }
  54891. declare module BABYLON {
  54892. /**
  54893. * Represents the different options available during the creation of
  54894. * a Environment helper.
  54895. *
  54896. * This can control the default ground, skybox and image processing setup of your scene.
  54897. */
  54898. export interface IEnvironmentHelperOptions {
  54899. /**
  54900. * Specifies whether or not to create a ground.
  54901. * True by default.
  54902. */
  54903. createGround: boolean;
  54904. /**
  54905. * Specifies the ground size.
  54906. * 15 by default.
  54907. */
  54908. groundSize: number;
  54909. /**
  54910. * The texture used on the ground for the main color.
  54911. * Comes from the BabylonJS CDN by default.
  54912. *
  54913. * Remarks: Can be either a texture or a url.
  54914. */
  54915. groundTexture: string | BaseTexture;
  54916. /**
  54917. * The color mixed in the ground texture by default.
  54918. * BabylonJS clearColor by default.
  54919. */
  54920. groundColor: Color3;
  54921. /**
  54922. * Specifies the ground opacity.
  54923. * 1 by default.
  54924. */
  54925. groundOpacity: number;
  54926. /**
  54927. * Enables the ground to receive shadows.
  54928. * True by default.
  54929. */
  54930. enableGroundShadow: boolean;
  54931. /**
  54932. * Helps preventing the shadow to be fully black on the ground.
  54933. * 0.5 by default.
  54934. */
  54935. groundShadowLevel: number;
  54936. /**
  54937. * Creates a mirror texture attach to the ground.
  54938. * false by default.
  54939. */
  54940. enableGroundMirror: boolean;
  54941. /**
  54942. * Specifies the ground mirror size ratio.
  54943. * 0.3 by default as the default kernel is 64.
  54944. */
  54945. groundMirrorSizeRatio: number;
  54946. /**
  54947. * Specifies the ground mirror blur kernel size.
  54948. * 64 by default.
  54949. */
  54950. groundMirrorBlurKernel: number;
  54951. /**
  54952. * Specifies the ground mirror visibility amount.
  54953. * 1 by default
  54954. */
  54955. groundMirrorAmount: number;
  54956. /**
  54957. * Specifies the ground mirror reflectance weight.
  54958. * This uses the standard weight of the background material to setup the fresnel effect
  54959. * of the mirror.
  54960. * 1 by default.
  54961. */
  54962. groundMirrorFresnelWeight: number;
  54963. /**
  54964. * Specifies the ground mirror Falloff distance.
  54965. * This can helps reducing the size of the reflection.
  54966. * 0 by Default.
  54967. */
  54968. groundMirrorFallOffDistance: number;
  54969. /**
  54970. * Specifies the ground mirror texture type.
  54971. * Unsigned Int by Default.
  54972. */
  54973. groundMirrorTextureType: number;
  54974. /**
  54975. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54976. * the shown objects.
  54977. */
  54978. groundYBias: number;
  54979. /**
  54980. * Specifies whether or not to create a skybox.
  54981. * True by default.
  54982. */
  54983. createSkybox: boolean;
  54984. /**
  54985. * Specifies the skybox size.
  54986. * 20 by default.
  54987. */
  54988. skyboxSize: number;
  54989. /**
  54990. * The texture used on the skybox for the main color.
  54991. * Comes from the BabylonJS CDN by default.
  54992. *
  54993. * Remarks: Can be either a texture or a url.
  54994. */
  54995. skyboxTexture: string | BaseTexture;
  54996. /**
  54997. * The color mixed in the skybox texture by default.
  54998. * BabylonJS clearColor by default.
  54999. */
  55000. skyboxColor: Color3;
  55001. /**
  55002. * The background rotation around the Y axis of the scene.
  55003. * This helps aligning the key lights of your scene with the background.
  55004. * 0 by default.
  55005. */
  55006. backgroundYRotation: number;
  55007. /**
  55008. * Compute automatically the size of the elements to best fit with the scene.
  55009. */
  55010. sizeAuto: boolean;
  55011. /**
  55012. * Default position of the rootMesh if autoSize is not true.
  55013. */
  55014. rootPosition: Vector3;
  55015. /**
  55016. * Sets up the image processing in the scene.
  55017. * true by default.
  55018. */
  55019. setupImageProcessing: boolean;
  55020. /**
  55021. * The texture used as your environment texture in the scene.
  55022. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55023. *
  55024. * Remarks: Can be either a texture or a url.
  55025. */
  55026. environmentTexture: string | BaseTexture;
  55027. /**
  55028. * The value of the exposure to apply to the scene.
  55029. * 0.6 by default if setupImageProcessing is true.
  55030. */
  55031. cameraExposure: number;
  55032. /**
  55033. * The value of the contrast to apply to the scene.
  55034. * 1.6 by default if setupImageProcessing is true.
  55035. */
  55036. cameraContrast: number;
  55037. /**
  55038. * Specifies whether or not tonemapping should be enabled in the scene.
  55039. * true by default if setupImageProcessing is true.
  55040. */
  55041. toneMappingEnabled: boolean;
  55042. }
  55043. /**
  55044. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55045. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55046. * It also helps with the default setup of your imageProcessing configuration.
  55047. */
  55048. export class EnvironmentHelper {
  55049. /**
  55050. * Default ground texture URL.
  55051. */
  55052. private static _groundTextureCDNUrl;
  55053. /**
  55054. * Default skybox texture URL.
  55055. */
  55056. private static _skyboxTextureCDNUrl;
  55057. /**
  55058. * Default environment texture URL.
  55059. */
  55060. private static _environmentTextureCDNUrl;
  55061. /**
  55062. * Creates the default options for the helper.
  55063. */
  55064. private static _getDefaultOptions;
  55065. private _rootMesh;
  55066. /**
  55067. * Gets the root mesh created by the helper.
  55068. */
  55069. get rootMesh(): Mesh;
  55070. private _skybox;
  55071. /**
  55072. * Gets the skybox created by the helper.
  55073. */
  55074. get skybox(): Nullable<Mesh>;
  55075. private _skyboxTexture;
  55076. /**
  55077. * Gets the skybox texture created by the helper.
  55078. */
  55079. get skyboxTexture(): Nullable<BaseTexture>;
  55080. private _skyboxMaterial;
  55081. /**
  55082. * Gets the skybox material created by the helper.
  55083. */
  55084. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55085. private _ground;
  55086. /**
  55087. * Gets the ground mesh created by the helper.
  55088. */
  55089. get ground(): Nullable<Mesh>;
  55090. private _groundTexture;
  55091. /**
  55092. * Gets the ground texture created by the helper.
  55093. */
  55094. get groundTexture(): Nullable<BaseTexture>;
  55095. private _groundMirror;
  55096. /**
  55097. * Gets the ground mirror created by the helper.
  55098. */
  55099. get groundMirror(): Nullable<MirrorTexture>;
  55100. /**
  55101. * Gets the ground mirror render list to helps pushing the meshes
  55102. * you wish in the ground reflection.
  55103. */
  55104. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55105. private _groundMaterial;
  55106. /**
  55107. * Gets the ground material created by the helper.
  55108. */
  55109. get groundMaterial(): Nullable<BackgroundMaterial>;
  55110. /**
  55111. * Stores the creation options.
  55112. */
  55113. private readonly _scene;
  55114. private _options;
  55115. /**
  55116. * This observable will be notified with any error during the creation of the environment,
  55117. * mainly texture creation errors.
  55118. */
  55119. onErrorObservable: Observable<{
  55120. message?: string;
  55121. exception?: any;
  55122. }>;
  55123. /**
  55124. * constructor
  55125. * @param options Defines the options we want to customize the helper
  55126. * @param scene The scene to add the material to
  55127. */
  55128. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55129. /**
  55130. * Updates the background according to the new options
  55131. * @param options
  55132. */
  55133. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55134. /**
  55135. * Sets the primary color of all the available elements.
  55136. * @param color the main color to affect to the ground and the background
  55137. */
  55138. setMainColor(color: Color3): void;
  55139. /**
  55140. * Setup the image processing according to the specified options.
  55141. */
  55142. private _setupImageProcessing;
  55143. /**
  55144. * Setup the environment texture according to the specified options.
  55145. */
  55146. private _setupEnvironmentTexture;
  55147. /**
  55148. * Setup the background according to the specified options.
  55149. */
  55150. private _setupBackground;
  55151. /**
  55152. * Get the scene sizes according to the setup.
  55153. */
  55154. private _getSceneSize;
  55155. /**
  55156. * Setup the ground according to the specified options.
  55157. */
  55158. private _setupGround;
  55159. /**
  55160. * Setup the ground material according to the specified options.
  55161. */
  55162. private _setupGroundMaterial;
  55163. /**
  55164. * Setup the ground diffuse texture according to the specified options.
  55165. */
  55166. private _setupGroundDiffuseTexture;
  55167. /**
  55168. * Setup the ground mirror texture according to the specified options.
  55169. */
  55170. private _setupGroundMirrorTexture;
  55171. /**
  55172. * Setup the ground to receive the mirror texture.
  55173. */
  55174. private _setupMirrorInGroundMaterial;
  55175. /**
  55176. * Setup the skybox according to the specified options.
  55177. */
  55178. private _setupSkybox;
  55179. /**
  55180. * Setup the skybox material according to the specified options.
  55181. */
  55182. private _setupSkyboxMaterial;
  55183. /**
  55184. * Setup the skybox reflection texture according to the specified options.
  55185. */
  55186. private _setupSkyboxReflectionTexture;
  55187. private _errorHandler;
  55188. /**
  55189. * Dispose all the elements created by the Helper.
  55190. */
  55191. dispose(): void;
  55192. }
  55193. }
  55194. declare module BABYLON {
  55195. /**
  55196. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55197. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55198. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55199. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55200. */
  55201. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55202. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55203. /**
  55204. * Define the source as a Monoscopic panoramic 360/180.
  55205. */
  55206. static readonly MODE_MONOSCOPIC: number;
  55207. /**
  55208. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55209. */
  55210. static readonly MODE_TOPBOTTOM: number;
  55211. /**
  55212. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55213. */
  55214. static readonly MODE_SIDEBYSIDE: number;
  55215. private _halfDome;
  55216. protected _useDirectMapping: boolean;
  55217. /**
  55218. * The texture being displayed on the sphere
  55219. */
  55220. protected _texture: T;
  55221. /**
  55222. * Gets the texture being displayed on the sphere
  55223. */
  55224. get texture(): T;
  55225. /**
  55226. * Sets the texture being displayed on the sphere
  55227. */
  55228. set texture(newTexture: T);
  55229. /**
  55230. * The skybox material
  55231. */
  55232. protected _material: BackgroundMaterial;
  55233. /**
  55234. * The surface used for the dome
  55235. */
  55236. protected _mesh: Mesh;
  55237. /**
  55238. * Gets the mesh used for the dome.
  55239. */
  55240. get mesh(): Mesh;
  55241. /**
  55242. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55243. */
  55244. private _halfDomeMask;
  55245. /**
  55246. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55247. * Also see the options.resolution property.
  55248. */
  55249. get fovMultiplier(): number;
  55250. set fovMultiplier(value: number);
  55251. protected _textureMode: number;
  55252. /**
  55253. * Gets or set the current texture mode for the texture. It can be:
  55254. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55255. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55256. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55257. */
  55258. get textureMode(): number;
  55259. /**
  55260. * Sets the current texture mode for the texture. It can be:
  55261. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55262. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55263. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55264. */
  55265. set textureMode(value: number);
  55266. /**
  55267. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55268. */
  55269. get halfDome(): boolean;
  55270. /**
  55271. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55272. */
  55273. set halfDome(enabled: boolean);
  55274. /**
  55275. * Oberserver used in Stereoscopic VR Mode.
  55276. */
  55277. private _onBeforeCameraRenderObserver;
  55278. /**
  55279. * Observable raised when an error occured while loading the 360 image
  55280. */
  55281. onLoadErrorObservable: Observable<string>;
  55282. /**
  55283. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55284. * @param name Element's name, child elements will append suffixes for their own names.
  55285. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55286. * @param options An object containing optional or exposed sub element properties
  55287. */
  55288. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55289. resolution?: number;
  55290. clickToPlay?: boolean;
  55291. autoPlay?: boolean;
  55292. loop?: boolean;
  55293. size?: number;
  55294. poster?: string;
  55295. faceForward?: boolean;
  55296. useDirectMapping?: boolean;
  55297. halfDomeMode?: boolean;
  55298. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55299. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55300. protected _changeTextureMode(value: number): void;
  55301. /**
  55302. * Releases resources associated with this node.
  55303. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55304. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55305. */
  55306. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55307. }
  55308. }
  55309. declare module BABYLON {
  55310. /**
  55311. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55312. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55313. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55314. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55315. */
  55316. export class PhotoDome extends TextureDome<Texture> {
  55317. /**
  55318. * Define the image as a Monoscopic panoramic 360 image.
  55319. */
  55320. static readonly MODE_MONOSCOPIC: number;
  55321. /**
  55322. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55323. */
  55324. static readonly MODE_TOPBOTTOM: number;
  55325. /**
  55326. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55327. */
  55328. static readonly MODE_SIDEBYSIDE: number;
  55329. /**
  55330. * Gets or sets the texture being displayed on the sphere
  55331. */
  55332. get photoTexture(): Texture;
  55333. /**
  55334. * sets the texture being displayed on the sphere
  55335. */
  55336. set photoTexture(value: Texture);
  55337. /**
  55338. * Gets the current video mode for the video. It can be:
  55339. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55340. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55341. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55342. */
  55343. get imageMode(): number;
  55344. /**
  55345. * Sets the current video mode for the video. It can be:
  55346. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55347. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55348. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55349. */
  55350. set imageMode(value: number);
  55351. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55352. }
  55353. }
  55354. declare module BABYLON {
  55355. /**
  55356. * Class used to host RGBD texture specific utilities
  55357. */
  55358. export class RGBDTextureTools {
  55359. /**
  55360. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55361. * @param texture the texture to expand.
  55362. */
  55363. static ExpandRGBDTexture(texture: Texture): void;
  55364. }
  55365. }
  55366. declare module BABYLON {
  55367. /**
  55368. * Class used to host texture specific utilities
  55369. */
  55370. export class BRDFTextureTools {
  55371. /**
  55372. * Prevents texture cache collision
  55373. */
  55374. private static _instanceNumber;
  55375. /**
  55376. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55377. * @param scene defines the hosting scene
  55378. * @returns the environment BRDF texture
  55379. */
  55380. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55381. private static _environmentBRDFBase64Texture;
  55382. }
  55383. }
  55384. declare module BABYLON {
  55385. /**
  55386. * @hidden
  55387. */
  55388. export interface IMaterialClearCoatDefines {
  55389. CLEARCOAT: boolean;
  55390. CLEARCOAT_DEFAULTIOR: boolean;
  55391. CLEARCOAT_TEXTURE: boolean;
  55392. CLEARCOAT_TEXTUREDIRECTUV: number;
  55393. CLEARCOAT_BUMP: boolean;
  55394. CLEARCOAT_BUMPDIRECTUV: number;
  55395. CLEARCOAT_TINT: boolean;
  55396. CLEARCOAT_TINT_TEXTURE: boolean;
  55397. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55398. /** @hidden */
  55399. _areTexturesDirty: boolean;
  55400. }
  55401. /**
  55402. * Define the code related to the clear coat parameters of the pbr material.
  55403. */
  55404. export class PBRClearCoatConfiguration {
  55405. /**
  55406. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55407. * The default fits with a polyurethane material.
  55408. */
  55409. private static readonly _DefaultIndexOfRefraction;
  55410. private _isEnabled;
  55411. /**
  55412. * Defines if the clear coat is enabled in the material.
  55413. */
  55414. isEnabled: boolean;
  55415. /**
  55416. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55417. */
  55418. intensity: number;
  55419. /**
  55420. * Defines the clear coat layer roughness.
  55421. */
  55422. roughness: number;
  55423. private _indexOfRefraction;
  55424. /**
  55425. * Defines the index of refraction of the clear coat.
  55426. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55427. * The default fits with a polyurethane material.
  55428. * Changing the default value is more performance intensive.
  55429. */
  55430. indexOfRefraction: number;
  55431. private _texture;
  55432. /**
  55433. * Stores the clear coat values in a texture.
  55434. */
  55435. texture: Nullable<BaseTexture>;
  55436. private _bumpTexture;
  55437. /**
  55438. * Define the clear coat specific bump texture.
  55439. */
  55440. bumpTexture: Nullable<BaseTexture>;
  55441. private _isTintEnabled;
  55442. /**
  55443. * Defines if the clear coat tint is enabled in the material.
  55444. */
  55445. isTintEnabled: boolean;
  55446. /**
  55447. * Defines the clear coat tint of the material.
  55448. * This is only use if tint is enabled
  55449. */
  55450. tintColor: Color3;
  55451. /**
  55452. * Defines the distance at which the tint color should be found in the
  55453. * clear coat media.
  55454. * This is only use if tint is enabled
  55455. */
  55456. tintColorAtDistance: number;
  55457. /**
  55458. * Defines the clear coat layer thickness.
  55459. * This is only use if tint is enabled
  55460. */
  55461. tintThickness: number;
  55462. private _tintTexture;
  55463. /**
  55464. * Stores the clear tint values in a texture.
  55465. * rgb is tint
  55466. * a is a thickness factor
  55467. */
  55468. tintTexture: Nullable<BaseTexture>;
  55469. /** @hidden */
  55470. private _internalMarkAllSubMeshesAsTexturesDirty;
  55471. /** @hidden */
  55472. _markAllSubMeshesAsTexturesDirty(): void;
  55473. /**
  55474. * Instantiate a new istance of clear coat configuration.
  55475. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55476. */
  55477. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55478. /**
  55479. * Gets wehter the submesh is ready to be used or not.
  55480. * @param defines the list of "defines" to update.
  55481. * @param scene defines the scene the material belongs to.
  55482. * @param engine defines the engine the material belongs to.
  55483. * @param disableBumpMap defines wether the material disables bump or not.
  55484. * @returns - boolean indicating that the submesh is ready or not.
  55485. */
  55486. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55487. /**
  55488. * Checks to see if a texture is used in the material.
  55489. * @param defines the list of "defines" to update.
  55490. * @param scene defines the scene to the material belongs to.
  55491. */
  55492. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55493. /**
  55494. * Binds the material data.
  55495. * @param uniformBuffer defines the Uniform buffer to fill in.
  55496. * @param scene defines the scene the material belongs to.
  55497. * @param engine defines the engine the material belongs to.
  55498. * @param disableBumpMap defines wether the material disables bump or not.
  55499. * @param isFrozen defines wether the material is frozen or not.
  55500. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55501. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55502. */
  55503. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55504. /**
  55505. * Checks to see if a texture is used in the material.
  55506. * @param texture - Base texture to use.
  55507. * @returns - Boolean specifying if a texture is used in the material.
  55508. */
  55509. hasTexture(texture: BaseTexture): boolean;
  55510. /**
  55511. * Returns an array of the actively used textures.
  55512. * @param activeTextures Array of BaseTextures
  55513. */
  55514. getActiveTextures(activeTextures: BaseTexture[]): void;
  55515. /**
  55516. * Returns the animatable textures.
  55517. * @param animatables Array of animatable textures.
  55518. */
  55519. getAnimatables(animatables: IAnimatable[]): void;
  55520. /**
  55521. * Disposes the resources of the material.
  55522. * @param forceDisposeTextures - Forces the disposal of all textures.
  55523. */
  55524. dispose(forceDisposeTextures?: boolean): void;
  55525. /**
  55526. * Get the current class name of the texture useful for serialization or dynamic coding.
  55527. * @returns "PBRClearCoatConfiguration"
  55528. */
  55529. getClassName(): string;
  55530. /**
  55531. * Add fallbacks to the effect fallbacks list.
  55532. * @param defines defines the Base texture to use.
  55533. * @param fallbacks defines the current fallback list.
  55534. * @param currentRank defines the current fallback rank.
  55535. * @returns the new fallback rank.
  55536. */
  55537. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55538. /**
  55539. * Add the required uniforms to the current list.
  55540. * @param uniforms defines the current uniform list.
  55541. */
  55542. static AddUniforms(uniforms: string[]): void;
  55543. /**
  55544. * Add the required samplers to the current list.
  55545. * @param samplers defines the current sampler list.
  55546. */
  55547. static AddSamplers(samplers: string[]): void;
  55548. /**
  55549. * Add the required uniforms to the current buffer.
  55550. * @param uniformBuffer defines the current uniform buffer.
  55551. */
  55552. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55553. /**
  55554. * Makes a duplicate of the current configuration into another one.
  55555. * @param clearCoatConfiguration define the config where to copy the info
  55556. */
  55557. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55558. /**
  55559. * Serializes this clear coat configuration.
  55560. * @returns - An object with the serialized config.
  55561. */
  55562. serialize(): any;
  55563. /**
  55564. * Parses a anisotropy Configuration from a serialized object.
  55565. * @param source - Serialized object.
  55566. * @param scene Defines the scene we are parsing for
  55567. * @param rootUrl Defines the rootUrl to load from
  55568. */
  55569. parse(source: any, scene: Scene, rootUrl: string): void;
  55570. }
  55571. }
  55572. declare module BABYLON {
  55573. /**
  55574. * @hidden
  55575. */
  55576. export interface IMaterialAnisotropicDefines {
  55577. ANISOTROPIC: boolean;
  55578. ANISOTROPIC_TEXTURE: boolean;
  55579. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55580. MAINUV1: boolean;
  55581. _areTexturesDirty: boolean;
  55582. _needUVs: boolean;
  55583. }
  55584. /**
  55585. * Define the code related to the anisotropic parameters of the pbr material.
  55586. */
  55587. export class PBRAnisotropicConfiguration {
  55588. private _isEnabled;
  55589. /**
  55590. * Defines if the anisotropy is enabled in the material.
  55591. */
  55592. isEnabled: boolean;
  55593. /**
  55594. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55595. */
  55596. intensity: number;
  55597. /**
  55598. * Defines if the effect is along the tangents, bitangents or in between.
  55599. * By default, the effect is "strectching" the highlights along the tangents.
  55600. */
  55601. direction: Vector2;
  55602. private _texture;
  55603. /**
  55604. * Stores the anisotropy values in a texture.
  55605. * rg is direction (like normal from -1 to 1)
  55606. * b is a intensity
  55607. */
  55608. texture: Nullable<BaseTexture>;
  55609. /** @hidden */
  55610. private _internalMarkAllSubMeshesAsTexturesDirty;
  55611. /** @hidden */
  55612. _markAllSubMeshesAsTexturesDirty(): void;
  55613. /**
  55614. * Instantiate a new istance of anisotropy configuration.
  55615. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55616. */
  55617. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55618. /**
  55619. * Specifies that the submesh is ready to be used.
  55620. * @param defines the list of "defines" to update.
  55621. * @param scene defines the scene the material belongs to.
  55622. * @returns - boolean indicating that the submesh is ready or not.
  55623. */
  55624. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55625. /**
  55626. * Checks to see if a texture is used in the material.
  55627. * @param defines the list of "defines" to update.
  55628. * @param mesh the mesh we are preparing the defines for.
  55629. * @param scene defines the scene the material belongs to.
  55630. */
  55631. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55632. /**
  55633. * Binds the material data.
  55634. * @param uniformBuffer defines the Uniform buffer to fill in.
  55635. * @param scene defines the scene the material belongs to.
  55636. * @param isFrozen defines wether the material is frozen or not.
  55637. */
  55638. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55639. /**
  55640. * Checks to see if a texture is used in the material.
  55641. * @param texture - Base texture to use.
  55642. * @returns - Boolean specifying if a texture is used in the material.
  55643. */
  55644. hasTexture(texture: BaseTexture): boolean;
  55645. /**
  55646. * Returns an array of the actively used textures.
  55647. * @param activeTextures Array of BaseTextures
  55648. */
  55649. getActiveTextures(activeTextures: BaseTexture[]): void;
  55650. /**
  55651. * Returns the animatable textures.
  55652. * @param animatables Array of animatable textures.
  55653. */
  55654. getAnimatables(animatables: IAnimatable[]): void;
  55655. /**
  55656. * Disposes the resources of the material.
  55657. * @param forceDisposeTextures - Forces the disposal of all textures.
  55658. */
  55659. dispose(forceDisposeTextures?: boolean): void;
  55660. /**
  55661. * Get the current class name of the texture useful for serialization or dynamic coding.
  55662. * @returns "PBRAnisotropicConfiguration"
  55663. */
  55664. getClassName(): string;
  55665. /**
  55666. * Add fallbacks to the effect fallbacks list.
  55667. * @param defines defines the Base texture to use.
  55668. * @param fallbacks defines the current fallback list.
  55669. * @param currentRank defines the current fallback rank.
  55670. * @returns the new fallback rank.
  55671. */
  55672. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55673. /**
  55674. * Add the required uniforms to the current list.
  55675. * @param uniforms defines the current uniform list.
  55676. */
  55677. static AddUniforms(uniforms: string[]): void;
  55678. /**
  55679. * Add the required uniforms to the current buffer.
  55680. * @param uniformBuffer defines the current uniform buffer.
  55681. */
  55682. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55683. /**
  55684. * Add the required samplers to the current list.
  55685. * @param samplers defines the current sampler list.
  55686. */
  55687. static AddSamplers(samplers: string[]): void;
  55688. /**
  55689. * Makes a duplicate of the current configuration into another one.
  55690. * @param anisotropicConfiguration define the config where to copy the info
  55691. */
  55692. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55693. /**
  55694. * Serializes this anisotropy configuration.
  55695. * @returns - An object with the serialized config.
  55696. */
  55697. serialize(): any;
  55698. /**
  55699. * Parses a anisotropy Configuration from a serialized object.
  55700. * @param source - Serialized object.
  55701. * @param scene Defines the scene we are parsing for
  55702. * @param rootUrl Defines the rootUrl to load from
  55703. */
  55704. parse(source: any, scene: Scene, rootUrl: string): void;
  55705. }
  55706. }
  55707. declare module BABYLON {
  55708. /**
  55709. * @hidden
  55710. */
  55711. export interface IMaterialBRDFDefines {
  55712. BRDF_V_HEIGHT_CORRELATED: boolean;
  55713. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55714. SPHERICAL_HARMONICS: boolean;
  55715. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55716. /** @hidden */
  55717. _areMiscDirty: boolean;
  55718. }
  55719. /**
  55720. * Define the code related to the BRDF parameters of the pbr material.
  55721. */
  55722. export class PBRBRDFConfiguration {
  55723. /**
  55724. * Default value used for the energy conservation.
  55725. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55726. */
  55727. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55728. /**
  55729. * Default value used for the Smith Visibility Height Correlated mode.
  55730. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55731. */
  55732. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55733. /**
  55734. * Default value used for the IBL diffuse part.
  55735. * This can help switching back to the polynomials mode globally which is a tiny bit
  55736. * less GPU intensive at the drawback of a lower quality.
  55737. */
  55738. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55739. /**
  55740. * Default value used for activating energy conservation for the specular workflow.
  55741. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55742. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55743. */
  55744. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55745. private _useEnergyConservation;
  55746. /**
  55747. * Defines if the material uses energy conservation.
  55748. */
  55749. useEnergyConservation: boolean;
  55750. private _useSmithVisibilityHeightCorrelated;
  55751. /**
  55752. * LEGACY Mode set to false
  55753. * Defines if the material uses height smith correlated visibility term.
  55754. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55755. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55756. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55757. * Not relying on height correlated will also disable energy conservation.
  55758. */
  55759. useSmithVisibilityHeightCorrelated: boolean;
  55760. private _useSphericalHarmonics;
  55761. /**
  55762. * LEGACY Mode set to false
  55763. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55764. * diffuse part of the IBL.
  55765. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55766. * to the ground truth.
  55767. */
  55768. useSphericalHarmonics: boolean;
  55769. private _useSpecularGlossinessInputEnergyConservation;
  55770. /**
  55771. * Defines if the material uses energy conservation, when the specular workflow is active.
  55772. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55773. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55774. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55775. */
  55776. useSpecularGlossinessInputEnergyConservation: boolean;
  55777. /** @hidden */
  55778. private _internalMarkAllSubMeshesAsMiscDirty;
  55779. /** @hidden */
  55780. _markAllSubMeshesAsMiscDirty(): void;
  55781. /**
  55782. * Instantiate a new istance of clear coat configuration.
  55783. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55784. */
  55785. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55786. /**
  55787. * Checks to see if a texture is used in the material.
  55788. * @param defines the list of "defines" to update.
  55789. */
  55790. prepareDefines(defines: IMaterialBRDFDefines): void;
  55791. /**
  55792. * Get the current class name of the texture useful for serialization or dynamic coding.
  55793. * @returns "PBRClearCoatConfiguration"
  55794. */
  55795. getClassName(): string;
  55796. /**
  55797. * Makes a duplicate of the current configuration into another one.
  55798. * @param brdfConfiguration define the config where to copy the info
  55799. */
  55800. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55801. /**
  55802. * Serializes this BRDF configuration.
  55803. * @returns - An object with the serialized config.
  55804. */
  55805. serialize(): any;
  55806. /**
  55807. * Parses a anisotropy Configuration from a serialized object.
  55808. * @param source - Serialized object.
  55809. * @param scene Defines the scene we are parsing for
  55810. * @param rootUrl Defines the rootUrl to load from
  55811. */
  55812. parse(source: any, scene: Scene, rootUrl: string): void;
  55813. }
  55814. }
  55815. declare module BABYLON {
  55816. /**
  55817. * @hidden
  55818. */
  55819. export interface IMaterialSheenDefines {
  55820. SHEEN: boolean;
  55821. SHEEN_TEXTURE: boolean;
  55822. SHEEN_TEXTUREDIRECTUV: number;
  55823. SHEEN_LINKWITHALBEDO: boolean;
  55824. SHEEN_ROUGHNESS: boolean;
  55825. SHEEN_ALBEDOSCALING: boolean;
  55826. /** @hidden */
  55827. _areTexturesDirty: boolean;
  55828. }
  55829. /**
  55830. * Define the code related to the Sheen parameters of the pbr material.
  55831. */
  55832. export class PBRSheenConfiguration {
  55833. private _isEnabled;
  55834. /**
  55835. * Defines if the material uses sheen.
  55836. */
  55837. isEnabled: boolean;
  55838. private _linkSheenWithAlbedo;
  55839. /**
  55840. * Defines if the sheen is linked to the sheen color.
  55841. */
  55842. linkSheenWithAlbedo: boolean;
  55843. /**
  55844. * Defines the sheen intensity.
  55845. */
  55846. intensity: number;
  55847. /**
  55848. * Defines the sheen color.
  55849. */
  55850. color: Color3;
  55851. private _texture;
  55852. /**
  55853. * Stores the sheen tint values in a texture.
  55854. * rgb is tint
  55855. * a is a intensity or roughness if roughness has been defined
  55856. */
  55857. texture: Nullable<BaseTexture>;
  55858. private _roughness;
  55859. /**
  55860. * Defines the sheen roughness.
  55861. * It is not taken into account if linkSheenWithAlbedo is true.
  55862. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55863. */
  55864. roughness: Nullable<number>;
  55865. private _albedoScaling;
  55866. /**
  55867. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55868. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55869. * making it easier to setup and tweak the effect
  55870. */
  55871. albedoScaling: boolean;
  55872. /** @hidden */
  55873. private _internalMarkAllSubMeshesAsTexturesDirty;
  55874. /** @hidden */
  55875. _markAllSubMeshesAsTexturesDirty(): void;
  55876. /**
  55877. * Instantiate a new istance of clear coat configuration.
  55878. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55879. */
  55880. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55881. /**
  55882. * Specifies that the submesh is ready to be used.
  55883. * @param defines the list of "defines" to update.
  55884. * @param scene defines the scene the material belongs to.
  55885. * @returns - boolean indicating that the submesh is ready or not.
  55886. */
  55887. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55888. /**
  55889. * Checks to see if a texture is used in the material.
  55890. * @param defines the list of "defines" to update.
  55891. * @param scene defines the scene the material belongs to.
  55892. */
  55893. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55894. /**
  55895. * Binds the material data.
  55896. * @param uniformBuffer defines the Uniform buffer to fill in.
  55897. * @param scene defines the scene the material belongs to.
  55898. * @param isFrozen defines wether the material is frozen or not.
  55899. */
  55900. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55901. /**
  55902. * Checks to see if a texture is used in the material.
  55903. * @param texture - Base texture to use.
  55904. * @returns - Boolean specifying if a texture is used in the material.
  55905. */
  55906. hasTexture(texture: BaseTexture): boolean;
  55907. /**
  55908. * Returns an array of the actively used textures.
  55909. * @param activeTextures Array of BaseTextures
  55910. */
  55911. getActiveTextures(activeTextures: BaseTexture[]): void;
  55912. /**
  55913. * Returns the animatable textures.
  55914. * @param animatables Array of animatable textures.
  55915. */
  55916. getAnimatables(animatables: IAnimatable[]): void;
  55917. /**
  55918. * Disposes the resources of the material.
  55919. * @param forceDisposeTextures - Forces the disposal of all textures.
  55920. */
  55921. dispose(forceDisposeTextures?: boolean): void;
  55922. /**
  55923. * Get the current class name of the texture useful for serialization or dynamic coding.
  55924. * @returns "PBRSheenConfiguration"
  55925. */
  55926. getClassName(): string;
  55927. /**
  55928. * Add fallbacks to the effect fallbacks list.
  55929. * @param defines defines the Base texture to use.
  55930. * @param fallbacks defines the current fallback list.
  55931. * @param currentRank defines the current fallback rank.
  55932. * @returns the new fallback rank.
  55933. */
  55934. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55935. /**
  55936. * Add the required uniforms to the current list.
  55937. * @param uniforms defines the current uniform list.
  55938. */
  55939. static AddUniforms(uniforms: string[]): void;
  55940. /**
  55941. * Add the required uniforms to the current buffer.
  55942. * @param uniformBuffer defines the current uniform buffer.
  55943. */
  55944. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55945. /**
  55946. * Add the required samplers to the current list.
  55947. * @param samplers defines the current sampler list.
  55948. */
  55949. static AddSamplers(samplers: string[]): void;
  55950. /**
  55951. * Makes a duplicate of the current configuration into another one.
  55952. * @param sheenConfiguration define the config where to copy the info
  55953. */
  55954. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55955. /**
  55956. * Serializes this BRDF configuration.
  55957. * @returns - An object with the serialized config.
  55958. */
  55959. serialize(): any;
  55960. /**
  55961. * Parses a anisotropy Configuration from a serialized object.
  55962. * @param source - Serialized object.
  55963. * @param scene Defines the scene we are parsing for
  55964. * @param rootUrl Defines the rootUrl to load from
  55965. */
  55966. parse(source: any, scene: Scene, rootUrl: string): void;
  55967. }
  55968. }
  55969. declare module BABYLON {
  55970. /**
  55971. * @hidden
  55972. */
  55973. export interface IMaterialSubSurfaceDefines {
  55974. SUBSURFACE: boolean;
  55975. SS_REFRACTION: boolean;
  55976. SS_TRANSLUCENCY: boolean;
  55977. SS_SCATTERING: boolean;
  55978. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55979. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55980. SS_REFRACTIONMAP_3D: boolean;
  55981. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55982. SS_LODINREFRACTIONALPHA: boolean;
  55983. SS_GAMMAREFRACTION: boolean;
  55984. SS_RGBDREFRACTION: boolean;
  55985. SS_LINEARSPECULARREFRACTION: boolean;
  55986. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55987. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55988. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55989. /** @hidden */
  55990. _areTexturesDirty: boolean;
  55991. }
  55992. /**
  55993. * Define the code related to the sub surface parameters of the pbr material.
  55994. */
  55995. export class PBRSubSurfaceConfiguration {
  55996. private _isRefractionEnabled;
  55997. /**
  55998. * Defines if the refraction is enabled in the material.
  55999. */
  56000. isRefractionEnabled: boolean;
  56001. private _isTranslucencyEnabled;
  56002. /**
  56003. * Defines if the translucency is enabled in the material.
  56004. */
  56005. isTranslucencyEnabled: boolean;
  56006. private _isScatteringEnabled;
  56007. /**
  56008. * Defines if the sub surface scattering is enabled in the material.
  56009. */
  56010. isScatteringEnabled: boolean;
  56011. private _scatteringDiffusionProfileIndex;
  56012. /**
  56013. * Diffusion profile for subsurface scattering.
  56014. * Useful for better scattering in the skins or foliages.
  56015. */
  56016. get scatteringDiffusionProfile(): Nullable<Color3>;
  56017. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56018. /**
  56019. * Defines the refraction intensity of the material.
  56020. * The refraction when enabled replaces the Diffuse part of the material.
  56021. * The intensity helps transitionning between diffuse and refraction.
  56022. */
  56023. refractionIntensity: number;
  56024. /**
  56025. * Defines the translucency intensity of the material.
  56026. * When translucency has been enabled, this defines how much of the "translucency"
  56027. * is addded to the diffuse part of the material.
  56028. */
  56029. translucencyIntensity: number;
  56030. /**
  56031. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56032. */
  56033. useAlbedoToTintRefraction: boolean;
  56034. private _thicknessTexture;
  56035. /**
  56036. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56037. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56038. * 0 would mean minimumThickness
  56039. * 1 would mean maximumThickness
  56040. * The other channels might be use as a mask to vary the different effects intensity.
  56041. */
  56042. thicknessTexture: Nullable<BaseTexture>;
  56043. private _refractionTexture;
  56044. /**
  56045. * Defines the texture to use for refraction.
  56046. */
  56047. refractionTexture: Nullable<BaseTexture>;
  56048. private _indexOfRefraction;
  56049. /**
  56050. * Index of refraction of the material base layer.
  56051. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56052. *
  56053. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56054. *
  56055. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56056. */
  56057. indexOfRefraction: number;
  56058. private _volumeIndexOfRefraction;
  56059. /**
  56060. * Index of refraction of the material's volume.
  56061. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56062. *
  56063. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56064. * the volume will use the same IOR as the surface.
  56065. */
  56066. get volumeIndexOfRefraction(): number;
  56067. set volumeIndexOfRefraction(value: number);
  56068. private _invertRefractionY;
  56069. /**
  56070. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56071. */
  56072. invertRefractionY: boolean;
  56073. private _linkRefractionWithTransparency;
  56074. /**
  56075. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56076. * Materials half opaque for instance using refraction could benefit from this control.
  56077. */
  56078. linkRefractionWithTransparency: boolean;
  56079. /**
  56080. * Defines the minimum thickness stored in the thickness map.
  56081. * If no thickness map is defined, this value will be used to simulate thickness.
  56082. */
  56083. minimumThickness: number;
  56084. /**
  56085. * Defines the maximum thickness stored in the thickness map.
  56086. */
  56087. maximumThickness: number;
  56088. /**
  56089. * Defines the volume tint of the material.
  56090. * This is used for both translucency and scattering.
  56091. */
  56092. tintColor: Color3;
  56093. /**
  56094. * Defines the distance at which the tint color should be found in the media.
  56095. * This is used for refraction only.
  56096. */
  56097. tintColorAtDistance: number;
  56098. /**
  56099. * Defines how far each channel transmit through the media.
  56100. * It is defined as a color to simplify it selection.
  56101. */
  56102. diffusionDistance: Color3;
  56103. private _useMaskFromThicknessTexture;
  56104. /**
  56105. * Stores the intensity of the different subsurface effects in the thickness texture.
  56106. * * the green channel is the translucency intensity.
  56107. * * the blue channel is the scattering intensity.
  56108. * * the alpha channel is the refraction intensity.
  56109. */
  56110. useMaskFromThicknessTexture: boolean;
  56111. private _scene;
  56112. /** @hidden */
  56113. private _internalMarkAllSubMeshesAsTexturesDirty;
  56114. private _internalMarkScenePrePassDirty;
  56115. /** @hidden */
  56116. _markAllSubMeshesAsTexturesDirty(): void;
  56117. /** @hidden */
  56118. _markScenePrePassDirty(): void;
  56119. /**
  56120. * Instantiate a new istance of sub surface configuration.
  56121. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56122. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56123. * @param scene The scene
  56124. */
  56125. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56126. /**
  56127. * Gets wehter the submesh is ready to be used or not.
  56128. * @param defines the list of "defines" to update.
  56129. * @param scene defines the scene the material belongs to.
  56130. * @returns - boolean indicating that the submesh is ready or not.
  56131. */
  56132. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56133. /**
  56134. * Checks to see if a texture is used in the material.
  56135. * @param defines the list of "defines" to update.
  56136. * @param scene defines the scene to the material belongs to.
  56137. */
  56138. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56139. /**
  56140. * Binds the material data.
  56141. * @param uniformBuffer defines the Uniform buffer to fill in.
  56142. * @param scene defines the scene the material belongs to.
  56143. * @param engine defines the engine the material belongs to.
  56144. * @param isFrozen defines whether the material is frozen or not.
  56145. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56146. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56147. */
  56148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56149. /**
  56150. * Unbinds the material from the mesh.
  56151. * @param activeEffect defines the effect that should be unbound from.
  56152. * @returns true if unbound, otherwise false
  56153. */
  56154. unbind(activeEffect: Effect): boolean;
  56155. /**
  56156. * Returns the texture used for refraction or null if none is used.
  56157. * @param scene defines the scene the material belongs to.
  56158. * @returns - Refraction texture if present. If no refraction texture and refraction
  56159. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56160. */
  56161. private _getRefractionTexture;
  56162. /**
  56163. * Returns true if alpha blending should be disabled.
  56164. */
  56165. get disableAlphaBlending(): boolean;
  56166. /**
  56167. * Fills the list of render target textures.
  56168. * @param renderTargets the list of render targets to update
  56169. */
  56170. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56171. /**
  56172. * Checks to see if a texture is used in the material.
  56173. * @param texture - Base texture to use.
  56174. * @returns - Boolean specifying if a texture is used in the material.
  56175. */
  56176. hasTexture(texture: BaseTexture): boolean;
  56177. /**
  56178. * Gets a boolean indicating that current material needs to register RTT
  56179. * @returns true if this uses a render target otherwise false.
  56180. */
  56181. hasRenderTargetTextures(): boolean;
  56182. /**
  56183. * Returns an array of the actively used textures.
  56184. * @param activeTextures Array of BaseTextures
  56185. */
  56186. getActiveTextures(activeTextures: BaseTexture[]): void;
  56187. /**
  56188. * Returns the animatable textures.
  56189. * @param animatables Array of animatable textures.
  56190. */
  56191. getAnimatables(animatables: IAnimatable[]): void;
  56192. /**
  56193. * Disposes the resources of the material.
  56194. * @param forceDisposeTextures - Forces the disposal of all textures.
  56195. */
  56196. dispose(forceDisposeTextures?: boolean): void;
  56197. /**
  56198. * Get the current class name of the texture useful for serialization or dynamic coding.
  56199. * @returns "PBRSubSurfaceConfiguration"
  56200. */
  56201. getClassName(): string;
  56202. /**
  56203. * Add fallbacks to the effect fallbacks list.
  56204. * @param defines defines the Base texture to use.
  56205. * @param fallbacks defines the current fallback list.
  56206. * @param currentRank defines the current fallback rank.
  56207. * @returns the new fallback rank.
  56208. */
  56209. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56210. /**
  56211. * Add the required uniforms to the current list.
  56212. * @param uniforms defines the current uniform list.
  56213. */
  56214. static AddUniforms(uniforms: string[]): void;
  56215. /**
  56216. * Add the required samplers to the current list.
  56217. * @param samplers defines the current sampler list.
  56218. */
  56219. static AddSamplers(samplers: string[]): void;
  56220. /**
  56221. * Add the required uniforms to the current buffer.
  56222. * @param uniformBuffer defines the current uniform buffer.
  56223. */
  56224. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56225. /**
  56226. * Makes a duplicate of the current configuration into another one.
  56227. * @param configuration define the config where to copy the info
  56228. */
  56229. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56230. /**
  56231. * Serializes this Sub Surface configuration.
  56232. * @returns - An object with the serialized config.
  56233. */
  56234. serialize(): any;
  56235. /**
  56236. * Parses a anisotropy Configuration from a serialized object.
  56237. * @param source - Serialized object.
  56238. * @param scene Defines the scene we are parsing for
  56239. * @param rootUrl Defines the rootUrl to load from
  56240. */
  56241. parse(source: any, scene: Scene, rootUrl: string): void;
  56242. }
  56243. }
  56244. declare module BABYLON {
  56245. /** @hidden */
  56246. export var pbrFragmentDeclaration: {
  56247. name: string;
  56248. shader: string;
  56249. };
  56250. }
  56251. declare module BABYLON {
  56252. /** @hidden */
  56253. export var pbrUboDeclaration: {
  56254. name: string;
  56255. shader: string;
  56256. };
  56257. }
  56258. declare module BABYLON {
  56259. /** @hidden */
  56260. export var pbrFragmentExtraDeclaration: {
  56261. name: string;
  56262. shader: string;
  56263. };
  56264. }
  56265. declare module BABYLON {
  56266. /** @hidden */
  56267. export var pbrFragmentSamplersDeclaration: {
  56268. name: string;
  56269. shader: string;
  56270. };
  56271. }
  56272. declare module BABYLON {
  56273. /** @hidden */
  56274. export var subSurfaceScatteringFunctions: {
  56275. name: string;
  56276. shader: string;
  56277. };
  56278. }
  56279. declare module BABYLON {
  56280. /** @hidden */
  56281. export var importanceSampling: {
  56282. name: string;
  56283. shader: string;
  56284. };
  56285. }
  56286. declare module BABYLON {
  56287. /** @hidden */
  56288. export var pbrHelperFunctions: {
  56289. name: string;
  56290. shader: string;
  56291. };
  56292. }
  56293. declare module BABYLON {
  56294. /** @hidden */
  56295. export var harmonicsFunctions: {
  56296. name: string;
  56297. shader: string;
  56298. };
  56299. }
  56300. declare module BABYLON {
  56301. /** @hidden */
  56302. export var pbrDirectLightingSetupFunctions: {
  56303. name: string;
  56304. shader: string;
  56305. };
  56306. }
  56307. declare module BABYLON {
  56308. /** @hidden */
  56309. export var pbrDirectLightingFalloffFunctions: {
  56310. name: string;
  56311. shader: string;
  56312. };
  56313. }
  56314. declare module BABYLON {
  56315. /** @hidden */
  56316. export var pbrBRDFFunctions: {
  56317. name: string;
  56318. shader: string;
  56319. };
  56320. }
  56321. declare module BABYLON {
  56322. /** @hidden */
  56323. export var hdrFilteringFunctions: {
  56324. name: string;
  56325. shader: string;
  56326. };
  56327. }
  56328. declare module BABYLON {
  56329. /** @hidden */
  56330. export var pbrDirectLightingFunctions: {
  56331. name: string;
  56332. shader: string;
  56333. };
  56334. }
  56335. declare module BABYLON {
  56336. /** @hidden */
  56337. export var pbrIBLFunctions: {
  56338. name: string;
  56339. shader: string;
  56340. };
  56341. }
  56342. declare module BABYLON {
  56343. /** @hidden */
  56344. export var pbrBlockAlbedoOpacity: {
  56345. name: string;
  56346. shader: string;
  56347. };
  56348. }
  56349. declare module BABYLON {
  56350. /** @hidden */
  56351. export var pbrBlockReflectivity: {
  56352. name: string;
  56353. shader: string;
  56354. };
  56355. }
  56356. declare module BABYLON {
  56357. /** @hidden */
  56358. export var pbrBlockAmbientOcclusion: {
  56359. name: string;
  56360. shader: string;
  56361. };
  56362. }
  56363. declare module BABYLON {
  56364. /** @hidden */
  56365. export var pbrBlockAlphaFresnel: {
  56366. name: string;
  56367. shader: string;
  56368. };
  56369. }
  56370. declare module BABYLON {
  56371. /** @hidden */
  56372. export var pbrBlockAnisotropic: {
  56373. name: string;
  56374. shader: string;
  56375. };
  56376. }
  56377. declare module BABYLON {
  56378. /** @hidden */
  56379. export var pbrBlockReflection: {
  56380. name: string;
  56381. shader: string;
  56382. };
  56383. }
  56384. declare module BABYLON {
  56385. /** @hidden */
  56386. export var pbrBlockSheen: {
  56387. name: string;
  56388. shader: string;
  56389. };
  56390. }
  56391. declare module BABYLON {
  56392. /** @hidden */
  56393. export var pbrBlockClearcoat: {
  56394. name: string;
  56395. shader: string;
  56396. };
  56397. }
  56398. declare module BABYLON {
  56399. /** @hidden */
  56400. export var pbrBlockSubSurface: {
  56401. name: string;
  56402. shader: string;
  56403. };
  56404. }
  56405. declare module BABYLON {
  56406. /** @hidden */
  56407. export var pbrBlockNormalGeometric: {
  56408. name: string;
  56409. shader: string;
  56410. };
  56411. }
  56412. declare module BABYLON {
  56413. /** @hidden */
  56414. export var pbrBlockNormalFinal: {
  56415. name: string;
  56416. shader: string;
  56417. };
  56418. }
  56419. declare module BABYLON {
  56420. /** @hidden */
  56421. export var pbrBlockLightmapInit: {
  56422. name: string;
  56423. shader: string;
  56424. };
  56425. }
  56426. declare module BABYLON {
  56427. /** @hidden */
  56428. export var pbrBlockGeometryInfo: {
  56429. name: string;
  56430. shader: string;
  56431. };
  56432. }
  56433. declare module BABYLON {
  56434. /** @hidden */
  56435. export var pbrBlockReflectance0: {
  56436. name: string;
  56437. shader: string;
  56438. };
  56439. }
  56440. declare module BABYLON {
  56441. /** @hidden */
  56442. export var pbrBlockReflectance: {
  56443. name: string;
  56444. shader: string;
  56445. };
  56446. }
  56447. declare module BABYLON {
  56448. /** @hidden */
  56449. export var pbrBlockDirectLighting: {
  56450. name: string;
  56451. shader: string;
  56452. };
  56453. }
  56454. declare module BABYLON {
  56455. /** @hidden */
  56456. export var pbrBlockFinalLitComponents: {
  56457. name: string;
  56458. shader: string;
  56459. };
  56460. }
  56461. declare module BABYLON {
  56462. /** @hidden */
  56463. export var pbrBlockFinalUnlitComponents: {
  56464. name: string;
  56465. shader: string;
  56466. };
  56467. }
  56468. declare module BABYLON {
  56469. /** @hidden */
  56470. export var pbrBlockFinalColorComposition: {
  56471. name: string;
  56472. shader: string;
  56473. };
  56474. }
  56475. declare module BABYLON {
  56476. /** @hidden */
  56477. export var pbrBlockImageProcessing: {
  56478. name: string;
  56479. shader: string;
  56480. };
  56481. }
  56482. declare module BABYLON {
  56483. /** @hidden */
  56484. export var pbrDebug: {
  56485. name: string;
  56486. shader: string;
  56487. };
  56488. }
  56489. declare module BABYLON {
  56490. /** @hidden */
  56491. export var pbrPixelShader: {
  56492. name: string;
  56493. shader: string;
  56494. };
  56495. }
  56496. declare module BABYLON {
  56497. /** @hidden */
  56498. export var pbrVertexDeclaration: {
  56499. name: string;
  56500. shader: string;
  56501. };
  56502. }
  56503. declare module BABYLON {
  56504. /** @hidden */
  56505. export var pbrVertexShader: {
  56506. name: string;
  56507. shader: string;
  56508. };
  56509. }
  56510. declare module BABYLON {
  56511. /**
  56512. * Manages the defines for the PBR Material.
  56513. * @hidden
  56514. */
  56515. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56516. PBR: boolean;
  56517. NUM_SAMPLES: string;
  56518. REALTIME_FILTERING: boolean;
  56519. MAINUV1: boolean;
  56520. MAINUV2: boolean;
  56521. UV1: boolean;
  56522. UV2: boolean;
  56523. ALBEDO: boolean;
  56524. GAMMAALBEDO: boolean;
  56525. ALBEDODIRECTUV: number;
  56526. VERTEXCOLOR: boolean;
  56527. DETAIL: boolean;
  56528. DETAILDIRECTUV: number;
  56529. DETAIL_NORMALBLENDMETHOD: number;
  56530. AMBIENT: boolean;
  56531. AMBIENTDIRECTUV: number;
  56532. AMBIENTINGRAYSCALE: boolean;
  56533. OPACITY: boolean;
  56534. VERTEXALPHA: boolean;
  56535. OPACITYDIRECTUV: number;
  56536. OPACITYRGB: boolean;
  56537. ALPHATEST: boolean;
  56538. DEPTHPREPASS: boolean;
  56539. ALPHABLEND: boolean;
  56540. ALPHAFROMALBEDO: boolean;
  56541. ALPHATESTVALUE: string;
  56542. SPECULAROVERALPHA: boolean;
  56543. RADIANCEOVERALPHA: boolean;
  56544. ALPHAFRESNEL: boolean;
  56545. LINEARALPHAFRESNEL: boolean;
  56546. PREMULTIPLYALPHA: boolean;
  56547. EMISSIVE: boolean;
  56548. EMISSIVEDIRECTUV: number;
  56549. REFLECTIVITY: boolean;
  56550. REFLECTIVITYDIRECTUV: number;
  56551. SPECULARTERM: boolean;
  56552. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56553. MICROSURFACEAUTOMATIC: boolean;
  56554. LODBASEDMICROSFURACE: boolean;
  56555. MICROSURFACEMAP: boolean;
  56556. MICROSURFACEMAPDIRECTUV: number;
  56557. METALLICWORKFLOW: boolean;
  56558. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56559. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56560. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56561. AOSTOREINMETALMAPRED: boolean;
  56562. METALLIC_REFLECTANCE: boolean;
  56563. METALLIC_REFLECTANCEDIRECTUV: number;
  56564. ENVIRONMENTBRDF: boolean;
  56565. ENVIRONMENTBRDF_RGBD: boolean;
  56566. NORMAL: boolean;
  56567. TANGENT: boolean;
  56568. BUMP: boolean;
  56569. BUMPDIRECTUV: number;
  56570. OBJECTSPACE_NORMALMAP: boolean;
  56571. PARALLAX: boolean;
  56572. PARALLAXOCCLUSION: boolean;
  56573. NORMALXYSCALE: boolean;
  56574. LIGHTMAP: boolean;
  56575. LIGHTMAPDIRECTUV: number;
  56576. USELIGHTMAPASSHADOWMAP: boolean;
  56577. GAMMALIGHTMAP: boolean;
  56578. RGBDLIGHTMAP: boolean;
  56579. REFLECTION: boolean;
  56580. REFLECTIONMAP_3D: boolean;
  56581. REFLECTIONMAP_SPHERICAL: boolean;
  56582. REFLECTIONMAP_PLANAR: boolean;
  56583. REFLECTIONMAP_CUBIC: boolean;
  56584. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56585. REFLECTIONMAP_PROJECTION: boolean;
  56586. REFLECTIONMAP_SKYBOX: boolean;
  56587. REFLECTIONMAP_EXPLICIT: boolean;
  56588. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56589. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56590. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56591. INVERTCUBICMAP: boolean;
  56592. USESPHERICALFROMREFLECTIONMAP: boolean;
  56593. USEIRRADIANCEMAP: boolean;
  56594. SPHERICAL_HARMONICS: boolean;
  56595. USESPHERICALINVERTEX: boolean;
  56596. REFLECTIONMAP_OPPOSITEZ: boolean;
  56597. LODINREFLECTIONALPHA: boolean;
  56598. GAMMAREFLECTION: boolean;
  56599. RGBDREFLECTION: boolean;
  56600. LINEARSPECULARREFLECTION: boolean;
  56601. RADIANCEOCCLUSION: boolean;
  56602. HORIZONOCCLUSION: boolean;
  56603. INSTANCES: boolean;
  56604. THIN_INSTANCES: boolean;
  56605. PREPASS: boolean;
  56606. PREPASS_IRRADIANCE: boolean;
  56607. PREPASS_IRRADIANCE_INDEX: number;
  56608. PREPASS_ALBEDO: boolean;
  56609. PREPASS_ALBEDO_INDEX: number;
  56610. PREPASS_DEPTHNORMAL: boolean;
  56611. PREPASS_DEPTHNORMAL_INDEX: number;
  56612. SCENE_MRT_COUNT: number;
  56613. NUM_BONE_INFLUENCERS: number;
  56614. BonesPerMesh: number;
  56615. BONETEXTURE: boolean;
  56616. NONUNIFORMSCALING: boolean;
  56617. MORPHTARGETS: boolean;
  56618. MORPHTARGETS_NORMAL: boolean;
  56619. MORPHTARGETS_TANGENT: boolean;
  56620. MORPHTARGETS_UV: boolean;
  56621. NUM_MORPH_INFLUENCERS: number;
  56622. IMAGEPROCESSING: boolean;
  56623. VIGNETTE: boolean;
  56624. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56625. VIGNETTEBLENDMODEOPAQUE: boolean;
  56626. TONEMAPPING: boolean;
  56627. TONEMAPPING_ACES: boolean;
  56628. CONTRAST: boolean;
  56629. COLORCURVES: boolean;
  56630. COLORGRADING: boolean;
  56631. COLORGRADING3D: boolean;
  56632. SAMPLER3DGREENDEPTH: boolean;
  56633. SAMPLER3DBGRMAP: boolean;
  56634. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56635. EXPOSURE: boolean;
  56636. MULTIVIEW: boolean;
  56637. USEPHYSICALLIGHTFALLOFF: boolean;
  56638. USEGLTFLIGHTFALLOFF: boolean;
  56639. TWOSIDEDLIGHTING: boolean;
  56640. SHADOWFLOAT: boolean;
  56641. CLIPPLANE: boolean;
  56642. CLIPPLANE2: boolean;
  56643. CLIPPLANE3: boolean;
  56644. CLIPPLANE4: boolean;
  56645. CLIPPLANE5: boolean;
  56646. CLIPPLANE6: boolean;
  56647. POINTSIZE: boolean;
  56648. FOG: boolean;
  56649. LOGARITHMICDEPTH: boolean;
  56650. FORCENORMALFORWARD: boolean;
  56651. SPECULARAA: boolean;
  56652. CLEARCOAT: boolean;
  56653. CLEARCOAT_DEFAULTIOR: boolean;
  56654. CLEARCOAT_TEXTURE: boolean;
  56655. CLEARCOAT_TEXTUREDIRECTUV: number;
  56656. CLEARCOAT_BUMP: boolean;
  56657. CLEARCOAT_BUMPDIRECTUV: number;
  56658. CLEARCOAT_TINT: boolean;
  56659. CLEARCOAT_TINT_TEXTURE: boolean;
  56660. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56661. ANISOTROPIC: boolean;
  56662. ANISOTROPIC_TEXTURE: boolean;
  56663. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56664. BRDF_V_HEIGHT_CORRELATED: boolean;
  56665. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56666. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56667. SHEEN: boolean;
  56668. SHEEN_TEXTURE: boolean;
  56669. SHEEN_TEXTUREDIRECTUV: number;
  56670. SHEEN_LINKWITHALBEDO: boolean;
  56671. SHEEN_ROUGHNESS: boolean;
  56672. SHEEN_ALBEDOSCALING: boolean;
  56673. SUBSURFACE: boolean;
  56674. SS_REFRACTION: boolean;
  56675. SS_TRANSLUCENCY: boolean;
  56676. SS_SCATTERING: boolean;
  56677. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56678. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56679. SS_REFRACTIONMAP_3D: boolean;
  56680. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56681. SS_LODINREFRACTIONALPHA: boolean;
  56682. SS_GAMMAREFRACTION: boolean;
  56683. SS_RGBDREFRACTION: boolean;
  56684. SS_LINEARSPECULARREFRACTION: boolean;
  56685. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56686. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56687. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56688. UNLIT: boolean;
  56689. DEBUGMODE: number;
  56690. /**
  56691. * Initializes the PBR Material defines.
  56692. */
  56693. constructor();
  56694. /**
  56695. * Resets the PBR Material defines.
  56696. */
  56697. reset(): void;
  56698. }
  56699. /**
  56700. * The Physically based material base class of BJS.
  56701. *
  56702. * This offers the main features of a standard PBR material.
  56703. * For more information, please refer to the documentation :
  56704. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56705. */
  56706. export abstract class PBRBaseMaterial extends PushMaterial {
  56707. /**
  56708. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56709. */
  56710. static readonly PBRMATERIAL_OPAQUE: number;
  56711. /**
  56712. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56713. */
  56714. static readonly PBRMATERIAL_ALPHATEST: number;
  56715. /**
  56716. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56717. */
  56718. static readonly PBRMATERIAL_ALPHABLEND: number;
  56719. /**
  56720. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56721. * They are also discarded below the alpha cutoff threshold to improve performances.
  56722. */
  56723. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56724. /**
  56725. * Defines the default value of how much AO map is occluding the analytical lights
  56726. * (point spot...).
  56727. */
  56728. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56729. /**
  56730. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56731. */
  56732. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56733. /**
  56734. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56735. * to enhance interoperability with other engines.
  56736. */
  56737. static readonly LIGHTFALLOFF_GLTF: number;
  56738. /**
  56739. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56740. * to enhance interoperability with other materials.
  56741. */
  56742. static readonly LIGHTFALLOFF_STANDARD: number;
  56743. /**
  56744. * Intensity of the direct lights e.g. the four lights available in your scene.
  56745. * This impacts both the direct diffuse and specular highlights.
  56746. */
  56747. protected _directIntensity: number;
  56748. /**
  56749. * Intensity of the emissive part of the material.
  56750. * This helps controlling the emissive effect without modifying the emissive color.
  56751. */
  56752. protected _emissiveIntensity: number;
  56753. /**
  56754. * Intensity of the environment e.g. how much the environment will light the object
  56755. * either through harmonics for rough material or through the refelction for shiny ones.
  56756. */
  56757. protected _environmentIntensity: number;
  56758. /**
  56759. * This is a special control allowing the reduction of the specular highlights coming from the
  56760. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56761. */
  56762. protected _specularIntensity: number;
  56763. /**
  56764. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56765. */
  56766. private _lightingInfos;
  56767. /**
  56768. * Debug Control allowing disabling the bump map on this material.
  56769. */
  56770. protected _disableBumpMap: boolean;
  56771. /**
  56772. * AKA Diffuse Texture in standard nomenclature.
  56773. */
  56774. protected _albedoTexture: Nullable<BaseTexture>;
  56775. /**
  56776. * AKA Occlusion Texture in other nomenclature.
  56777. */
  56778. protected _ambientTexture: Nullable<BaseTexture>;
  56779. /**
  56780. * AKA Occlusion Texture Intensity in other nomenclature.
  56781. */
  56782. protected _ambientTextureStrength: number;
  56783. /**
  56784. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56785. * 1 means it completely occludes it
  56786. * 0 mean it has no impact
  56787. */
  56788. protected _ambientTextureImpactOnAnalyticalLights: number;
  56789. /**
  56790. * Stores the alpha values in a texture.
  56791. */
  56792. protected _opacityTexture: Nullable<BaseTexture>;
  56793. /**
  56794. * Stores the reflection values in a texture.
  56795. */
  56796. protected _reflectionTexture: Nullable<BaseTexture>;
  56797. /**
  56798. * Stores the emissive values in a texture.
  56799. */
  56800. protected _emissiveTexture: Nullable<BaseTexture>;
  56801. /**
  56802. * AKA Specular texture in other nomenclature.
  56803. */
  56804. protected _reflectivityTexture: Nullable<BaseTexture>;
  56805. /**
  56806. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56807. */
  56808. protected _metallicTexture: Nullable<BaseTexture>;
  56809. /**
  56810. * Specifies the metallic scalar of the metallic/roughness workflow.
  56811. * Can also be used to scale the metalness values of the metallic texture.
  56812. */
  56813. protected _metallic: Nullable<number>;
  56814. /**
  56815. * Specifies the roughness scalar of the metallic/roughness workflow.
  56816. * Can also be used to scale the roughness values of the metallic texture.
  56817. */
  56818. protected _roughness: Nullable<number>;
  56819. /**
  56820. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56821. * By default the indexOfrefraction is used to compute F0;
  56822. *
  56823. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56824. *
  56825. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56826. * F90 = metallicReflectanceColor;
  56827. */
  56828. protected _metallicF0Factor: number;
  56829. /**
  56830. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56831. * By default the F90 is always 1;
  56832. *
  56833. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56834. *
  56835. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56836. * F90 = metallicReflectanceColor;
  56837. */
  56838. protected _metallicReflectanceColor: Color3;
  56839. /**
  56840. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56841. * This is multiply against the scalar values defined in the material.
  56842. */
  56843. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56844. /**
  56845. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56846. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56847. */
  56848. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56849. /**
  56850. * Stores surface normal data used to displace a mesh in a texture.
  56851. */
  56852. protected _bumpTexture: Nullable<BaseTexture>;
  56853. /**
  56854. * Stores the pre-calculated light information of a mesh in a texture.
  56855. */
  56856. protected _lightmapTexture: Nullable<BaseTexture>;
  56857. /**
  56858. * The color of a material in ambient lighting.
  56859. */
  56860. protected _ambientColor: Color3;
  56861. /**
  56862. * AKA Diffuse Color in other nomenclature.
  56863. */
  56864. protected _albedoColor: Color3;
  56865. /**
  56866. * AKA Specular Color in other nomenclature.
  56867. */
  56868. protected _reflectivityColor: Color3;
  56869. /**
  56870. * The color applied when light is reflected from a material.
  56871. */
  56872. protected _reflectionColor: Color3;
  56873. /**
  56874. * The color applied when light is emitted from a material.
  56875. */
  56876. protected _emissiveColor: Color3;
  56877. /**
  56878. * AKA Glossiness in other nomenclature.
  56879. */
  56880. protected _microSurface: number;
  56881. /**
  56882. * Specifies that the material will use the light map as a show map.
  56883. */
  56884. protected _useLightmapAsShadowmap: boolean;
  56885. /**
  56886. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56887. * makes the reflect vector face the model (under horizon).
  56888. */
  56889. protected _useHorizonOcclusion: boolean;
  56890. /**
  56891. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56892. * too much the area relying on ambient texture to define their ambient occlusion.
  56893. */
  56894. protected _useRadianceOcclusion: boolean;
  56895. /**
  56896. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56897. */
  56898. protected _useAlphaFromAlbedoTexture: boolean;
  56899. /**
  56900. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56901. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56902. */
  56903. protected _useSpecularOverAlpha: boolean;
  56904. /**
  56905. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56906. */
  56907. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56908. /**
  56909. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56910. */
  56911. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56912. /**
  56913. * Specifies if the metallic texture contains the roughness information in its green channel.
  56914. */
  56915. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56916. /**
  56917. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56918. */
  56919. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56920. /**
  56921. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56922. */
  56923. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56924. /**
  56925. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56926. */
  56927. protected _useAmbientInGrayScale: boolean;
  56928. /**
  56929. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56930. * The material will try to infer what glossiness each pixel should be.
  56931. */
  56932. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56933. /**
  56934. * Defines the falloff type used in this material.
  56935. * It by default is Physical.
  56936. */
  56937. protected _lightFalloff: number;
  56938. /**
  56939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56941. */
  56942. protected _useRadianceOverAlpha: boolean;
  56943. /**
  56944. * Allows using an object space normal map (instead of tangent space).
  56945. */
  56946. protected _useObjectSpaceNormalMap: boolean;
  56947. /**
  56948. * Allows using the bump map in parallax mode.
  56949. */
  56950. protected _useParallax: boolean;
  56951. /**
  56952. * Allows using the bump map in parallax occlusion mode.
  56953. */
  56954. protected _useParallaxOcclusion: boolean;
  56955. /**
  56956. * Controls the scale bias of the parallax mode.
  56957. */
  56958. protected _parallaxScaleBias: number;
  56959. /**
  56960. * If sets to true, disables all the lights affecting the material.
  56961. */
  56962. protected _disableLighting: boolean;
  56963. /**
  56964. * Number of Simultaneous lights allowed on the material.
  56965. */
  56966. protected _maxSimultaneousLights: number;
  56967. /**
  56968. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56969. */
  56970. protected _invertNormalMapX: boolean;
  56971. /**
  56972. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56973. */
  56974. protected _invertNormalMapY: boolean;
  56975. /**
  56976. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56977. */
  56978. protected _twoSidedLighting: boolean;
  56979. /**
  56980. * Defines the alpha limits in alpha test mode.
  56981. */
  56982. protected _alphaCutOff: number;
  56983. /**
  56984. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56985. */
  56986. protected _forceAlphaTest: boolean;
  56987. /**
  56988. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56989. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56990. */
  56991. protected _useAlphaFresnel: boolean;
  56992. /**
  56993. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56994. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56995. */
  56996. protected _useLinearAlphaFresnel: boolean;
  56997. /**
  56998. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56999. * from cos thetav and roughness:
  57000. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57001. */
  57002. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57003. /**
  57004. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57005. */
  57006. protected _forceIrradianceInFragment: boolean;
  57007. private _realTimeFiltering;
  57008. /**
  57009. * Enables realtime filtering on the texture.
  57010. */
  57011. get realTimeFiltering(): boolean;
  57012. set realTimeFiltering(b: boolean);
  57013. private _realTimeFilteringQuality;
  57014. /**
  57015. * Quality switch for realtime filtering
  57016. */
  57017. get realTimeFilteringQuality(): number;
  57018. set realTimeFilteringQuality(n: number);
  57019. /**
  57020. * Can this material render to several textures at once
  57021. */
  57022. get canRenderToMRT(): boolean;
  57023. /**
  57024. * Force normal to face away from face.
  57025. */
  57026. protected _forceNormalForward: boolean;
  57027. /**
  57028. * Enables specular anti aliasing in the PBR shader.
  57029. * It will both interacts on the Geometry for analytical and IBL lighting.
  57030. * It also prefilter the roughness map based on the bump values.
  57031. */
  57032. protected _enableSpecularAntiAliasing: boolean;
  57033. /**
  57034. * Default configuration related to image processing available in the PBR Material.
  57035. */
  57036. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57037. /**
  57038. * Keep track of the image processing observer to allow dispose and replace.
  57039. */
  57040. private _imageProcessingObserver;
  57041. /**
  57042. * Attaches a new image processing configuration to the PBR Material.
  57043. * @param configuration
  57044. */
  57045. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57046. /**
  57047. * Stores the available render targets.
  57048. */
  57049. private _renderTargets;
  57050. /**
  57051. * Sets the global ambient color for the material used in lighting calculations.
  57052. */
  57053. private _globalAmbientColor;
  57054. /**
  57055. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57056. */
  57057. private _useLogarithmicDepth;
  57058. /**
  57059. * If set to true, no lighting calculations will be applied.
  57060. */
  57061. private _unlit;
  57062. private _debugMode;
  57063. /**
  57064. * @hidden
  57065. * This is reserved for the inspector.
  57066. * Defines the material debug mode.
  57067. * It helps seeing only some components of the material while troubleshooting.
  57068. */
  57069. debugMode: number;
  57070. /**
  57071. * @hidden
  57072. * This is reserved for the inspector.
  57073. * Specify from where on screen the debug mode should start.
  57074. * The value goes from -1 (full screen) to 1 (not visible)
  57075. * It helps with side by side comparison against the final render
  57076. * This defaults to -1
  57077. */
  57078. private debugLimit;
  57079. /**
  57080. * @hidden
  57081. * This is reserved for the inspector.
  57082. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57083. * You can use the factor to better multiply the final value.
  57084. */
  57085. private debugFactor;
  57086. /**
  57087. * Defines the clear coat layer parameters for the material.
  57088. */
  57089. readonly clearCoat: PBRClearCoatConfiguration;
  57090. /**
  57091. * Defines the anisotropic parameters for the material.
  57092. */
  57093. readonly anisotropy: PBRAnisotropicConfiguration;
  57094. /**
  57095. * Defines the BRDF parameters for the material.
  57096. */
  57097. readonly brdf: PBRBRDFConfiguration;
  57098. /**
  57099. * Defines the Sheen parameters for the material.
  57100. */
  57101. readonly sheen: PBRSheenConfiguration;
  57102. /**
  57103. * Defines the SubSurface parameters for the material.
  57104. */
  57105. readonly subSurface: PBRSubSurfaceConfiguration;
  57106. /**
  57107. * Defines the detail map parameters for the material.
  57108. */
  57109. readonly detailMap: DetailMapConfiguration;
  57110. protected _rebuildInParallel: boolean;
  57111. /**
  57112. * Instantiates a new PBRMaterial instance.
  57113. *
  57114. * @param name The material name
  57115. * @param scene The scene the material will be use in.
  57116. */
  57117. constructor(name: string, scene: Scene);
  57118. /**
  57119. * Gets a boolean indicating that current material needs to register RTT
  57120. */
  57121. get hasRenderTargetTextures(): boolean;
  57122. /**
  57123. * Gets the name of the material class.
  57124. */
  57125. getClassName(): string;
  57126. /**
  57127. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57128. */
  57129. get useLogarithmicDepth(): boolean;
  57130. /**
  57131. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57132. */
  57133. set useLogarithmicDepth(value: boolean);
  57134. /**
  57135. * Returns true if alpha blending should be disabled.
  57136. */
  57137. protected get _disableAlphaBlending(): boolean;
  57138. /**
  57139. * Specifies whether or not this material should be rendered in alpha blend mode.
  57140. */
  57141. needAlphaBlending(): boolean;
  57142. /**
  57143. * Specifies whether or not this material should be rendered in alpha test mode.
  57144. */
  57145. needAlphaTesting(): boolean;
  57146. /**
  57147. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57148. */
  57149. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57150. /**
  57151. * Gets the texture used for the alpha test.
  57152. */
  57153. getAlphaTestTexture(): Nullable<BaseTexture>;
  57154. /**
  57155. * Specifies that the submesh is ready to be used.
  57156. * @param mesh - BJS mesh.
  57157. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57158. * @param useInstances - Specifies that instances should be used.
  57159. * @returns - boolean indicating that the submesh is ready or not.
  57160. */
  57161. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57162. /**
  57163. * Specifies if the material uses metallic roughness workflow.
  57164. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57165. */
  57166. isMetallicWorkflow(): boolean;
  57167. private _prepareEffect;
  57168. private _prepareDefines;
  57169. /**
  57170. * Force shader compilation
  57171. */
  57172. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57173. /**
  57174. * Initializes the uniform buffer layout for the shader.
  57175. */
  57176. buildUniformLayout(): void;
  57177. /**
  57178. * Unbinds the material from the mesh
  57179. */
  57180. unbind(): void;
  57181. /**
  57182. * Binds the submesh data.
  57183. * @param world - The world matrix.
  57184. * @param mesh - The BJS mesh.
  57185. * @param subMesh - A submesh of the BJS mesh.
  57186. */
  57187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57188. /**
  57189. * Returns the animatable textures.
  57190. * @returns - Array of animatable textures.
  57191. */
  57192. getAnimatables(): IAnimatable[];
  57193. /**
  57194. * Returns the texture used for reflections.
  57195. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57196. */
  57197. private _getReflectionTexture;
  57198. /**
  57199. * Returns an array of the actively used textures.
  57200. * @returns - Array of BaseTextures
  57201. */
  57202. getActiveTextures(): BaseTexture[];
  57203. /**
  57204. * Checks to see if a texture is used in the material.
  57205. * @param texture - Base texture to use.
  57206. * @returns - Boolean specifying if a texture is used in the material.
  57207. */
  57208. hasTexture(texture: BaseTexture): boolean;
  57209. /**
  57210. * Sets the required values to the prepass renderer.
  57211. * @param prePassRenderer defines the prepass renderer to setup
  57212. */
  57213. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57214. /**
  57215. * Disposes the resources of the material.
  57216. * @param forceDisposeEffect - Forces the disposal of effects.
  57217. * @param forceDisposeTextures - Forces the disposal of all textures.
  57218. */
  57219. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57220. }
  57221. }
  57222. declare module BABYLON {
  57223. /**
  57224. * The Physically based material of BJS.
  57225. *
  57226. * This offers the main features of a standard PBR material.
  57227. * For more information, please refer to the documentation :
  57228. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57229. */
  57230. export class PBRMaterial extends PBRBaseMaterial {
  57231. /**
  57232. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57233. */
  57234. static readonly PBRMATERIAL_OPAQUE: number;
  57235. /**
  57236. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57237. */
  57238. static readonly PBRMATERIAL_ALPHATEST: number;
  57239. /**
  57240. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57241. */
  57242. static readonly PBRMATERIAL_ALPHABLEND: number;
  57243. /**
  57244. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57245. * They are also discarded below the alpha cutoff threshold to improve performances.
  57246. */
  57247. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57248. /**
  57249. * Defines the default value of how much AO map is occluding the analytical lights
  57250. * (point spot...).
  57251. */
  57252. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57253. /**
  57254. * Intensity of the direct lights e.g. the four lights available in your scene.
  57255. * This impacts both the direct diffuse and specular highlights.
  57256. */
  57257. directIntensity: number;
  57258. /**
  57259. * Intensity of the emissive part of the material.
  57260. * This helps controlling the emissive effect without modifying the emissive color.
  57261. */
  57262. emissiveIntensity: number;
  57263. /**
  57264. * Intensity of the environment e.g. how much the environment will light the object
  57265. * either through harmonics for rough material or through the refelction for shiny ones.
  57266. */
  57267. environmentIntensity: number;
  57268. /**
  57269. * This is a special control allowing the reduction of the specular highlights coming from the
  57270. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57271. */
  57272. specularIntensity: number;
  57273. /**
  57274. * Debug Control allowing disabling the bump map on this material.
  57275. */
  57276. disableBumpMap: boolean;
  57277. /**
  57278. * AKA Diffuse Texture in standard nomenclature.
  57279. */
  57280. albedoTexture: BaseTexture;
  57281. /**
  57282. * AKA Occlusion Texture in other nomenclature.
  57283. */
  57284. ambientTexture: BaseTexture;
  57285. /**
  57286. * AKA Occlusion Texture Intensity in other nomenclature.
  57287. */
  57288. ambientTextureStrength: number;
  57289. /**
  57290. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57291. * 1 means it completely occludes it
  57292. * 0 mean it has no impact
  57293. */
  57294. ambientTextureImpactOnAnalyticalLights: number;
  57295. /**
  57296. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57297. */
  57298. opacityTexture: BaseTexture;
  57299. /**
  57300. * Stores the reflection values in a texture.
  57301. */
  57302. reflectionTexture: Nullable<BaseTexture>;
  57303. /**
  57304. * Stores the emissive values in a texture.
  57305. */
  57306. emissiveTexture: BaseTexture;
  57307. /**
  57308. * AKA Specular texture in other nomenclature.
  57309. */
  57310. reflectivityTexture: BaseTexture;
  57311. /**
  57312. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57313. */
  57314. metallicTexture: BaseTexture;
  57315. /**
  57316. * Specifies the metallic scalar of the metallic/roughness workflow.
  57317. * Can also be used to scale the metalness values of the metallic texture.
  57318. */
  57319. metallic: Nullable<number>;
  57320. /**
  57321. * Specifies the roughness scalar of the metallic/roughness workflow.
  57322. * Can also be used to scale the roughness values of the metallic texture.
  57323. */
  57324. roughness: Nullable<number>;
  57325. /**
  57326. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57327. * By default the indexOfrefraction is used to compute F0;
  57328. *
  57329. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57330. *
  57331. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57332. * F90 = metallicReflectanceColor;
  57333. */
  57334. metallicF0Factor: number;
  57335. /**
  57336. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57337. * By default the F90 is always 1;
  57338. *
  57339. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57340. *
  57341. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57342. * F90 = metallicReflectanceColor;
  57343. */
  57344. metallicReflectanceColor: Color3;
  57345. /**
  57346. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57347. * This is multiply against the scalar values defined in the material.
  57348. */
  57349. metallicReflectanceTexture: Nullable<BaseTexture>;
  57350. /**
  57351. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57352. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57353. */
  57354. microSurfaceTexture: BaseTexture;
  57355. /**
  57356. * Stores surface normal data used to displace a mesh in a texture.
  57357. */
  57358. bumpTexture: BaseTexture;
  57359. /**
  57360. * Stores the pre-calculated light information of a mesh in a texture.
  57361. */
  57362. lightmapTexture: BaseTexture;
  57363. /**
  57364. * Stores the refracted light information in a texture.
  57365. */
  57366. get refractionTexture(): Nullable<BaseTexture>;
  57367. set refractionTexture(value: Nullable<BaseTexture>);
  57368. /**
  57369. * The color of a material in ambient lighting.
  57370. */
  57371. ambientColor: Color3;
  57372. /**
  57373. * AKA Diffuse Color in other nomenclature.
  57374. */
  57375. albedoColor: Color3;
  57376. /**
  57377. * AKA Specular Color in other nomenclature.
  57378. */
  57379. reflectivityColor: Color3;
  57380. /**
  57381. * The color reflected from the material.
  57382. */
  57383. reflectionColor: Color3;
  57384. /**
  57385. * The color emitted from the material.
  57386. */
  57387. emissiveColor: Color3;
  57388. /**
  57389. * AKA Glossiness in other nomenclature.
  57390. */
  57391. microSurface: number;
  57392. /**
  57393. * Index of refraction of the material base layer.
  57394. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57395. *
  57396. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57397. *
  57398. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57399. */
  57400. get indexOfRefraction(): number;
  57401. set indexOfRefraction(value: number);
  57402. /**
  57403. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57404. */
  57405. get invertRefractionY(): boolean;
  57406. set invertRefractionY(value: boolean);
  57407. /**
  57408. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57409. * Materials half opaque for instance using refraction could benefit from this control.
  57410. */
  57411. get linkRefractionWithTransparency(): boolean;
  57412. set linkRefractionWithTransparency(value: boolean);
  57413. /**
  57414. * If true, the light map contains occlusion information instead of lighting info.
  57415. */
  57416. useLightmapAsShadowmap: boolean;
  57417. /**
  57418. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57419. */
  57420. useAlphaFromAlbedoTexture: boolean;
  57421. /**
  57422. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57423. */
  57424. forceAlphaTest: boolean;
  57425. /**
  57426. * Defines the alpha limits in alpha test mode.
  57427. */
  57428. alphaCutOff: number;
  57429. /**
  57430. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57431. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57432. */
  57433. useSpecularOverAlpha: boolean;
  57434. /**
  57435. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57436. */
  57437. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57438. /**
  57439. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57440. */
  57441. useRoughnessFromMetallicTextureAlpha: boolean;
  57442. /**
  57443. * Specifies if the metallic texture contains the roughness information in its green channel.
  57444. */
  57445. useRoughnessFromMetallicTextureGreen: boolean;
  57446. /**
  57447. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57448. */
  57449. useMetallnessFromMetallicTextureBlue: boolean;
  57450. /**
  57451. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57452. */
  57453. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57454. /**
  57455. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57456. */
  57457. useAmbientInGrayScale: boolean;
  57458. /**
  57459. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57460. * The material will try to infer what glossiness each pixel should be.
  57461. */
  57462. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57463. /**
  57464. * BJS is using an harcoded light falloff based on a manually sets up range.
  57465. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57466. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57467. */
  57468. get usePhysicalLightFalloff(): boolean;
  57469. /**
  57470. * BJS is using an harcoded light falloff based on a manually sets up range.
  57471. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57472. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57473. */
  57474. set usePhysicalLightFalloff(value: boolean);
  57475. /**
  57476. * In order to support the falloff compatibility with gltf, a special mode has been added
  57477. * to reproduce the gltf light falloff.
  57478. */
  57479. get useGLTFLightFalloff(): boolean;
  57480. /**
  57481. * In order to support the falloff compatibility with gltf, a special mode has been added
  57482. * to reproduce the gltf light falloff.
  57483. */
  57484. set useGLTFLightFalloff(value: boolean);
  57485. /**
  57486. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57487. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57488. */
  57489. useRadianceOverAlpha: boolean;
  57490. /**
  57491. * Allows using an object space normal map (instead of tangent space).
  57492. */
  57493. useObjectSpaceNormalMap: boolean;
  57494. /**
  57495. * Allows using the bump map in parallax mode.
  57496. */
  57497. useParallax: boolean;
  57498. /**
  57499. * Allows using the bump map in parallax occlusion mode.
  57500. */
  57501. useParallaxOcclusion: boolean;
  57502. /**
  57503. * Controls the scale bias of the parallax mode.
  57504. */
  57505. parallaxScaleBias: number;
  57506. /**
  57507. * If sets to true, disables all the lights affecting the material.
  57508. */
  57509. disableLighting: boolean;
  57510. /**
  57511. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57512. */
  57513. forceIrradianceInFragment: boolean;
  57514. /**
  57515. * Number of Simultaneous lights allowed on the material.
  57516. */
  57517. maxSimultaneousLights: number;
  57518. /**
  57519. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57520. */
  57521. invertNormalMapX: boolean;
  57522. /**
  57523. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57524. */
  57525. invertNormalMapY: boolean;
  57526. /**
  57527. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57528. */
  57529. twoSidedLighting: boolean;
  57530. /**
  57531. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57532. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57533. */
  57534. useAlphaFresnel: boolean;
  57535. /**
  57536. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57537. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57538. */
  57539. useLinearAlphaFresnel: boolean;
  57540. /**
  57541. * Let user defines the brdf lookup texture used for IBL.
  57542. * A default 8bit version is embedded but you could point at :
  57543. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57544. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57545. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57546. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57547. */
  57548. environmentBRDFTexture: Nullable<BaseTexture>;
  57549. /**
  57550. * Force normal to face away from face.
  57551. */
  57552. forceNormalForward: boolean;
  57553. /**
  57554. * Enables specular anti aliasing in the PBR shader.
  57555. * It will both interacts on the Geometry for analytical and IBL lighting.
  57556. * It also prefilter the roughness map based on the bump values.
  57557. */
  57558. enableSpecularAntiAliasing: boolean;
  57559. /**
  57560. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57561. * makes the reflect vector face the model (under horizon).
  57562. */
  57563. useHorizonOcclusion: boolean;
  57564. /**
  57565. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57566. * too much the area relying on ambient texture to define their ambient occlusion.
  57567. */
  57568. useRadianceOcclusion: boolean;
  57569. /**
  57570. * If set to true, no lighting calculations will be applied.
  57571. */
  57572. unlit: boolean;
  57573. /**
  57574. * Gets the image processing configuration used either in this material.
  57575. */
  57576. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57577. /**
  57578. * Sets the Default image processing configuration used either in the this material.
  57579. *
  57580. * If sets to null, the scene one is in use.
  57581. */
  57582. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57583. /**
  57584. * Gets wether the color curves effect is enabled.
  57585. */
  57586. get cameraColorCurvesEnabled(): boolean;
  57587. /**
  57588. * Sets wether the color curves effect is enabled.
  57589. */
  57590. set cameraColorCurvesEnabled(value: boolean);
  57591. /**
  57592. * Gets wether the color grading effect is enabled.
  57593. */
  57594. get cameraColorGradingEnabled(): boolean;
  57595. /**
  57596. * Gets wether the color grading effect is enabled.
  57597. */
  57598. set cameraColorGradingEnabled(value: boolean);
  57599. /**
  57600. * Gets wether tonemapping is enabled or not.
  57601. */
  57602. get cameraToneMappingEnabled(): boolean;
  57603. /**
  57604. * Sets wether tonemapping is enabled or not
  57605. */
  57606. set cameraToneMappingEnabled(value: boolean);
  57607. /**
  57608. * The camera exposure used on this material.
  57609. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57610. * This corresponds to a photographic exposure.
  57611. */
  57612. get cameraExposure(): number;
  57613. /**
  57614. * The camera exposure used on this material.
  57615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57616. * This corresponds to a photographic exposure.
  57617. */
  57618. set cameraExposure(value: number);
  57619. /**
  57620. * Gets The camera contrast used on this material.
  57621. */
  57622. get cameraContrast(): number;
  57623. /**
  57624. * Sets The camera contrast used on this material.
  57625. */
  57626. set cameraContrast(value: number);
  57627. /**
  57628. * Gets the Color Grading 2D Lookup Texture.
  57629. */
  57630. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57631. /**
  57632. * Sets the Color Grading 2D Lookup Texture.
  57633. */
  57634. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57635. /**
  57636. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57637. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57638. * 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;
  57639. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57640. */
  57641. get cameraColorCurves(): Nullable<ColorCurves>;
  57642. /**
  57643. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57644. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57645. * 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;
  57646. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57647. */
  57648. set cameraColorCurves(value: Nullable<ColorCurves>);
  57649. /**
  57650. * Instantiates a new PBRMaterial instance.
  57651. *
  57652. * @param name The material name
  57653. * @param scene The scene the material will be use in.
  57654. */
  57655. constructor(name: string, scene: Scene);
  57656. /**
  57657. * Returns the name of this material class.
  57658. */
  57659. getClassName(): string;
  57660. /**
  57661. * Makes a duplicate of the current material.
  57662. * @param name - name to use for the new material.
  57663. */
  57664. clone(name: string): PBRMaterial;
  57665. /**
  57666. * Serializes this PBR Material.
  57667. * @returns - An object with the serialized material.
  57668. */
  57669. serialize(): any;
  57670. /**
  57671. * Parses a PBR Material from a serialized object.
  57672. * @param source - Serialized object.
  57673. * @param scene - BJS scene instance.
  57674. * @param rootUrl - url for the scene object
  57675. * @returns - PBRMaterial
  57676. */
  57677. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57678. }
  57679. }
  57680. declare module BABYLON {
  57681. /**
  57682. * Direct draw surface info
  57683. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57684. */
  57685. export interface DDSInfo {
  57686. /**
  57687. * Width of the texture
  57688. */
  57689. width: number;
  57690. /**
  57691. * Width of the texture
  57692. */
  57693. height: number;
  57694. /**
  57695. * Number of Mipmaps for the texture
  57696. * @see https://en.wikipedia.org/wiki/Mipmap
  57697. */
  57698. mipmapCount: number;
  57699. /**
  57700. * If the textures format is a known fourCC format
  57701. * @see https://www.fourcc.org/
  57702. */
  57703. isFourCC: boolean;
  57704. /**
  57705. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57706. */
  57707. isRGB: boolean;
  57708. /**
  57709. * If the texture is a lumincance format
  57710. */
  57711. isLuminance: boolean;
  57712. /**
  57713. * If this is a cube texture
  57714. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57715. */
  57716. isCube: boolean;
  57717. /**
  57718. * If the texture is a compressed format eg. FOURCC_DXT1
  57719. */
  57720. isCompressed: boolean;
  57721. /**
  57722. * The dxgiFormat of the texture
  57723. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57724. */
  57725. dxgiFormat: number;
  57726. /**
  57727. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57728. */
  57729. textureType: number;
  57730. /**
  57731. * Sphericle polynomial created for the dds texture
  57732. */
  57733. sphericalPolynomial?: SphericalPolynomial;
  57734. }
  57735. /**
  57736. * Class used to provide DDS decompression tools
  57737. */
  57738. export class DDSTools {
  57739. /**
  57740. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57741. */
  57742. static StoreLODInAlphaChannel: boolean;
  57743. /**
  57744. * Gets DDS information from an array buffer
  57745. * @param data defines the array buffer view to read data from
  57746. * @returns the DDS information
  57747. */
  57748. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57749. private static _FloatView;
  57750. private static _Int32View;
  57751. private static _ToHalfFloat;
  57752. private static _FromHalfFloat;
  57753. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57754. private static _GetHalfFloatRGBAArrayBuffer;
  57755. private static _GetFloatRGBAArrayBuffer;
  57756. private static _GetFloatAsUIntRGBAArrayBuffer;
  57757. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57758. private static _GetRGBAArrayBuffer;
  57759. private static _ExtractLongWordOrder;
  57760. private static _GetRGBArrayBuffer;
  57761. private static _GetLuminanceArrayBuffer;
  57762. /**
  57763. * Uploads DDS Levels to a Babylon Texture
  57764. * @hidden
  57765. */
  57766. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57767. }
  57768. interface ThinEngine {
  57769. /**
  57770. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57771. * @param rootUrl defines the url where the file to load is located
  57772. * @param scene defines the current scene
  57773. * @param lodScale defines scale to apply to the mip map selection
  57774. * @param lodOffset defines offset to apply to the mip map selection
  57775. * @param onLoad defines an optional callback raised when the texture is loaded
  57776. * @param onError defines an optional callback raised if there is an issue to load the texture
  57777. * @param format defines the format of the data
  57778. * @param forcedExtension defines the extension to use to pick the right loader
  57779. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57780. * @returns the cube texture as an InternalTexture
  57781. */
  57782. 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;
  57783. }
  57784. }
  57785. declare module BABYLON {
  57786. /**
  57787. * Implementation of the DDS Texture Loader.
  57788. * @hidden
  57789. */
  57790. export class _DDSTextureLoader implements IInternalTextureLoader {
  57791. /**
  57792. * Defines wether the loader supports cascade loading the different faces.
  57793. */
  57794. readonly supportCascades: boolean;
  57795. /**
  57796. * This returns if the loader support the current file information.
  57797. * @param extension defines the file extension of the file being loaded
  57798. * @returns true if the loader can load the specified file
  57799. */
  57800. canLoad(extension: string): boolean;
  57801. /**
  57802. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57803. * @param data contains the texture data
  57804. * @param texture defines the BabylonJS internal texture
  57805. * @param createPolynomials will be true if polynomials have been requested
  57806. * @param onLoad defines the callback to trigger once the texture is ready
  57807. * @param onError defines the callback to trigger in case of error
  57808. */
  57809. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57810. /**
  57811. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57812. * @param data contains the texture data
  57813. * @param texture defines the BabylonJS internal texture
  57814. * @param callback defines the method to call once ready to upload
  57815. */
  57816. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57817. }
  57818. }
  57819. declare module BABYLON {
  57820. /**
  57821. * Implementation of the ENV Texture Loader.
  57822. * @hidden
  57823. */
  57824. export class _ENVTextureLoader implements IInternalTextureLoader {
  57825. /**
  57826. * Defines wether the loader supports cascade loading the different faces.
  57827. */
  57828. readonly supportCascades: boolean;
  57829. /**
  57830. * This returns if the loader support the current file information.
  57831. * @param extension defines the file extension of the file being loaded
  57832. * @returns true if the loader can load the specified file
  57833. */
  57834. canLoad(extension: string): boolean;
  57835. /**
  57836. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57837. * @param data contains the texture data
  57838. * @param texture defines the BabylonJS internal texture
  57839. * @param createPolynomials will be true if polynomials have been requested
  57840. * @param onLoad defines the callback to trigger once the texture is ready
  57841. * @param onError defines the callback to trigger in case of error
  57842. */
  57843. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57844. /**
  57845. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57846. * @param data contains the texture data
  57847. * @param texture defines the BabylonJS internal texture
  57848. * @param callback defines the method to call once ready to upload
  57849. */
  57850. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57851. }
  57852. }
  57853. declare module BABYLON {
  57854. /**
  57855. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57856. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57857. */
  57858. export class KhronosTextureContainer {
  57859. /** contents of the KTX container file */
  57860. data: ArrayBufferView;
  57861. private static HEADER_LEN;
  57862. private static COMPRESSED_2D;
  57863. private static COMPRESSED_3D;
  57864. private static TEX_2D;
  57865. private static TEX_3D;
  57866. /**
  57867. * Gets the openGL type
  57868. */
  57869. glType: number;
  57870. /**
  57871. * Gets the openGL type size
  57872. */
  57873. glTypeSize: number;
  57874. /**
  57875. * Gets the openGL format
  57876. */
  57877. glFormat: number;
  57878. /**
  57879. * Gets the openGL internal format
  57880. */
  57881. glInternalFormat: number;
  57882. /**
  57883. * Gets the base internal format
  57884. */
  57885. glBaseInternalFormat: number;
  57886. /**
  57887. * Gets image width in pixel
  57888. */
  57889. pixelWidth: number;
  57890. /**
  57891. * Gets image height in pixel
  57892. */
  57893. pixelHeight: number;
  57894. /**
  57895. * Gets image depth in pixels
  57896. */
  57897. pixelDepth: number;
  57898. /**
  57899. * Gets the number of array elements
  57900. */
  57901. numberOfArrayElements: number;
  57902. /**
  57903. * Gets the number of faces
  57904. */
  57905. numberOfFaces: number;
  57906. /**
  57907. * Gets the number of mipmap levels
  57908. */
  57909. numberOfMipmapLevels: number;
  57910. /**
  57911. * Gets the bytes of key value data
  57912. */
  57913. bytesOfKeyValueData: number;
  57914. /**
  57915. * Gets the load type
  57916. */
  57917. loadType: number;
  57918. /**
  57919. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57920. */
  57921. isInvalid: boolean;
  57922. /**
  57923. * Creates a new KhronosTextureContainer
  57924. * @param data contents of the KTX container file
  57925. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57926. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57927. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57928. */
  57929. constructor(
  57930. /** contents of the KTX container file */
  57931. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57932. /**
  57933. * Uploads KTX content to a Babylon Texture.
  57934. * It is assumed that the texture has already been created & is currently bound
  57935. * @hidden
  57936. */
  57937. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57938. private _upload2DCompressedLevels;
  57939. /**
  57940. * Checks if the given data starts with a KTX file identifier.
  57941. * @param data the data to check
  57942. * @returns true if the data is a KTX file or false otherwise
  57943. */
  57944. static IsValid(data: ArrayBufferView): boolean;
  57945. }
  57946. }
  57947. declare module BABYLON {
  57948. /**
  57949. * Helper class to push actions to a pool of workers.
  57950. */
  57951. export class WorkerPool implements IDisposable {
  57952. private _workerInfos;
  57953. private _pendingActions;
  57954. /**
  57955. * Constructor
  57956. * @param workers Array of workers to use for actions
  57957. */
  57958. constructor(workers: Array<Worker>);
  57959. /**
  57960. * Terminates all workers and clears any pending actions.
  57961. */
  57962. dispose(): void;
  57963. /**
  57964. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57965. * pended until a worker has completed its action.
  57966. * @param action The action to perform. Call onComplete when the action is complete.
  57967. */
  57968. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57969. private _execute;
  57970. }
  57971. }
  57972. declare module BABYLON {
  57973. /**
  57974. * Class for loading KTX2 files
  57975. * @hidden
  57976. */
  57977. export class KhronosTextureContainer2 {
  57978. private static _WorkerPoolPromise?;
  57979. private static _Initialized;
  57980. private static _Ktx2Decoder;
  57981. /**
  57982. * URL to use when loading the KTX2 decoder module
  57983. */
  57984. static JSModuleURL: string;
  57985. /**
  57986. * Default number of workers used to handle data decoding
  57987. */
  57988. static DefaultNumWorkers: number;
  57989. private static GetDefaultNumWorkers;
  57990. private _engine;
  57991. private static _CreateWorkerPool;
  57992. /**
  57993. * Constructor
  57994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57995. */
  57996. constructor(engine: ThinEngine, numWorkers?: number);
  57997. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57998. /**
  57999. * Stop all async operations and release resources.
  58000. */
  58001. dispose(): void;
  58002. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58003. /**
  58004. * Checks if the given data starts with a KTX2 file identifier.
  58005. * @param data the data to check
  58006. * @returns true if the data is a KTX2 file or false otherwise
  58007. */
  58008. static IsValid(data: ArrayBufferView): boolean;
  58009. }
  58010. export function workerFunc(): void;
  58011. }
  58012. declare module BABYLON {
  58013. /**
  58014. * Implementation of the KTX Texture Loader.
  58015. * @hidden
  58016. */
  58017. export class _KTXTextureLoader implements IInternalTextureLoader {
  58018. /**
  58019. * Defines wether the loader supports cascade loading the different faces.
  58020. */
  58021. readonly supportCascades: boolean;
  58022. /**
  58023. * This returns if the loader support the current file information.
  58024. * @param extension defines the file extension of the file being loaded
  58025. * @param mimeType defines the optional mime type of the file being loaded
  58026. * @returns true if the loader can load the specified file
  58027. */
  58028. canLoad(extension: string, mimeType?: string): boolean;
  58029. /**
  58030. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58031. * @param data contains the texture data
  58032. * @param texture defines the BabylonJS internal texture
  58033. * @param createPolynomials will be true if polynomials have been requested
  58034. * @param onLoad defines the callback to trigger once the texture is ready
  58035. * @param onError defines the callback to trigger in case of error
  58036. */
  58037. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58038. /**
  58039. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58040. * @param data contains the texture data
  58041. * @param texture defines the BabylonJS internal texture
  58042. * @param callback defines the method to call once ready to upload
  58043. */
  58044. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58045. }
  58046. }
  58047. declare module BABYLON {
  58048. /** @hidden */
  58049. export var _forceSceneHelpersToBundle: boolean;
  58050. interface Scene {
  58051. /**
  58052. * Creates a default light for the scene.
  58053. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58054. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58055. */
  58056. createDefaultLight(replace?: boolean): void;
  58057. /**
  58058. * Creates a default camera for the scene.
  58059. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58060. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58061. * @param replace has default false, when true replaces the active camera in the scene
  58062. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58063. */
  58064. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58065. /**
  58066. * Creates a default camera and a default light.
  58067. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58068. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58069. * @param replace has the default false, when true replaces the active camera/light in the scene
  58070. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58071. */
  58072. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58073. /**
  58074. * Creates a new sky box
  58075. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58076. * @param environmentTexture defines the texture to use as environment texture
  58077. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58078. * @param scale defines the overall scale of the skybox
  58079. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58080. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58081. * @returns a new mesh holding the sky box
  58082. */
  58083. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58084. /**
  58085. * Creates a new environment
  58086. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58087. * @param options defines the options you can use to configure the environment
  58088. * @returns the new EnvironmentHelper
  58089. */
  58090. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58091. /**
  58092. * Creates a new VREXperienceHelper
  58093. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58094. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58095. * @returns a new VREXperienceHelper
  58096. */
  58097. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58098. /**
  58099. * Creates a new WebXRDefaultExperience
  58100. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58101. * @param options experience options
  58102. * @returns a promise for a new WebXRDefaultExperience
  58103. */
  58104. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58105. }
  58106. }
  58107. declare module BABYLON {
  58108. /**
  58109. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58110. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58111. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58112. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58113. */
  58114. export class VideoDome extends TextureDome<VideoTexture> {
  58115. /**
  58116. * Define the video source as a Monoscopic panoramic 360 video.
  58117. */
  58118. static readonly MODE_MONOSCOPIC: number;
  58119. /**
  58120. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58121. */
  58122. static readonly MODE_TOPBOTTOM: number;
  58123. /**
  58124. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58125. */
  58126. static readonly MODE_SIDEBYSIDE: number;
  58127. /**
  58128. * Get the video texture associated with this video dome
  58129. */
  58130. get videoTexture(): VideoTexture;
  58131. /**
  58132. * Get the video mode of this dome
  58133. */
  58134. get videoMode(): number;
  58135. /**
  58136. * Set the video mode of this dome.
  58137. * @see textureMode
  58138. */
  58139. set videoMode(value: number);
  58140. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58141. }
  58142. }
  58143. declare module BABYLON {
  58144. /**
  58145. * This class can be used to get instrumentation data from a Babylon engine
  58146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58147. */
  58148. export class EngineInstrumentation implements IDisposable {
  58149. /**
  58150. * Define the instrumented engine.
  58151. */
  58152. engine: Engine;
  58153. private _captureGPUFrameTime;
  58154. private _gpuFrameTimeToken;
  58155. private _gpuFrameTime;
  58156. private _captureShaderCompilationTime;
  58157. private _shaderCompilationTime;
  58158. private _onBeginFrameObserver;
  58159. private _onEndFrameObserver;
  58160. private _onBeforeShaderCompilationObserver;
  58161. private _onAfterShaderCompilationObserver;
  58162. /**
  58163. * Gets the perf counter used for GPU frame time
  58164. */
  58165. get gpuFrameTimeCounter(): PerfCounter;
  58166. /**
  58167. * Gets the GPU frame time capture status
  58168. */
  58169. get captureGPUFrameTime(): boolean;
  58170. /**
  58171. * Enable or disable the GPU frame time capture
  58172. */
  58173. set captureGPUFrameTime(value: boolean);
  58174. /**
  58175. * Gets the perf counter used for shader compilation time
  58176. */
  58177. get shaderCompilationTimeCounter(): PerfCounter;
  58178. /**
  58179. * Gets the shader compilation time capture status
  58180. */
  58181. get captureShaderCompilationTime(): boolean;
  58182. /**
  58183. * Enable or disable the shader compilation time capture
  58184. */
  58185. set captureShaderCompilationTime(value: boolean);
  58186. /**
  58187. * Instantiates a new engine instrumentation.
  58188. * This class can be used to get instrumentation data from a Babylon engine
  58189. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58190. * @param engine Defines the engine to instrument
  58191. */
  58192. constructor(
  58193. /**
  58194. * Define the instrumented engine.
  58195. */
  58196. engine: Engine);
  58197. /**
  58198. * Dispose and release associated resources.
  58199. */
  58200. dispose(): void;
  58201. }
  58202. }
  58203. declare module BABYLON {
  58204. /**
  58205. * This class can be used to get instrumentation data from a Babylon engine
  58206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58207. */
  58208. export class SceneInstrumentation implements IDisposable {
  58209. /**
  58210. * Defines the scene to instrument
  58211. */
  58212. scene: Scene;
  58213. private _captureActiveMeshesEvaluationTime;
  58214. private _activeMeshesEvaluationTime;
  58215. private _captureRenderTargetsRenderTime;
  58216. private _renderTargetsRenderTime;
  58217. private _captureFrameTime;
  58218. private _frameTime;
  58219. private _captureRenderTime;
  58220. private _renderTime;
  58221. private _captureInterFrameTime;
  58222. private _interFrameTime;
  58223. private _captureParticlesRenderTime;
  58224. private _particlesRenderTime;
  58225. private _captureSpritesRenderTime;
  58226. private _spritesRenderTime;
  58227. private _capturePhysicsTime;
  58228. private _physicsTime;
  58229. private _captureAnimationsTime;
  58230. private _animationsTime;
  58231. private _captureCameraRenderTime;
  58232. private _cameraRenderTime;
  58233. private _onBeforeActiveMeshesEvaluationObserver;
  58234. private _onAfterActiveMeshesEvaluationObserver;
  58235. private _onBeforeRenderTargetsRenderObserver;
  58236. private _onAfterRenderTargetsRenderObserver;
  58237. private _onAfterRenderObserver;
  58238. private _onBeforeDrawPhaseObserver;
  58239. private _onAfterDrawPhaseObserver;
  58240. private _onBeforeAnimationsObserver;
  58241. private _onBeforeParticlesRenderingObserver;
  58242. private _onAfterParticlesRenderingObserver;
  58243. private _onBeforeSpritesRenderingObserver;
  58244. private _onAfterSpritesRenderingObserver;
  58245. private _onBeforePhysicsObserver;
  58246. private _onAfterPhysicsObserver;
  58247. private _onAfterAnimationsObserver;
  58248. private _onBeforeCameraRenderObserver;
  58249. private _onAfterCameraRenderObserver;
  58250. /**
  58251. * Gets the perf counter used for active meshes evaluation time
  58252. */
  58253. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58254. /**
  58255. * Gets the active meshes evaluation time capture status
  58256. */
  58257. get captureActiveMeshesEvaluationTime(): boolean;
  58258. /**
  58259. * Enable or disable the active meshes evaluation time capture
  58260. */
  58261. set captureActiveMeshesEvaluationTime(value: boolean);
  58262. /**
  58263. * Gets the perf counter used for render targets render time
  58264. */
  58265. get renderTargetsRenderTimeCounter(): PerfCounter;
  58266. /**
  58267. * Gets the render targets render time capture status
  58268. */
  58269. get captureRenderTargetsRenderTime(): boolean;
  58270. /**
  58271. * Enable or disable the render targets render time capture
  58272. */
  58273. set captureRenderTargetsRenderTime(value: boolean);
  58274. /**
  58275. * Gets the perf counter used for particles render time
  58276. */
  58277. get particlesRenderTimeCounter(): PerfCounter;
  58278. /**
  58279. * Gets the particles render time capture status
  58280. */
  58281. get captureParticlesRenderTime(): boolean;
  58282. /**
  58283. * Enable or disable the particles render time capture
  58284. */
  58285. set captureParticlesRenderTime(value: boolean);
  58286. /**
  58287. * Gets the perf counter used for sprites render time
  58288. */
  58289. get spritesRenderTimeCounter(): PerfCounter;
  58290. /**
  58291. * Gets the sprites render time capture status
  58292. */
  58293. get captureSpritesRenderTime(): boolean;
  58294. /**
  58295. * Enable or disable the sprites render time capture
  58296. */
  58297. set captureSpritesRenderTime(value: boolean);
  58298. /**
  58299. * Gets the perf counter used for physics time
  58300. */
  58301. get physicsTimeCounter(): PerfCounter;
  58302. /**
  58303. * Gets the physics time capture status
  58304. */
  58305. get capturePhysicsTime(): boolean;
  58306. /**
  58307. * Enable or disable the physics time capture
  58308. */
  58309. set capturePhysicsTime(value: boolean);
  58310. /**
  58311. * Gets the perf counter used for animations time
  58312. */
  58313. get animationsTimeCounter(): PerfCounter;
  58314. /**
  58315. * Gets the animations time capture status
  58316. */
  58317. get captureAnimationsTime(): boolean;
  58318. /**
  58319. * Enable or disable the animations time capture
  58320. */
  58321. set captureAnimationsTime(value: boolean);
  58322. /**
  58323. * Gets the perf counter used for frame time capture
  58324. */
  58325. get frameTimeCounter(): PerfCounter;
  58326. /**
  58327. * Gets the frame time capture status
  58328. */
  58329. get captureFrameTime(): boolean;
  58330. /**
  58331. * Enable or disable the frame time capture
  58332. */
  58333. set captureFrameTime(value: boolean);
  58334. /**
  58335. * Gets the perf counter used for inter-frames time capture
  58336. */
  58337. get interFrameTimeCounter(): PerfCounter;
  58338. /**
  58339. * Gets the inter-frames time capture status
  58340. */
  58341. get captureInterFrameTime(): boolean;
  58342. /**
  58343. * Enable or disable the inter-frames time capture
  58344. */
  58345. set captureInterFrameTime(value: boolean);
  58346. /**
  58347. * Gets the perf counter used for render time capture
  58348. */
  58349. get renderTimeCounter(): PerfCounter;
  58350. /**
  58351. * Gets the render time capture status
  58352. */
  58353. get captureRenderTime(): boolean;
  58354. /**
  58355. * Enable or disable the render time capture
  58356. */
  58357. set captureRenderTime(value: boolean);
  58358. /**
  58359. * Gets the perf counter used for camera render time capture
  58360. */
  58361. get cameraRenderTimeCounter(): PerfCounter;
  58362. /**
  58363. * Gets the camera render time capture status
  58364. */
  58365. get captureCameraRenderTime(): boolean;
  58366. /**
  58367. * Enable or disable the camera render time capture
  58368. */
  58369. set captureCameraRenderTime(value: boolean);
  58370. /**
  58371. * Gets the perf counter used for draw calls
  58372. */
  58373. get drawCallsCounter(): PerfCounter;
  58374. /**
  58375. * Instantiates a new scene instrumentation.
  58376. * This class can be used to get instrumentation data from a Babylon engine
  58377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58378. * @param scene Defines the scene to instrument
  58379. */
  58380. constructor(
  58381. /**
  58382. * Defines the scene to instrument
  58383. */
  58384. scene: Scene);
  58385. /**
  58386. * Dispose and release associated resources.
  58387. */
  58388. dispose(): void;
  58389. }
  58390. }
  58391. declare module BABYLON {
  58392. /** @hidden */
  58393. export var glowMapGenerationPixelShader: {
  58394. name: string;
  58395. shader: string;
  58396. };
  58397. }
  58398. declare module BABYLON {
  58399. /** @hidden */
  58400. export var glowMapGenerationVertexShader: {
  58401. name: string;
  58402. shader: string;
  58403. };
  58404. }
  58405. declare module BABYLON {
  58406. /**
  58407. * Effect layer options. This helps customizing the behaviour
  58408. * of the effect layer.
  58409. */
  58410. export interface IEffectLayerOptions {
  58411. /**
  58412. * Multiplication factor apply to the canvas size to compute the render target size
  58413. * used to generated the objects (the smaller the faster).
  58414. */
  58415. mainTextureRatio: number;
  58416. /**
  58417. * Enforces a fixed size texture to ensure effect stability across devices.
  58418. */
  58419. mainTextureFixedSize?: number;
  58420. /**
  58421. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58422. */
  58423. alphaBlendingMode: number;
  58424. /**
  58425. * The camera attached to the layer.
  58426. */
  58427. camera: Nullable<Camera>;
  58428. /**
  58429. * The rendering group to draw the layer in.
  58430. */
  58431. renderingGroupId: number;
  58432. }
  58433. /**
  58434. * The effect layer Helps adding post process effect blended with the main pass.
  58435. *
  58436. * This can be for instance use to generate glow or higlight effects on the scene.
  58437. *
  58438. * The effect layer class can not be used directly and is intented to inherited from to be
  58439. * customized per effects.
  58440. */
  58441. export abstract class EffectLayer {
  58442. private _vertexBuffers;
  58443. private _indexBuffer;
  58444. private _cachedDefines;
  58445. private _effectLayerMapGenerationEffect;
  58446. private _effectLayerOptions;
  58447. private _mergeEffect;
  58448. protected _scene: Scene;
  58449. protected _engine: Engine;
  58450. protected _maxSize: number;
  58451. protected _mainTextureDesiredSize: ISize;
  58452. protected _mainTexture: RenderTargetTexture;
  58453. protected _shouldRender: boolean;
  58454. protected _postProcesses: PostProcess[];
  58455. protected _textures: BaseTexture[];
  58456. protected _emissiveTextureAndColor: {
  58457. texture: Nullable<BaseTexture>;
  58458. color: Color4;
  58459. };
  58460. /**
  58461. * The name of the layer
  58462. */
  58463. name: string;
  58464. /**
  58465. * The clear color of the texture used to generate the glow map.
  58466. */
  58467. neutralColor: Color4;
  58468. /**
  58469. * Specifies whether the highlight layer is enabled or not.
  58470. */
  58471. isEnabled: boolean;
  58472. /**
  58473. * Gets the camera attached to the layer.
  58474. */
  58475. get camera(): Nullable<Camera>;
  58476. /**
  58477. * Gets the rendering group id the layer should render in.
  58478. */
  58479. get renderingGroupId(): number;
  58480. set renderingGroupId(renderingGroupId: number);
  58481. /**
  58482. * An event triggered when the effect layer has been disposed.
  58483. */
  58484. onDisposeObservable: Observable<EffectLayer>;
  58485. /**
  58486. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58487. */
  58488. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58489. /**
  58490. * An event triggered when the generated texture is being merged in the scene.
  58491. */
  58492. onBeforeComposeObservable: Observable<EffectLayer>;
  58493. /**
  58494. * An event triggered when the mesh is rendered into the effect render target.
  58495. */
  58496. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58497. /**
  58498. * An event triggered after the mesh has been rendered into the effect render target.
  58499. */
  58500. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58501. /**
  58502. * An event triggered when the generated texture has been merged in the scene.
  58503. */
  58504. onAfterComposeObservable: Observable<EffectLayer>;
  58505. /**
  58506. * An event triggered when the efffect layer changes its size.
  58507. */
  58508. onSizeChangedObservable: Observable<EffectLayer>;
  58509. /** @hidden */
  58510. static _SceneComponentInitialization: (scene: Scene) => void;
  58511. /**
  58512. * Instantiates a new effect Layer and references it in the scene.
  58513. * @param name The name of the layer
  58514. * @param scene The scene to use the layer in
  58515. */
  58516. constructor(
  58517. /** The Friendly of the effect in the scene */
  58518. name: string, scene: Scene);
  58519. /**
  58520. * Get the effect name of the layer.
  58521. * @return The effect name
  58522. */
  58523. abstract getEffectName(): string;
  58524. /**
  58525. * Checks for the readiness of the element composing the layer.
  58526. * @param subMesh the mesh to check for
  58527. * @param useInstances specify whether or not to use instances to render the mesh
  58528. * @return true if ready otherwise, false
  58529. */
  58530. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58531. /**
  58532. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58533. * @returns true if the effect requires stencil during the main canvas render pass.
  58534. */
  58535. abstract needStencil(): boolean;
  58536. /**
  58537. * Create the merge effect. This is the shader use to blit the information back
  58538. * to the main canvas at the end of the scene rendering.
  58539. * @returns The effect containing the shader used to merge the effect on the main canvas
  58540. */
  58541. protected abstract _createMergeEffect(): Effect;
  58542. /**
  58543. * Creates the render target textures and post processes used in the effect layer.
  58544. */
  58545. protected abstract _createTextureAndPostProcesses(): void;
  58546. /**
  58547. * Implementation specific of rendering the generating effect on the main canvas.
  58548. * @param effect The effect used to render through
  58549. */
  58550. protected abstract _internalRender(effect: Effect): void;
  58551. /**
  58552. * Sets the required values for both the emissive texture and and the main color.
  58553. */
  58554. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58555. /**
  58556. * Free any resources and references associated to a mesh.
  58557. * Internal use
  58558. * @param mesh The mesh to free.
  58559. */
  58560. abstract _disposeMesh(mesh: Mesh): void;
  58561. /**
  58562. * Serializes this layer (Glow or Highlight for example)
  58563. * @returns a serialized layer object
  58564. */
  58565. abstract serialize?(): any;
  58566. /**
  58567. * Initializes the effect layer with the required options.
  58568. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58569. */
  58570. protected _init(options: Partial<IEffectLayerOptions>): void;
  58571. /**
  58572. * Generates the index buffer of the full screen quad blending to the main canvas.
  58573. */
  58574. private _generateIndexBuffer;
  58575. /**
  58576. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58577. */
  58578. private _generateVertexBuffer;
  58579. /**
  58580. * Sets the main texture desired size which is the closest power of two
  58581. * of the engine canvas size.
  58582. */
  58583. private _setMainTextureSize;
  58584. /**
  58585. * Creates the main texture for the effect layer.
  58586. */
  58587. protected _createMainTexture(): void;
  58588. /**
  58589. * Adds specific effects defines.
  58590. * @param defines The defines to add specifics to.
  58591. */
  58592. protected _addCustomEffectDefines(defines: string[]): void;
  58593. /**
  58594. * Checks for the readiness of the element composing the layer.
  58595. * @param subMesh the mesh to check for
  58596. * @param useInstances specify whether or not to use instances to render the mesh
  58597. * @param emissiveTexture the associated emissive texture used to generate the glow
  58598. * @return true if ready otherwise, false
  58599. */
  58600. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58601. /**
  58602. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58603. */
  58604. render(): void;
  58605. /**
  58606. * Determine if a given mesh will be used in the current effect.
  58607. * @param mesh mesh to test
  58608. * @returns true if the mesh will be used
  58609. */
  58610. hasMesh(mesh: AbstractMesh): boolean;
  58611. /**
  58612. * Returns true if the layer contains information to display, otherwise false.
  58613. * @returns true if the glow layer should be rendered
  58614. */
  58615. shouldRender(): boolean;
  58616. /**
  58617. * Returns true if the mesh should render, otherwise false.
  58618. * @param mesh The mesh to render
  58619. * @returns true if it should render otherwise false
  58620. */
  58621. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58622. /**
  58623. * Returns true if the mesh can be rendered, otherwise false.
  58624. * @param mesh The mesh to render
  58625. * @param material The material used on the mesh
  58626. * @returns true if it can be rendered otherwise false
  58627. */
  58628. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58629. /**
  58630. * Returns true if the mesh should render, otherwise false.
  58631. * @param mesh The mesh to render
  58632. * @returns true if it should render otherwise false
  58633. */
  58634. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58635. /**
  58636. * Renders the submesh passed in parameter to the generation map.
  58637. */
  58638. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58639. /**
  58640. * Defines whether the current material of the mesh should be use to render the effect.
  58641. * @param mesh defines the current mesh to render
  58642. */
  58643. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58644. /**
  58645. * Rebuild the required buffers.
  58646. * @hidden Internal use only.
  58647. */
  58648. _rebuild(): void;
  58649. /**
  58650. * Dispose only the render target textures and post process.
  58651. */
  58652. private _disposeTextureAndPostProcesses;
  58653. /**
  58654. * Dispose the highlight layer and free resources.
  58655. */
  58656. dispose(): void;
  58657. /**
  58658. * Gets the class name of the effect layer
  58659. * @returns the string with the class name of the effect layer
  58660. */
  58661. getClassName(): string;
  58662. /**
  58663. * Creates an effect layer from parsed effect layer data
  58664. * @param parsedEffectLayer defines effect layer data
  58665. * @param scene defines the current scene
  58666. * @param rootUrl defines the root URL containing the effect layer information
  58667. * @returns a parsed effect Layer
  58668. */
  58669. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58670. }
  58671. }
  58672. declare module BABYLON {
  58673. interface AbstractScene {
  58674. /**
  58675. * The list of effect layers (highlights/glow) added to the scene
  58676. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58677. * @see https://doc.babylonjs.com/how_to/glow_layer
  58678. */
  58679. effectLayers: Array<EffectLayer>;
  58680. /**
  58681. * Removes the given effect layer from this scene.
  58682. * @param toRemove defines the effect layer to remove
  58683. * @returns the index of the removed effect layer
  58684. */
  58685. removeEffectLayer(toRemove: EffectLayer): number;
  58686. /**
  58687. * Adds the given effect layer to this scene
  58688. * @param newEffectLayer defines the effect layer to add
  58689. */
  58690. addEffectLayer(newEffectLayer: EffectLayer): void;
  58691. }
  58692. /**
  58693. * Defines the layer scene component responsible to manage any effect layers
  58694. * in a given scene.
  58695. */
  58696. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58697. /**
  58698. * The component name helpfull to identify the component in the list of scene components.
  58699. */
  58700. readonly name: string;
  58701. /**
  58702. * The scene the component belongs to.
  58703. */
  58704. scene: Scene;
  58705. private _engine;
  58706. private _renderEffects;
  58707. private _needStencil;
  58708. private _previousStencilState;
  58709. /**
  58710. * Creates a new instance of the component for the given scene
  58711. * @param scene Defines the scene to register the component in
  58712. */
  58713. constructor(scene: Scene);
  58714. /**
  58715. * Registers the component in a given scene
  58716. */
  58717. register(): void;
  58718. /**
  58719. * Rebuilds the elements related to this component in case of
  58720. * context lost for instance.
  58721. */
  58722. rebuild(): void;
  58723. /**
  58724. * Serializes the component data to the specified json object
  58725. * @param serializationObject The object to serialize to
  58726. */
  58727. serialize(serializationObject: any): void;
  58728. /**
  58729. * Adds all the elements from the container to the scene
  58730. * @param container the container holding the elements
  58731. */
  58732. addFromContainer(container: AbstractScene): void;
  58733. /**
  58734. * Removes all the elements in the container from the scene
  58735. * @param container contains the elements to remove
  58736. * @param dispose if the removed element should be disposed (default: false)
  58737. */
  58738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58739. /**
  58740. * Disposes the component and the associated ressources.
  58741. */
  58742. dispose(): void;
  58743. private _isReadyForMesh;
  58744. private _renderMainTexture;
  58745. private _setStencil;
  58746. private _setStencilBack;
  58747. private _draw;
  58748. private _drawCamera;
  58749. private _drawRenderingGroup;
  58750. }
  58751. }
  58752. declare module BABYLON {
  58753. /** @hidden */
  58754. export var glowMapMergePixelShader: {
  58755. name: string;
  58756. shader: string;
  58757. };
  58758. }
  58759. declare module BABYLON {
  58760. /** @hidden */
  58761. export var glowMapMergeVertexShader: {
  58762. name: string;
  58763. shader: string;
  58764. };
  58765. }
  58766. declare module BABYLON {
  58767. interface AbstractScene {
  58768. /**
  58769. * Return a the first highlight layer of the scene with a given name.
  58770. * @param name The name of the highlight layer to look for.
  58771. * @return The highlight layer if found otherwise null.
  58772. */
  58773. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58774. }
  58775. /**
  58776. * Glow layer options. This helps customizing the behaviour
  58777. * of the glow layer.
  58778. */
  58779. export interface IGlowLayerOptions {
  58780. /**
  58781. * Multiplication factor apply to the canvas size to compute the render target size
  58782. * used to generated the glowing objects (the smaller the faster).
  58783. */
  58784. mainTextureRatio: number;
  58785. /**
  58786. * Enforces a fixed size texture to ensure resize independant blur.
  58787. */
  58788. mainTextureFixedSize?: number;
  58789. /**
  58790. * How big is the kernel of the blur texture.
  58791. */
  58792. blurKernelSize: number;
  58793. /**
  58794. * The camera attached to the layer.
  58795. */
  58796. camera: Nullable<Camera>;
  58797. /**
  58798. * Enable MSAA by chosing the number of samples.
  58799. */
  58800. mainTextureSamples?: number;
  58801. /**
  58802. * The rendering group to draw the layer in.
  58803. */
  58804. renderingGroupId: number;
  58805. }
  58806. /**
  58807. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58808. *
  58809. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58810. *
  58811. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58812. */
  58813. export class GlowLayer extends EffectLayer {
  58814. /**
  58815. * Effect Name of the layer.
  58816. */
  58817. static readonly EffectName: string;
  58818. /**
  58819. * The default blur kernel size used for the glow.
  58820. */
  58821. static DefaultBlurKernelSize: number;
  58822. /**
  58823. * The default texture size ratio used for the glow.
  58824. */
  58825. static DefaultTextureRatio: number;
  58826. /**
  58827. * Sets the kernel size of the blur.
  58828. */
  58829. set blurKernelSize(value: number);
  58830. /**
  58831. * Gets the kernel size of the blur.
  58832. */
  58833. get blurKernelSize(): number;
  58834. /**
  58835. * Sets the glow intensity.
  58836. */
  58837. set intensity(value: number);
  58838. /**
  58839. * Gets the glow intensity.
  58840. */
  58841. get intensity(): number;
  58842. private _options;
  58843. private _intensity;
  58844. private _horizontalBlurPostprocess1;
  58845. private _verticalBlurPostprocess1;
  58846. private _horizontalBlurPostprocess2;
  58847. private _verticalBlurPostprocess2;
  58848. private _blurTexture1;
  58849. private _blurTexture2;
  58850. private _postProcesses1;
  58851. private _postProcesses2;
  58852. private _includedOnlyMeshes;
  58853. private _excludedMeshes;
  58854. private _meshesUsingTheirOwnMaterials;
  58855. /**
  58856. * Callback used to let the user override the color selection on a per mesh basis
  58857. */
  58858. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58859. /**
  58860. * Callback used to let the user override the texture selection on a per mesh basis
  58861. */
  58862. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58863. /**
  58864. * Instantiates a new glow Layer and references it to the scene.
  58865. * @param name The name of the layer
  58866. * @param scene The scene to use the layer in
  58867. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58868. */
  58869. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58870. /**
  58871. * Get the effect name of the layer.
  58872. * @return The effect name
  58873. */
  58874. getEffectName(): string;
  58875. /**
  58876. * Create the merge effect. This is the shader use to blit the information back
  58877. * to the main canvas at the end of the scene rendering.
  58878. */
  58879. protected _createMergeEffect(): Effect;
  58880. /**
  58881. * Creates the render target textures and post processes used in the glow layer.
  58882. */
  58883. protected _createTextureAndPostProcesses(): void;
  58884. /**
  58885. * Checks for the readiness of the element composing the layer.
  58886. * @param subMesh the mesh to check for
  58887. * @param useInstances specify wether or not to use instances to render the mesh
  58888. * @param emissiveTexture the associated emissive texture used to generate the glow
  58889. * @return true if ready otherwise, false
  58890. */
  58891. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58892. /**
  58893. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58894. */
  58895. needStencil(): boolean;
  58896. /**
  58897. * Returns true if the mesh can be rendered, otherwise false.
  58898. * @param mesh The mesh to render
  58899. * @param material The material used on the mesh
  58900. * @returns true if it can be rendered otherwise false
  58901. */
  58902. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58903. /**
  58904. * Implementation specific of rendering the generating effect on the main canvas.
  58905. * @param effect The effect used to render through
  58906. */
  58907. protected _internalRender(effect: Effect): void;
  58908. /**
  58909. * Sets the required values for both the emissive texture and and the main color.
  58910. */
  58911. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58912. /**
  58913. * Returns true if the mesh should render, otherwise false.
  58914. * @param mesh The mesh to render
  58915. * @returns true if it should render otherwise false
  58916. */
  58917. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58918. /**
  58919. * Adds specific effects defines.
  58920. * @param defines The defines to add specifics to.
  58921. */
  58922. protected _addCustomEffectDefines(defines: string[]): void;
  58923. /**
  58924. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58925. * @param mesh The mesh to exclude from the glow layer
  58926. */
  58927. addExcludedMesh(mesh: Mesh): void;
  58928. /**
  58929. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58930. * @param mesh The mesh to remove
  58931. */
  58932. removeExcludedMesh(mesh: Mesh): void;
  58933. /**
  58934. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58935. * @param mesh The mesh to include in the glow layer
  58936. */
  58937. addIncludedOnlyMesh(mesh: Mesh): void;
  58938. /**
  58939. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58940. * @param mesh The mesh to remove
  58941. */
  58942. removeIncludedOnlyMesh(mesh: Mesh): void;
  58943. /**
  58944. * Determine if a given mesh will be used in the glow layer
  58945. * @param mesh The mesh to test
  58946. * @returns true if the mesh will be highlighted by the current glow layer
  58947. */
  58948. hasMesh(mesh: AbstractMesh): boolean;
  58949. /**
  58950. * Defines whether the current material of the mesh should be use to render the effect.
  58951. * @param mesh defines the current mesh to render
  58952. */
  58953. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58954. /**
  58955. * Add a mesh to be rendered through its own material and not with emissive only.
  58956. * @param mesh The mesh for which we need to use its material
  58957. */
  58958. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58959. /**
  58960. * Remove a mesh from being rendered through its own material and not with emissive only.
  58961. * @param mesh The mesh for which we need to not use its material
  58962. */
  58963. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58964. /**
  58965. * Free any resources and references associated to a mesh.
  58966. * Internal use
  58967. * @param mesh The mesh to free.
  58968. * @hidden
  58969. */
  58970. _disposeMesh(mesh: Mesh): void;
  58971. /**
  58972. * Gets the class name of the effect layer
  58973. * @returns the string with the class name of the effect layer
  58974. */
  58975. getClassName(): string;
  58976. /**
  58977. * Serializes this glow layer
  58978. * @returns a serialized glow layer object
  58979. */
  58980. serialize(): any;
  58981. /**
  58982. * Creates a Glow Layer from parsed glow layer data
  58983. * @param parsedGlowLayer defines glow layer data
  58984. * @param scene defines the current scene
  58985. * @param rootUrl defines the root URL containing the glow layer information
  58986. * @returns a parsed Glow Layer
  58987. */
  58988. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58989. }
  58990. }
  58991. declare module BABYLON {
  58992. /** @hidden */
  58993. export var glowBlurPostProcessPixelShader: {
  58994. name: string;
  58995. shader: string;
  58996. };
  58997. }
  58998. declare module BABYLON {
  58999. interface AbstractScene {
  59000. /**
  59001. * Return a the first highlight layer of the scene with a given name.
  59002. * @param name The name of the highlight layer to look for.
  59003. * @return The highlight layer if found otherwise null.
  59004. */
  59005. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59006. }
  59007. /**
  59008. * Highlight layer options. This helps customizing the behaviour
  59009. * of the highlight layer.
  59010. */
  59011. export interface IHighlightLayerOptions {
  59012. /**
  59013. * Multiplication factor apply to the canvas size to compute the render target size
  59014. * used to generated the glowing objects (the smaller the faster).
  59015. */
  59016. mainTextureRatio: number;
  59017. /**
  59018. * Enforces a fixed size texture to ensure resize independant blur.
  59019. */
  59020. mainTextureFixedSize?: number;
  59021. /**
  59022. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59023. * of the picture to blur (the smaller the faster).
  59024. */
  59025. blurTextureSizeRatio: number;
  59026. /**
  59027. * How big in texel of the blur texture is the vertical blur.
  59028. */
  59029. blurVerticalSize: number;
  59030. /**
  59031. * How big in texel of the blur texture is the horizontal blur.
  59032. */
  59033. blurHorizontalSize: number;
  59034. /**
  59035. * Alpha blending mode used to apply the blur. Default is combine.
  59036. */
  59037. alphaBlendingMode: number;
  59038. /**
  59039. * The camera attached to the layer.
  59040. */
  59041. camera: Nullable<Camera>;
  59042. /**
  59043. * Should we display highlight as a solid stroke?
  59044. */
  59045. isStroke?: boolean;
  59046. /**
  59047. * The rendering group to draw the layer in.
  59048. */
  59049. renderingGroupId: number;
  59050. }
  59051. /**
  59052. * The highlight layer Helps adding a glow effect around a mesh.
  59053. *
  59054. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59055. * glowy meshes to your scene.
  59056. *
  59057. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59058. */
  59059. export class HighlightLayer extends EffectLayer {
  59060. name: string;
  59061. /**
  59062. * Effect Name of the highlight layer.
  59063. */
  59064. static readonly EffectName: string;
  59065. /**
  59066. * The neutral color used during the preparation of the glow effect.
  59067. * This is black by default as the blend operation is a blend operation.
  59068. */
  59069. static NeutralColor: Color4;
  59070. /**
  59071. * Stencil value used for glowing meshes.
  59072. */
  59073. static GlowingMeshStencilReference: number;
  59074. /**
  59075. * Stencil value used for the other meshes in the scene.
  59076. */
  59077. static NormalMeshStencilReference: number;
  59078. /**
  59079. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59080. */
  59081. innerGlow: boolean;
  59082. /**
  59083. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59084. */
  59085. outerGlow: boolean;
  59086. /**
  59087. * Specifies the horizontal size of the blur.
  59088. */
  59089. set blurHorizontalSize(value: number);
  59090. /**
  59091. * Specifies the vertical size of the blur.
  59092. */
  59093. set blurVerticalSize(value: number);
  59094. /**
  59095. * Gets the horizontal size of the blur.
  59096. */
  59097. get blurHorizontalSize(): number;
  59098. /**
  59099. * Gets the vertical size of the blur.
  59100. */
  59101. get blurVerticalSize(): number;
  59102. /**
  59103. * An event triggered when the highlight layer is being blurred.
  59104. */
  59105. onBeforeBlurObservable: Observable<HighlightLayer>;
  59106. /**
  59107. * An event triggered when the highlight layer has been blurred.
  59108. */
  59109. onAfterBlurObservable: Observable<HighlightLayer>;
  59110. private _instanceGlowingMeshStencilReference;
  59111. private _options;
  59112. private _downSamplePostprocess;
  59113. private _horizontalBlurPostprocess;
  59114. private _verticalBlurPostprocess;
  59115. private _blurTexture;
  59116. private _meshes;
  59117. private _excludedMeshes;
  59118. /**
  59119. * Instantiates a new highlight Layer and references it to the scene..
  59120. * @param name The name of the layer
  59121. * @param scene The scene to use the layer in
  59122. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59123. */
  59124. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59125. /**
  59126. * Get the effect name of the layer.
  59127. * @return The effect name
  59128. */
  59129. getEffectName(): string;
  59130. /**
  59131. * Create the merge effect. This is the shader use to blit the information back
  59132. * to the main canvas at the end of the scene rendering.
  59133. */
  59134. protected _createMergeEffect(): Effect;
  59135. /**
  59136. * Creates the render target textures and post processes used in the highlight layer.
  59137. */
  59138. protected _createTextureAndPostProcesses(): void;
  59139. /**
  59140. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59141. */
  59142. needStencil(): boolean;
  59143. /**
  59144. * Checks for the readiness of the element composing the layer.
  59145. * @param subMesh the mesh to check for
  59146. * @param useInstances specify wether or not to use instances to render the mesh
  59147. * @param emissiveTexture the associated emissive texture used to generate the glow
  59148. * @return true if ready otherwise, false
  59149. */
  59150. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59151. /**
  59152. * Implementation specific of rendering the generating effect on the main canvas.
  59153. * @param effect The effect used to render through
  59154. */
  59155. protected _internalRender(effect: Effect): void;
  59156. /**
  59157. * Returns true if the layer contains information to display, otherwise false.
  59158. */
  59159. shouldRender(): boolean;
  59160. /**
  59161. * Returns true if the mesh should render, otherwise false.
  59162. * @param mesh The mesh to render
  59163. * @returns true if it should render otherwise false
  59164. */
  59165. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59166. /**
  59167. * Returns true if the mesh can be rendered, otherwise false.
  59168. * @param mesh The mesh to render
  59169. * @param material The material used on the mesh
  59170. * @returns true if it can be rendered otherwise false
  59171. */
  59172. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59173. /**
  59174. * Adds specific effects defines.
  59175. * @param defines The defines to add specifics to.
  59176. */
  59177. protected _addCustomEffectDefines(defines: string[]): void;
  59178. /**
  59179. * Sets the required values for both the emissive texture and and the main color.
  59180. */
  59181. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59182. /**
  59183. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59184. * @param mesh The mesh to exclude from the highlight layer
  59185. */
  59186. addExcludedMesh(mesh: Mesh): void;
  59187. /**
  59188. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59189. * @param mesh The mesh to highlight
  59190. */
  59191. removeExcludedMesh(mesh: Mesh): void;
  59192. /**
  59193. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59194. * @param mesh mesh to test
  59195. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59196. */
  59197. hasMesh(mesh: AbstractMesh): boolean;
  59198. /**
  59199. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59200. * @param mesh The mesh to highlight
  59201. * @param color The color of the highlight
  59202. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59203. */
  59204. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59205. /**
  59206. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59207. * @param mesh The mesh to highlight
  59208. */
  59209. removeMesh(mesh: Mesh): void;
  59210. /**
  59211. * Remove all the meshes currently referenced in the highlight layer
  59212. */
  59213. removeAllMeshes(): void;
  59214. /**
  59215. * Force the stencil to the normal expected value for none glowing parts
  59216. */
  59217. private _defaultStencilReference;
  59218. /**
  59219. * Free any resources and references associated to a mesh.
  59220. * Internal use
  59221. * @param mesh The mesh to free.
  59222. * @hidden
  59223. */
  59224. _disposeMesh(mesh: Mesh): void;
  59225. /**
  59226. * Dispose the highlight layer and free resources.
  59227. */
  59228. dispose(): void;
  59229. /**
  59230. * Gets the class name of the effect layer
  59231. * @returns the string with the class name of the effect layer
  59232. */
  59233. getClassName(): string;
  59234. /**
  59235. * Serializes this Highlight layer
  59236. * @returns a serialized Highlight layer object
  59237. */
  59238. serialize(): any;
  59239. /**
  59240. * Creates a Highlight layer from parsed Highlight layer data
  59241. * @param parsedHightlightLayer defines the Highlight layer data
  59242. * @param scene defines the current scene
  59243. * @param rootUrl defines the root URL containing the Highlight layer information
  59244. * @returns a parsed Highlight layer
  59245. */
  59246. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59247. }
  59248. }
  59249. declare module BABYLON {
  59250. interface AbstractScene {
  59251. /**
  59252. * The list of layers (background and foreground) of the scene
  59253. */
  59254. layers: Array<Layer>;
  59255. }
  59256. /**
  59257. * Defines the layer scene component responsible to manage any layers
  59258. * in a given scene.
  59259. */
  59260. export class LayerSceneComponent implements ISceneComponent {
  59261. /**
  59262. * The component name helpfull to identify the component in the list of scene components.
  59263. */
  59264. readonly name: string;
  59265. /**
  59266. * The scene the component belongs to.
  59267. */
  59268. scene: Scene;
  59269. private _engine;
  59270. /**
  59271. * Creates a new instance of the component for the given scene
  59272. * @param scene Defines the scene to register the component in
  59273. */
  59274. constructor(scene: Scene);
  59275. /**
  59276. * Registers the component in a given scene
  59277. */
  59278. register(): void;
  59279. /**
  59280. * Rebuilds the elements related to this component in case of
  59281. * context lost for instance.
  59282. */
  59283. rebuild(): void;
  59284. /**
  59285. * Disposes the component and the associated ressources.
  59286. */
  59287. dispose(): void;
  59288. private _draw;
  59289. private _drawCameraPredicate;
  59290. private _drawCameraBackground;
  59291. private _drawCameraForeground;
  59292. private _drawRenderTargetPredicate;
  59293. private _drawRenderTargetBackground;
  59294. private _drawRenderTargetForeground;
  59295. /**
  59296. * Adds all the elements from the container to the scene
  59297. * @param container the container holding the elements
  59298. */
  59299. addFromContainer(container: AbstractScene): void;
  59300. /**
  59301. * Removes all the elements in the container from the scene
  59302. * @param container contains the elements to remove
  59303. * @param dispose if the removed element should be disposed (default: false)
  59304. */
  59305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59306. }
  59307. }
  59308. declare module BABYLON {
  59309. /** @hidden */
  59310. export var layerPixelShader: {
  59311. name: string;
  59312. shader: string;
  59313. };
  59314. }
  59315. declare module BABYLON {
  59316. /** @hidden */
  59317. export var layerVertexShader: {
  59318. name: string;
  59319. shader: string;
  59320. };
  59321. }
  59322. declare module BABYLON {
  59323. /**
  59324. * This represents a full screen 2d layer.
  59325. * This can be useful to display a picture in the background of your scene for instance.
  59326. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59327. */
  59328. export class Layer {
  59329. /**
  59330. * Define the name of the layer.
  59331. */
  59332. name: string;
  59333. /**
  59334. * Define the texture the layer should display.
  59335. */
  59336. texture: Nullable<Texture>;
  59337. /**
  59338. * Is the layer in background or foreground.
  59339. */
  59340. isBackground: boolean;
  59341. /**
  59342. * Define the color of the layer (instead of texture).
  59343. */
  59344. color: Color4;
  59345. /**
  59346. * Define the scale of the layer in order to zoom in out of the texture.
  59347. */
  59348. scale: Vector2;
  59349. /**
  59350. * Define an offset for the layer in order to shift the texture.
  59351. */
  59352. offset: Vector2;
  59353. /**
  59354. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59355. */
  59356. alphaBlendingMode: number;
  59357. /**
  59358. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59359. * Alpha test will not mix with the background color in case of transparency.
  59360. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59361. */
  59362. alphaTest: boolean;
  59363. /**
  59364. * Define a mask to restrict the layer to only some of the scene cameras.
  59365. */
  59366. layerMask: number;
  59367. /**
  59368. * Define the list of render target the layer is visible into.
  59369. */
  59370. renderTargetTextures: RenderTargetTexture[];
  59371. /**
  59372. * Define if the layer is only used in renderTarget or if it also
  59373. * renders in the main frame buffer of the canvas.
  59374. */
  59375. renderOnlyInRenderTargetTextures: boolean;
  59376. private _scene;
  59377. private _vertexBuffers;
  59378. private _indexBuffer;
  59379. private _effect;
  59380. private _previousDefines;
  59381. /**
  59382. * An event triggered when the layer is disposed.
  59383. */
  59384. onDisposeObservable: Observable<Layer>;
  59385. private _onDisposeObserver;
  59386. /**
  59387. * Back compatibility with callback before the onDisposeObservable existed.
  59388. * The set callback will be triggered when the layer has been disposed.
  59389. */
  59390. set onDispose(callback: () => void);
  59391. /**
  59392. * An event triggered before rendering the scene
  59393. */
  59394. onBeforeRenderObservable: Observable<Layer>;
  59395. private _onBeforeRenderObserver;
  59396. /**
  59397. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59398. * The set callback will be triggered just before rendering the layer.
  59399. */
  59400. set onBeforeRender(callback: () => void);
  59401. /**
  59402. * An event triggered after rendering the scene
  59403. */
  59404. onAfterRenderObservable: Observable<Layer>;
  59405. private _onAfterRenderObserver;
  59406. /**
  59407. * Back compatibility with callback before the onAfterRenderObservable existed.
  59408. * The set callback will be triggered just after rendering the layer.
  59409. */
  59410. set onAfterRender(callback: () => void);
  59411. /**
  59412. * Instantiates a new layer.
  59413. * This represents a full screen 2d layer.
  59414. * This can be useful to display a picture in the background of your scene for instance.
  59415. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59416. * @param name Define the name of the layer in the scene
  59417. * @param imgUrl Define the url of the texture to display in the layer
  59418. * @param scene Define the scene the layer belongs to
  59419. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59420. * @param color Defines a color for the layer
  59421. */
  59422. constructor(
  59423. /**
  59424. * Define the name of the layer.
  59425. */
  59426. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59427. private _createIndexBuffer;
  59428. /** @hidden */
  59429. _rebuild(): void;
  59430. /**
  59431. * Renders the layer in the scene.
  59432. */
  59433. render(): void;
  59434. /**
  59435. * Disposes and releases the associated ressources.
  59436. */
  59437. dispose(): void;
  59438. }
  59439. }
  59440. declare module BABYLON {
  59441. /** @hidden */
  59442. export var lensFlarePixelShader: {
  59443. name: string;
  59444. shader: string;
  59445. };
  59446. }
  59447. declare module BABYLON {
  59448. /** @hidden */
  59449. export var lensFlareVertexShader: {
  59450. name: string;
  59451. shader: string;
  59452. };
  59453. }
  59454. declare module BABYLON {
  59455. /**
  59456. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59457. * It is usually composed of several `lensFlare`.
  59458. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59459. */
  59460. export class LensFlareSystem {
  59461. /**
  59462. * Define the name of the lens flare system
  59463. */
  59464. name: string;
  59465. /**
  59466. * List of lens flares used in this system.
  59467. */
  59468. lensFlares: LensFlare[];
  59469. /**
  59470. * Define a limit from the border the lens flare can be visible.
  59471. */
  59472. borderLimit: number;
  59473. /**
  59474. * Define a viewport border we do not want to see the lens flare in.
  59475. */
  59476. viewportBorder: number;
  59477. /**
  59478. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59479. */
  59480. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59481. /**
  59482. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59483. */
  59484. layerMask: number;
  59485. /**
  59486. * Define the id of the lens flare system in the scene.
  59487. * (equal to name by default)
  59488. */
  59489. id: string;
  59490. private _scene;
  59491. private _emitter;
  59492. private _vertexBuffers;
  59493. private _indexBuffer;
  59494. private _effect;
  59495. private _positionX;
  59496. private _positionY;
  59497. private _isEnabled;
  59498. /** @hidden */
  59499. static _SceneComponentInitialization: (scene: Scene) => void;
  59500. /**
  59501. * Instantiates a lens flare system.
  59502. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59503. * It is usually composed of several `lensFlare`.
  59504. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59505. * @param name Define the name of the lens flare system in the scene
  59506. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59507. * @param scene Define the scene the lens flare system belongs to
  59508. */
  59509. constructor(
  59510. /**
  59511. * Define the name of the lens flare system
  59512. */
  59513. name: string, emitter: any, scene: Scene);
  59514. /**
  59515. * Define if the lens flare system is enabled.
  59516. */
  59517. get isEnabled(): boolean;
  59518. set isEnabled(value: boolean);
  59519. /**
  59520. * Get the scene the effects belongs to.
  59521. * @returns the scene holding the lens flare system
  59522. */
  59523. getScene(): Scene;
  59524. /**
  59525. * Get the emitter of the lens flare system.
  59526. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59527. * @returns the emitter of the lens flare system
  59528. */
  59529. getEmitter(): any;
  59530. /**
  59531. * Set the emitter of the lens flare system.
  59532. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59533. * @param newEmitter Define the new emitter of the system
  59534. */
  59535. setEmitter(newEmitter: any): void;
  59536. /**
  59537. * Get the lens flare system emitter position.
  59538. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59539. * @returns the position
  59540. */
  59541. getEmitterPosition(): Vector3;
  59542. /**
  59543. * @hidden
  59544. */
  59545. computeEffectivePosition(globalViewport: Viewport): boolean;
  59546. /** @hidden */
  59547. _isVisible(): boolean;
  59548. /**
  59549. * @hidden
  59550. */
  59551. render(): boolean;
  59552. /**
  59553. * Dispose and release the lens flare with its associated resources.
  59554. */
  59555. dispose(): void;
  59556. /**
  59557. * Parse a lens flare system from a JSON repressentation
  59558. * @param parsedLensFlareSystem Define the JSON to parse
  59559. * @param scene Define the scene the parsed system should be instantiated in
  59560. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59561. * @returns the parsed system
  59562. */
  59563. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59564. /**
  59565. * Serialize the current Lens Flare System into a JSON representation.
  59566. * @returns the serialized JSON
  59567. */
  59568. serialize(): any;
  59569. }
  59570. }
  59571. declare module BABYLON {
  59572. /**
  59573. * This represents one of the lens effect in a `lensFlareSystem`.
  59574. * It controls one of the indiviual texture used in the effect.
  59575. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59576. */
  59577. export class LensFlare {
  59578. /**
  59579. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59580. */
  59581. size: number;
  59582. /**
  59583. * 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.
  59584. */
  59585. position: number;
  59586. /**
  59587. * Define the lens color.
  59588. */
  59589. color: Color3;
  59590. /**
  59591. * Define the lens texture.
  59592. */
  59593. texture: Nullable<Texture>;
  59594. /**
  59595. * Define the alpha mode to render this particular lens.
  59596. */
  59597. alphaMode: number;
  59598. private _system;
  59599. /**
  59600. * Creates a new Lens Flare.
  59601. * This represents one of the lens effect in a `lensFlareSystem`.
  59602. * It controls one of the indiviual texture used in the effect.
  59603. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59604. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59605. * @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.
  59606. * @param color Define the lens color
  59607. * @param imgUrl Define the lens texture url
  59608. * @param system Define the `lensFlareSystem` this flare is part of
  59609. * @returns The newly created Lens Flare
  59610. */
  59611. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59612. /**
  59613. * Instantiates a new Lens Flare.
  59614. * This represents one of the lens effect in a `lensFlareSystem`.
  59615. * It controls one of the indiviual texture used in the effect.
  59616. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59617. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59618. * @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.
  59619. * @param color Define the lens color
  59620. * @param imgUrl Define the lens texture url
  59621. * @param system Define the `lensFlareSystem` this flare is part of
  59622. */
  59623. constructor(
  59624. /**
  59625. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59626. */
  59627. size: number,
  59628. /**
  59629. * 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.
  59630. */
  59631. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59632. /**
  59633. * Dispose and release the lens flare with its associated resources.
  59634. */
  59635. dispose(): void;
  59636. }
  59637. }
  59638. declare module BABYLON {
  59639. interface AbstractScene {
  59640. /**
  59641. * The list of lens flare system added to the scene
  59642. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59643. */
  59644. lensFlareSystems: Array<LensFlareSystem>;
  59645. /**
  59646. * Removes the given lens flare system from this scene.
  59647. * @param toRemove The lens flare system to remove
  59648. * @returns The index of the removed lens flare system
  59649. */
  59650. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59651. /**
  59652. * Adds the given lens flare system to this scene
  59653. * @param newLensFlareSystem The lens flare system to add
  59654. */
  59655. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59656. /**
  59657. * Gets a lens flare system using its name
  59658. * @param name defines the name to look for
  59659. * @returns the lens flare system or null if not found
  59660. */
  59661. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59662. /**
  59663. * Gets a lens flare system using its id
  59664. * @param id defines the id to look for
  59665. * @returns the lens flare system or null if not found
  59666. */
  59667. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59668. }
  59669. /**
  59670. * Defines the lens flare scene component responsible to manage any lens flares
  59671. * in a given scene.
  59672. */
  59673. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59674. /**
  59675. * The component name helpfull to identify the component in the list of scene components.
  59676. */
  59677. readonly name: string;
  59678. /**
  59679. * The scene the component belongs to.
  59680. */
  59681. scene: Scene;
  59682. /**
  59683. * Creates a new instance of the component for the given scene
  59684. * @param scene Defines the scene to register the component in
  59685. */
  59686. constructor(scene: Scene);
  59687. /**
  59688. * Registers the component in a given scene
  59689. */
  59690. register(): void;
  59691. /**
  59692. * Rebuilds the elements related to this component in case of
  59693. * context lost for instance.
  59694. */
  59695. rebuild(): void;
  59696. /**
  59697. * Adds all the elements from the container to the scene
  59698. * @param container the container holding the elements
  59699. */
  59700. addFromContainer(container: AbstractScene): void;
  59701. /**
  59702. * Removes all the elements in the container from the scene
  59703. * @param container contains the elements to remove
  59704. * @param dispose if the removed element should be disposed (default: false)
  59705. */
  59706. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59707. /**
  59708. * Serializes the component data to the specified json object
  59709. * @param serializationObject The object to serialize to
  59710. */
  59711. serialize(serializationObject: any): void;
  59712. /**
  59713. * Disposes the component and the associated ressources.
  59714. */
  59715. dispose(): void;
  59716. private _draw;
  59717. }
  59718. }
  59719. declare module BABYLON {
  59720. /** @hidden */
  59721. export var depthPixelShader: {
  59722. name: string;
  59723. shader: string;
  59724. };
  59725. }
  59726. declare module BABYLON {
  59727. /** @hidden */
  59728. export var depthVertexShader: {
  59729. name: string;
  59730. shader: string;
  59731. };
  59732. }
  59733. declare module BABYLON {
  59734. /**
  59735. * This represents a depth renderer in Babylon.
  59736. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59737. */
  59738. export class DepthRenderer {
  59739. private _scene;
  59740. private _depthMap;
  59741. private _effect;
  59742. private readonly _storeNonLinearDepth;
  59743. private readonly _clearColor;
  59744. /** Get if the depth renderer is using packed depth or not */
  59745. readonly isPacked: boolean;
  59746. private _cachedDefines;
  59747. private _camera;
  59748. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59749. enabled: boolean;
  59750. /**
  59751. * Specifiess that the depth renderer will only be used within
  59752. * the camera it is created for.
  59753. * This can help forcing its rendering during the camera processing.
  59754. */
  59755. useOnlyInActiveCamera: boolean;
  59756. /** @hidden */
  59757. static _SceneComponentInitialization: (scene: Scene) => void;
  59758. /**
  59759. * Instantiates a depth renderer
  59760. * @param scene The scene the renderer belongs to
  59761. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59762. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59763. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59764. */
  59765. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59766. /**
  59767. * Creates the depth rendering effect and checks if the effect is ready.
  59768. * @param subMesh The submesh to be used to render the depth map of
  59769. * @param useInstances If multiple world instances should be used
  59770. * @returns if the depth renderer is ready to render the depth map
  59771. */
  59772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59773. /**
  59774. * Gets the texture which the depth map will be written to.
  59775. * @returns The depth map texture
  59776. */
  59777. getDepthMap(): RenderTargetTexture;
  59778. /**
  59779. * Disposes of the depth renderer.
  59780. */
  59781. dispose(): void;
  59782. }
  59783. }
  59784. declare module BABYLON {
  59785. /** @hidden */
  59786. export var minmaxReduxPixelShader: {
  59787. name: string;
  59788. shader: string;
  59789. };
  59790. }
  59791. declare module BABYLON {
  59792. /**
  59793. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59794. * and maximum values from all values of the texture.
  59795. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59796. * The source values are read from the red channel of the texture.
  59797. */
  59798. export class MinMaxReducer {
  59799. /**
  59800. * Observable triggered when the computation has been performed
  59801. */
  59802. onAfterReductionPerformed: Observable<{
  59803. min: number;
  59804. max: number;
  59805. }>;
  59806. protected _camera: Camera;
  59807. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59808. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59809. protected _postProcessManager: PostProcessManager;
  59810. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59811. protected _forceFullscreenViewport: boolean;
  59812. /**
  59813. * Creates a min/max reducer
  59814. * @param camera The camera to use for the post processes
  59815. */
  59816. constructor(camera: Camera);
  59817. /**
  59818. * Gets the texture used to read the values from.
  59819. */
  59820. get sourceTexture(): Nullable<RenderTargetTexture>;
  59821. /**
  59822. * Sets the source texture to read the values from.
  59823. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59824. * because in such textures '1' value must not be taken into account to compute the maximum
  59825. * as this value is used to clear the texture.
  59826. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59827. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59828. * @param depthRedux Indicates if the texture is a depth texture or not
  59829. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59830. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59831. */
  59832. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59833. /**
  59834. * Defines the refresh rate of the computation.
  59835. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59836. */
  59837. get refreshRate(): number;
  59838. set refreshRate(value: number);
  59839. protected _activated: boolean;
  59840. /**
  59841. * Gets the activation status of the reducer
  59842. */
  59843. get activated(): boolean;
  59844. /**
  59845. * Activates the reduction computation.
  59846. * When activated, the observers registered in onAfterReductionPerformed are
  59847. * called after the compuation is performed
  59848. */
  59849. activate(): void;
  59850. /**
  59851. * Deactivates the reduction computation.
  59852. */
  59853. deactivate(): void;
  59854. /**
  59855. * Disposes the min/max reducer
  59856. * @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.
  59857. */
  59858. dispose(disposeAll?: boolean): void;
  59859. }
  59860. }
  59861. declare module BABYLON {
  59862. /**
  59863. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59864. */
  59865. export class DepthReducer extends MinMaxReducer {
  59866. private _depthRenderer;
  59867. private _depthRendererId;
  59868. /**
  59869. * Gets the depth renderer used for the computation.
  59870. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59871. */
  59872. get depthRenderer(): Nullable<DepthRenderer>;
  59873. /**
  59874. * Creates a depth reducer
  59875. * @param camera The camera used to render the depth texture
  59876. */
  59877. constructor(camera: Camera);
  59878. /**
  59879. * Sets the depth renderer to use to generate the depth map
  59880. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59881. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59882. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59883. */
  59884. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59885. /** @hidden */
  59886. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59887. /**
  59888. * Activates the reduction computation.
  59889. * When activated, the observers registered in onAfterReductionPerformed are
  59890. * called after the compuation is performed
  59891. */
  59892. activate(): void;
  59893. /**
  59894. * Deactivates the reduction computation.
  59895. */
  59896. deactivate(): void;
  59897. /**
  59898. * Disposes the depth reducer
  59899. * @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.
  59900. */
  59901. dispose(disposeAll?: boolean): void;
  59902. }
  59903. }
  59904. declare module BABYLON {
  59905. /**
  59906. * A CSM implementation allowing casting shadows on large scenes.
  59907. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59908. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59909. */
  59910. export class CascadedShadowGenerator extends ShadowGenerator {
  59911. private static readonly frustumCornersNDCSpace;
  59912. /**
  59913. * Name of the CSM class
  59914. */
  59915. static CLASSNAME: string;
  59916. /**
  59917. * Defines the default number of cascades used by the CSM.
  59918. */
  59919. static readonly DEFAULT_CASCADES_COUNT: number;
  59920. /**
  59921. * Defines the minimum number of cascades used by the CSM.
  59922. */
  59923. static readonly MIN_CASCADES_COUNT: number;
  59924. /**
  59925. * Defines the maximum number of cascades used by the CSM.
  59926. */
  59927. static readonly MAX_CASCADES_COUNT: number;
  59928. protected _validateFilter(filter: number): number;
  59929. /**
  59930. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59931. */
  59932. penumbraDarkness: number;
  59933. private _numCascades;
  59934. /**
  59935. * Gets or set the number of cascades used by the CSM.
  59936. */
  59937. get numCascades(): number;
  59938. set numCascades(value: number);
  59939. /**
  59940. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59941. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59942. */
  59943. stabilizeCascades: boolean;
  59944. private _freezeShadowCastersBoundingInfo;
  59945. private _freezeShadowCastersBoundingInfoObservable;
  59946. /**
  59947. * Enables or disables the shadow casters bounding info computation.
  59948. * If your shadow casters don't move, you can disable this feature.
  59949. * If it is enabled, the bounding box computation is done every frame.
  59950. */
  59951. get freezeShadowCastersBoundingInfo(): boolean;
  59952. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59953. private _scbiMin;
  59954. private _scbiMax;
  59955. protected _computeShadowCastersBoundingInfo(): void;
  59956. protected _shadowCastersBoundingInfo: BoundingInfo;
  59957. /**
  59958. * Gets or sets the shadow casters bounding info.
  59959. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59960. * so that the system won't overwrite the bounds you provide
  59961. */
  59962. get shadowCastersBoundingInfo(): BoundingInfo;
  59963. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59964. protected _breaksAreDirty: boolean;
  59965. protected _minDistance: number;
  59966. protected _maxDistance: number;
  59967. /**
  59968. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59969. *
  59970. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59971. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59972. * @param min minimal distance for the breaks (default to 0.)
  59973. * @param max maximal distance for the breaks (default to 1.)
  59974. */
  59975. setMinMaxDistance(min: number, max: number): void;
  59976. /** Gets the minimal distance used in the cascade break computation */
  59977. get minDistance(): number;
  59978. /** Gets the maximal distance used in the cascade break computation */
  59979. get maxDistance(): number;
  59980. /**
  59981. * Gets the class name of that object
  59982. * @returns "CascadedShadowGenerator"
  59983. */
  59984. getClassName(): string;
  59985. private _cascadeMinExtents;
  59986. private _cascadeMaxExtents;
  59987. /**
  59988. * Gets a cascade minimum extents
  59989. * @param cascadeIndex index of the cascade
  59990. * @returns the minimum cascade extents
  59991. */
  59992. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59993. /**
  59994. * Gets a cascade maximum extents
  59995. * @param cascadeIndex index of the cascade
  59996. * @returns the maximum cascade extents
  59997. */
  59998. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59999. private _cascades;
  60000. private _currentLayer;
  60001. private _viewSpaceFrustumsZ;
  60002. private _viewMatrices;
  60003. private _projectionMatrices;
  60004. private _transformMatrices;
  60005. private _transformMatricesAsArray;
  60006. private _frustumLengths;
  60007. private _lightSizeUVCorrection;
  60008. private _depthCorrection;
  60009. private _frustumCornersWorldSpace;
  60010. private _frustumCenter;
  60011. private _shadowCameraPos;
  60012. private _shadowMaxZ;
  60013. /**
  60014. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60015. * It defaults to camera.maxZ
  60016. */
  60017. get shadowMaxZ(): number;
  60018. /**
  60019. * Sets the shadow max z distance.
  60020. */
  60021. set shadowMaxZ(value: number);
  60022. protected _debug: boolean;
  60023. /**
  60024. * Gets or sets the debug flag.
  60025. * When enabled, the cascades are materialized by different colors on the screen.
  60026. */
  60027. get debug(): boolean;
  60028. set debug(dbg: boolean);
  60029. private _depthClamp;
  60030. /**
  60031. * Gets or sets the depth clamping value.
  60032. *
  60033. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60034. * to account for the shadow casters far away.
  60035. *
  60036. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60037. */
  60038. get depthClamp(): boolean;
  60039. set depthClamp(value: boolean);
  60040. private _cascadeBlendPercentage;
  60041. /**
  60042. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60043. * It defaults to 0.1 (10% blending).
  60044. */
  60045. get cascadeBlendPercentage(): number;
  60046. set cascadeBlendPercentage(value: number);
  60047. private _lambda;
  60048. /**
  60049. * Gets or set the lambda parameter.
  60050. * This parameter is used to split the camera frustum and create the cascades.
  60051. * 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.
  60052. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60053. */
  60054. get lambda(): number;
  60055. set lambda(value: number);
  60056. /**
  60057. * Gets the view matrix corresponding to a given cascade
  60058. * @param cascadeNum cascade to retrieve the view matrix from
  60059. * @returns the cascade view matrix
  60060. */
  60061. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60062. /**
  60063. * Gets the projection matrix corresponding to a given cascade
  60064. * @param cascadeNum cascade to retrieve the projection matrix from
  60065. * @returns the cascade projection matrix
  60066. */
  60067. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60068. /**
  60069. * Gets the transformation matrix corresponding to a given cascade
  60070. * @param cascadeNum cascade to retrieve the transformation matrix from
  60071. * @returns the cascade transformation matrix
  60072. */
  60073. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60074. private _depthRenderer;
  60075. /**
  60076. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60077. *
  60078. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60079. *
  60080. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60081. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60082. * @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
  60083. */
  60084. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60085. private _depthReducer;
  60086. private _autoCalcDepthBounds;
  60087. /**
  60088. * Gets or sets the autoCalcDepthBounds property.
  60089. *
  60090. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60091. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60092. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60093. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60094. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60095. */
  60096. get autoCalcDepthBounds(): boolean;
  60097. set autoCalcDepthBounds(value: boolean);
  60098. /**
  60099. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60100. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60101. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60102. * for setting the refresh rate on the renderer yourself!
  60103. */
  60104. get autoCalcDepthBoundsRefreshRate(): number;
  60105. set autoCalcDepthBoundsRefreshRate(value: number);
  60106. /**
  60107. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60108. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60109. * you change the camera near/far planes!
  60110. */
  60111. splitFrustum(): void;
  60112. private _splitFrustum;
  60113. private _computeMatrices;
  60114. private _computeFrustumInWorldSpace;
  60115. private _computeCascadeFrustum;
  60116. /**
  60117. * Support test.
  60118. */
  60119. static get IsSupported(): boolean;
  60120. /** @hidden */
  60121. static _SceneComponentInitialization: (scene: Scene) => void;
  60122. /**
  60123. * Creates a Cascaded Shadow Generator object.
  60124. * A ShadowGenerator is the required tool to use the shadows.
  60125. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60126. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60127. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60128. * @param light The directional light object generating the shadows.
  60129. * @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.
  60130. */
  60131. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60132. protected _initializeGenerator(): void;
  60133. protected _createTargetRenderTexture(): void;
  60134. protected _initializeShadowMap(): void;
  60135. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60136. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60137. /**
  60138. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60139. * @param defines Defines of the material we want to update
  60140. * @param lightIndex Index of the light in the enabled light list of the material
  60141. */
  60142. prepareDefines(defines: any, lightIndex: number): void;
  60143. /**
  60144. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60145. * defined in the generator but impacting the effect).
  60146. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60147. * @param effect The effect we are binfing the information for
  60148. */
  60149. bindShadowLight(lightIndex: string, effect: Effect): void;
  60150. /**
  60151. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60152. * (eq to view projection * shadow projection matrices)
  60153. * @returns The transform matrix used to create the shadow map
  60154. */
  60155. getTransformMatrix(): Matrix;
  60156. /**
  60157. * Disposes the ShadowGenerator.
  60158. * Returns nothing.
  60159. */
  60160. dispose(): void;
  60161. /**
  60162. * Serializes the shadow generator setup to a json object.
  60163. * @returns The serialized JSON object
  60164. */
  60165. serialize(): any;
  60166. /**
  60167. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60168. * @param parsedShadowGenerator The JSON object to parse
  60169. * @param scene The scene to create the shadow map for
  60170. * @returns The parsed shadow generator
  60171. */
  60172. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60173. }
  60174. }
  60175. declare module BABYLON {
  60176. /**
  60177. * Defines the shadow generator component responsible to manage any shadow generators
  60178. * in a given scene.
  60179. */
  60180. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60181. /**
  60182. * The component name helpfull to identify the component in the list of scene components.
  60183. */
  60184. readonly name: string;
  60185. /**
  60186. * The scene the component belongs to.
  60187. */
  60188. scene: Scene;
  60189. /**
  60190. * Creates a new instance of the component for the given scene
  60191. * @param scene Defines the scene to register the component in
  60192. */
  60193. constructor(scene: Scene);
  60194. /**
  60195. * Registers the component in a given scene
  60196. */
  60197. register(): void;
  60198. /**
  60199. * Rebuilds the elements related to this component in case of
  60200. * context lost for instance.
  60201. */
  60202. rebuild(): void;
  60203. /**
  60204. * Serializes the component data to the specified json object
  60205. * @param serializationObject The object to serialize to
  60206. */
  60207. serialize(serializationObject: any): void;
  60208. /**
  60209. * Adds all the elements from the container to the scene
  60210. * @param container the container holding the elements
  60211. */
  60212. addFromContainer(container: AbstractScene): void;
  60213. /**
  60214. * Removes all the elements in the container from the scene
  60215. * @param container contains the elements to remove
  60216. * @param dispose if the removed element should be disposed (default: false)
  60217. */
  60218. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60219. /**
  60220. * Rebuilds the elements related to this component in case of
  60221. * context lost for instance.
  60222. */
  60223. dispose(): void;
  60224. private _gatherRenderTargets;
  60225. }
  60226. }
  60227. declare module BABYLON {
  60228. /**
  60229. * A point light is a light defined by an unique point in world space.
  60230. * The light is emitted in every direction from this point.
  60231. * A good example of a point light is a standard light bulb.
  60232. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60233. */
  60234. export class PointLight extends ShadowLight {
  60235. private _shadowAngle;
  60236. /**
  60237. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60238. * This specifies what angle the shadow will use to be created.
  60239. *
  60240. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60241. */
  60242. get shadowAngle(): number;
  60243. /**
  60244. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60245. * This specifies what angle the shadow will use to be created.
  60246. *
  60247. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60248. */
  60249. set shadowAngle(value: number);
  60250. /**
  60251. * Gets the direction if it has been set.
  60252. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60253. */
  60254. get direction(): Vector3;
  60255. /**
  60256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60257. */
  60258. set direction(value: Vector3);
  60259. /**
  60260. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60261. * A PointLight emits the light in every direction.
  60262. * It can cast shadows.
  60263. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60264. * ```javascript
  60265. * var pointLight = new PointLight("pl", camera.position, scene);
  60266. * ```
  60267. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60268. * @param name The light friendly name
  60269. * @param position The position of the point light in the scene
  60270. * @param scene The scene the lights belongs to
  60271. */
  60272. constructor(name: string, position: Vector3, scene: Scene);
  60273. /**
  60274. * Returns the string "PointLight"
  60275. * @returns the class name
  60276. */
  60277. getClassName(): string;
  60278. /**
  60279. * Returns the integer 0.
  60280. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60281. */
  60282. getTypeID(): number;
  60283. /**
  60284. * Specifies wether or not the shadowmap should be a cube texture.
  60285. * @returns true if the shadowmap needs to be a cube texture.
  60286. */
  60287. needCube(): boolean;
  60288. /**
  60289. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60290. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60291. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60292. */
  60293. getShadowDirection(faceIndex?: number): Vector3;
  60294. /**
  60295. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60296. * - fov = PI / 2
  60297. * - aspect ratio : 1.0
  60298. * - z-near and far equal to the active camera minZ and maxZ.
  60299. * Returns the PointLight.
  60300. */
  60301. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60302. protected _buildUniformLayout(): void;
  60303. /**
  60304. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60305. * @param effect The effect to update
  60306. * @param lightIndex The index of the light in the effect to update
  60307. * @returns The point light
  60308. */
  60309. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60310. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60311. /**
  60312. * Prepares the list of defines specific to the light type.
  60313. * @param defines the list of defines
  60314. * @param lightIndex defines the index of the light for the effect
  60315. */
  60316. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60317. }
  60318. }
  60319. declare module BABYLON {
  60320. /**
  60321. * Header information of HDR texture files.
  60322. */
  60323. export interface HDRInfo {
  60324. /**
  60325. * The height of the texture in pixels.
  60326. */
  60327. height: number;
  60328. /**
  60329. * The width of the texture in pixels.
  60330. */
  60331. width: number;
  60332. /**
  60333. * The index of the beginning of the data in the binary file.
  60334. */
  60335. dataPosition: number;
  60336. }
  60337. /**
  60338. * This groups tools to convert HDR texture to native colors array.
  60339. */
  60340. export class HDRTools {
  60341. private static Ldexp;
  60342. private static Rgbe2float;
  60343. private static readStringLine;
  60344. /**
  60345. * Reads header information from an RGBE texture stored in a native array.
  60346. * More information on this format are available here:
  60347. * https://en.wikipedia.org/wiki/RGBE_image_format
  60348. *
  60349. * @param uint8array The binary file stored in native array.
  60350. * @return The header information.
  60351. */
  60352. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60353. /**
  60354. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60355. * This RGBE texture needs to store the information as a panorama.
  60356. *
  60357. * More information on this format are available here:
  60358. * https://en.wikipedia.org/wiki/RGBE_image_format
  60359. *
  60360. * @param buffer The binary file stored in an array buffer.
  60361. * @param size The expected size of the extracted cubemap.
  60362. * @return The Cube Map information.
  60363. */
  60364. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60365. /**
  60366. * Returns the pixels data extracted from an RGBE texture.
  60367. * This pixels will be stored left to right up to down in the R G B order in one array.
  60368. *
  60369. * More information on this format are available here:
  60370. * https://en.wikipedia.org/wiki/RGBE_image_format
  60371. *
  60372. * @param uint8array The binary file stored in an array buffer.
  60373. * @param hdrInfo The header information of the file.
  60374. * @return The pixels data in RGB right to left up to down order.
  60375. */
  60376. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60377. private static RGBE_ReadPixels_RLE;
  60378. private static RGBE_ReadPixels_NOT_RLE;
  60379. }
  60380. }
  60381. declare module BABYLON {
  60382. /**
  60383. * Effect Render Options
  60384. */
  60385. export interface IEffectRendererOptions {
  60386. /**
  60387. * Defines the vertices positions.
  60388. */
  60389. positions?: number[];
  60390. /**
  60391. * Defines the indices.
  60392. */
  60393. indices?: number[];
  60394. }
  60395. /**
  60396. * Helper class to render one or more effects.
  60397. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60398. */
  60399. export class EffectRenderer {
  60400. private engine;
  60401. private static _DefaultOptions;
  60402. private _vertexBuffers;
  60403. private _indexBuffer;
  60404. private _fullscreenViewport;
  60405. /**
  60406. * Creates an effect renderer
  60407. * @param engine the engine to use for rendering
  60408. * @param options defines the options of the effect renderer
  60409. */
  60410. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60411. /**
  60412. * Sets the current viewport in normalized coordinates 0-1
  60413. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60414. */
  60415. setViewport(viewport?: Viewport): void;
  60416. /**
  60417. * Binds the embedded attributes buffer to the effect.
  60418. * @param effect Defines the effect to bind the attributes for
  60419. */
  60420. bindBuffers(effect: Effect): void;
  60421. /**
  60422. * Sets the current effect wrapper to use during draw.
  60423. * The effect needs to be ready before calling this api.
  60424. * This also sets the default full screen position attribute.
  60425. * @param effectWrapper Defines the effect to draw with
  60426. */
  60427. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60428. /**
  60429. * Restores engine states
  60430. */
  60431. restoreStates(): void;
  60432. /**
  60433. * Draws a full screen quad.
  60434. */
  60435. draw(): void;
  60436. private isRenderTargetTexture;
  60437. /**
  60438. * renders one or more effects to a specified texture
  60439. * @param effectWrapper the effect to renderer
  60440. * @param outputTexture texture to draw to, if null it will render to the screen.
  60441. */
  60442. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60443. /**
  60444. * Disposes of the effect renderer
  60445. */
  60446. dispose(): void;
  60447. }
  60448. /**
  60449. * Options to create an EffectWrapper
  60450. */
  60451. interface EffectWrapperCreationOptions {
  60452. /**
  60453. * Engine to use to create the effect
  60454. */
  60455. engine: ThinEngine;
  60456. /**
  60457. * Fragment shader for the effect
  60458. */
  60459. fragmentShader: string;
  60460. /**
  60461. * Use the shader store instead of direct source code
  60462. */
  60463. useShaderStore?: boolean;
  60464. /**
  60465. * Vertex shader for the effect
  60466. */
  60467. vertexShader?: string;
  60468. /**
  60469. * Attributes to use in the shader
  60470. */
  60471. attributeNames?: Array<string>;
  60472. /**
  60473. * Uniforms to use in the shader
  60474. */
  60475. uniformNames?: Array<string>;
  60476. /**
  60477. * Texture sampler names to use in the shader
  60478. */
  60479. samplerNames?: Array<string>;
  60480. /**
  60481. * Defines to use in the shader
  60482. */
  60483. defines?: Array<string>;
  60484. /**
  60485. * Callback when effect is compiled
  60486. */
  60487. onCompiled?: Nullable<(effect: Effect) => void>;
  60488. /**
  60489. * The friendly name of the effect displayed in Spector.
  60490. */
  60491. name?: string;
  60492. }
  60493. /**
  60494. * Wraps an effect to be used for rendering
  60495. */
  60496. export class EffectWrapper {
  60497. /**
  60498. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60499. */
  60500. onApplyObservable: Observable<{}>;
  60501. /**
  60502. * The underlying effect
  60503. */
  60504. effect: Effect;
  60505. /**
  60506. * Creates an effect to be renderer
  60507. * @param creationOptions options to create the effect
  60508. */
  60509. constructor(creationOptions: EffectWrapperCreationOptions);
  60510. /**
  60511. * Disposes of the effect wrapper
  60512. */
  60513. dispose(): void;
  60514. }
  60515. }
  60516. declare module BABYLON {
  60517. /** @hidden */
  60518. export var hdrFilteringVertexShader: {
  60519. name: string;
  60520. shader: string;
  60521. };
  60522. }
  60523. declare module BABYLON {
  60524. /** @hidden */
  60525. export var hdrFilteringPixelShader: {
  60526. name: string;
  60527. shader: string;
  60528. };
  60529. }
  60530. declare module BABYLON {
  60531. /**
  60532. * Options for texture filtering
  60533. */
  60534. interface IHDRFilteringOptions {
  60535. /**
  60536. * Scales pixel intensity for the input HDR map.
  60537. */
  60538. hdrScale?: number;
  60539. /**
  60540. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60541. */
  60542. quality?: number;
  60543. }
  60544. /**
  60545. * Filters HDR maps to get correct renderings of PBR reflections
  60546. */
  60547. export class HDRFiltering {
  60548. private _engine;
  60549. private _effectRenderer;
  60550. private _effectWrapper;
  60551. private _lodGenerationOffset;
  60552. private _lodGenerationScale;
  60553. /**
  60554. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60555. * you care about baking speed.
  60556. */
  60557. quality: number;
  60558. /**
  60559. * Scales pixel intensity for the input HDR map.
  60560. */
  60561. hdrScale: number;
  60562. /**
  60563. * Instantiates HDR filter for reflection maps
  60564. *
  60565. * @param engine Thin engine
  60566. * @param options Options
  60567. */
  60568. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60569. private _createRenderTarget;
  60570. private _prefilterInternal;
  60571. private _createEffect;
  60572. /**
  60573. * Get a value indicating if the filter is ready to be used
  60574. * @param texture Texture to filter
  60575. * @returns true if the filter is ready
  60576. */
  60577. isReady(texture: BaseTexture): boolean;
  60578. /**
  60579. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60580. * Prefiltering will be invoked at the end of next rendering pass.
  60581. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60582. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60583. * @param texture Texture to filter
  60584. * @param onFinished Callback when filtering is done
  60585. * @return Promise called when prefiltering is done
  60586. */
  60587. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60588. }
  60589. }
  60590. declare module BABYLON {
  60591. /**
  60592. * This represents a texture coming from an HDR input.
  60593. *
  60594. * The only supported format is currently panorama picture stored in RGBE format.
  60595. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60596. */
  60597. export class HDRCubeTexture extends BaseTexture {
  60598. private static _facesMapping;
  60599. private _generateHarmonics;
  60600. private _noMipmap;
  60601. private _prefilterOnLoad;
  60602. private _textureMatrix;
  60603. private _size;
  60604. private _onLoad;
  60605. private _onError;
  60606. /**
  60607. * The texture URL.
  60608. */
  60609. url: string;
  60610. protected _isBlocking: boolean;
  60611. /**
  60612. * Sets wether or not the texture is blocking during loading.
  60613. */
  60614. set isBlocking(value: boolean);
  60615. /**
  60616. * Gets wether or not the texture is blocking during loading.
  60617. */
  60618. get isBlocking(): boolean;
  60619. protected _rotationY: number;
  60620. /**
  60621. * Sets texture matrix rotation angle around Y axis in radians.
  60622. */
  60623. set rotationY(value: number);
  60624. /**
  60625. * Gets texture matrix rotation angle around Y axis radians.
  60626. */
  60627. get rotationY(): number;
  60628. /**
  60629. * Gets or sets the center of the bounding box associated with the cube texture
  60630. * It must define where the camera used to render the texture was set
  60631. */
  60632. boundingBoxPosition: Vector3;
  60633. private _boundingBoxSize;
  60634. /**
  60635. * Gets or sets the size of the bounding box associated with the cube texture
  60636. * When defined, the cubemap will switch to local mode
  60637. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60638. * @example https://www.babylonjs-playground.com/#RNASML
  60639. */
  60640. set boundingBoxSize(value: Vector3);
  60641. get boundingBoxSize(): Vector3;
  60642. /**
  60643. * Instantiates an HDRTexture from the following parameters.
  60644. *
  60645. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60646. * @param sceneOrEngine The scene or engine the texture will be used in
  60647. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60648. * @param noMipmap Forces to not generate the mipmap if true
  60649. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60650. * @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)
  60651. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60652. */
  60653. 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>);
  60654. /**
  60655. * Get the current class name of the texture useful for serialization or dynamic coding.
  60656. * @returns "HDRCubeTexture"
  60657. */
  60658. getClassName(): string;
  60659. /**
  60660. * Occurs when the file is raw .hdr file.
  60661. */
  60662. private loadTexture;
  60663. clone(): HDRCubeTexture;
  60664. delayLoad(): void;
  60665. /**
  60666. * Get the texture reflection matrix used to rotate/transform the reflection.
  60667. * @returns the reflection matrix
  60668. */
  60669. getReflectionTextureMatrix(): Matrix;
  60670. /**
  60671. * Set the texture reflection matrix used to rotate/transform the reflection.
  60672. * @param value Define the reflection matrix to set
  60673. */
  60674. setReflectionTextureMatrix(value: Matrix): void;
  60675. /**
  60676. * Parses a JSON representation of an HDR Texture in order to create the texture
  60677. * @param parsedTexture Define the JSON representation
  60678. * @param scene Define the scene the texture should be created in
  60679. * @param rootUrl Define the root url in case we need to load relative dependencies
  60680. * @returns the newly created texture after parsing
  60681. */
  60682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60683. serialize(): any;
  60684. }
  60685. }
  60686. declare module BABYLON {
  60687. /**
  60688. * Class used to control physics engine
  60689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60690. */
  60691. export class PhysicsEngine implements IPhysicsEngine {
  60692. private _physicsPlugin;
  60693. /**
  60694. * Global value used to control the smallest number supported by the simulation
  60695. */
  60696. static Epsilon: number;
  60697. private _impostors;
  60698. private _joints;
  60699. private _subTimeStep;
  60700. /**
  60701. * Gets the gravity vector used by the simulation
  60702. */
  60703. gravity: Vector3;
  60704. /**
  60705. * Factory used to create the default physics plugin.
  60706. * @returns The default physics plugin
  60707. */
  60708. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60709. /**
  60710. * Creates a new Physics Engine
  60711. * @param gravity defines the gravity vector used by the simulation
  60712. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60713. */
  60714. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60715. /**
  60716. * Sets the gravity vector used by the simulation
  60717. * @param gravity defines the gravity vector to use
  60718. */
  60719. setGravity(gravity: Vector3): void;
  60720. /**
  60721. * Set the time step of the physics engine.
  60722. * Default is 1/60.
  60723. * To slow it down, enter 1/600 for example.
  60724. * To speed it up, 1/30
  60725. * @param newTimeStep defines the new timestep to apply to this world.
  60726. */
  60727. setTimeStep(newTimeStep?: number): void;
  60728. /**
  60729. * Get the time step of the physics engine.
  60730. * @returns the current time step
  60731. */
  60732. getTimeStep(): number;
  60733. /**
  60734. * Set the sub time step of the physics engine.
  60735. * Default is 0 meaning there is no sub steps
  60736. * To increase physics resolution precision, set a small value (like 1 ms)
  60737. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60738. */
  60739. setSubTimeStep(subTimeStep?: number): void;
  60740. /**
  60741. * Get the sub time step of the physics engine.
  60742. * @returns the current sub time step
  60743. */
  60744. getSubTimeStep(): number;
  60745. /**
  60746. * Release all resources
  60747. */
  60748. dispose(): void;
  60749. /**
  60750. * Gets the name of the current physics plugin
  60751. * @returns the name of the plugin
  60752. */
  60753. getPhysicsPluginName(): string;
  60754. /**
  60755. * Adding a new impostor for the impostor tracking.
  60756. * This will be done by the impostor itself.
  60757. * @param impostor the impostor to add
  60758. */
  60759. addImpostor(impostor: PhysicsImpostor): void;
  60760. /**
  60761. * Remove an impostor from the engine.
  60762. * This impostor and its mesh will not longer be updated by the physics engine.
  60763. * @param impostor the impostor to remove
  60764. */
  60765. removeImpostor(impostor: PhysicsImpostor): void;
  60766. /**
  60767. * Add a joint to the physics engine
  60768. * @param mainImpostor defines the main impostor to which the joint is added.
  60769. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60770. * @param joint defines the joint that will connect both impostors.
  60771. */
  60772. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60773. /**
  60774. * Removes a joint from the simulation
  60775. * @param mainImpostor defines the impostor used with the joint
  60776. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60777. * @param joint defines the joint to remove
  60778. */
  60779. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60780. /**
  60781. * Called by the scene. No need to call it.
  60782. * @param delta defines the timespam between frames
  60783. */
  60784. _step(delta: number): void;
  60785. /**
  60786. * Gets the current plugin used to run the simulation
  60787. * @returns current plugin
  60788. */
  60789. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60790. /**
  60791. * Gets the list of physic impostors
  60792. * @returns an array of PhysicsImpostor
  60793. */
  60794. getImpostors(): Array<PhysicsImpostor>;
  60795. /**
  60796. * Gets the impostor for a physics enabled object
  60797. * @param object defines the object impersonated by the impostor
  60798. * @returns the PhysicsImpostor or null if not found
  60799. */
  60800. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60801. /**
  60802. * Gets the impostor for a physics body object
  60803. * @param body defines physics body used by the impostor
  60804. * @returns the PhysicsImpostor or null if not found
  60805. */
  60806. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60807. /**
  60808. * Does a raycast in the physics world
  60809. * @param from when should the ray start?
  60810. * @param to when should the ray end?
  60811. * @returns PhysicsRaycastResult
  60812. */
  60813. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60814. }
  60815. }
  60816. declare module BABYLON {
  60817. /** @hidden */
  60818. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60819. private _useDeltaForWorldStep;
  60820. world: any;
  60821. name: string;
  60822. private _physicsMaterials;
  60823. private _fixedTimeStep;
  60824. private _cannonRaycastResult;
  60825. private _raycastResult;
  60826. private _physicsBodysToRemoveAfterStep;
  60827. private _firstFrame;
  60828. BJSCANNON: any;
  60829. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60830. setGravity(gravity: Vector3): void;
  60831. setTimeStep(timeStep: number): void;
  60832. getTimeStep(): number;
  60833. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60834. private _removeMarkedPhysicsBodiesFromWorld;
  60835. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60836. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60837. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60838. private _processChildMeshes;
  60839. removePhysicsBody(impostor: PhysicsImpostor): void;
  60840. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60841. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60842. private _addMaterial;
  60843. private _checkWithEpsilon;
  60844. private _createShape;
  60845. private _createHeightmap;
  60846. private _minus90X;
  60847. private _plus90X;
  60848. private _tmpPosition;
  60849. private _tmpDeltaPosition;
  60850. private _tmpUnityRotation;
  60851. private _updatePhysicsBodyTransformation;
  60852. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60853. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60854. isSupported(): boolean;
  60855. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60856. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60857. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60858. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60859. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60860. getBodyMass(impostor: PhysicsImpostor): number;
  60861. getBodyFriction(impostor: PhysicsImpostor): number;
  60862. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60863. getBodyRestitution(impostor: PhysicsImpostor): number;
  60864. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60865. sleepBody(impostor: PhysicsImpostor): void;
  60866. wakeUpBody(impostor: PhysicsImpostor): void;
  60867. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60868. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60869. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60870. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60871. getRadius(impostor: PhysicsImpostor): number;
  60872. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60873. dispose(): void;
  60874. private _extendNamespace;
  60875. /**
  60876. * Does a raycast in the physics world
  60877. * @param from when should the ray start?
  60878. * @param to when should the ray end?
  60879. * @returns PhysicsRaycastResult
  60880. */
  60881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60882. }
  60883. }
  60884. declare module BABYLON {
  60885. /** @hidden */
  60886. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60887. private _useDeltaForWorldStep;
  60888. world: any;
  60889. name: string;
  60890. BJSOIMO: any;
  60891. private _raycastResult;
  60892. private _fixedTimeStep;
  60893. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60894. setGravity(gravity: Vector3): void;
  60895. setTimeStep(timeStep: number): void;
  60896. getTimeStep(): number;
  60897. private _tmpImpostorsArray;
  60898. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60899. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60900. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60901. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60902. private _tmpPositionVector;
  60903. removePhysicsBody(impostor: PhysicsImpostor): void;
  60904. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60905. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60906. isSupported(): boolean;
  60907. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60908. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60909. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60910. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60911. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60912. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60913. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60914. getBodyMass(impostor: PhysicsImpostor): number;
  60915. getBodyFriction(impostor: PhysicsImpostor): number;
  60916. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60917. getBodyRestitution(impostor: PhysicsImpostor): number;
  60918. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60919. sleepBody(impostor: PhysicsImpostor): void;
  60920. wakeUpBody(impostor: PhysicsImpostor): void;
  60921. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60922. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60923. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60924. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60925. getRadius(impostor: PhysicsImpostor): number;
  60926. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60927. dispose(): void;
  60928. /**
  60929. * Does a raycast in the physics world
  60930. * @param from when should the ray start?
  60931. * @param to when should the ray end?
  60932. * @returns PhysicsRaycastResult
  60933. */
  60934. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60935. }
  60936. }
  60937. declare module BABYLON {
  60938. /**
  60939. * AmmoJS Physics plugin
  60940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60941. * @see https://github.com/kripken/ammo.js/
  60942. */
  60943. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60944. private _useDeltaForWorldStep;
  60945. /**
  60946. * Reference to the Ammo library
  60947. */
  60948. bjsAMMO: any;
  60949. /**
  60950. * Created ammoJS world which physics bodies are added to
  60951. */
  60952. world: any;
  60953. /**
  60954. * Name of the plugin
  60955. */
  60956. name: string;
  60957. private _timeStep;
  60958. private _fixedTimeStep;
  60959. private _maxSteps;
  60960. private _tmpQuaternion;
  60961. private _tmpAmmoTransform;
  60962. private _tmpAmmoQuaternion;
  60963. private _tmpAmmoConcreteContactResultCallback;
  60964. private _collisionConfiguration;
  60965. private _dispatcher;
  60966. private _overlappingPairCache;
  60967. private _solver;
  60968. private _softBodySolver;
  60969. private _tmpAmmoVectorA;
  60970. private _tmpAmmoVectorB;
  60971. private _tmpAmmoVectorC;
  60972. private _tmpAmmoVectorD;
  60973. private _tmpContactCallbackResult;
  60974. private _tmpAmmoVectorRCA;
  60975. private _tmpAmmoVectorRCB;
  60976. private _raycastResult;
  60977. private static readonly DISABLE_COLLISION_FLAG;
  60978. private static readonly KINEMATIC_FLAG;
  60979. private static readonly DISABLE_DEACTIVATION_FLAG;
  60980. /**
  60981. * Initializes the ammoJS plugin
  60982. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60983. * @param ammoInjection can be used to inject your own ammo reference
  60984. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60985. */
  60986. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60987. /**
  60988. * Sets the gravity of the physics world (m/(s^2))
  60989. * @param gravity Gravity to set
  60990. */
  60991. setGravity(gravity: Vector3): void;
  60992. /**
  60993. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60994. * @param timeStep timestep to use in seconds
  60995. */
  60996. setTimeStep(timeStep: number): void;
  60997. /**
  60998. * 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)
  60999. * @param fixedTimeStep fixedTimeStep to use in seconds
  61000. */
  61001. setFixedTimeStep(fixedTimeStep: number): void;
  61002. /**
  61003. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61004. * @param maxSteps the maximum number of steps by the physics engine per frame
  61005. */
  61006. setMaxSteps(maxSteps: number): void;
  61007. /**
  61008. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61009. * @returns the current timestep in seconds
  61010. */
  61011. getTimeStep(): number;
  61012. /**
  61013. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61014. */
  61015. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61016. private _isImpostorInContact;
  61017. private _isImpostorPairInContact;
  61018. private _stepSimulation;
  61019. /**
  61020. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61021. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61022. * After the step the babylon meshes are set to the position of the physics imposters
  61023. * @param delta amount of time to step forward
  61024. * @param impostors array of imposters to update before/after the step
  61025. */
  61026. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61027. /**
  61028. * Update babylon mesh to match physics world object
  61029. * @param impostor imposter to match
  61030. */
  61031. private _afterSoftStep;
  61032. /**
  61033. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61034. * @param impostor imposter to match
  61035. */
  61036. private _ropeStep;
  61037. /**
  61038. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61039. * @param impostor imposter to match
  61040. */
  61041. private _softbodyOrClothStep;
  61042. private _tmpMatrix;
  61043. /**
  61044. * Applies an impulse on the imposter
  61045. * @param impostor imposter to apply impulse to
  61046. * @param force amount of force to be applied to the imposter
  61047. * @param contactPoint the location to apply the impulse on the imposter
  61048. */
  61049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61050. /**
  61051. * Applies a force on the imposter
  61052. * @param impostor imposter to apply force
  61053. * @param force amount of force to be applied to the imposter
  61054. * @param contactPoint the location to apply the force on the imposter
  61055. */
  61056. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61057. /**
  61058. * Creates a physics body using the plugin
  61059. * @param impostor the imposter to create the physics body on
  61060. */
  61061. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61062. /**
  61063. * Removes the physics body from the imposter and disposes of the body's memory
  61064. * @param impostor imposter to remove the physics body from
  61065. */
  61066. removePhysicsBody(impostor: PhysicsImpostor): void;
  61067. /**
  61068. * Generates a joint
  61069. * @param impostorJoint the imposter joint to create the joint with
  61070. */
  61071. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61072. /**
  61073. * Removes a joint
  61074. * @param impostorJoint the imposter joint to remove the joint from
  61075. */
  61076. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61077. private _addMeshVerts;
  61078. /**
  61079. * Initialise the soft body vertices to match its object's (mesh) vertices
  61080. * Softbody vertices (nodes) are in world space and to match this
  61081. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61082. * @param impostor to create the softbody for
  61083. */
  61084. private _softVertexData;
  61085. /**
  61086. * Create an impostor's soft body
  61087. * @param impostor to create the softbody for
  61088. */
  61089. private _createSoftbody;
  61090. /**
  61091. * Create cloth for an impostor
  61092. * @param impostor to create the softbody for
  61093. */
  61094. private _createCloth;
  61095. /**
  61096. * Create rope for an impostor
  61097. * @param impostor to create the softbody for
  61098. */
  61099. private _createRope;
  61100. /**
  61101. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61102. * @param impostor to create the custom physics shape for
  61103. */
  61104. private _createCustom;
  61105. private _addHullVerts;
  61106. private _createShape;
  61107. /**
  61108. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61109. * @param impostor imposter containing the physics body and babylon object
  61110. */
  61111. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61112. /**
  61113. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61114. * @param impostor imposter containing the physics body and babylon object
  61115. * @param newPosition new position
  61116. * @param newRotation new rotation
  61117. */
  61118. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61119. /**
  61120. * If this plugin is supported
  61121. * @returns true if its supported
  61122. */
  61123. isSupported(): boolean;
  61124. /**
  61125. * Sets the linear velocity of the physics body
  61126. * @param impostor imposter to set the velocity on
  61127. * @param velocity velocity to set
  61128. */
  61129. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61130. /**
  61131. * Sets the angular velocity of the physics body
  61132. * @param impostor imposter to set the velocity on
  61133. * @param velocity velocity to set
  61134. */
  61135. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61136. /**
  61137. * gets the linear velocity
  61138. * @param impostor imposter to get linear velocity from
  61139. * @returns linear velocity
  61140. */
  61141. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61142. /**
  61143. * gets the angular velocity
  61144. * @param impostor imposter to get angular velocity from
  61145. * @returns angular velocity
  61146. */
  61147. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61148. /**
  61149. * Sets the mass of physics body
  61150. * @param impostor imposter to set the mass on
  61151. * @param mass mass to set
  61152. */
  61153. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61154. /**
  61155. * Gets the mass of the physics body
  61156. * @param impostor imposter to get the mass from
  61157. * @returns mass
  61158. */
  61159. getBodyMass(impostor: PhysicsImpostor): number;
  61160. /**
  61161. * Gets friction of the impostor
  61162. * @param impostor impostor to get friction from
  61163. * @returns friction value
  61164. */
  61165. getBodyFriction(impostor: PhysicsImpostor): number;
  61166. /**
  61167. * Sets friction of the impostor
  61168. * @param impostor impostor to set friction on
  61169. * @param friction friction value
  61170. */
  61171. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61172. /**
  61173. * Gets restitution of the impostor
  61174. * @param impostor impostor to get restitution from
  61175. * @returns restitution value
  61176. */
  61177. getBodyRestitution(impostor: PhysicsImpostor): number;
  61178. /**
  61179. * Sets resitution of the impostor
  61180. * @param impostor impostor to set resitution on
  61181. * @param restitution resitution value
  61182. */
  61183. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61184. /**
  61185. * Gets pressure inside the impostor
  61186. * @param impostor impostor to get pressure from
  61187. * @returns pressure value
  61188. */
  61189. getBodyPressure(impostor: PhysicsImpostor): number;
  61190. /**
  61191. * Sets pressure inside a soft body impostor
  61192. * Cloth and rope must remain 0 pressure
  61193. * @param impostor impostor to set pressure on
  61194. * @param pressure pressure value
  61195. */
  61196. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61197. /**
  61198. * Gets stiffness of the impostor
  61199. * @param impostor impostor to get stiffness from
  61200. * @returns pressure value
  61201. */
  61202. getBodyStiffness(impostor: PhysicsImpostor): number;
  61203. /**
  61204. * Sets stiffness of the impostor
  61205. * @param impostor impostor to set stiffness on
  61206. * @param stiffness stiffness value from 0 to 1
  61207. */
  61208. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61209. /**
  61210. * Gets velocityIterations of the impostor
  61211. * @param impostor impostor to get velocity iterations from
  61212. * @returns velocityIterations value
  61213. */
  61214. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61215. /**
  61216. * Sets velocityIterations of the impostor
  61217. * @param impostor impostor to set velocity iterations on
  61218. * @param velocityIterations velocityIterations value
  61219. */
  61220. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61221. /**
  61222. * Gets positionIterations of the impostor
  61223. * @param impostor impostor to get position iterations from
  61224. * @returns positionIterations value
  61225. */
  61226. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61227. /**
  61228. * Sets positionIterations of the impostor
  61229. * @param impostor impostor to set position on
  61230. * @param positionIterations positionIterations value
  61231. */
  61232. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61233. /**
  61234. * Append an anchor to a cloth object
  61235. * @param impostor is the cloth impostor to add anchor to
  61236. * @param otherImpostor is the rigid impostor to anchor to
  61237. * @param width ratio across width from 0 to 1
  61238. * @param height ratio up height from 0 to 1
  61239. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61240. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61241. */
  61242. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61243. /**
  61244. * Append an hook to a rope object
  61245. * @param impostor is the rope impostor to add hook to
  61246. * @param otherImpostor is the rigid impostor to hook to
  61247. * @param length ratio along the rope from 0 to 1
  61248. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61249. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61250. */
  61251. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61252. /**
  61253. * Sleeps the physics body and stops it from being active
  61254. * @param impostor impostor to sleep
  61255. */
  61256. sleepBody(impostor: PhysicsImpostor): void;
  61257. /**
  61258. * Activates the physics body
  61259. * @param impostor impostor to activate
  61260. */
  61261. wakeUpBody(impostor: PhysicsImpostor): void;
  61262. /**
  61263. * Updates the distance parameters of the joint
  61264. * @param joint joint to update
  61265. * @param maxDistance maximum distance of the joint
  61266. * @param minDistance minimum distance of the joint
  61267. */
  61268. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61269. /**
  61270. * Sets a motor on the joint
  61271. * @param joint joint to set motor on
  61272. * @param speed speed of the motor
  61273. * @param maxForce maximum force of the motor
  61274. * @param motorIndex index of the motor
  61275. */
  61276. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61277. /**
  61278. * Sets the motors limit
  61279. * @param joint joint to set limit on
  61280. * @param upperLimit upper limit
  61281. * @param lowerLimit lower limit
  61282. */
  61283. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61284. /**
  61285. * Syncs the position and rotation of a mesh with the impostor
  61286. * @param mesh mesh to sync
  61287. * @param impostor impostor to update the mesh with
  61288. */
  61289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61290. /**
  61291. * Gets the radius of the impostor
  61292. * @param impostor impostor to get radius from
  61293. * @returns the radius
  61294. */
  61295. getRadius(impostor: PhysicsImpostor): number;
  61296. /**
  61297. * Gets the box size of the impostor
  61298. * @param impostor impostor to get box size from
  61299. * @param result the resulting box size
  61300. */
  61301. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61302. /**
  61303. * Disposes of the impostor
  61304. */
  61305. dispose(): void;
  61306. /**
  61307. * Does a raycast in the physics world
  61308. * @param from when should the ray start?
  61309. * @param to when should the ray end?
  61310. * @returns PhysicsRaycastResult
  61311. */
  61312. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61313. }
  61314. }
  61315. declare module BABYLON {
  61316. interface AbstractScene {
  61317. /**
  61318. * The list of reflection probes added to the scene
  61319. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61320. */
  61321. reflectionProbes: Array<ReflectionProbe>;
  61322. /**
  61323. * Removes the given reflection probe from this scene.
  61324. * @param toRemove The reflection probe to remove
  61325. * @returns The index of the removed reflection probe
  61326. */
  61327. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61328. /**
  61329. * Adds the given reflection probe to this scene.
  61330. * @param newReflectionProbe The reflection probe to add
  61331. */
  61332. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61333. }
  61334. /**
  61335. * Class used to generate realtime reflection / refraction cube textures
  61336. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61337. */
  61338. export class ReflectionProbe {
  61339. /** defines the name of the probe */
  61340. name: string;
  61341. private _scene;
  61342. private _renderTargetTexture;
  61343. private _projectionMatrix;
  61344. private _viewMatrix;
  61345. private _target;
  61346. private _add;
  61347. private _attachedMesh;
  61348. private _invertYAxis;
  61349. /** Gets or sets probe position (center of the cube map) */
  61350. position: Vector3;
  61351. /**
  61352. * Creates a new reflection probe
  61353. * @param name defines the name of the probe
  61354. * @param size defines the texture resolution (for each face)
  61355. * @param scene defines the hosting scene
  61356. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61357. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61358. */
  61359. constructor(
  61360. /** defines the name of the probe */
  61361. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61362. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61363. get samples(): number;
  61364. set samples(value: number);
  61365. /** Gets or sets the refresh rate to use (on every frame by default) */
  61366. get refreshRate(): number;
  61367. set refreshRate(value: number);
  61368. /**
  61369. * Gets the hosting scene
  61370. * @returns a Scene
  61371. */
  61372. getScene(): Scene;
  61373. /** Gets the internal CubeTexture used to render to */
  61374. get cubeTexture(): RenderTargetTexture;
  61375. /** Gets the list of meshes to render */
  61376. get renderList(): Nullable<AbstractMesh[]>;
  61377. /**
  61378. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61379. * @param mesh defines the mesh to attach to
  61380. */
  61381. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61382. /**
  61383. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61384. * @param renderingGroupId The rendering group id corresponding to its index
  61385. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61386. */
  61387. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61388. /**
  61389. * Clean all associated resources
  61390. */
  61391. dispose(): void;
  61392. /**
  61393. * Converts the reflection probe information to a readable string for debug purpose.
  61394. * @param fullDetails Supports for multiple levels of logging within scene loading
  61395. * @returns the human readable reflection probe info
  61396. */
  61397. toString(fullDetails?: boolean): string;
  61398. /**
  61399. * Get the class name of the relfection probe.
  61400. * @returns "ReflectionProbe"
  61401. */
  61402. getClassName(): string;
  61403. /**
  61404. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61405. * @returns The JSON representation of the texture
  61406. */
  61407. serialize(): any;
  61408. /**
  61409. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61410. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61411. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61412. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61413. * @returns The parsed reflection probe if successful
  61414. */
  61415. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61416. }
  61417. }
  61418. declare module BABYLON {
  61419. /** @hidden */
  61420. export var _BabylonLoaderRegistered: boolean;
  61421. /**
  61422. * Helps setting up some configuration for the babylon file loader.
  61423. */
  61424. export class BabylonFileLoaderConfiguration {
  61425. /**
  61426. * The loader does not allow injecting custom physix engine into the plugins.
  61427. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61428. * So you could set this variable to your engine import to make it work.
  61429. */
  61430. static LoaderInjectedPhysicsEngine: any;
  61431. }
  61432. }
  61433. declare module BABYLON {
  61434. /**
  61435. * The Physically based simple base material of BJS.
  61436. *
  61437. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61438. * It is used as the base class for both the specGloss and metalRough conventions.
  61439. */
  61440. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61441. /**
  61442. * Number of Simultaneous lights allowed on the material.
  61443. */
  61444. maxSimultaneousLights: number;
  61445. /**
  61446. * If sets to true, disables all the lights affecting the material.
  61447. */
  61448. disableLighting: boolean;
  61449. /**
  61450. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61451. */
  61452. environmentTexture: BaseTexture;
  61453. /**
  61454. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61455. */
  61456. invertNormalMapX: boolean;
  61457. /**
  61458. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61459. */
  61460. invertNormalMapY: boolean;
  61461. /**
  61462. * Normal map used in the model.
  61463. */
  61464. normalTexture: BaseTexture;
  61465. /**
  61466. * Emissivie color used to self-illuminate the model.
  61467. */
  61468. emissiveColor: Color3;
  61469. /**
  61470. * Emissivie texture used to self-illuminate the model.
  61471. */
  61472. emissiveTexture: BaseTexture;
  61473. /**
  61474. * Occlusion Channel Strenght.
  61475. */
  61476. occlusionStrength: number;
  61477. /**
  61478. * Occlusion Texture of the material (adding extra occlusion effects).
  61479. */
  61480. occlusionTexture: BaseTexture;
  61481. /**
  61482. * Defines the alpha limits in alpha test mode.
  61483. */
  61484. alphaCutOff: number;
  61485. /**
  61486. * Gets the current double sided mode.
  61487. */
  61488. get doubleSided(): boolean;
  61489. /**
  61490. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61491. */
  61492. set doubleSided(value: boolean);
  61493. /**
  61494. * Stores the pre-calculated light information of a mesh in a texture.
  61495. */
  61496. lightmapTexture: BaseTexture;
  61497. /**
  61498. * If true, the light map contains occlusion information instead of lighting info.
  61499. */
  61500. useLightmapAsShadowmap: boolean;
  61501. /**
  61502. * Instantiates a new PBRMaterial instance.
  61503. *
  61504. * @param name The material name
  61505. * @param scene The scene the material will be use in.
  61506. */
  61507. constructor(name: string, scene: Scene);
  61508. getClassName(): string;
  61509. }
  61510. }
  61511. declare module BABYLON {
  61512. /**
  61513. * The PBR material of BJS following the metal roughness convention.
  61514. *
  61515. * This fits to the PBR convention in the GLTF definition:
  61516. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61517. */
  61518. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61519. /**
  61520. * The base color has two different interpretations depending on the value of metalness.
  61521. * When the material is a metal, the base color is the specific measured reflectance value
  61522. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61523. * of the material.
  61524. */
  61525. baseColor: Color3;
  61526. /**
  61527. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61528. * well as opacity information in the alpha channel.
  61529. */
  61530. baseTexture: BaseTexture;
  61531. /**
  61532. * Specifies the metallic scalar value of the material.
  61533. * Can also be used to scale the metalness values of the metallic texture.
  61534. */
  61535. metallic: number;
  61536. /**
  61537. * Specifies the roughness scalar value of the material.
  61538. * Can also be used to scale the roughness values of the metallic texture.
  61539. */
  61540. roughness: number;
  61541. /**
  61542. * Texture containing both the metallic value in the B channel and the
  61543. * roughness value in the G channel to keep better precision.
  61544. */
  61545. metallicRoughnessTexture: BaseTexture;
  61546. /**
  61547. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61548. *
  61549. * @param name The material name
  61550. * @param scene The scene the material will be use in.
  61551. */
  61552. constructor(name: string, scene: Scene);
  61553. /**
  61554. * Return the currrent class name of the material.
  61555. */
  61556. getClassName(): string;
  61557. /**
  61558. * Makes a duplicate of the current material.
  61559. * @param name - name to use for the new material.
  61560. */
  61561. clone(name: string): PBRMetallicRoughnessMaterial;
  61562. /**
  61563. * Serialize the material to a parsable JSON object.
  61564. */
  61565. serialize(): any;
  61566. /**
  61567. * Parses a JSON object correponding to the serialize function.
  61568. */
  61569. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61570. }
  61571. }
  61572. declare module BABYLON {
  61573. /**
  61574. * The PBR material of BJS following the specular glossiness convention.
  61575. *
  61576. * This fits to the PBR convention in the GLTF definition:
  61577. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61578. */
  61579. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61580. /**
  61581. * Specifies the diffuse color of the material.
  61582. */
  61583. diffuseColor: Color3;
  61584. /**
  61585. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61586. * channel.
  61587. */
  61588. diffuseTexture: BaseTexture;
  61589. /**
  61590. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61591. */
  61592. specularColor: Color3;
  61593. /**
  61594. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61595. */
  61596. glossiness: number;
  61597. /**
  61598. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61599. */
  61600. specularGlossinessTexture: BaseTexture;
  61601. /**
  61602. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61603. *
  61604. * @param name The material name
  61605. * @param scene The scene the material will be use in.
  61606. */
  61607. constructor(name: string, scene: Scene);
  61608. /**
  61609. * Return the currrent class name of the material.
  61610. */
  61611. getClassName(): string;
  61612. /**
  61613. * Makes a duplicate of the current material.
  61614. * @param name - name to use for the new material.
  61615. */
  61616. clone(name: string): PBRSpecularGlossinessMaterial;
  61617. /**
  61618. * Serialize the material to a parsable JSON object.
  61619. */
  61620. serialize(): any;
  61621. /**
  61622. * Parses a JSON object correponding to the serialize function.
  61623. */
  61624. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61625. }
  61626. }
  61627. declare module BABYLON {
  61628. /**
  61629. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61630. * It can help converting any input color in a desired output one. This can then be used to create effects
  61631. * from sepia, black and white to sixties or futuristic rendering...
  61632. *
  61633. * The only supported format is currently 3dl.
  61634. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61635. */
  61636. export class ColorGradingTexture extends BaseTexture {
  61637. /**
  61638. * The texture URL.
  61639. */
  61640. url: string;
  61641. /**
  61642. * Empty line regex stored for GC.
  61643. */
  61644. private static _noneEmptyLineRegex;
  61645. private _textureMatrix;
  61646. private _onLoad;
  61647. /**
  61648. * Instantiates a ColorGradingTexture from the following parameters.
  61649. *
  61650. * @param url The location of the color gradind data (currently only supporting 3dl)
  61651. * @param sceneOrEngine The scene or engine the texture will be used in
  61652. * @param onLoad defines a callback triggered when the texture has been loaded
  61653. */
  61654. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61655. /**
  61656. * Fires the onload event from the constructor if requested.
  61657. */
  61658. private _triggerOnLoad;
  61659. /**
  61660. * Returns the texture matrix used in most of the material.
  61661. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61662. */
  61663. getTextureMatrix(): Matrix;
  61664. /**
  61665. * Occurs when the file being loaded is a .3dl LUT file.
  61666. */
  61667. private load3dlTexture;
  61668. /**
  61669. * Starts the loading process of the texture.
  61670. */
  61671. private loadTexture;
  61672. /**
  61673. * Clones the color gradind texture.
  61674. */
  61675. clone(): ColorGradingTexture;
  61676. /**
  61677. * Called during delayed load for textures.
  61678. */
  61679. delayLoad(): void;
  61680. /**
  61681. * Parses a color grading texture serialized by Babylon.
  61682. * @param parsedTexture The texture information being parsedTexture
  61683. * @param scene The scene to load the texture in
  61684. * @param rootUrl The root url of the data assets to load
  61685. * @return A color gradind texture
  61686. */
  61687. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61688. /**
  61689. * Serializes the LUT texture to json format.
  61690. */
  61691. serialize(): any;
  61692. }
  61693. }
  61694. declare module BABYLON {
  61695. /**
  61696. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61697. */
  61698. export class EquiRectangularCubeTexture extends BaseTexture {
  61699. /** The six faces of the cube. */
  61700. private static _FacesMapping;
  61701. private _noMipmap;
  61702. private _onLoad;
  61703. private _onError;
  61704. /** The size of the cubemap. */
  61705. private _size;
  61706. /** The buffer of the image. */
  61707. private _buffer;
  61708. /** The width of the input image. */
  61709. private _width;
  61710. /** The height of the input image. */
  61711. private _height;
  61712. /** The URL to the image. */
  61713. url: string;
  61714. /**
  61715. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61716. * @param url The location of the image
  61717. * @param scene The scene the texture will be used in
  61718. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61719. * @param noMipmap Forces to not generate the mipmap if true
  61720. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61721. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61722. * @param onLoad — defines a callback called when texture is loaded
  61723. * @param onError — defines a callback called if there is an error
  61724. */
  61725. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61726. /**
  61727. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61728. */
  61729. private loadImage;
  61730. /**
  61731. * Convert the image buffer into a cubemap and create a CubeTexture.
  61732. */
  61733. private loadTexture;
  61734. /**
  61735. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61736. * @param buffer The ArrayBuffer that should be converted.
  61737. * @returns The buffer as Float32Array.
  61738. */
  61739. private getFloat32ArrayFromArrayBuffer;
  61740. /**
  61741. * Get the current class name of the texture useful for serialization or dynamic coding.
  61742. * @returns "EquiRectangularCubeTexture"
  61743. */
  61744. getClassName(): string;
  61745. /**
  61746. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61747. * @returns A clone of the current EquiRectangularCubeTexture.
  61748. */
  61749. clone(): EquiRectangularCubeTexture;
  61750. }
  61751. }
  61752. declare module BABYLON {
  61753. /**
  61754. * Defines the options related to the creation of an HtmlElementTexture
  61755. */
  61756. export interface IHtmlElementTextureOptions {
  61757. /**
  61758. * Defines wether mip maps should be created or not.
  61759. */
  61760. generateMipMaps?: boolean;
  61761. /**
  61762. * Defines the sampling mode of the texture.
  61763. */
  61764. samplingMode?: number;
  61765. /**
  61766. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61767. */
  61768. engine: Nullable<ThinEngine>;
  61769. /**
  61770. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61771. */
  61772. scene: Nullable<Scene>;
  61773. }
  61774. /**
  61775. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61776. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61777. * is automatically managed.
  61778. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61779. * in your application.
  61780. *
  61781. * As the update is not automatic, you need to call them manually.
  61782. */
  61783. export class HtmlElementTexture extends BaseTexture {
  61784. /**
  61785. * The texture URL.
  61786. */
  61787. element: HTMLVideoElement | HTMLCanvasElement;
  61788. private static readonly DefaultOptions;
  61789. private _textureMatrix;
  61790. private _isVideo;
  61791. private _generateMipMaps;
  61792. private _samplingMode;
  61793. /**
  61794. * Instantiates a HtmlElementTexture from the following parameters.
  61795. *
  61796. * @param name Defines the name of the texture
  61797. * @param element Defines the video or canvas the texture is filled with
  61798. * @param options Defines the other none mandatory texture creation options
  61799. */
  61800. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61801. private _createInternalTexture;
  61802. /**
  61803. * Returns the texture matrix used in most of the material.
  61804. */
  61805. getTextureMatrix(): Matrix;
  61806. /**
  61807. * Updates the content of the texture.
  61808. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61809. */
  61810. update(invertY?: Nullable<boolean>): void;
  61811. }
  61812. }
  61813. declare module BABYLON {
  61814. /**
  61815. * Based on jsTGALoader - Javascript loader for TGA file
  61816. * By Vincent Thibault
  61817. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61818. */
  61819. export class TGATools {
  61820. private static _TYPE_INDEXED;
  61821. private static _TYPE_RGB;
  61822. private static _TYPE_GREY;
  61823. private static _TYPE_RLE_INDEXED;
  61824. private static _TYPE_RLE_RGB;
  61825. private static _TYPE_RLE_GREY;
  61826. private static _ORIGIN_MASK;
  61827. private static _ORIGIN_SHIFT;
  61828. private static _ORIGIN_BL;
  61829. private static _ORIGIN_BR;
  61830. private static _ORIGIN_UL;
  61831. private static _ORIGIN_UR;
  61832. /**
  61833. * Gets the header of a TGA file
  61834. * @param data defines the TGA data
  61835. * @returns the header
  61836. */
  61837. static GetTGAHeader(data: Uint8Array): any;
  61838. /**
  61839. * Uploads TGA content to a Babylon Texture
  61840. * @hidden
  61841. */
  61842. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61843. /** @hidden */
  61844. 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;
  61845. /** @hidden */
  61846. 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;
  61847. /** @hidden */
  61848. 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;
  61849. /** @hidden */
  61850. 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;
  61851. /** @hidden */
  61852. 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;
  61853. /** @hidden */
  61854. 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;
  61855. }
  61856. }
  61857. declare module BABYLON {
  61858. /**
  61859. * Implementation of the TGA Texture Loader.
  61860. * @hidden
  61861. */
  61862. export class _TGATextureLoader implements IInternalTextureLoader {
  61863. /**
  61864. * Defines wether the loader supports cascade loading the different faces.
  61865. */
  61866. readonly supportCascades: boolean;
  61867. /**
  61868. * This returns if the loader support the current file information.
  61869. * @param extension defines the file extension of the file being loaded
  61870. * @returns true if the loader can load the specified file
  61871. */
  61872. canLoad(extension: string): boolean;
  61873. /**
  61874. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61875. * @param data contains the texture data
  61876. * @param texture defines the BabylonJS internal texture
  61877. * @param createPolynomials will be true if polynomials have been requested
  61878. * @param onLoad defines the callback to trigger once the texture is ready
  61879. * @param onError defines the callback to trigger in case of error
  61880. */
  61881. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61882. /**
  61883. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61884. * @param data contains the texture data
  61885. * @param texture defines the BabylonJS internal texture
  61886. * @param callback defines the method to call once ready to upload
  61887. */
  61888. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /**
  61893. * Info about the .basis files
  61894. */
  61895. class BasisFileInfo {
  61896. /**
  61897. * If the file has alpha
  61898. */
  61899. hasAlpha: boolean;
  61900. /**
  61901. * Info about each image of the basis file
  61902. */
  61903. images: Array<{
  61904. levels: Array<{
  61905. width: number;
  61906. height: number;
  61907. transcodedPixels: ArrayBufferView;
  61908. }>;
  61909. }>;
  61910. }
  61911. /**
  61912. * Result of transcoding a basis file
  61913. */
  61914. class TranscodeResult {
  61915. /**
  61916. * Info about the .basis file
  61917. */
  61918. fileInfo: BasisFileInfo;
  61919. /**
  61920. * Format to use when loading the file
  61921. */
  61922. format: number;
  61923. }
  61924. /**
  61925. * Configuration options for the Basis transcoder
  61926. */
  61927. export class BasisTranscodeConfiguration {
  61928. /**
  61929. * Supported compression formats used to determine the supported output format of the transcoder
  61930. */
  61931. supportedCompressionFormats?: {
  61932. /**
  61933. * etc1 compression format
  61934. */
  61935. etc1?: boolean;
  61936. /**
  61937. * s3tc compression format
  61938. */
  61939. s3tc?: boolean;
  61940. /**
  61941. * pvrtc compression format
  61942. */
  61943. pvrtc?: boolean;
  61944. /**
  61945. * etc2 compression format
  61946. */
  61947. etc2?: boolean;
  61948. };
  61949. /**
  61950. * If mipmap levels should be loaded for transcoded images (Default: true)
  61951. */
  61952. loadMipmapLevels?: boolean;
  61953. /**
  61954. * Index of a single image to load (Default: all images)
  61955. */
  61956. loadSingleImage?: number;
  61957. }
  61958. /**
  61959. * Used to load .Basis files
  61960. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61961. */
  61962. export class BasisTools {
  61963. private static _IgnoreSupportedFormats;
  61964. /**
  61965. * URL to use when loading the basis transcoder
  61966. */
  61967. static JSModuleURL: string;
  61968. /**
  61969. * URL to use when loading the wasm module for the transcoder
  61970. */
  61971. static WasmModuleURL: string;
  61972. /**
  61973. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61974. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61975. * @returns internal format corresponding to the Basis format
  61976. */
  61977. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61978. private static _WorkerPromise;
  61979. private static _Worker;
  61980. private static _actionId;
  61981. private static _CreateWorkerAsync;
  61982. /**
  61983. * Transcodes a loaded image file to compressed pixel data
  61984. * @param data image data to transcode
  61985. * @param config configuration options for the transcoding
  61986. * @returns a promise resulting in the transcoded image
  61987. */
  61988. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61989. /**
  61990. * Loads a texture from the transcode result
  61991. * @param texture texture load to
  61992. * @param transcodeResult the result of transcoding the basis file to load from
  61993. */
  61994. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61995. }
  61996. }
  61997. declare module BABYLON {
  61998. /**
  61999. * Loader for .basis file format
  62000. */
  62001. export class _BasisTextureLoader implements IInternalTextureLoader {
  62002. /**
  62003. * Defines whether the loader supports cascade loading the different faces.
  62004. */
  62005. readonly supportCascades: boolean;
  62006. /**
  62007. * This returns if the loader support the current file information.
  62008. * @param extension defines the file extension of the file being loaded
  62009. * @returns true if the loader can load the specified file
  62010. */
  62011. canLoad(extension: string): boolean;
  62012. /**
  62013. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62014. * @param data contains the texture data
  62015. * @param texture defines the BabylonJS internal texture
  62016. * @param createPolynomials will be true if polynomials have been requested
  62017. * @param onLoad defines the callback to trigger once the texture is ready
  62018. * @param onError defines the callback to trigger in case of error
  62019. */
  62020. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62021. /**
  62022. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62023. * @param data contains the texture data
  62024. * @param texture defines the BabylonJS internal texture
  62025. * @param callback defines the method to call once ready to upload
  62026. */
  62027. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62028. }
  62029. }
  62030. declare module BABYLON {
  62031. /**
  62032. * Defines the basic options interface of a TexturePacker Frame
  62033. */
  62034. export interface ITexturePackerFrame {
  62035. /**
  62036. * The frame ID
  62037. */
  62038. id: number;
  62039. /**
  62040. * The frames Scale
  62041. */
  62042. scale: Vector2;
  62043. /**
  62044. * The Frames offset
  62045. */
  62046. offset: Vector2;
  62047. }
  62048. /**
  62049. * This is a support class for frame Data on texture packer sets.
  62050. */
  62051. export class TexturePackerFrame implements ITexturePackerFrame {
  62052. /**
  62053. * The frame ID
  62054. */
  62055. id: number;
  62056. /**
  62057. * The frames Scale
  62058. */
  62059. scale: Vector2;
  62060. /**
  62061. * The Frames offset
  62062. */
  62063. offset: Vector2;
  62064. /**
  62065. * Initializes a texture package frame.
  62066. * @param id The numerical frame identifier
  62067. * @param scale Scalar Vector2 for UV frame
  62068. * @param offset Vector2 for the frame position in UV units.
  62069. * @returns TexturePackerFrame
  62070. */
  62071. constructor(id: number, scale: Vector2, offset: Vector2);
  62072. }
  62073. }
  62074. declare module BABYLON {
  62075. /**
  62076. * Defines the basic options interface of a TexturePacker
  62077. */
  62078. export interface ITexturePackerOptions {
  62079. /**
  62080. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62081. */
  62082. map?: string[];
  62083. /**
  62084. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62085. */
  62086. uvsIn?: string;
  62087. /**
  62088. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62089. */
  62090. uvsOut?: string;
  62091. /**
  62092. * number representing the layout style. Defaults to LAYOUT_STRIP
  62093. */
  62094. layout?: number;
  62095. /**
  62096. * number of columns if using custom column count layout(2). This defaults to 4.
  62097. */
  62098. colnum?: number;
  62099. /**
  62100. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62101. */
  62102. updateInputMeshes?: boolean;
  62103. /**
  62104. * boolean flag to dispose all the source textures. Defaults to true.
  62105. */
  62106. disposeSources?: boolean;
  62107. /**
  62108. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62109. */
  62110. fillBlanks?: boolean;
  62111. /**
  62112. * string value representing the context fill style color. Defaults to 'black'.
  62113. */
  62114. customFillColor?: string;
  62115. /**
  62116. * Width and Height Value of each Frame in the TexturePacker Sets
  62117. */
  62118. frameSize?: number;
  62119. /**
  62120. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62121. */
  62122. paddingRatio?: number;
  62123. /**
  62124. * Number that declares the fill method for the padding gutter.
  62125. */
  62126. paddingMode?: number;
  62127. /**
  62128. * If in SUBUV_COLOR padding mode what color to use.
  62129. */
  62130. paddingColor?: Color3 | Color4;
  62131. }
  62132. /**
  62133. * Defines the basic interface of a TexturePacker JSON File
  62134. */
  62135. export interface ITexturePackerJSON {
  62136. /**
  62137. * The frame ID
  62138. */
  62139. name: string;
  62140. /**
  62141. * The base64 channel data
  62142. */
  62143. sets: any;
  62144. /**
  62145. * The options of the Packer
  62146. */
  62147. options: ITexturePackerOptions;
  62148. /**
  62149. * The frame data of the Packer
  62150. */
  62151. frames: Array<number>;
  62152. }
  62153. /**
  62154. * This is a support class that generates a series of packed texture sets.
  62155. * @see https://doc.babylonjs.com/babylon101/materials
  62156. */
  62157. export class TexturePacker {
  62158. /** Packer Layout Constant 0 */
  62159. static readonly LAYOUT_STRIP: number;
  62160. /** Packer Layout Constant 1 */
  62161. static readonly LAYOUT_POWER2: number;
  62162. /** Packer Layout Constant 2 */
  62163. static readonly LAYOUT_COLNUM: number;
  62164. /** Packer Layout Constant 0 */
  62165. static readonly SUBUV_WRAP: number;
  62166. /** Packer Layout Constant 1 */
  62167. static readonly SUBUV_EXTEND: number;
  62168. /** Packer Layout Constant 2 */
  62169. static readonly SUBUV_COLOR: number;
  62170. /** The Name of the Texture Package */
  62171. name: string;
  62172. /** The scene scope of the TexturePacker */
  62173. scene: Scene;
  62174. /** The Meshes to target */
  62175. meshes: AbstractMesh[];
  62176. /** Arguments passed with the Constructor */
  62177. options: ITexturePackerOptions;
  62178. /** The promise that is started upon initialization */
  62179. promise: Nullable<Promise<TexturePacker | string>>;
  62180. /** The Container object for the channel sets that are generated */
  62181. sets: object;
  62182. /** The Container array for the frames that are generated */
  62183. frames: TexturePackerFrame[];
  62184. /** The expected number of textures the system is parsing. */
  62185. private _expecting;
  62186. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62187. private _paddingValue;
  62188. /**
  62189. * Initializes a texture package series from an array of meshes or a single mesh.
  62190. * @param name The name of the package
  62191. * @param meshes The target meshes to compose the package from
  62192. * @param options The arguments that texture packer should follow while building.
  62193. * @param scene The scene which the textures are scoped to.
  62194. * @returns TexturePacker
  62195. */
  62196. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62197. /**
  62198. * Starts the package process
  62199. * @param resolve The promises resolution function
  62200. * @returns TexturePacker
  62201. */
  62202. private _createFrames;
  62203. /**
  62204. * Calculates the Size of the Channel Sets
  62205. * @returns Vector2
  62206. */
  62207. private _calculateSize;
  62208. /**
  62209. * Calculates the UV data for the frames.
  62210. * @param baseSize the base frameSize
  62211. * @param padding the base frame padding
  62212. * @param dtSize size of the Dynamic Texture for that channel
  62213. * @param dtUnits is 1/dtSize
  62214. * @param update flag to update the input meshes
  62215. */
  62216. private _calculateMeshUVFrames;
  62217. /**
  62218. * Calculates the frames Offset.
  62219. * @param index of the frame
  62220. * @returns Vector2
  62221. */
  62222. private _getFrameOffset;
  62223. /**
  62224. * Updates a Mesh to the frame data
  62225. * @param mesh that is the target
  62226. * @param frameID or the frame index
  62227. */
  62228. private _updateMeshUV;
  62229. /**
  62230. * Updates a Meshes materials to use the texture packer channels
  62231. * @param m is the mesh to target
  62232. * @param force all channels on the packer to be set.
  62233. */
  62234. private _updateTextureReferences;
  62235. /**
  62236. * Public method to set a Mesh to a frame
  62237. * @param m that is the target
  62238. * @param frameID or the frame index
  62239. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62240. */
  62241. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62242. /**
  62243. * Starts the async promise to compile the texture packer.
  62244. * @returns Promise<void>
  62245. */
  62246. processAsync(): Promise<void>;
  62247. /**
  62248. * Disposes all textures associated with this packer
  62249. */
  62250. dispose(): void;
  62251. /**
  62252. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62253. * @param imageType is the image type to use.
  62254. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62255. */
  62256. download(imageType?: string, quality?: number): void;
  62257. /**
  62258. * Public method to load a texturePacker JSON file.
  62259. * @param data of the JSON file in string format.
  62260. */
  62261. updateFromJSON(data: string): void;
  62262. }
  62263. }
  62264. declare module BABYLON {
  62265. /**
  62266. * 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.
  62267. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62268. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62269. */
  62270. export class CustomProceduralTexture extends ProceduralTexture {
  62271. private _animate;
  62272. private _time;
  62273. private _config;
  62274. private _texturePath;
  62275. /**
  62276. * Instantiates a new Custom Procedural Texture.
  62277. * 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.
  62278. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62279. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62280. * @param name Define the name of the texture
  62281. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62282. * @param size Define the size of the texture to create
  62283. * @param scene Define the scene the texture belongs to
  62284. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62285. * @param generateMipMaps Define if the texture should creates mip maps or not
  62286. */
  62287. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62288. private _loadJson;
  62289. /**
  62290. * Is the texture ready to be used ? (rendered at least once)
  62291. * @returns true if ready, otherwise, false.
  62292. */
  62293. isReady(): boolean;
  62294. /**
  62295. * Render the texture to its associated render target.
  62296. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62297. */
  62298. render(useCameraPostProcess?: boolean): void;
  62299. /**
  62300. * Update the list of dependant textures samplers in the shader.
  62301. */
  62302. updateTextures(): void;
  62303. /**
  62304. * Update the uniform values of the procedural texture in the shader.
  62305. */
  62306. updateShaderUniforms(): void;
  62307. /**
  62308. * Define if the texture animates or not.
  62309. */
  62310. get animate(): boolean;
  62311. set animate(value: boolean);
  62312. }
  62313. }
  62314. declare module BABYLON {
  62315. /** @hidden */
  62316. export var noisePixelShader: {
  62317. name: string;
  62318. shader: string;
  62319. };
  62320. }
  62321. declare module BABYLON {
  62322. /**
  62323. * Class used to generate noise procedural textures
  62324. */
  62325. export class NoiseProceduralTexture extends ProceduralTexture {
  62326. /** Gets or sets the start time (default is 0) */
  62327. time: number;
  62328. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62329. brightness: number;
  62330. /** Defines the number of octaves to process */
  62331. octaves: number;
  62332. /** Defines the level of persistence (0.8 by default) */
  62333. persistence: number;
  62334. /** Gets or sets animation speed factor (default is 1) */
  62335. animationSpeedFactor: number;
  62336. /**
  62337. * Creates a new NoiseProceduralTexture
  62338. * @param name defines the name fo the texture
  62339. * @param size defines the size of the texture (default is 256)
  62340. * @param scene defines the hosting scene
  62341. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62342. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62343. */
  62344. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62345. private _updateShaderUniforms;
  62346. protected _getDefines(): string;
  62347. /** Generate the current state of the procedural texture */
  62348. render(useCameraPostProcess?: boolean): void;
  62349. /**
  62350. * Serializes this noise procedural texture
  62351. * @returns a serialized noise procedural texture object
  62352. */
  62353. serialize(): any;
  62354. /**
  62355. * Clone the texture.
  62356. * @returns the cloned texture
  62357. */
  62358. clone(): NoiseProceduralTexture;
  62359. /**
  62360. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62361. * @param parsedTexture defines parsed texture data
  62362. * @param scene defines the current scene
  62363. * @param rootUrl defines the root URL containing noise procedural texture information
  62364. * @returns a parsed NoiseProceduralTexture
  62365. */
  62366. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62367. }
  62368. }
  62369. declare module BABYLON {
  62370. /**
  62371. * Raw cube texture where the raw buffers are passed in
  62372. */
  62373. export class RawCubeTexture extends CubeTexture {
  62374. /**
  62375. * Creates a cube texture where the raw buffers are passed in.
  62376. * @param scene defines the scene the texture is attached to
  62377. * @param data defines the array of data to use to create each face
  62378. * @param size defines the size of the textures
  62379. * @param format defines the format of the data
  62380. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62381. * @param generateMipMaps defines if the engine should generate the mip levels
  62382. * @param invertY defines if data must be stored with Y axis inverted
  62383. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62384. * @param compression defines the compression used (null by default)
  62385. */
  62386. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62387. /**
  62388. * Updates the raw cube texture.
  62389. * @param data defines the data to store
  62390. * @param format defines the data format
  62391. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62392. * @param invertY defines if data must be stored with Y axis inverted
  62393. * @param compression defines the compression used (null by default)
  62394. * @param level defines which level of the texture to update
  62395. */
  62396. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62397. /**
  62398. * Updates a raw cube texture with RGBD encoded data.
  62399. * @param data defines the array of data [mipmap][face] to use to create each face
  62400. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62401. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62402. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62403. * @returns a promsie that resolves when the operation is complete
  62404. */
  62405. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62406. /**
  62407. * Clones the raw cube texture.
  62408. * @return a new cube texture
  62409. */
  62410. clone(): CubeTexture;
  62411. /** @hidden */
  62412. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62413. }
  62414. }
  62415. declare module BABYLON {
  62416. /**
  62417. * Class used to store 2D array textures containing user data
  62418. */
  62419. export class RawTexture2DArray extends Texture {
  62420. /** Gets or sets the texture format to use */
  62421. format: number;
  62422. /**
  62423. * Create a new RawTexture2DArray
  62424. * @param data defines the data of the texture
  62425. * @param width defines the width of the texture
  62426. * @param height defines the height of the texture
  62427. * @param depth defines the number of layers of the texture
  62428. * @param format defines the texture format to use
  62429. * @param scene defines the hosting scene
  62430. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62431. * @param invertY defines if texture must be stored with Y axis inverted
  62432. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62433. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62434. */
  62435. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62436. /** Gets or sets the texture format to use */
  62437. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62438. /**
  62439. * Update the texture with new data
  62440. * @param data defines the data to store in the texture
  62441. */
  62442. update(data: ArrayBufferView): void;
  62443. }
  62444. }
  62445. declare module BABYLON {
  62446. /**
  62447. * Class used to store 3D textures containing user data
  62448. */
  62449. export class RawTexture3D extends Texture {
  62450. /** Gets or sets the texture format to use */
  62451. format: number;
  62452. /**
  62453. * Create a new RawTexture3D
  62454. * @param data defines the data of the texture
  62455. * @param width defines the width of the texture
  62456. * @param height defines the height of the texture
  62457. * @param depth defines the depth of the texture
  62458. * @param format defines the texture format to use
  62459. * @param scene defines the hosting scene
  62460. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62461. * @param invertY defines if texture must be stored with Y axis inverted
  62462. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62463. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62464. */
  62465. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62466. /** Gets or sets the texture format to use */
  62467. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62468. /**
  62469. * Update the texture with new data
  62470. * @param data defines the data to store in the texture
  62471. */
  62472. update(data: ArrayBufferView): void;
  62473. }
  62474. }
  62475. declare module BABYLON {
  62476. /**
  62477. * Creates a refraction texture used by refraction channel of the standard material.
  62478. * It is like a mirror but to see through a material.
  62479. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62480. */
  62481. export class RefractionTexture extends RenderTargetTexture {
  62482. /**
  62483. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62484. * 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.
  62485. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62486. */
  62487. refractionPlane: Plane;
  62488. /**
  62489. * Define how deep under the surface we should see.
  62490. */
  62491. depth: number;
  62492. /**
  62493. * Creates a refraction texture used by refraction channel of the standard material.
  62494. * It is like a mirror but to see through a material.
  62495. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62496. * @param name Define the texture name
  62497. * @param size Define the size of the underlying texture
  62498. * @param scene Define the scene the refraction belongs to
  62499. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62500. */
  62501. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62502. /**
  62503. * Clone the refraction texture.
  62504. * @returns the cloned texture
  62505. */
  62506. clone(): RefractionTexture;
  62507. /**
  62508. * Serialize the texture to a JSON representation you could use in Parse later on
  62509. * @returns the serialized JSON representation
  62510. */
  62511. serialize(): any;
  62512. }
  62513. }
  62514. declare module BABYLON {
  62515. /**
  62516. * Block used to add support for vertex skinning (bones)
  62517. */
  62518. export class BonesBlock extends NodeMaterialBlock {
  62519. /**
  62520. * Creates a new BonesBlock
  62521. * @param name defines the block name
  62522. */
  62523. constructor(name: string);
  62524. /**
  62525. * Initialize the block and prepare the context for build
  62526. * @param state defines the state that will be used for the build
  62527. */
  62528. initialize(state: NodeMaterialBuildState): void;
  62529. /**
  62530. * Gets the current class name
  62531. * @returns the class name
  62532. */
  62533. getClassName(): string;
  62534. /**
  62535. * Gets the matrix indices input component
  62536. */
  62537. get matricesIndices(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the matrix weights input component
  62540. */
  62541. get matricesWeights(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the extra matrix indices input component
  62544. */
  62545. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the extra matrix weights input component
  62548. */
  62549. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the world input component
  62552. */
  62553. get world(): NodeMaterialConnectionPoint;
  62554. /**
  62555. * Gets the output component
  62556. */
  62557. get output(): NodeMaterialConnectionPoint;
  62558. autoConfigure(material: NodeMaterial): void;
  62559. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62562. protected _buildBlock(state: NodeMaterialBuildState): this;
  62563. }
  62564. }
  62565. declare module BABYLON {
  62566. /**
  62567. * Block used to add support for instances
  62568. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62569. */
  62570. export class InstancesBlock extends NodeMaterialBlock {
  62571. /**
  62572. * Creates a new InstancesBlock
  62573. * @param name defines the block name
  62574. */
  62575. constructor(name: string);
  62576. /**
  62577. * Gets the current class name
  62578. * @returns the class name
  62579. */
  62580. getClassName(): string;
  62581. /**
  62582. * Gets the first world row input component
  62583. */
  62584. get world0(): NodeMaterialConnectionPoint;
  62585. /**
  62586. * Gets the second world row input component
  62587. */
  62588. get world1(): NodeMaterialConnectionPoint;
  62589. /**
  62590. * Gets the third world row input component
  62591. */
  62592. get world2(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the forth world row input component
  62595. */
  62596. get world3(): NodeMaterialConnectionPoint;
  62597. /**
  62598. * Gets the world input component
  62599. */
  62600. get world(): NodeMaterialConnectionPoint;
  62601. /**
  62602. * Gets the output component
  62603. */
  62604. get output(): NodeMaterialConnectionPoint;
  62605. /**
  62606. * Gets the isntanceID component
  62607. */
  62608. get instanceID(): NodeMaterialConnectionPoint;
  62609. autoConfigure(material: NodeMaterial): void;
  62610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62611. protected _buildBlock(state: NodeMaterialBuildState): this;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /**
  62616. * Block used to add morph targets support to vertex shader
  62617. */
  62618. export class MorphTargetsBlock extends NodeMaterialBlock {
  62619. private _repeatableContentAnchor;
  62620. /**
  62621. * Create a new MorphTargetsBlock
  62622. * @param name defines the block name
  62623. */
  62624. constructor(name: string);
  62625. /**
  62626. * Gets the current class name
  62627. * @returns the class name
  62628. */
  62629. getClassName(): string;
  62630. /**
  62631. * Gets the position input component
  62632. */
  62633. get position(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the normal input component
  62636. */
  62637. get normal(): NodeMaterialConnectionPoint;
  62638. /**
  62639. * Gets the tangent input component
  62640. */
  62641. get tangent(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the tangent input component
  62644. */
  62645. get uv(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the position output component
  62648. */
  62649. get positionOutput(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the normal output component
  62652. */
  62653. get normalOutput(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the tangent output component
  62656. */
  62657. get tangentOutput(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the tangent output component
  62660. */
  62661. get uvOutput(): NodeMaterialConnectionPoint;
  62662. initialize(state: NodeMaterialBuildState): void;
  62663. autoConfigure(material: NodeMaterial): void;
  62664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62666. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62667. protected _buildBlock(state: NodeMaterialBuildState): this;
  62668. }
  62669. }
  62670. declare module BABYLON {
  62671. /**
  62672. * Block used to get data information from a light
  62673. */
  62674. export class LightInformationBlock extends NodeMaterialBlock {
  62675. private _lightDataUniformName;
  62676. private _lightColorUniformName;
  62677. private _lightTypeDefineName;
  62678. /**
  62679. * Gets or sets the light associated with this block
  62680. */
  62681. light: Nullable<Light>;
  62682. /**
  62683. * Creates a new LightInformationBlock
  62684. * @param name defines the block name
  62685. */
  62686. constructor(name: string);
  62687. /**
  62688. * Gets the current class name
  62689. * @returns the class name
  62690. */
  62691. getClassName(): string;
  62692. /**
  62693. * Gets the world position input component
  62694. */
  62695. get worldPosition(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the direction output component
  62698. */
  62699. get direction(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the direction output component
  62702. */
  62703. get color(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the direction output component
  62706. */
  62707. get intensity(): NodeMaterialConnectionPoint;
  62708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62709. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62710. protected _buildBlock(state: NodeMaterialBuildState): this;
  62711. serialize(): any;
  62712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * Block used to add image processing support to fragment shader
  62718. */
  62719. export class ImageProcessingBlock extends NodeMaterialBlock {
  62720. /**
  62721. * Create a new ImageProcessingBlock
  62722. * @param name defines the block name
  62723. */
  62724. constructor(name: string);
  62725. /**
  62726. * Gets the current class name
  62727. * @returns the class name
  62728. */
  62729. getClassName(): string;
  62730. /**
  62731. * Gets the color input component
  62732. */
  62733. get color(): NodeMaterialConnectionPoint;
  62734. /**
  62735. * Gets the output component
  62736. */
  62737. get output(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Initialize the block and prepare the context for build
  62740. * @param state defines the state that will be used for the build
  62741. */
  62742. initialize(state: NodeMaterialBuildState): void;
  62743. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62744. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62745. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62746. protected _buildBlock(state: NodeMaterialBuildState): this;
  62747. }
  62748. }
  62749. declare module BABYLON {
  62750. /**
  62751. * Block used to pertub normals based on a normal map
  62752. */
  62753. export class PerturbNormalBlock extends NodeMaterialBlock {
  62754. private _tangentSpaceParameterName;
  62755. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62756. invertX: boolean;
  62757. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62758. invertY: boolean;
  62759. /**
  62760. * Create a new PerturbNormalBlock
  62761. * @param name defines the block name
  62762. */
  62763. constructor(name: string);
  62764. /**
  62765. * Gets the current class name
  62766. * @returns the class name
  62767. */
  62768. getClassName(): string;
  62769. /**
  62770. * Gets the world position input component
  62771. */
  62772. get worldPosition(): NodeMaterialConnectionPoint;
  62773. /**
  62774. * Gets the world normal input component
  62775. */
  62776. get worldNormal(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the world tangent input component
  62779. */
  62780. get worldTangent(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the uv input component
  62783. */
  62784. get uv(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the normal map color input component
  62787. */
  62788. get normalMapColor(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the strength input component
  62791. */
  62792. get strength(): NodeMaterialConnectionPoint;
  62793. /**
  62794. * Gets the output component
  62795. */
  62796. get output(): NodeMaterialConnectionPoint;
  62797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62799. autoConfigure(material: NodeMaterial): void;
  62800. protected _buildBlock(state: NodeMaterialBuildState): this;
  62801. protected _dumpPropertiesCode(): string;
  62802. serialize(): any;
  62803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62804. }
  62805. }
  62806. declare module BABYLON {
  62807. /**
  62808. * Block used to discard a pixel if a value is smaller than a cutoff
  62809. */
  62810. export class DiscardBlock extends NodeMaterialBlock {
  62811. /**
  62812. * Create a new DiscardBlock
  62813. * @param name defines the block name
  62814. */
  62815. constructor(name: string);
  62816. /**
  62817. * Gets the current class name
  62818. * @returns the class name
  62819. */
  62820. getClassName(): string;
  62821. /**
  62822. * Gets the color input component
  62823. */
  62824. get value(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the cutoff input component
  62827. */
  62828. get cutoff(): NodeMaterialConnectionPoint;
  62829. protected _buildBlock(state: NodeMaterialBuildState): this;
  62830. }
  62831. }
  62832. declare module BABYLON {
  62833. /**
  62834. * Block used to test if the fragment shader is front facing
  62835. */
  62836. export class FrontFacingBlock extends NodeMaterialBlock {
  62837. /**
  62838. * Creates a new FrontFacingBlock
  62839. * @param name defines the block name
  62840. */
  62841. constructor(name: string);
  62842. /**
  62843. * Gets the current class name
  62844. * @returns the class name
  62845. */
  62846. getClassName(): string;
  62847. /**
  62848. * Gets the output component
  62849. */
  62850. get output(): NodeMaterialConnectionPoint;
  62851. protected _buildBlock(state: NodeMaterialBuildState): this;
  62852. }
  62853. }
  62854. declare module BABYLON {
  62855. /**
  62856. * Block used to get the derivative value on x and y of a given input
  62857. */
  62858. export class DerivativeBlock extends NodeMaterialBlock {
  62859. /**
  62860. * Create a new DerivativeBlock
  62861. * @param name defines the block name
  62862. */
  62863. constructor(name: string);
  62864. /**
  62865. * Gets the current class name
  62866. * @returns the class name
  62867. */
  62868. getClassName(): string;
  62869. /**
  62870. * Gets the input component
  62871. */
  62872. get input(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the derivative output on x
  62875. */
  62876. get dx(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the derivative output on y
  62879. */
  62880. get dy(): NodeMaterialConnectionPoint;
  62881. protected _buildBlock(state: NodeMaterialBuildState): this;
  62882. }
  62883. }
  62884. declare module BABYLON {
  62885. /**
  62886. * Block used to make gl_FragCoord available
  62887. */
  62888. export class FragCoordBlock extends NodeMaterialBlock {
  62889. /**
  62890. * Creates a new FragCoordBlock
  62891. * @param name defines the block name
  62892. */
  62893. constructor(name: string);
  62894. /**
  62895. * Gets the current class name
  62896. * @returns the class name
  62897. */
  62898. getClassName(): string;
  62899. /**
  62900. * Gets the xy component
  62901. */
  62902. get xy(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the xyz component
  62905. */
  62906. get xyz(): NodeMaterialConnectionPoint;
  62907. /**
  62908. * Gets the xyzw component
  62909. */
  62910. get xyzw(): NodeMaterialConnectionPoint;
  62911. /**
  62912. * Gets the x component
  62913. */
  62914. get x(): NodeMaterialConnectionPoint;
  62915. /**
  62916. * Gets the y component
  62917. */
  62918. get y(): NodeMaterialConnectionPoint;
  62919. /**
  62920. * Gets the z component
  62921. */
  62922. get z(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the w component
  62925. */
  62926. get output(): NodeMaterialConnectionPoint;
  62927. protected writeOutputs(state: NodeMaterialBuildState): string;
  62928. protected _buildBlock(state: NodeMaterialBuildState): this;
  62929. }
  62930. }
  62931. declare module BABYLON {
  62932. /**
  62933. * Block used to get the screen sizes
  62934. */
  62935. export class ScreenSizeBlock extends NodeMaterialBlock {
  62936. private _varName;
  62937. private _scene;
  62938. /**
  62939. * Creates a new ScreenSizeBlock
  62940. * @param name defines the block name
  62941. */
  62942. constructor(name: string);
  62943. /**
  62944. * Gets the current class name
  62945. * @returns the class name
  62946. */
  62947. getClassName(): string;
  62948. /**
  62949. * Gets the xy component
  62950. */
  62951. get xy(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the x component
  62954. */
  62955. get x(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the y component
  62958. */
  62959. get y(): NodeMaterialConnectionPoint;
  62960. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62961. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62962. protected _buildBlock(state: NodeMaterialBuildState): this;
  62963. }
  62964. }
  62965. declare module BABYLON {
  62966. /**
  62967. * Block used to add support for scene fog
  62968. */
  62969. export class FogBlock extends NodeMaterialBlock {
  62970. private _fogDistanceName;
  62971. private _fogParameters;
  62972. /**
  62973. * Create a new FogBlock
  62974. * @param name defines the block name
  62975. */
  62976. constructor(name: string);
  62977. /**
  62978. * Gets the current class name
  62979. * @returns the class name
  62980. */
  62981. getClassName(): string;
  62982. /**
  62983. * Gets the world position input component
  62984. */
  62985. get worldPosition(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the view input component
  62988. */
  62989. get view(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the color input component
  62992. */
  62993. get input(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the fog color input component
  62996. */
  62997. get fogColor(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the output component
  63000. */
  63001. get output(): NodeMaterialConnectionPoint;
  63002. autoConfigure(material: NodeMaterial): void;
  63003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63004. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63005. protected _buildBlock(state: NodeMaterialBuildState): this;
  63006. }
  63007. }
  63008. declare module BABYLON {
  63009. /**
  63010. * Block used to add light in the fragment shader
  63011. */
  63012. export class LightBlock extends NodeMaterialBlock {
  63013. private _lightId;
  63014. /**
  63015. * Gets or sets the light associated with this block
  63016. */
  63017. light: Nullable<Light>;
  63018. /**
  63019. * Create a new LightBlock
  63020. * @param name defines the block name
  63021. */
  63022. constructor(name: string);
  63023. /**
  63024. * Gets the current class name
  63025. * @returns the class name
  63026. */
  63027. getClassName(): string;
  63028. /**
  63029. * Gets the world position input component
  63030. */
  63031. get worldPosition(): NodeMaterialConnectionPoint;
  63032. /**
  63033. * Gets the world normal input component
  63034. */
  63035. get worldNormal(): NodeMaterialConnectionPoint;
  63036. /**
  63037. * Gets the camera (or eye) position component
  63038. */
  63039. get cameraPosition(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the glossiness component
  63042. */
  63043. get glossiness(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the glossinness power component
  63046. */
  63047. get glossPower(): NodeMaterialConnectionPoint;
  63048. /**
  63049. * Gets the diffuse color component
  63050. */
  63051. get diffuseColor(): NodeMaterialConnectionPoint;
  63052. /**
  63053. * Gets the specular color component
  63054. */
  63055. get specularColor(): NodeMaterialConnectionPoint;
  63056. /**
  63057. * Gets the diffuse output component
  63058. */
  63059. get diffuseOutput(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the specular output component
  63062. */
  63063. get specularOutput(): NodeMaterialConnectionPoint;
  63064. /**
  63065. * Gets the shadow output component
  63066. */
  63067. get shadow(): NodeMaterialConnectionPoint;
  63068. autoConfigure(material: NodeMaterial): void;
  63069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63070. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63071. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63072. private _injectVertexCode;
  63073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63074. serialize(): any;
  63075. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63076. }
  63077. }
  63078. declare module BABYLON {
  63079. /**
  63080. * Block used to read a reflection texture from a sampler
  63081. */
  63082. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63083. /**
  63084. * Create a new ReflectionTextureBlock
  63085. * @param name defines the block name
  63086. */
  63087. constructor(name: string);
  63088. /**
  63089. * Gets the current class name
  63090. * @returns the class name
  63091. */
  63092. getClassName(): string;
  63093. /**
  63094. * Gets the world position input component
  63095. */
  63096. get position(): NodeMaterialConnectionPoint;
  63097. /**
  63098. * Gets the world position input component
  63099. */
  63100. get worldPosition(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the world normal input component
  63103. */
  63104. get worldNormal(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the world input component
  63107. */
  63108. get world(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the camera (or eye) position component
  63111. */
  63112. get cameraPosition(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the view input component
  63115. */
  63116. get view(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the rgb output component
  63119. */
  63120. get rgb(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the rgba output component
  63123. */
  63124. get rgba(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the r output component
  63127. */
  63128. get r(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the g output component
  63131. */
  63132. get g(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the b output component
  63135. */
  63136. get b(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the a output component
  63139. */
  63140. get a(): NodeMaterialConnectionPoint;
  63141. autoConfigure(material: NodeMaterial): void;
  63142. protected _buildBlock(state: NodeMaterialBuildState): this;
  63143. }
  63144. }
  63145. declare module BABYLON {
  63146. /**
  63147. * Block used to add 2 vectors
  63148. */
  63149. export class AddBlock extends NodeMaterialBlock {
  63150. /**
  63151. * Creates a new AddBlock
  63152. * @param name defines the block name
  63153. */
  63154. constructor(name: string);
  63155. /**
  63156. * Gets the current class name
  63157. * @returns the class name
  63158. */
  63159. getClassName(): string;
  63160. /**
  63161. * Gets the left operand input component
  63162. */
  63163. get left(): NodeMaterialConnectionPoint;
  63164. /**
  63165. * Gets the right operand input component
  63166. */
  63167. get right(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the output component
  63170. */
  63171. get output(): NodeMaterialConnectionPoint;
  63172. protected _buildBlock(state: NodeMaterialBuildState): this;
  63173. }
  63174. }
  63175. declare module BABYLON {
  63176. /**
  63177. * Block used to scale a vector by a float
  63178. */
  63179. export class ScaleBlock extends NodeMaterialBlock {
  63180. /**
  63181. * Creates a new ScaleBlock
  63182. * @param name defines the block name
  63183. */
  63184. constructor(name: string);
  63185. /**
  63186. * Gets the current class name
  63187. * @returns the class name
  63188. */
  63189. getClassName(): string;
  63190. /**
  63191. * Gets the input component
  63192. */
  63193. get input(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the factor input component
  63196. */
  63197. get factor(): NodeMaterialConnectionPoint;
  63198. /**
  63199. * Gets the output component
  63200. */
  63201. get output(): NodeMaterialConnectionPoint;
  63202. protected _buildBlock(state: NodeMaterialBuildState): this;
  63203. }
  63204. }
  63205. declare module BABYLON {
  63206. /**
  63207. * Block used to clamp a float
  63208. */
  63209. export class ClampBlock extends NodeMaterialBlock {
  63210. /** Gets or sets the minimum range */
  63211. minimum: number;
  63212. /** Gets or sets the maximum range */
  63213. maximum: number;
  63214. /**
  63215. * Creates a new ClampBlock
  63216. * @param name defines the block name
  63217. */
  63218. constructor(name: string);
  63219. /**
  63220. * Gets the current class name
  63221. * @returns the class name
  63222. */
  63223. getClassName(): string;
  63224. /**
  63225. * Gets the value input component
  63226. */
  63227. get value(): NodeMaterialConnectionPoint;
  63228. /**
  63229. * Gets the output component
  63230. */
  63231. get output(): NodeMaterialConnectionPoint;
  63232. protected _buildBlock(state: NodeMaterialBuildState): this;
  63233. protected _dumpPropertiesCode(): string;
  63234. serialize(): any;
  63235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63236. }
  63237. }
  63238. declare module BABYLON {
  63239. /**
  63240. * Block used to apply a cross product between 2 vectors
  63241. */
  63242. export class CrossBlock extends NodeMaterialBlock {
  63243. /**
  63244. * Creates a new CrossBlock
  63245. * @param name defines the block name
  63246. */
  63247. constructor(name: string);
  63248. /**
  63249. * Gets the current class name
  63250. * @returns the class name
  63251. */
  63252. getClassName(): string;
  63253. /**
  63254. * Gets the left operand input component
  63255. */
  63256. get left(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the right operand input component
  63259. */
  63260. get right(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the output component
  63263. */
  63264. get output(): NodeMaterialConnectionPoint;
  63265. protected _buildBlock(state: NodeMaterialBuildState): this;
  63266. }
  63267. }
  63268. declare module BABYLON {
  63269. /**
  63270. * Block used to apply a dot product between 2 vectors
  63271. */
  63272. export class DotBlock extends NodeMaterialBlock {
  63273. /**
  63274. * Creates a new DotBlock
  63275. * @param name defines the block name
  63276. */
  63277. constructor(name: string);
  63278. /**
  63279. * Gets the current class name
  63280. * @returns the class name
  63281. */
  63282. getClassName(): string;
  63283. /**
  63284. * Gets the left operand input component
  63285. */
  63286. get left(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the right operand input component
  63289. */
  63290. get right(): NodeMaterialConnectionPoint;
  63291. /**
  63292. * Gets the output component
  63293. */
  63294. get output(): NodeMaterialConnectionPoint;
  63295. protected _buildBlock(state: NodeMaterialBuildState): this;
  63296. }
  63297. }
  63298. declare module BABYLON {
  63299. /**
  63300. * Block used to normalize a vector
  63301. */
  63302. export class NormalizeBlock extends NodeMaterialBlock {
  63303. /**
  63304. * Creates a new NormalizeBlock
  63305. * @param name defines the block name
  63306. */
  63307. constructor(name: string);
  63308. /**
  63309. * Gets the current class name
  63310. * @returns the class name
  63311. */
  63312. getClassName(): string;
  63313. /**
  63314. * Gets the input component
  63315. */
  63316. get input(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the output component
  63319. */
  63320. get output(): NodeMaterialConnectionPoint;
  63321. protected _buildBlock(state: NodeMaterialBuildState): this;
  63322. }
  63323. }
  63324. declare module BABYLON {
  63325. /**
  63326. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63327. */
  63328. export class ColorMergerBlock extends NodeMaterialBlock {
  63329. /**
  63330. * Create a new ColorMergerBlock
  63331. * @param name defines the block name
  63332. */
  63333. constructor(name: string);
  63334. /**
  63335. * Gets the current class name
  63336. * @returns the class name
  63337. */
  63338. getClassName(): string;
  63339. /**
  63340. * Gets the rgb component (input)
  63341. */
  63342. get rgbIn(): NodeMaterialConnectionPoint;
  63343. /**
  63344. * Gets the r component (input)
  63345. */
  63346. get r(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the g component (input)
  63349. */
  63350. get g(): NodeMaterialConnectionPoint;
  63351. /**
  63352. * Gets the b component (input)
  63353. */
  63354. get b(): NodeMaterialConnectionPoint;
  63355. /**
  63356. * Gets the a component (input)
  63357. */
  63358. get a(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the rgba component (output)
  63361. */
  63362. get rgba(): NodeMaterialConnectionPoint;
  63363. /**
  63364. * Gets the rgb component (output)
  63365. */
  63366. get rgbOut(): NodeMaterialConnectionPoint;
  63367. /**
  63368. * Gets the rgb component (output)
  63369. * @deprecated Please use rgbOut instead.
  63370. */
  63371. get rgb(): NodeMaterialConnectionPoint;
  63372. protected _buildBlock(state: NodeMaterialBuildState): this;
  63373. }
  63374. }
  63375. declare module BABYLON {
  63376. /**
  63377. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63378. */
  63379. export class VectorSplitterBlock extends NodeMaterialBlock {
  63380. /**
  63381. * Create a new VectorSplitterBlock
  63382. * @param name defines the block name
  63383. */
  63384. constructor(name: string);
  63385. /**
  63386. * Gets the current class name
  63387. * @returns the class name
  63388. */
  63389. getClassName(): string;
  63390. /**
  63391. * Gets the xyzw component (input)
  63392. */
  63393. get xyzw(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the xyz component (input)
  63396. */
  63397. get xyzIn(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the xy component (input)
  63400. */
  63401. get xyIn(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the xyz component (output)
  63404. */
  63405. get xyzOut(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the xy component (output)
  63408. */
  63409. get xyOut(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the x component (output)
  63412. */
  63413. get x(): NodeMaterialConnectionPoint;
  63414. /**
  63415. * Gets the y component (output)
  63416. */
  63417. get y(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the z component (output)
  63420. */
  63421. get z(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the w component (output)
  63424. */
  63425. get w(): NodeMaterialConnectionPoint;
  63426. protected _inputRename(name: string): string;
  63427. protected _outputRename(name: string): string;
  63428. protected _buildBlock(state: NodeMaterialBuildState): this;
  63429. }
  63430. }
  63431. declare module BABYLON {
  63432. /**
  63433. * Block used to lerp between 2 values
  63434. */
  63435. export class LerpBlock extends NodeMaterialBlock {
  63436. /**
  63437. * Creates a new LerpBlock
  63438. * @param name defines the block name
  63439. */
  63440. constructor(name: string);
  63441. /**
  63442. * Gets the current class name
  63443. * @returns the class name
  63444. */
  63445. getClassName(): string;
  63446. /**
  63447. * Gets the left operand input component
  63448. */
  63449. get left(): NodeMaterialConnectionPoint;
  63450. /**
  63451. * Gets the right operand input component
  63452. */
  63453. get right(): NodeMaterialConnectionPoint;
  63454. /**
  63455. * Gets the gradient operand input component
  63456. */
  63457. get gradient(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the output component
  63460. */
  63461. get output(): NodeMaterialConnectionPoint;
  63462. protected _buildBlock(state: NodeMaterialBuildState): this;
  63463. }
  63464. }
  63465. declare module BABYLON {
  63466. /**
  63467. * Block used to divide 2 vectors
  63468. */
  63469. export class DivideBlock extends NodeMaterialBlock {
  63470. /**
  63471. * Creates a new DivideBlock
  63472. * @param name defines the block name
  63473. */
  63474. constructor(name: string);
  63475. /**
  63476. * Gets the current class name
  63477. * @returns the class name
  63478. */
  63479. getClassName(): string;
  63480. /**
  63481. * Gets the left operand input component
  63482. */
  63483. get left(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the right operand input component
  63486. */
  63487. get right(): NodeMaterialConnectionPoint;
  63488. /**
  63489. * Gets the output component
  63490. */
  63491. get output(): NodeMaterialConnectionPoint;
  63492. protected _buildBlock(state: NodeMaterialBuildState): this;
  63493. }
  63494. }
  63495. declare module BABYLON {
  63496. /**
  63497. * Block used to subtract 2 vectors
  63498. */
  63499. export class SubtractBlock extends NodeMaterialBlock {
  63500. /**
  63501. * Creates a new SubtractBlock
  63502. * @param name defines the block name
  63503. */
  63504. constructor(name: string);
  63505. /**
  63506. * Gets the current class name
  63507. * @returns the class name
  63508. */
  63509. getClassName(): string;
  63510. /**
  63511. * Gets the left operand input component
  63512. */
  63513. get left(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the right operand input component
  63516. */
  63517. get right(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the output component
  63520. */
  63521. get output(): NodeMaterialConnectionPoint;
  63522. protected _buildBlock(state: NodeMaterialBuildState): this;
  63523. }
  63524. }
  63525. declare module BABYLON {
  63526. /**
  63527. * Block used to step a value
  63528. */
  63529. export class StepBlock extends NodeMaterialBlock {
  63530. /**
  63531. * Creates a new StepBlock
  63532. * @param name defines the block name
  63533. */
  63534. constructor(name: string);
  63535. /**
  63536. * Gets the current class name
  63537. * @returns the class name
  63538. */
  63539. getClassName(): string;
  63540. /**
  63541. * Gets the value operand input component
  63542. */
  63543. get value(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the edge operand input component
  63546. */
  63547. get edge(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the output component
  63550. */
  63551. get output(): NodeMaterialConnectionPoint;
  63552. protected _buildBlock(state: NodeMaterialBuildState): this;
  63553. }
  63554. }
  63555. declare module BABYLON {
  63556. /**
  63557. * Block used to get the opposite (1 - x) of a value
  63558. */
  63559. export class OneMinusBlock extends NodeMaterialBlock {
  63560. /**
  63561. * Creates a new OneMinusBlock
  63562. * @param name defines the block name
  63563. */
  63564. constructor(name: string);
  63565. /**
  63566. * Gets the current class name
  63567. * @returns the class name
  63568. */
  63569. getClassName(): string;
  63570. /**
  63571. * Gets the input component
  63572. */
  63573. get input(): NodeMaterialConnectionPoint;
  63574. /**
  63575. * Gets the output component
  63576. */
  63577. get output(): NodeMaterialConnectionPoint;
  63578. protected _buildBlock(state: NodeMaterialBuildState): this;
  63579. }
  63580. }
  63581. declare module BABYLON {
  63582. /**
  63583. * Block used to get the view direction
  63584. */
  63585. export class ViewDirectionBlock extends NodeMaterialBlock {
  63586. /**
  63587. * Creates a new ViewDirectionBlock
  63588. * @param name defines the block name
  63589. */
  63590. constructor(name: string);
  63591. /**
  63592. * Gets the current class name
  63593. * @returns the class name
  63594. */
  63595. getClassName(): string;
  63596. /**
  63597. * Gets the world position component
  63598. */
  63599. get worldPosition(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the camera position component
  63602. */
  63603. get cameraPosition(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the output component
  63606. */
  63607. get output(): NodeMaterialConnectionPoint;
  63608. autoConfigure(material: NodeMaterial): void;
  63609. protected _buildBlock(state: NodeMaterialBuildState): this;
  63610. }
  63611. }
  63612. declare module BABYLON {
  63613. /**
  63614. * Block used to compute fresnel value
  63615. */
  63616. export class FresnelBlock extends NodeMaterialBlock {
  63617. /**
  63618. * Create a new FresnelBlock
  63619. * @param name defines the block name
  63620. */
  63621. constructor(name: string);
  63622. /**
  63623. * Gets the current class name
  63624. * @returns the class name
  63625. */
  63626. getClassName(): string;
  63627. /**
  63628. * Gets the world normal input component
  63629. */
  63630. get worldNormal(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the view direction input component
  63633. */
  63634. get viewDirection(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the bias input component
  63637. */
  63638. get bias(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the camera (or eye) position component
  63641. */
  63642. get power(): NodeMaterialConnectionPoint;
  63643. /**
  63644. * Gets the fresnel output component
  63645. */
  63646. get fresnel(): NodeMaterialConnectionPoint;
  63647. autoConfigure(material: NodeMaterial): void;
  63648. protected _buildBlock(state: NodeMaterialBuildState): this;
  63649. }
  63650. }
  63651. declare module BABYLON {
  63652. /**
  63653. * Block used to get the max of 2 values
  63654. */
  63655. export class MaxBlock extends NodeMaterialBlock {
  63656. /**
  63657. * Creates a new MaxBlock
  63658. * @param name defines the block name
  63659. */
  63660. constructor(name: string);
  63661. /**
  63662. * Gets the current class name
  63663. * @returns the class name
  63664. */
  63665. getClassName(): string;
  63666. /**
  63667. * Gets the left operand input component
  63668. */
  63669. get left(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the right operand input component
  63672. */
  63673. get right(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the output component
  63676. */
  63677. get output(): NodeMaterialConnectionPoint;
  63678. protected _buildBlock(state: NodeMaterialBuildState): this;
  63679. }
  63680. }
  63681. declare module BABYLON {
  63682. /**
  63683. * Block used to get the min of 2 values
  63684. */
  63685. export class MinBlock extends NodeMaterialBlock {
  63686. /**
  63687. * Creates a new MinBlock
  63688. * @param name defines the block name
  63689. */
  63690. constructor(name: string);
  63691. /**
  63692. * Gets the current class name
  63693. * @returns the class name
  63694. */
  63695. getClassName(): string;
  63696. /**
  63697. * Gets the left operand input component
  63698. */
  63699. get left(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the right operand input component
  63702. */
  63703. get right(): NodeMaterialConnectionPoint;
  63704. /**
  63705. * Gets the output component
  63706. */
  63707. get output(): NodeMaterialConnectionPoint;
  63708. protected _buildBlock(state: NodeMaterialBuildState): this;
  63709. }
  63710. }
  63711. declare module BABYLON {
  63712. /**
  63713. * Block used to get the distance between 2 values
  63714. */
  63715. export class DistanceBlock extends NodeMaterialBlock {
  63716. /**
  63717. * Creates a new DistanceBlock
  63718. * @param name defines the block name
  63719. */
  63720. constructor(name: string);
  63721. /**
  63722. * Gets the current class name
  63723. * @returns the class name
  63724. */
  63725. getClassName(): string;
  63726. /**
  63727. * Gets the left operand input component
  63728. */
  63729. get left(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the right operand input component
  63732. */
  63733. get right(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the output component
  63736. */
  63737. get output(): NodeMaterialConnectionPoint;
  63738. protected _buildBlock(state: NodeMaterialBuildState): this;
  63739. }
  63740. }
  63741. declare module BABYLON {
  63742. /**
  63743. * Block used to get the length of a vector
  63744. */
  63745. export class LengthBlock extends NodeMaterialBlock {
  63746. /**
  63747. * Creates a new LengthBlock
  63748. * @param name defines the block name
  63749. */
  63750. constructor(name: string);
  63751. /**
  63752. * Gets the current class name
  63753. * @returns the class name
  63754. */
  63755. getClassName(): string;
  63756. /**
  63757. * Gets the value input component
  63758. */
  63759. get value(): NodeMaterialConnectionPoint;
  63760. /**
  63761. * Gets the output component
  63762. */
  63763. get output(): NodeMaterialConnectionPoint;
  63764. protected _buildBlock(state: NodeMaterialBuildState): this;
  63765. }
  63766. }
  63767. declare module BABYLON {
  63768. /**
  63769. * Block used to get negative version of a value (i.e. x * -1)
  63770. */
  63771. export class NegateBlock extends NodeMaterialBlock {
  63772. /**
  63773. * Creates a new NegateBlock
  63774. * @param name defines the block name
  63775. */
  63776. constructor(name: string);
  63777. /**
  63778. * Gets the current class name
  63779. * @returns the class name
  63780. */
  63781. getClassName(): string;
  63782. /**
  63783. * Gets the value input component
  63784. */
  63785. get value(): NodeMaterialConnectionPoint;
  63786. /**
  63787. * Gets the output component
  63788. */
  63789. get output(): NodeMaterialConnectionPoint;
  63790. protected _buildBlock(state: NodeMaterialBuildState): this;
  63791. }
  63792. }
  63793. declare module BABYLON {
  63794. /**
  63795. * Block used to get the value of the first parameter raised to the power of the second
  63796. */
  63797. export class PowBlock extends NodeMaterialBlock {
  63798. /**
  63799. * Creates a new PowBlock
  63800. * @param name defines the block name
  63801. */
  63802. constructor(name: string);
  63803. /**
  63804. * Gets the current class name
  63805. * @returns the class name
  63806. */
  63807. getClassName(): string;
  63808. /**
  63809. * Gets the value operand input component
  63810. */
  63811. get value(): NodeMaterialConnectionPoint;
  63812. /**
  63813. * Gets the power operand input component
  63814. */
  63815. get power(): NodeMaterialConnectionPoint;
  63816. /**
  63817. * Gets the output component
  63818. */
  63819. get output(): NodeMaterialConnectionPoint;
  63820. protected _buildBlock(state: NodeMaterialBuildState): this;
  63821. }
  63822. }
  63823. declare module BABYLON {
  63824. /**
  63825. * Block used to get a random number
  63826. */
  63827. export class RandomNumberBlock extends NodeMaterialBlock {
  63828. /**
  63829. * Creates a new RandomNumberBlock
  63830. * @param name defines the block name
  63831. */
  63832. constructor(name: string);
  63833. /**
  63834. * Gets the current class name
  63835. * @returns the class name
  63836. */
  63837. getClassName(): string;
  63838. /**
  63839. * Gets the seed input component
  63840. */
  63841. get seed(): NodeMaterialConnectionPoint;
  63842. /**
  63843. * Gets the output component
  63844. */
  63845. get output(): NodeMaterialConnectionPoint;
  63846. protected _buildBlock(state: NodeMaterialBuildState): this;
  63847. }
  63848. }
  63849. declare module BABYLON {
  63850. /**
  63851. * Block used to compute arc tangent of 2 values
  63852. */
  63853. export class ArcTan2Block extends NodeMaterialBlock {
  63854. /**
  63855. * Creates a new ArcTan2Block
  63856. * @param name defines the block name
  63857. */
  63858. constructor(name: string);
  63859. /**
  63860. * Gets the current class name
  63861. * @returns the class name
  63862. */
  63863. getClassName(): string;
  63864. /**
  63865. * Gets the x operand input component
  63866. */
  63867. get x(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the y operand input component
  63870. */
  63871. get y(): NodeMaterialConnectionPoint;
  63872. /**
  63873. * Gets the output component
  63874. */
  63875. get output(): NodeMaterialConnectionPoint;
  63876. protected _buildBlock(state: NodeMaterialBuildState): this;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to smooth step a value
  63882. */
  63883. export class SmoothStepBlock extends NodeMaterialBlock {
  63884. /**
  63885. * Creates a new SmoothStepBlock
  63886. * @param name defines the block name
  63887. */
  63888. constructor(name: string);
  63889. /**
  63890. * Gets the current class name
  63891. * @returns the class name
  63892. */
  63893. getClassName(): string;
  63894. /**
  63895. * Gets the value operand input component
  63896. */
  63897. get value(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the first edge operand input component
  63900. */
  63901. get edge0(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the second edge operand input component
  63904. */
  63905. get edge1(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the output component
  63908. */
  63909. get output(): NodeMaterialConnectionPoint;
  63910. protected _buildBlock(state: NodeMaterialBuildState): this;
  63911. }
  63912. }
  63913. declare module BABYLON {
  63914. /**
  63915. * Block used to get the reciprocal (1 / x) of a value
  63916. */
  63917. export class ReciprocalBlock extends NodeMaterialBlock {
  63918. /**
  63919. * Creates a new ReciprocalBlock
  63920. * @param name defines the block name
  63921. */
  63922. constructor(name: string);
  63923. /**
  63924. * Gets the current class name
  63925. * @returns the class name
  63926. */
  63927. getClassName(): string;
  63928. /**
  63929. * Gets the input component
  63930. */
  63931. get input(): NodeMaterialConnectionPoint;
  63932. /**
  63933. * Gets the output component
  63934. */
  63935. get output(): NodeMaterialConnectionPoint;
  63936. protected _buildBlock(state: NodeMaterialBuildState): this;
  63937. }
  63938. }
  63939. declare module BABYLON {
  63940. /**
  63941. * Block used to replace a color by another one
  63942. */
  63943. export class ReplaceColorBlock extends NodeMaterialBlock {
  63944. /**
  63945. * Creates a new ReplaceColorBlock
  63946. * @param name defines the block name
  63947. */
  63948. constructor(name: string);
  63949. /**
  63950. * Gets the current class name
  63951. * @returns the class name
  63952. */
  63953. getClassName(): string;
  63954. /**
  63955. * Gets the value input component
  63956. */
  63957. get value(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the reference input component
  63960. */
  63961. get reference(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the distance input component
  63964. */
  63965. get distance(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the replacement input component
  63968. */
  63969. get replacement(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the output component
  63972. */
  63973. get output(): NodeMaterialConnectionPoint;
  63974. protected _buildBlock(state: NodeMaterialBuildState): this;
  63975. }
  63976. }
  63977. declare module BABYLON {
  63978. /**
  63979. * Block used to posterize a value
  63980. * @see https://en.wikipedia.org/wiki/Posterization
  63981. */
  63982. export class PosterizeBlock extends NodeMaterialBlock {
  63983. /**
  63984. * Creates a new PosterizeBlock
  63985. * @param name defines the block name
  63986. */
  63987. constructor(name: string);
  63988. /**
  63989. * Gets the current class name
  63990. * @returns the class name
  63991. */
  63992. getClassName(): string;
  63993. /**
  63994. * Gets the value input component
  63995. */
  63996. get value(): NodeMaterialConnectionPoint;
  63997. /**
  63998. * Gets the steps input component
  63999. */
  64000. get steps(): NodeMaterialConnectionPoint;
  64001. /**
  64002. * Gets the output component
  64003. */
  64004. get output(): NodeMaterialConnectionPoint;
  64005. protected _buildBlock(state: NodeMaterialBuildState): this;
  64006. }
  64007. }
  64008. declare module BABYLON {
  64009. /**
  64010. * Operations supported by the Wave block
  64011. */
  64012. export enum WaveBlockKind {
  64013. /** SawTooth */
  64014. SawTooth = 0,
  64015. /** Square */
  64016. Square = 1,
  64017. /** Triangle */
  64018. Triangle = 2
  64019. }
  64020. /**
  64021. * Block used to apply wave operation to floats
  64022. */
  64023. export class WaveBlock extends NodeMaterialBlock {
  64024. /**
  64025. * Gets or sets the kibnd of wave to be applied by the block
  64026. */
  64027. kind: WaveBlockKind;
  64028. /**
  64029. * Creates a new WaveBlock
  64030. * @param name defines the block name
  64031. */
  64032. constructor(name: string);
  64033. /**
  64034. * Gets the current class name
  64035. * @returns the class name
  64036. */
  64037. getClassName(): string;
  64038. /**
  64039. * Gets the input component
  64040. */
  64041. get input(): NodeMaterialConnectionPoint;
  64042. /**
  64043. * Gets the output component
  64044. */
  64045. get output(): NodeMaterialConnectionPoint;
  64046. protected _buildBlock(state: NodeMaterialBuildState): this;
  64047. serialize(): any;
  64048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64049. }
  64050. }
  64051. declare module BABYLON {
  64052. /**
  64053. * Class used to store a color step for the GradientBlock
  64054. */
  64055. export class GradientBlockColorStep {
  64056. private _step;
  64057. /**
  64058. * Gets value indicating which step this color is associated with (between 0 and 1)
  64059. */
  64060. get step(): number;
  64061. /**
  64062. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64063. */
  64064. set step(val: number);
  64065. private _color;
  64066. /**
  64067. * Gets the color associated with this step
  64068. */
  64069. get color(): Color3;
  64070. /**
  64071. * Sets the color associated with this step
  64072. */
  64073. set color(val: Color3);
  64074. /**
  64075. * Creates a new GradientBlockColorStep
  64076. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64077. * @param color defines the color associated with this step
  64078. */
  64079. constructor(step: number, color: Color3);
  64080. }
  64081. /**
  64082. * Block used to return a color from a gradient based on an input value between 0 and 1
  64083. */
  64084. export class GradientBlock extends NodeMaterialBlock {
  64085. /**
  64086. * Gets or sets the list of color steps
  64087. */
  64088. colorSteps: GradientBlockColorStep[];
  64089. /** Gets an observable raised when the value is changed */
  64090. onValueChangedObservable: Observable<GradientBlock>;
  64091. /** calls observable when the value is changed*/
  64092. colorStepsUpdated(): void;
  64093. /**
  64094. * Creates a new GradientBlock
  64095. * @param name defines the block name
  64096. */
  64097. constructor(name: string);
  64098. /**
  64099. * Gets the current class name
  64100. * @returns the class name
  64101. */
  64102. getClassName(): string;
  64103. /**
  64104. * Gets the gradient input component
  64105. */
  64106. get gradient(): NodeMaterialConnectionPoint;
  64107. /**
  64108. * Gets the output component
  64109. */
  64110. get output(): NodeMaterialConnectionPoint;
  64111. private _writeColorConstant;
  64112. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64113. serialize(): any;
  64114. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64115. protected _dumpPropertiesCode(): string;
  64116. }
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * Block used to normalize lerp between 2 values
  64121. */
  64122. export class NLerpBlock extends NodeMaterialBlock {
  64123. /**
  64124. * Creates a new NLerpBlock
  64125. * @param name defines the block name
  64126. */
  64127. constructor(name: string);
  64128. /**
  64129. * Gets the current class name
  64130. * @returns the class name
  64131. */
  64132. getClassName(): string;
  64133. /**
  64134. * Gets the left operand input component
  64135. */
  64136. get left(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the right operand input component
  64139. */
  64140. get right(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the gradient operand input component
  64143. */
  64144. get gradient(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the output component
  64147. */
  64148. get output(): NodeMaterialConnectionPoint;
  64149. protected _buildBlock(state: NodeMaterialBuildState): this;
  64150. }
  64151. }
  64152. declare module BABYLON {
  64153. /**
  64154. * block used to Generate a Worley Noise 3D Noise Pattern
  64155. */
  64156. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64157. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64158. manhattanDistance: boolean;
  64159. /**
  64160. * Creates a new WorleyNoise3DBlock
  64161. * @param name defines the block name
  64162. */
  64163. constructor(name: string);
  64164. /**
  64165. * Gets the current class name
  64166. * @returns the class name
  64167. */
  64168. getClassName(): string;
  64169. /**
  64170. * Gets the seed input component
  64171. */
  64172. get seed(): NodeMaterialConnectionPoint;
  64173. /**
  64174. * Gets the jitter input component
  64175. */
  64176. get jitter(): NodeMaterialConnectionPoint;
  64177. /**
  64178. * Gets the output component
  64179. */
  64180. get output(): NodeMaterialConnectionPoint;
  64181. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64182. /**
  64183. * Exposes the properties to the UI?
  64184. */
  64185. protected _dumpPropertiesCode(): string;
  64186. /**
  64187. * Exposes the properties to the Seralize?
  64188. */
  64189. serialize(): any;
  64190. /**
  64191. * Exposes the properties to the deseralize?
  64192. */
  64193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64194. }
  64195. }
  64196. declare module BABYLON {
  64197. /**
  64198. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64199. */
  64200. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64201. /**
  64202. * Creates a new SimplexPerlin3DBlock
  64203. * @param name defines the block name
  64204. */
  64205. constructor(name: string);
  64206. /**
  64207. * Gets the current class name
  64208. * @returns the class name
  64209. */
  64210. getClassName(): string;
  64211. /**
  64212. * Gets the seed operand input component
  64213. */
  64214. get seed(): NodeMaterialConnectionPoint;
  64215. /**
  64216. * Gets the output component
  64217. */
  64218. get output(): NodeMaterialConnectionPoint;
  64219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64220. }
  64221. }
  64222. declare module BABYLON {
  64223. /**
  64224. * Block used to blend normals
  64225. */
  64226. export class NormalBlendBlock extends NodeMaterialBlock {
  64227. /**
  64228. * Creates a new NormalBlendBlock
  64229. * @param name defines the block name
  64230. */
  64231. constructor(name: string);
  64232. /**
  64233. * Gets the current class name
  64234. * @returns the class name
  64235. */
  64236. getClassName(): string;
  64237. /**
  64238. * Gets the first input component
  64239. */
  64240. get normalMap0(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the second input component
  64243. */
  64244. get normalMap1(): NodeMaterialConnectionPoint;
  64245. /**
  64246. * Gets the output component
  64247. */
  64248. get output(): NodeMaterialConnectionPoint;
  64249. protected _buildBlock(state: NodeMaterialBuildState): this;
  64250. }
  64251. }
  64252. declare module BABYLON {
  64253. /**
  64254. * Block used to rotate a 2d vector by a given angle
  64255. */
  64256. export class Rotate2dBlock extends NodeMaterialBlock {
  64257. /**
  64258. * Creates a new Rotate2dBlock
  64259. * @param name defines the block name
  64260. */
  64261. constructor(name: string);
  64262. /**
  64263. * Gets the current class name
  64264. * @returns the class name
  64265. */
  64266. getClassName(): string;
  64267. /**
  64268. * Gets the input vector
  64269. */
  64270. get input(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the input angle
  64273. */
  64274. get angle(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the output component
  64277. */
  64278. get output(): NodeMaterialConnectionPoint;
  64279. autoConfigure(material: NodeMaterial): void;
  64280. protected _buildBlock(state: NodeMaterialBuildState): this;
  64281. }
  64282. }
  64283. declare module BABYLON {
  64284. /**
  64285. * Block used to get the reflected vector from a direction and a normal
  64286. */
  64287. export class ReflectBlock extends NodeMaterialBlock {
  64288. /**
  64289. * Creates a new ReflectBlock
  64290. * @param name defines the block name
  64291. */
  64292. constructor(name: string);
  64293. /**
  64294. * Gets the current class name
  64295. * @returns the class name
  64296. */
  64297. getClassName(): string;
  64298. /**
  64299. * Gets the incident component
  64300. */
  64301. get incident(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the normal component
  64304. */
  64305. get normal(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the output component
  64308. */
  64309. get output(): NodeMaterialConnectionPoint;
  64310. protected _buildBlock(state: NodeMaterialBuildState): this;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * Block used to get the refracted vector from a direction and a normal
  64316. */
  64317. export class RefractBlock extends NodeMaterialBlock {
  64318. /**
  64319. * Creates a new RefractBlock
  64320. * @param name defines the block name
  64321. */
  64322. constructor(name: string);
  64323. /**
  64324. * Gets the current class name
  64325. * @returns the class name
  64326. */
  64327. getClassName(): string;
  64328. /**
  64329. * Gets the incident component
  64330. */
  64331. get incident(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the normal component
  64334. */
  64335. get normal(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the index of refraction component
  64338. */
  64339. get ior(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the output component
  64342. */
  64343. get output(): NodeMaterialConnectionPoint;
  64344. protected _buildBlock(state: NodeMaterialBuildState): this;
  64345. }
  64346. }
  64347. declare module BABYLON {
  64348. /**
  64349. * Block used to desaturate a color
  64350. */
  64351. export class DesaturateBlock extends NodeMaterialBlock {
  64352. /**
  64353. * Creates a new DesaturateBlock
  64354. * @param name defines the block name
  64355. */
  64356. constructor(name: string);
  64357. /**
  64358. * Gets the current class name
  64359. * @returns the class name
  64360. */
  64361. getClassName(): string;
  64362. /**
  64363. * Gets the color operand input component
  64364. */
  64365. get color(): NodeMaterialConnectionPoint;
  64366. /**
  64367. * Gets the level operand input component
  64368. */
  64369. get level(): NodeMaterialConnectionPoint;
  64370. /**
  64371. * Gets the output component
  64372. */
  64373. get output(): NodeMaterialConnectionPoint;
  64374. protected _buildBlock(state: NodeMaterialBuildState): this;
  64375. }
  64376. }
  64377. declare module BABYLON {
  64378. /**
  64379. * Block used to implement the ambient occlusion module of the PBR material
  64380. */
  64381. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64382. /**
  64383. * Create a new AmbientOcclusionBlock
  64384. * @param name defines the block name
  64385. */
  64386. constructor(name: string);
  64387. /**
  64388. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64389. */
  64390. useAmbientInGrayScale: boolean;
  64391. /**
  64392. * Initialize the block and prepare the context for build
  64393. * @param state defines the state that will be used for the build
  64394. */
  64395. initialize(state: NodeMaterialBuildState): void;
  64396. /**
  64397. * Gets the current class name
  64398. * @returns the class name
  64399. */
  64400. getClassName(): string;
  64401. /**
  64402. * Gets the texture input component
  64403. */
  64404. get texture(): NodeMaterialConnectionPoint;
  64405. /**
  64406. * Gets the texture intensity component
  64407. */
  64408. get intensity(): NodeMaterialConnectionPoint;
  64409. /**
  64410. * Gets the direct light intensity input component
  64411. */
  64412. get directLightIntensity(): NodeMaterialConnectionPoint;
  64413. /**
  64414. * Gets the ambient occlusion object output component
  64415. */
  64416. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64417. /**
  64418. * Gets the main code of the block (fragment side)
  64419. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64420. * @returns the shader code
  64421. */
  64422. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64423. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64424. protected _buildBlock(state: NodeMaterialBuildState): this;
  64425. protected _dumpPropertiesCode(): string;
  64426. serialize(): any;
  64427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64428. }
  64429. }
  64430. declare module BABYLON {
  64431. /**
  64432. * Block used to implement the reflection module of the PBR material
  64433. */
  64434. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64435. /** @hidden */
  64436. _defineLODReflectionAlpha: string;
  64437. /** @hidden */
  64438. _defineLinearSpecularReflection: string;
  64439. private _vEnvironmentIrradianceName;
  64440. /** @hidden */
  64441. _vReflectionMicrosurfaceInfosName: string;
  64442. /** @hidden */
  64443. _vReflectionInfosName: string;
  64444. /** @hidden */
  64445. _vReflectionFilteringInfoName: string;
  64446. private _scene;
  64447. /**
  64448. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64449. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64450. * It's less burden on the user side in the editor part.
  64451. */
  64452. /** @hidden */
  64453. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64454. /** @hidden */
  64455. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64456. /** @hidden */
  64457. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64458. /**
  64459. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64460. * diffuse part of the IBL.
  64461. */
  64462. useSphericalHarmonics: boolean;
  64463. /**
  64464. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64465. */
  64466. forceIrradianceInFragment: boolean;
  64467. /**
  64468. * Create a new ReflectionBlock
  64469. * @param name defines the block name
  64470. */
  64471. constructor(name: string);
  64472. /**
  64473. * Gets the current class name
  64474. * @returns the class name
  64475. */
  64476. getClassName(): string;
  64477. /**
  64478. * Gets the position input component
  64479. */
  64480. get position(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the world position input component
  64483. */
  64484. get worldPosition(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the world normal input component
  64487. */
  64488. get worldNormal(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the world input component
  64491. */
  64492. get world(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the camera (or eye) position component
  64495. */
  64496. get cameraPosition(): NodeMaterialConnectionPoint;
  64497. /**
  64498. * Gets the view input component
  64499. */
  64500. get view(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the color input component
  64503. */
  64504. get color(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the reflection object output component
  64507. */
  64508. get reflection(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64511. */
  64512. get hasTexture(): boolean;
  64513. /**
  64514. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64515. */
  64516. get reflectionColor(): string;
  64517. protected _getTexture(): Nullable<BaseTexture>;
  64518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64519. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64520. /**
  64521. * Gets the code to inject in the vertex shader
  64522. * @param state current state of the node material building
  64523. * @returns the shader code
  64524. */
  64525. handleVertexSide(state: NodeMaterialBuildState): string;
  64526. /**
  64527. * Gets the main code of the block (fragment side)
  64528. * @param state current state of the node material building
  64529. * @param normalVarName name of the existing variable corresponding to the normal
  64530. * @returns the shader code
  64531. */
  64532. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64533. protected _buildBlock(state: NodeMaterialBuildState): this;
  64534. protected _dumpPropertiesCode(): string;
  64535. serialize(): any;
  64536. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64537. }
  64538. }
  64539. declare module BABYLON {
  64540. /**
  64541. * Block used to implement the sheen module of the PBR material
  64542. */
  64543. export class SheenBlock extends NodeMaterialBlock {
  64544. /**
  64545. * Create a new SheenBlock
  64546. * @param name defines the block name
  64547. */
  64548. constructor(name: string);
  64549. /**
  64550. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64551. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64552. * making it easier to setup and tweak the effect
  64553. */
  64554. albedoScaling: boolean;
  64555. /**
  64556. * Defines if the sheen is linked to the sheen color.
  64557. */
  64558. linkSheenWithAlbedo: boolean;
  64559. /**
  64560. * Initialize the block and prepare the context for build
  64561. * @param state defines the state that will be used for the build
  64562. */
  64563. initialize(state: NodeMaterialBuildState): void;
  64564. /**
  64565. * Gets the current class name
  64566. * @returns the class name
  64567. */
  64568. getClassName(): string;
  64569. /**
  64570. * Gets the intensity input component
  64571. */
  64572. get intensity(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the color input component
  64575. */
  64576. get color(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the roughness input component
  64579. */
  64580. get roughness(): NodeMaterialConnectionPoint;
  64581. /**
  64582. * Gets the sheen object output component
  64583. */
  64584. get sheen(): NodeMaterialConnectionPoint;
  64585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64586. /**
  64587. * Gets the main code of the block (fragment side)
  64588. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64589. * @returns the shader code
  64590. */
  64591. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64592. protected _buildBlock(state: NodeMaterialBuildState): this;
  64593. protected _dumpPropertiesCode(): string;
  64594. serialize(): any;
  64595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * Block used to implement the reflectivity module of the PBR material
  64601. */
  64602. export class ReflectivityBlock extends NodeMaterialBlock {
  64603. private _metallicReflectanceColor;
  64604. private _metallicF0Factor;
  64605. /** @hidden */
  64606. _vMetallicReflectanceFactorsName: string;
  64607. /**
  64608. * The property below is set by the main PBR block prior to calling methods of this class.
  64609. */
  64610. /** @hidden */
  64611. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64612. /**
  64613. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64614. */
  64615. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64616. /**
  64617. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64618. */
  64619. useMetallnessFromMetallicTextureBlue: boolean;
  64620. /**
  64621. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64622. */
  64623. useRoughnessFromMetallicTextureAlpha: boolean;
  64624. /**
  64625. * Specifies if the metallic texture contains the roughness information in its green channel.
  64626. */
  64627. useRoughnessFromMetallicTextureGreen: boolean;
  64628. /**
  64629. * Create a new ReflectivityBlock
  64630. * @param name defines the block name
  64631. */
  64632. constructor(name: string);
  64633. /**
  64634. * Initialize the block and prepare the context for build
  64635. * @param state defines the state that will be used for the build
  64636. */
  64637. initialize(state: NodeMaterialBuildState): void;
  64638. /**
  64639. * Gets the current class name
  64640. * @returns the class name
  64641. */
  64642. getClassName(): string;
  64643. /**
  64644. * Gets the metallic input component
  64645. */
  64646. get metallic(): NodeMaterialConnectionPoint;
  64647. /**
  64648. * Gets the roughness input component
  64649. */
  64650. get roughness(): NodeMaterialConnectionPoint;
  64651. /**
  64652. * Gets the texture input component
  64653. */
  64654. get texture(): NodeMaterialConnectionPoint;
  64655. /**
  64656. * Gets the reflectivity object output component
  64657. */
  64658. get reflectivity(): NodeMaterialConnectionPoint;
  64659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64660. /**
  64661. * Gets the main code of the block (fragment side)
  64662. * @param state current state of the node material building
  64663. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64664. * @returns the shader code
  64665. */
  64666. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64668. protected _buildBlock(state: NodeMaterialBuildState): this;
  64669. protected _dumpPropertiesCode(): string;
  64670. serialize(): any;
  64671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64672. }
  64673. }
  64674. declare module BABYLON {
  64675. /**
  64676. * Block used to implement the anisotropy module of the PBR material
  64677. */
  64678. export class AnisotropyBlock extends NodeMaterialBlock {
  64679. /**
  64680. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64681. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64682. * It's less burden on the user side in the editor part.
  64683. */
  64684. /** @hidden */
  64685. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64686. /** @hidden */
  64687. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64688. /**
  64689. * Create a new AnisotropyBlock
  64690. * @param name defines the block name
  64691. */
  64692. constructor(name: string);
  64693. /**
  64694. * Initialize the block and prepare the context for build
  64695. * @param state defines the state that will be used for the build
  64696. */
  64697. initialize(state: NodeMaterialBuildState): void;
  64698. /**
  64699. * Gets the current class name
  64700. * @returns the class name
  64701. */
  64702. getClassName(): string;
  64703. /**
  64704. * Gets the intensity input component
  64705. */
  64706. get intensity(): NodeMaterialConnectionPoint;
  64707. /**
  64708. * Gets the direction input component
  64709. */
  64710. get direction(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the texture input component
  64713. */
  64714. get texture(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the uv input component
  64717. */
  64718. get uv(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the worldTangent input component
  64721. */
  64722. get worldTangent(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the anisotropy object output component
  64725. */
  64726. get anisotropy(): NodeMaterialConnectionPoint;
  64727. private _generateTBNSpace;
  64728. /**
  64729. * Gets the main code of the block (fragment side)
  64730. * @param state current state of the node material building
  64731. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64732. * @returns the shader code
  64733. */
  64734. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64736. protected _buildBlock(state: NodeMaterialBuildState): this;
  64737. }
  64738. }
  64739. declare module BABYLON {
  64740. /**
  64741. * Block used to implement the clear coat module of the PBR material
  64742. */
  64743. export class ClearCoatBlock extends NodeMaterialBlock {
  64744. private _scene;
  64745. /**
  64746. * Create a new ClearCoatBlock
  64747. * @param name defines the block name
  64748. */
  64749. constructor(name: string);
  64750. /**
  64751. * Initialize the block and prepare the context for build
  64752. * @param state defines the state that will be used for the build
  64753. */
  64754. initialize(state: NodeMaterialBuildState): void;
  64755. /**
  64756. * Gets the current class name
  64757. * @returns the class name
  64758. */
  64759. getClassName(): string;
  64760. /**
  64761. * Gets the intensity input component
  64762. */
  64763. get intensity(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the roughness input component
  64766. */
  64767. get roughness(): NodeMaterialConnectionPoint;
  64768. /**
  64769. * Gets the ior input component
  64770. */
  64771. get ior(): NodeMaterialConnectionPoint;
  64772. /**
  64773. * Gets the texture input component
  64774. */
  64775. get texture(): NodeMaterialConnectionPoint;
  64776. /**
  64777. * Gets the bump texture input component
  64778. */
  64779. get bumpTexture(): NodeMaterialConnectionPoint;
  64780. /**
  64781. * Gets the uv input component
  64782. */
  64783. get uv(): NodeMaterialConnectionPoint;
  64784. /**
  64785. * Gets the tint color input component
  64786. */
  64787. get tintColor(): NodeMaterialConnectionPoint;
  64788. /**
  64789. * Gets the tint "at distance" input component
  64790. */
  64791. get tintAtDistance(): NodeMaterialConnectionPoint;
  64792. /**
  64793. * Gets the tint thickness input component
  64794. */
  64795. get tintThickness(): NodeMaterialConnectionPoint;
  64796. /**
  64797. * Gets the world tangent input component
  64798. */
  64799. get worldTangent(): NodeMaterialConnectionPoint;
  64800. /**
  64801. * Gets the clear coat object output component
  64802. */
  64803. get clearcoat(): NodeMaterialConnectionPoint;
  64804. autoConfigure(material: NodeMaterial): void;
  64805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64806. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64807. private _generateTBNSpace;
  64808. /**
  64809. * Gets the main code of the block (fragment side)
  64810. * @param state current state of the node material building
  64811. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64812. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64813. * @param worldPosVarName name of the variable holding the world position
  64814. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64815. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64816. * @param worldNormalVarName name of the variable holding the world normal
  64817. * @returns the shader code
  64818. */
  64819. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64820. protected _buildBlock(state: NodeMaterialBuildState): this;
  64821. }
  64822. }
  64823. declare module BABYLON {
  64824. /**
  64825. * Block used to implement the sub surface module of the PBR material
  64826. */
  64827. export class SubSurfaceBlock extends NodeMaterialBlock {
  64828. /**
  64829. * Create a new SubSurfaceBlock
  64830. * @param name defines the block name
  64831. */
  64832. constructor(name: string);
  64833. /**
  64834. * Stores the intensity of the different subsurface effects in the thickness texture.
  64835. * * the green channel is the translucency intensity.
  64836. * * the blue channel is the scattering intensity.
  64837. * * the alpha channel is the refraction intensity.
  64838. */
  64839. useMaskFromThicknessTexture: boolean;
  64840. /**
  64841. * Initialize the block and prepare the context for build
  64842. * @param state defines the state that will be used for the build
  64843. */
  64844. initialize(state: NodeMaterialBuildState): void;
  64845. /**
  64846. * Gets the current class name
  64847. * @returns the class name
  64848. */
  64849. getClassName(): string;
  64850. /**
  64851. * Gets the min thickness input component
  64852. */
  64853. get minThickness(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the max thickness input component
  64856. */
  64857. get maxThickness(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the thickness texture component
  64860. */
  64861. get thicknessTexture(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the tint color input component
  64864. */
  64865. get tintColor(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the translucency intensity input component
  64868. */
  64869. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64870. /**
  64871. * Gets the translucency diffusion distance input component
  64872. */
  64873. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64874. /**
  64875. * Gets the refraction object parameters
  64876. */
  64877. get refraction(): NodeMaterialConnectionPoint;
  64878. /**
  64879. * Gets the sub surface object output component
  64880. */
  64881. get subsurface(): NodeMaterialConnectionPoint;
  64882. autoConfigure(material: NodeMaterial): void;
  64883. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64884. /**
  64885. * Gets the main code of the block (fragment side)
  64886. * @param state current state of the node material building
  64887. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64888. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64889. * @param worldPosVarName name of the variable holding the world position
  64890. * @returns the shader code
  64891. */
  64892. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64893. protected _buildBlock(state: NodeMaterialBuildState): this;
  64894. }
  64895. }
  64896. declare module BABYLON {
  64897. /**
  64898. * Block used to implement the PBR metallic/roughness model
  64899. */
  64900. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64901. /**
  64902. * Gets or sets the light associated with this block
  64903. */
  64904. light: Nullable<Light>;
  64905. private _lightId;
  64906. private _scene;
  64907. private _environmentBRDFTexture;
  64908. private _environmentBrdfSamplerName;
  64909. private _vNormalWName;
  64910. private _invertNormalName;
  64911. /**
  64912. * Create a new ReflectionBlock
  64913. * @param name defines the block name
  64914. */
  64915. constructor(name: string);
  64916. /**
  64917. * Intensity of the direct lights e.g. the four lights available in your scene.
  64918. * This impacts both the direct diffuse and specular highlights.
  64919. */
  64920. directIntensity: number;
  64921. /**
  64922. * Intensity of the environment e.g. how much the environment will light the object
  64923. * either through harmonics for rough material or through the refelction for shiny ones.
  64924. */
  64925. environmentIntensity: number;
  64926. /**
  64927. * This is a special control allowing the reduction of the specular highlights coming from the
  64928. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64929. */
  64930. specularIntensity: number;
  64931. /**
  64932. * Defines the falloff type used in this material.
  64933. * It by default is Physical.
  64934. */
  64935. lightFalloff: number;
  64936. /**
  64937. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64938. */
  64939. useAlphaFromAlbedoTexture: boolean;
  64940. /**
  64941. * Specifies that alpha test should be used
  64942. */
  64943. useAlphaTest: boolean;
  64944. /**
  64945. * Defines the alpha limits in alpha test mode.
  64946. */
  64947. alphaTestCutoff: number;
  64948. /**
  64949. * Specifies that alpha blending should be used
  64950. */
  64951. useAlphaBlending: boolean;
  64952. /**
  64953. * Defines if the alpha value should be determined via the rgb values.
  64954. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64955. */
  64956. opacityRGB: boolean;
  64957. /**
  64958. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64959. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64960. */
  64961. useRadianceOverAlpha: boolean;
  64962. /**
  64963. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64964. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64965. */
  64966. useSpecularOverAlpha: boolean;
  64967. /**
  64968. * Enables specular anti aliasing in the PBR shader.
  64969. * It will both interacts on the Geometry for analytical and IBL lighting.
  64970. * It also prefilter the roughness map based on the bump values.
  64971. */
  64972. enableSpecularAntiAliasing: boolean;
  64973. /**
  64974. * Enables realtime filtering on the texture.
  64975. */
  64976. realTimeFiltering: boolean;
  64977. /**
  64978. * Quality switch for realtime filtering
  64979. */
  64980. realTimeFilteringQuality: number;
  64981. /**
  64982. * Defines if the material uses energy conservation.
  64983. */
  64984. useEnergyConservation: boolean;
  64985. /**
  64986. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64987. * too much the area relying on ambient texture to define their ambient occlusion.
  64988. */
  64989. useRadianceOcclusion: boolean;
  64990. /**
  64991. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64992. * makes the reflect vector face the model (under horizon).
  64993. */
  64994. useHorizonOcclusion: boolean;
  64995. /**
  64996. * If set to true, no lighting calculations will be applied.
  64997. */
  64998. unlit: boolean;
  64999. /**
  65000. * Force normal to face away from face.
  65001. */
  65002. forceNormalForward: boolean;
  65003. /**
  65004. * Defines the material debug mode.
  65005. * It helps seeing only some components of the material while troubleshooting.
  65006. */
  65007. debugMode: number;
  65008. /**
  65009. * Specify from where on screen the debug mode should start.
  65010. * The value goes from -1 (full screen) to 1 (not visible)
  65011. * It helps with side by side comparison against the final render
  65012. * This defaults to 0
  65013. */
  65014. debugLimit: number;
  65015. /**
  65016. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65017. * You can use the factor to better multiply the final value.
  65018. */
  65019. debugFactor: number;
  65020. /**
  65021. * Initialize the block and prepare the context for build
  65022. * @param state defines the state that will be used for the build
  65023. */
  65024. initialize(state: NodeMaterialBuildState): void;
  65025. /**
  65026. * Gets the current class name
  65027. * @returns the class name
  65028. */
  65029. getClassName(): string;
  65030. /**
  65031. * Gets the world position input component
  65032. */
  65033. get worldPosition(): NodeMaterialConnectionPoint;
  65034. /**
  65035. * Gets the world normal input component
  65036. */
  65037. get worldNormal(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the perturbed normal input component
  65040. */
  65041. get perturbedNormal(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the camera position input component
  65044. */
  65045. get cameraPosition(): NodeMaterialConnectionPoint;
  65046. /**
  65047. * Gets the base color input component
  65048. */
  65049. get baseColor(): NodeMaterialConnectionPoint;
  65050. /**
  65051. * Gets the opacity texture input component
  65052. */
  65053. get opacityTexture(): NodeMaterialConnectionPoint;
  65054. /**
  65055. * Gets the ambient color input component
  65056. */
  65057. get ambientColor(): NodeMaterialConnectionPoint;
  65058. /**
  65059. * Gets the reflectivity object parameters
  65060. */
  65061. get reflectivity(): NodeMaterialConnectionPoint;
  65062. /**
  65063. * Gets the ambient occlusion object parameters
  65064. */
  65065. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65066. /**
  65067. * Gets the reflection object parameters
  65068. */
  65069. get reflection(): NodeMaterialConnectionPoint;
  65070. /**
  65071. * Gets the sheen object parameters
  65072. */
  65073. get sheen(): NodeMaterialConnectionPoint;
  65074. /**
  65075. * Gets the clear coat object parameters
  65076. */
  65077. get clearcoat(): NodeMaterialConnectionPoint;
  65078. /**
  65079. * Gets the sub surface object parameters
  65080. */
  65081. get subsurface(): NodeMaterialConnectionPoint;
  65082. /**
  65083. * Gets the anisotropy object parameters
  65084. */
  65085. get anisotropy(): NodeMaterialConnectionPoint;
  65086. /**
  65087. * Gets the ambient output component
  65088. */
  65089. get ambient(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the diffuse output component
  65092. */
  65093. get diffuse(): NodeMaterialConnectionPoint;
  65094. /**
  65095. * Gets the specular output component
  65096. */
  65097. get specular(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the sheen output component
  65100. */
  65101. get sheenDir(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the clear coat output component
  65104. */
  65105. get clearcoatDir(): NodeMaterialConnectionPoint;
  65106. /**
  65107. * Gets the indirect diffuse output component
  65108. */
  65109. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65110. /**
  65111. * Gets the indirect specular output component
  65112. */
  65113. get specularIndirect(): NodeMaterialConnectionPoint;
  65114. /**
  65115. * Gets the indirect sheen output component
  65116. */
  65117. get sheenIndirect(): NodeMaterialConnectionPoint;
  65118. /**
  65119. * Gets the indirect clear coat output component
  65120. */
  65121. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65122. /**
  65123. * Gets the refraction output component
  65124. */
  65125. get refraction(): NodeMaterialConnectionPoint;
  65126. /**
  65127. * Gets the global lighting output component
  65128. */
  65129. get lighting(): NodeMaterialConnectionPoint;
  65130. /**
  65131. * Gets the shadow output component
  65132. */
  65133. get shadow(): NodeMaterialConnectionPoint;
  65134. /**
  65135. * Gets the alpha output component
  65136. */
  65137. get alpha(): NodeMaterialConnectionPoint;
  65138. autoConfigure(material: NodeMaterial): void;
  65139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65140. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65142. private _injectVertexCode;
  65143. /**
  65144. * Gets the code corresponding to the albedo/opacity module
  65145. * @returns the shader code
  65146. */
  65147. getAlbedoOpacityCode(): string;
  65148. protected _buildBlock(state: NodeMaterialBuildState): this;
  65149. protected _dumpPropertiesCode(): string;
  65150. serialize(): any;
  65151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65152. }
  65153. }
  65154. declare module BABYLON {
  65155. /**
  65156. * Block used to compute value of one parameter modulo another
  65157. */
  65158. export class ModBlock extends NodeMaterialBlock {
  65159. /**
  65160. * Creates a new ModBlock
  65161. * @param name defines the block name
  65162. */
  65163. constructor(name: string);
  65164. /**
  65165. * Gets the current class name
  65166. * @returns the class name
  65167. */
  65168. getClassName(): string;
  65169. /**
  65170. * Gets the left operand input component
  65171. */
  65172. get left(): NodeMaterialConnectionPoint;
  65173. /**
  65174. * Gets the right operand input component
  65175. */
  65176. get right(): NodeMaterialConnectionPoint;
  65177. /**
  65178. * Gets the output component
  65179. */
  65180. get output(): NodeMaterialConnectionPoint;
  65181. protected _buildBlock(state: NodeMaterialBuildState): this;
  65182. }
  65183. }
  65184. declare module BABYLON {
  65185. /**
  65186. * Configuration for Draco compression
  65187. */
  65188. export interface IDracoCompressionConfiguration {
  65189. /**
  65190. * Configuration for the decoder.
  65191. */
  65192. decoder: {
  65193. /**
  65194. * The url to the WebAssembly module.
  65195. */
  65196. wasmUrl?: string;
  65197. /**
  65198. * The url to the WebAssembly binary.
  65199. */
  65200. wasmBinaryUrl?: string;
  65201. /**
  65202. * The url to the fallback JavaScript module.
  65203. */
  65204. fallbackUrl?: string;
  65205. };
  65206. }
  65207. /**
  65208. * Draco compression (https://google.github.io/draco/)
  65209. *
  65210. * This class wraps the Draco module.
  65211. *
  65212. * **Encoder**
  65213. *
  65214. * The encoder is not currently implemented.
  65215. *
  65216. * **Decoder**
  65217. *
  65218. * 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.
  65219. *
  65220. * To update the configuration, use the following code:
  65221. * ```javascript
  65222. * DracoCompression.Configuration = {
  65223. * decoder: {
  65224. * wasmUrl: "<url to the WebAssembly library>",
  65225. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65226. * fallbackUrl: "<url to the fallback JavaScript library>",
  65227. * }
  65228. * };
  65229. * ```
  65230. *
  65231. * 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.
  65232. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65233. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65234. *
  65235. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65236. * ```javascript
  65237. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65238. * ```
  65239. *
  65240. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65241. */
  65242. export class DracoCompression implements IDisposable {
  65243. private _workerPoolPromise?;
  65244. private _decoderModulePromise?;
  65245. /**
  65246. * The configuration. Defaults to the following urls:
  65247. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65248. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65249. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65250. */
  65251. static Configuration: IDracoCompressionConfiguration;
  65252. /**
  65253. * Returns true if the decoder configuration is available.
  65254. */
  65255. static get DecoderAvailable(): boolean;
  65256. /**
  65257. * Default number of workers to create when creating the draco compression object.
  65258. */
  65259. static DefaultNumWorkers: number;
  65260. private static GetDefaultNumWorkers;
  65261. private static _Default;
  65262. /**
  65263. * Default instance for the draco compression object.
  65264. */
  65265. static get Default(): DracoCompression;
  65266. /**
  65267. * Constructor
  65268. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65269. */
  65270. constructor(numWorkers?: number);
  65271. /**
  65272. * Stop all async operations and release resources.
  65273. */
  65274. dispose(): void;
  65275. /**
  65276. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65277. * @returns a promise that resolves when ready
  65278. */
  65279. whenReadyAsync(): Promise<void>;
  65280. /**
  65281. * Decode Draco compressed mesh data to vertex data.
  65282. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65283. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65284. * @returns A promise that resolves with the decoded vertex data
  65285. */
  65286. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65287. [kind: string]: number;
  65288. }): Promise<VertexData>;
  65289. }
  65290. }
  65291. declare module BABYLON {
  65292. /**
  65293. * Class for building Constructive Solid Geometry
  65294. */
  65295. export class CSG {
  65296. private polygons;
  65297. /**
  65298. * The world matrix
  65299. */
  65300. matrix: Matrix;
  65301. /**
  65302. * Stores the position
  65303. */
  65304. position: Vector3;
  65305. /**
  65306. * Stores the rotation
  65307. */
  65308. rotation: Vector3;
  65309. /**
  65310. * Stores the rotation quaternion
  65311. */
  65312. rotationQuaternion: Nullable<Quaternion>;
  65313. /**
  65314. * Stores the scaling vector
  65315. */
  65316. scaling: Vector3;
  65317. /**
  65318. * Convert the Mesh to CSG
  65319. * @param mesh The Mesh to convert to CSG
  65320. * @returns A new CSG from the Mesh
  65321. */
  65322. static FromMesh(mesh: Mesh): CSG;
  65323. /**
  65324. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65325. * @param polygons Polygons used to construct a CSG solid
  65326. */
  65327. private static FromPolygons;
  65328. /**
  65329. * Clones, or makes a deep copy, of the CSG
  65330. * @returns A new CSG
  65331. */
  65332. clone(): CSG;
  65333. /**
  65334. * Unions this CSG with another CSG
  65335. * @param csg The CSG to union against this CSG
  65336. * @returns The unioned CSG
  65337. */
  65338. union(csg: CSG): CSG;
  65339. /**
  65340. * Unions this CSG with another CSG in place
  65341. * @param csg The CSG to union against this CSG
  65342. */
  65343. unionInPlace(csg: CSG): void;
  65344. /**
  65345. * Subtracts this CSG with another CSG
  65346. * @param csg The CSG to subtract against this CSG
  65347. * @returns A new CSG
  65348. */
  65349. subtract(csg: CSG): CSG;
  65350. /**
  65351. * Subtracts this CSG with another CSG in place
  65352. * @param csg The CSG to subtact against this CSG
  65353. */
  65354. subtractInPlace(csg: CSG): void;
  65355. /**
  65356. * Intersect this CSG with another CSG
  65357. * @param csg The CSG to intersect against this CSG
  65358. * @returns A new CSG
  65359. */
  65360. intersect(csg: CSG): CSG;
  65361. /**
  65362. * Intersects this CSG with another CSG in place
  65363. * @param csg The CSG to intersect against this CSG
  65364. */
  65365. intersectInPlace(csg: CSG): void;
  65366. /**
  65367. * Return a new CSG solid with solid and empty space switched. This solid is
  65368. * not modified.
  65369. * @returns A new CSG solid with solid and empty space switched
  65370. */
  65371. inverse(): CSG;
  65372. /**
  65373. * Inverses the CSG in place
  65374. */
  65375. inverseInPlace(): void;
  65376. /**
  65377. * This is used to keep meshes transformations so they can be restored
  65378. * when we build back a Babylon Mesh
  65379. * NB : All CSG operations are performed in world coordinates
  65380. * @param csg The CSG to copy the transform attributes from
  65381. * @returns This CSG
  65382. */
  65383. copyTransformAttributes(csg: CSG): CSG;
  65384. /**
  65385. * Build Raw mesh from CSG
  65386. * Coordinates here are in world space
  65387. * @param name The name of the mesh geometry
  65388. * @param scene The Scene
  65389. * @param keepSubMeshes Specifies if the submeshes should be kept
  65390. * @returns A new Mesh
  65391. */
  65392. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65393. /**
  65394. * Build Mesh from CSG taking material and transforms into account
  65395. * @param name The name of the Mesh
  65396. * @param material The material of the Mesh
  65397. * @param scene The Scene
  65398. * @param keepSubMeshes Specifies if submeshes should be kept
  65399. * @returns The new Mesh
  65400. */
  65401. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65402. }
  65403. }
  65404. declare module BABYLON {
  65405. /**
  65406. * Class used to create a trail following a mesh
  65407. */
  65408. export class TrailMesh extends Mesh {
  65409. private _generator;
  65410. private _autoStart;
  65411. private _running;
  65412. private _diameter;
  65413. private _length;
  65414. private _sectionPolygonPointsCount;
  65415. private _sectionVectors;
  65416. private _sectionNormalVectors;
  65417. private _beforeRenderObserver;
  65418. /**
  65419. * @constructor
  65420. * @param name The value used by scene.getMeshByName() to do a lookup.
  65421. * @param generator The mesh or transform node to generate a trail.
  65422. * @param scene The scene to add this mesh to.
  65423. * @param diameter Diameter of trailing mesh. Default is 1.
  65424. * @param length Length of trailing mesh. Default is 60.
  65425. * @param autoStart Automatically start trailing mesh. Default true.
  65426. */
  65427. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65428. /**
  65429. * "TrailMesh"
  65430. * @returns "TrailMesh"
  65431. */
  65432. getClassName(): string;
  65433. private _createMesh;
  65434. /**
  65435. * Start trailing mesh.
  65436. */
  65437. start(): void;
  65438. /**
  65439. * Stop trailing mesh.
  65440. */
  65441. stop(): void;
  65442. /**
  65443. * Update trailing mesh geometry.
  65444. */
  65445. update(): void;
  65446. /**
  65447. * Returns a new TrailMesh object.
  65448. * @param name is a string, the name given to the new mesh
  65449. * @param newGenerator use new generator object for cloned trail mesh
  65450. * @returns a new mesh
  65451. */
  65452. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65453. /**
  65454. * Serializes this trail mesh
  65455. * @param serializationObject object to write serialization to
  65456. */
  65457. serialize(serializationObject: any): void;
  65458. /**
  65459. * Parses a serialized trail mesh
  65460. * @param parsedMesh the serialized mesh
  65461. * @param scene the scene to create the trail mesh in
  65462. * @returns the created trail mesh
  65463. */
  65464. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65465. }
  65466. }
  65467. declare module BABYLON {
  65468. /**
  65469. * Class containing static functions to help procedurally build meshes
  65470. */
  65471. export class TiledBoxBuilder {
  65472. /**
  65473. * Creates a box mesh
  65474. * 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)
  65475. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65477. * * 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
  65478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65479. * @param name defines the name of the mesh
  65480. * @param options defines the options used to create the mesh
  65481. * @param scene defines the hosting scene
  65482. * @returns the box mesh
  65483. */
  65484. static CreateTiledBox(name: string, options: {
  65485. pattern?: number;
  65486. width?: number;
  65487. height?: number;
  65488. depth?: number;
  65489. tileSize?: number;
  65490. tileWidth?: number;
  65491. tileHeight?: number;
  65492. alignHorizontal?: number;
  65493. alignVertical?: number;
  65494. faceUV?: Vector4[];
  65495. faceColors?: Color4[];
  65496. sideOrientation?: number;
  65497. updatable?: boolean;
  65498. }, scene?: Nullable<Scene>): Mesh;
  65499. }
  65500. }
  65501. declare module BABYLON {
  65502. /**
  65503. * Class containing static functions to help procedurally build meshes
  65504. */
  65505. export class TorusKnotBuilder {
  65506. /**
  65507. * Creates a torus knot mesh
  65508. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65509. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65510. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65511. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65513. * * 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
  65514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65515. * @param name defines the name of the mesh
  65516. * @param options defines the options used to create the mesh
  65517. * @param scene defines the hosting scene
  65518. * @returns the torus knot mesh
  65519. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65520. */
  65521. static CreateTorusKnot(name: string, options: {
  65522. radius?: number;
  65523. tube?: number;
  65524. radialSegments?: number;
  65525. tubularSegments?: number;
  65526. p?: number;
  65527. q?: number;
  65528. updatable?: boolean;
  65529. sideOrientation?: number;
  65530. frontUVs?: Vector4;
  65531. backUVs?: Vector4;
  65532. }, scene: any): Mesh;
  65533. }
  65534. }
  65535. declare module BABYLON {
  65536. /**
  65537. * Polygon
  65538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65539. */
  65540. export class Polygon {
  65541. /**
  65542. * Creates a rectangle
  65543. * @param xmin bottom X coord
  65544. * @param ymin bottom Y coord
  65545. * @param xmax top X coord
  65546. * @param ymax top Y coord
  65547. * @returns points that make the resulting rectation
  65548. */
  65549. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65550. /**
  65551. * Creates a circle
  65552. * @param radius radius of circle
  65553. * @param cx scale in x
  65554. * @param cy scale in y
  65555. * @param numberOfSides number of sides that make up the circle
  65556. * @returns points that make the resulting circle
  65557. */
  65558. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65559. /**
  65560. * Creates a polygon from input string
  65561. * @param input Input polygon data
  65562. * @returns the parsed points
  65563. */
  65564. static Parse(input: string): Vector2[];
  65565. /**
  65566. * Starts building a polygon from x and y coordinates
  65567. * @param x x coordinate
  65568. * @param y y coordinate
  65569. * @returns the started path2
  65570. */
  65571. static StartingAt(x: number, y: number): Path2;
  65572. }
  65573. /**
  65574. * Builds a polygon
  65575. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65576. */
  65577. export class PolygonMeshBuilder {
  65578. private _points;
  65579. private _outlinepoints;
  65580. private _holes;
  65581. private _name;
  65582. private _scene;
  65583. private _epoints;
  65584. private _eholes;
  65585. private _addToepoint;
  65586. /**
  65587. * Babylon reference to the earcut plugin.
  65588. */
  65589. bjsEarcut: any;
  65590. /**
  65591. * Creates a PolygonMeshBuilder
  65592. * @param name name of the builder
  65593. * @param contours Path of the polygon
  65594. * @param scene scene to add to when creating the mesh
  65595. * @param earcutInjection can be used to inject your own earcut reference
  65596. */
  65597. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65598. /**
  65599. * Adds a whole within the polygon
  65600. * @param hole Array of points defining the hole
  65601. * @returns this
  65602. */
  65603. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65604. /**
  65605. * Creates the polygon
  65606. * @param updatable If the mesh should be updatable
  65607. * @param depth The depth of the mesh created
  65608. * @returns the created mesh
  65609. */
  65610. build(updatable?: boolean, depth?: number): Mesh;
  65611. /**
  65612. * Creates the polygon
  65613. * @param depth The depth of the mesh created
  65614. * @returns the created VertexData
  65615. */
  65616. buildVertexData(depth?: number): VertexData;
  65617. /**
  65618. * Adds a side to the polygon
  65619. * @param positions points that make the polygon
  65620. * @param normals normals of the polygon
  65621. * @param uvs uvs of the polygon
  65622. * @param indices indices of the polygon
  65623. * @param bounds bounds of the polygon
  65624. * @param points points of the polygon
  65625. * @param depth depth of the polygon
  65626. * @param flip flip of the polygon
  65627. */
  65628. private addSide;
  65629. }
  65630. }
  65631. declare module BABYLON {
  65632. /**
  65633. * Class containing static functions to help procedurally build meshes
  65634. */
  65635. export class PolygonBuilder {
  65636. /**
  65637. * Creates a polygon mesh
  65638. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65639. * * 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
  65640. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65642. * * 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)
  65643. * * Remember you can only change the shape positions, not their number when updating a polygon
  65644. * @param name defines the name of the mesh
  65645. * @param options defines the options used to create the mesh
  65646. * @param scene defines the hosting scene
  65647. * @param earcutInjection can be used to inject your own earcut reference
  65648. * @returns the polygon mesh
  65649. */
  65650. static CreatePolygon(name: string, options: {
  65651. shape: Vector3[];
  65652. holes?: Vector3[][];
  65653. depth?: number;
  65654. faceUV?: Vector4[];
  65655. faceColors?: Color4[];
  65656. updatable?: boolean;
  65657. sideOrientation?: number;
  65658. frontUVs?: Vector4;
  65659. backUVs?: Vector4;
  65660. wrap?: boolean;
  65661. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65662. /**
  65663. * Creates an extruded polygon mesh, with depth in the Y direction.
  65664. * * 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)
  65665. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65666. * @param name defines the name of the mesh
  65667. * @param options defines the options used to create the mesh
  65668. * @param scene defines the hosting scene
  65669. * @param earcutInjection can be used to inject your own earcut reference
  65670. * @returns the polygon mesh
  65671. */
  65672. static ExtrudePolygon(name: string, options: {
  65673. shape: Vector3[];
  65674. holes?: Vector3[][];
  65675. depth?: number;
  65676. faceUV?: Vector4[];
  65677. faceColors?: Color4[];
  65678. updatable?: boolean;
  65679. sideOrientation?: number;
  65680. frontUVs?: Vector4;
  65681. backUVs?: Vector4;
  65682. wrap?: boolean;
  65683. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65684. }
  65685. }
  65686. declare module BABYLON {
  65687. /**
  65688. * Class containing static functions to help procedurally build meshes
  65689. */
  65690. export class LatheBuilder {
  65691. /**
  65692. * Creates lathe mesh.
  65693. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65694. * * 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
  65695. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65696. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65697. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65698. * * 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
  65699. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65700. * * 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
  65701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65702. * * 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
  65703. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65705. * @param name defines the name of the mesh
  65706. * @param options defines the options used to create the mesh
  65707. * @param scene defines the hosting scene
  65708. * @returns the lathe mesh
  65709. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65710. */
  65711. static CreateLathe(name: string, options: {
  65712. shape: Vector3[];
  65713. radius?: number;
  65714. tessellation?: number;
  65715. clip?: number;
  65716. arc?: number;
  65717. closed?: boolean;
  65718. updatable?: boolean;
  65719. sideOrientation?: number;
  65720. frontUVs?: Vector4;
  65721. backUVs?: Vector4;
  65722. cap?: number;
  65723. invertUV?: boolean;
  65724. }, scene?: Nullable<Scene>): Mesh;
  65725. }
  65726. }
  65727. declare module BABYLON {
  65728. /**
  65729. * Class containing static functions to help procedurally build meshes
  65730. */
  65731. export class TiledPlaneBuilder {
  65732. /**
  65733. * Creates a tiled plane mesh
  65734. * * The parameter `pattern` will, depending on value, do nothing or
  65735. * * * flip (reflect about central vertical) alternate tiles across and up
  65736. * * * flip every tile on alternate rows
  65737. * * * rotate (180 degs) alternate tiles across and up
  65738. * * * rotate every tile on alternate rows
  65739. * * * flip and rotate alternate tiles across and up
  65740. * * * flip and rotate every tile on alternate rows
  65741. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65742. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65743. * * 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
  65744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65745. * * 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)
  65746. * * 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)
  65747. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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. * @returns the box mesh
  65752. */
  65753. static CreateTiledPlane(name: string, options: {
  65754. pattern?: number;
  65755. tileSize?: number;
  65756. tileWidth?: number;
  65757. tileHeight?: number;
  65758. size?: number;
  65759. width?: number;
  65760. height?: number;
  65761. alignHorizontal?: number;
  65762. alignVertical?: number;
  65763. sideOrientation?: number;
  65764. frontUVs?: Vector4;
  65765. backUVs?: Vector4;
  65766. updatable?: boolean;
  65767. }, scene?: Nullable<Scene>): Mesh;
  65768. }
  65769. }
  65770. declare module BABYLON {
  65771. /**
  65772. * Class containing static functions to help procedurally build meshes
  65773. */
  65774. export class TubeBuilder {
  65775. /**
  65776. * Creates a tube mesh.
  65777. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65778. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65779. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65780. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65781. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65782. * * 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)
  65783. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65784. * * 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
  65785. * * 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
  65786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65787. * * 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
  65788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65790. * @param name defines the name of the mesh
  65791. * @param options defines the options used to create the mesh
  65792. * @param scene defines the hosting scene
  65793. * @returns the tube mesh
  65794. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65795. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65796. */
  65797. static CreateTube(name: string, options: {
  65798. path: Vector3[];
  65799. radius?: number;
  65800. tessellation?: number;
  65801. radiusFunction?: {
  65802. (i: number, distance: number): number;
  65803. };
  65804. cap?: number;
  65805. arc?: number;
  65806. updatable?: boolean;
  65807. sideOrientation?: number;
  65808. frontUVs?: Vector4;
  65809. backUVs?: Vector4;
  65810. instance?: Mesh;
  65811. invertUV?: boolean;
  65812. }, scene?: Nullable<Scene>): Mesh;
  65813. }
  65814. }
  65815. declare module BABYLON {
  65816. /**
  65817. * Class containing static functions to help procedurally build meshes
  65818. */
  65819. export class IcoSphereBuilder {
  65820. /**
  65821. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65822. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65823. * * 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`)
  65824. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65825. * * 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
  65826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65827. * * 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
  65828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65829. * @param name defines the name of the mesh
  65830. * @param options defines the options used to create the mesh
  65831. * @param scene defines the hosting scene
  65832. * @returns the icosahedron mesh
  65833. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65834. */
  65835. static CreateIcoSphere(name: string, options: {
  65836. radius?: number;
  65837. radiusX?: number;
  65838. radiusY?: number;
  65839. radiusZ?: number;
  65840. flat?: boolean;
  65841. subdivisions?: number;
  65842. sideOrientation?: number;
  65843. frontUVs?: Vector4;
  65844. backUVs?: Vector4;
  65845. updatable?: boolean;
  65846. }, scene?: Nullable<Scene>): Mesh;
  65847. }
  65848. }
  65849. declare module BABYLON {
  65850. /**
  65851. * Class containing static functions to help procedurally build meshes
  65852. */
  65853. export class DecalBuilder {
  65854. /**
  65855. * Creates a decal mesh.
  65856. * 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
  65857. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65858. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65859. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65860. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65861. * @param name defines the name of the mesh
  65862. * @param sourceMesh defines the mesh where the decal must be applied
  65863. * @param options defines the options used to create the mesh
  65864. * @param scene defines the hosting scene
  65865. * @returns the decal mesh
  65866. * @see https://doc.babylonjs.com/how_to/decals
  65867. */
  65868. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65869. position?: Vector3;
  65870. normal?: Vector3;
  65871. size?: Vector3;
  65872. angle?: number;
  65873. }): Mesh;
  65874. }
  65875. }
  65876. declare module BABYLON {
  65877. /**
  65878. * Class containing static functions to help procedurally build meshes
  65879. */
  65880. export class MeshBuilder {
  65881. /**
  65882. * Creates a box mesh
  65883. * * The parameter `size` sets the size (float) of each box side (default 1)
  65884. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65885. * * 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)
  65886. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65888. * * 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
  65889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65890. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65891. * @param name defines the name of the mesh
  65892. * @param options defines the options used to create the mesh
  65893. * @param scene defines the hosting scene
  65894. * @returns the box mesh
  65895. */
  65896. static CreateBox(name: string, options: {
  65897. size?: number;
  65898. width?: number;
  65899. height?: number;
  65900. depth?: number;
  65901. faceUV?: Vector4[];
  65902. faceColors?: Color4[];
  65903. sideOrientation?: number;
  65904. frontUVs?: Vector4;
  65905. backUVs?: Vector4;
  65906. wrap?: boolean;
  65907. topBaseAt?: number;
  65908. bottomBaseAt?: number;
  65909. updatable?: boolean;
  65910. }, scene?: Nullable<Scene>): Mesh;
  65911. /**
  65912. * Creates a tiled box mesh
  65913. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65915. * @param name defines the name of the mesh
  65916. * @param options defines the options used to create the mesh
  65917. * @param scene defines the hosting scene
  65918. * @returns the tiled box mesh
  65919. */
  65920. static CreateTiledBox(name: string, options: {
  65921. pattern?: number;
  65922. size?: number;
  65923. width?: number;
  65924. height?: number;
  65925. depth: number;
  65926. tileSize?: number;
  65927. tileWidth?: number;
  65928. tileHeight?: number;
  65929. faceUV?: Vector4[];
  65930. faceColors?: Color4[];
  65931. alignHorizontal?: number;
  65932. alignVertical?: number;
  65933. sideOrientation?: number;
  65934. updatable?: boolean;
  65935. }, scene?: Nullable<Scene>): Mesh;
  65936. /**
  65937. * Creates a sphere mesh
  65938. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65939. * * 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`)
  65940. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65941. * * 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
  65942. * * 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)
  65943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65944. * * 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
  65945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65946. * @param name defines the name of the mesh
  65947. * @param options defines the options used to create the mesh
  65948. * @param scene defines the hosting scene
  65949. * @returns the sphere mesh
  65950. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65951. */
  65952. static CreateSphere(name: string, options: {
  65953. segments?: number;
  65954. diameter?: number;
  65955. diameterX?: number;
  65956. diameterY?: number;
  65957. diameterZ?: number;
  65958. arc?: number;
  65959. slice?: number;
  65960. sideOrientation?: number;
  65961. frontUVs?: Vector4;
  65962. backUVs?: Vector4;
  65963. updatable?: boolean;
  65964. }, scene?: Nullable<Scene>): Mesh;
  65965. /**
  65966. * Creates a plane polygonal mesh. By default, this is a disc
  65967. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65968. * * 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
  65969. * * 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
  65970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65971. * * 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
  65972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65973. * @param name defines the name of the mesh
  65974. * @param options defines the options used to create the mesh
  65975. * @param scene defines the hosting scene
  65976. * @returns the plane polygonal mesh
  65977. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65978. */
  65979. static CreateDisc(name: string, options: {
  65980. radius?: number;
  65981. tessellation?: number;
  65982. arc?: number;
  65983. updatable?: boolean;
  65984. sideOrientation?: number;
  65985. frontUVs?: Vector4;
  65986. backUVs?: Vector4;
  65987. }, scene?: Nullable<Scene>): Mesh;
  65988. /**
  65989. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65990. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65991. * * 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`)
  65992. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65993. * * 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
  65994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65995. * * 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
  65996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65997. * @param name defines the name of the mesh
  65998. * @param options defines the options used to create the mesh
  65999. * @param scene defines the hosting scene
  66000. * @returns the icosahedron mesh
  66001. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66002. */
  66003. static CreateIcoSphere(name: string, options: {
  66004. radius?: number;
  66005. radiusX?: number;
  66006. radiusY?: number;
  66007. radiusZ?: number;
  66008. flat?: boolean;
  66009. subdivisions?: number;
  66010. sideOrientation?: number;
  66011. frontUVs?: Vector4;
  66012. backUVs?: Vector4;
  66013. updatable?: boolean;
  66014. }, scene?: Nullable<Scene>): Mesh;
  66015. /**
  66016. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66017. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66018. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66019. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66020. * * 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
  66021. * * 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
  66022. * * 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
  66023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66024. * * 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
  66025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66026. * * 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
  66027. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66028. * * 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
  66029. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66031. * @param name defines the name of the mesh
  66032. * @param options defines the options used to create the mesh
  66033. * @param scene defines the hosting scene
  66034. * @returns the ribbon mesh
  66035. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66036. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66037. */
  66038. static CreateRibbon(name: string, options: {
  66039. pathArray: Vector3[][];
  66040. closeArray?: boolean;
  66041. closePath?: boolean;
  66042. offset?: number;
  66043. updatable?: boolean;
  66044. sideOrientation?: number;
  66045. frontUVs?: Vector4;
  66046. backUVs?: Vector4;
  66047. instance?: Mesh;
  66048. invertUV?: boolean;
  66049. uvs?: Vector2[];
  66050. colors?: Color4[];
  66051. }, scene?: Nullable<Scene>): Mesh;
  66052. /**
  66053. * Creates a cylinder or a cone mesh
  66054. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66055. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66056. * * 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.
  66057. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66058. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66059. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66060. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66061. * * 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).
  66062. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66063. * * 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).
  66064. * * 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
  66065. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66066. * * 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
  66067. * * 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.
  66068. * * If `enclose` is false, a ring surface is one element.
  66069. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66070. * * 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
  66071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66072. * * 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
  66073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66074. * @param name defines the name of the mesh
  66075. * @param options defines the options used to create the mesh
  66076. * @param scene defines the hosting scene
  66077. * @returns the cylinder mesh
  66078. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66079. */
  66080. static CreateCylinder(name: string, options: {
  66081. height?: number;
  66082. diameterTop?: number;
  66083. diameterBottom?: number;
  66084. diameter?: number;
  66085. tessellation?: number;
  66086. subdivisions?: number;
  66087. arc?: number;
  66088. faceColors?: Color4[];
  66089. faceUV?: Vector4[];
  66090. updatable?: boolean;
  66091. hasRings?: boolean;
  66092. enclose?: boolean;
  66093. cap?: number;
  66094. sideOrientation?: number;
  66095. frontUVs?: Vector4;
  66096. backUVs?: Vector4;
  66097. }, scene?: Nullable<Scene>): Mesh;
  66098. /**
  66099. * Creates a torus mesh
  66100. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66101. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66102. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66104. * * 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
  66105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66106. * @param name defines the name of the mesh
  66107. * @param options defines the options used to create the mesh
  66108. * @param scene defines the hosting scene
  66109. * @returns the torus mesh
  66110. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66111. */
  66112. static CreateTorus(name: string, options: {
  66113. diameter?: number;
  66114. thickness?: number;
  66115. tessellation?: number;
  66116. updatable?: boolean;
  66117. sideOrientation?: number;
  66118. frontUVs?: Vector4;
  66119. backUVs?: Vector4;
  66120. }, scene?: Nullable<Scene>): Mesh;
  66121. /**
  66122. * Creates a torus knot mesh
  66123. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66124. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66125. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66126. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66128. * * 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
  66129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66130. * @param name defines the name of the mesh
  66131. * @param options defines the options used to create the mesh
  66132. * @param scene defines the hosting scene
  66133. * @returns the torus knot mesh
  66134. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66135. */
  66136. static CreateTorusKnot(name: string, options: {
  66137. radius?: number;
  66138. tube?: number;
  66139. radialSegments?: number;
  66140. tubularSegments?: number;
  66141. p?: number;
  66142. q?: number;
  66143. updatable?: boolean;
  66144. sideOrientation?: number;
  66145. frontUVs?: Vector4;
  66146. backUVs?: Vector4;
  66147. }, scene?: Nullable<Scene>): Mesh;
  66148. /**
  66149. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66150. * * 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
  66151. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66152. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66153. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66154. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66155. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66156. * * 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
  66157. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66160. * @param name defines the name of the new line system
  66161. * @param options defines the options used to create the line system
  66162. * @param scene defines the hosting scene
  66163. * @returns a new line system mesh
  66164. */
  66165. static CreateLineSystem(name: string, options: {
  66166. lines: Vector3[][];
  66167. updatable?: boolean;
  66168. instance?: Nullable<LinesMesh>;
  66169. colors?: Nullable<Color4[][]>;
  66170. useVertexAlpha?: boolean;
  66171. }, scene: Nullable<Scene>): LinesMesh;
  66172. /**
  66173. * Creates a line mesh
  66174. * 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
  66175. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66176. * * The parameter `points` is an array successive Vector3
  66177. * * 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
  66178. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66179. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66180. * * When updating an instance, remember that only point positions can change, not the number of points
  66181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66183. * @param name defines the name of the new line system
  66184. * @param options defines the options used to create the line system
  66185. * @param scene defines the hosting scene
  66186. * @returns a new line mesh
  66187. */
  66188. static CreateLines(name: string, options: {
  66189. points: Vector3[];
  66190. updatable?: boolean;
  66191. instance?: Nullable<LinesMesh>;
  66192. colors?: Color4[];
  66193. useVertexAlpha?: boolean;
  66194. }, scene?: Nullable<Scene>): LinesMesh;
  66195. /**
  66196. * Creates a dashed line mesh
  66197. * * 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
  66198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66199. * * The parameter `points` is an array successive Vector3
  66200. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66201. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66202. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66203. * * 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
  66204. * * When updating an instance, remember that only point positions can change, not the number of points
  66205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66206. * @param name defines the name of the mesh
  66207. * @param options defines the options used to create the mesh
  66208. * @param scene defines the hosting scene
  66209. * @returns the dashed line mesh
  66210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66211. */
  66212. static CreateDashedLines(name: string, options: {
  66213. points: Vector3[];
  66214. dashSize?: number;
  66215. gapSize?: number;
  66216. dashNb?: number;
  66217. updatable?: boolean;
  66218. instance?: LinesMesh;
  66219. }, scene?: Nullable<Scene>): LinesMesh;
  66220. /**
  66221. * 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.
  66222. * * 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.
  66223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66224. * * 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.
  66225. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66226. * * 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
  66227. * * 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
  66228. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66230. * * 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
  66231. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66233. * @param name defines the name of the mesh
  66234. * @param options defines the options used to create the mesh
  66235. * @param scene defines the hosting scene
  66236. * @returns the extruded shape mesh
  66237. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66238. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66239. */
  66240. static ExtrudeShape(name: string, options: {
  66241. shape: Vector3[];
  66242. path: Vector3[];
  66243. scale?: number;
  66244. rotation?: number;
  66245. cap?: number;
  66246. updatable?: boolean;
  66247. sideOrientation?: number;
  66248. frontUVs?: Vector4;
  66249. backUVs?: Vector4;
  66250. instance?: Mesh;
  66251. invertUV?: boolean;
  66252. }, scene?: Nullable<Scene>): Mesh;
  66253. /**
  66254. * Creates an custom extruded shape mesh.
  66255. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66256. * * 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.
  66257. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66258. * * 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
  66259. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66260. * * 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
  66261. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66262. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66263. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66264. * * 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
  66265. * * 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
  66266. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66268. * * 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
  66269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66271. * @param name defines the name of the mesh
  66272. * @param options defines the options used to create the mesh
  66273. * @param scene defines the hosting scene
  66274. * @returns the custom extruded shape mesh
  66275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66276. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66278. */
  66279. static ExtrudeShapeCustom(name: string, options: {
  66280. shape: Vector3[];
  66281. path: Vector3[];
  66282. scaleFunction?: any;
  66283. rotationFunction?: any;
  66284. ribbonCloseArray?: boolean;
  66285. ribbonClosePath?: boolean;
  66286. cap?: number;
  66287. updatable?: boolean;
  66288. sideOrientation?: number;
  66289. frontUVs?: Vector4;
  66290. backUVs?: Vector4;
  66291. instance?: Mesh;
  66292. invertUV?: boolean;
  66293. }, scene?: Nullable<Scene>): Mesh;
  66294. /**
  66295. * Creates lathe mesh.
  66296. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66297. * * 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
  66298. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66299. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66300. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66301. * * 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
  66302. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66303. * * 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
  66304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66305. * * 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
  66306. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66308. * @param name defines the name of the mesh
  66309. * @param options defines the options used to create the mesh
  66310. * @param scene defines the hosting scene
  66311. * @returns the lathe mesh
  66312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66313. */
  66314. static CreateLathe(name: string, options: {
  66315. shape: Vector3[];
  66316. radius?: number;
  66317. tessellation?: number;
  66318. clip?: number;
  66319. arc?: number;
  66320. closed?: boolean;
  66321. updatable?: boolean;
  66322. sideOrientation?: number;
  66323. frontUVs?: Vector4;
  66324. backUVs?: Vector4;
  66325. cap?: number;
  66326. invertUV?: boolean;
  66327. }, scene?: Nullable<Scene>): Mesh;
  66328. /**
  66329. * Creates a tiled plane mesh
  66330. * * You can set a limited pattern arrangement with the tiles
  66331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66332. * * 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
  66333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66334. * @param name defines the name of the mesh
  66335. * @param options defines the options used to create the mesh
  66336. * @param scene defines the hosting scene
  66337. * @returns the plane mesh
  66338. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66339. */
  66340. static CreateTiledPlane(name: string, options: {
  66341. pattern?: number;
  66342. tileSize?: number;
  66343. tileWidth?: number;
  66344. tileHeight?: number;
  66345. size?: number;
  66346. width?: number;
  66347. height?: number;
  66348. alignHorizontal?: number;
  66349. alignVertical?: number;
  66350. sideOrientation?: number;
  66351. frontUVs?: Vector4;
  66352. backUVs?: Vector4;
  66353. updatable?: boolean;
  66354. }, scene?: Nullable<Scene>): Mesh;
  66355. /**
  66356. * Creates a plane mesh
  66357. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66358. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66359. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66361. * * 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
  66362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66363. * @param name defines the name of the mesh
  66364. * @param options defines the options used to create the mesh
  66365. * @param scene defines the hosting scene
  66366. * @returns the plane mesh
  66367. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66368. */
  66369. static CreatePlane(name: string, options: {
  66370. size?: number;
  66371. width?: number;
  66372. height?: number;
  66373. sideOrientation?: number;
  66374. frontUVs?: Vector4;
  66375. backUVs?: Vector4;
  66376. updatable?: boolean;
  66377. sourcePlane?: Plane;
  66378. }, scene?: Nullable<Scene>): Mesh;
  66379. /**
  66380. * Creates a ground mesh
  66381. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66382. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66384. * @param name defines the name of the mesh
  66385. * @param options defines the options used to create the mesh
  66386. * @param scene defines the hosting scene
  66387. * @returns the ground mesh
  66388. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66389. */
  66390. static CreateGround(name: string, options: {
  66391. width?: number;
  66392. height?: number;
  66393. subdivisions?: number;
  66394. subdivisionsX?: number;
  66395. subdivisionsY?: number;
  66396. updatable?: boolean;
  66397. }, scene?: Nullable<Scene>): Mesh;
  66398. /**
  66399. * Creates a tiled ground mesh
  66400. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66401. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66402. * * 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
  66403. * * 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
  66404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66405. * @param name defines the name of the mesh
  66406. * @param options defines the options used to create the mesh
  66407. * @param scene defines the hosting scene
  66408. * @returns the tiled ground mesh
  66409. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66410. */
  66411. static CreateTiledGround(name: string, options: {
  66412. xmin: number;
  66413. zmin: number;
  66414. xmax: number;
  66415. zmax: number;
  66416. subdivisions?: {
  66417. w: number;
  66418. h: number;
  66419. };
  66420. precision?: {
  66421. w: number;
  66422. h: number;
  66423. };
  66424. updatable?: boolean;
  66425. }, scene?: Nullable<Scene>): Mesh;
  66426. /**
  66427. * Creates a ground mesh from a height map
  66428. * * The parameter `url` sets the URL of the height map image resource.
  66429. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66430. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66431. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66432. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66433. * * 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.
  66434. * * 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).
  66435. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66437. * @param name defines the name of the mesh
  66438. * @param url defines the url to the height map
  66439. * @param options defines the options used to create the mesh
  66440. * @param scene defines the hosting scene
  66441. * @returns the ground mesh
  66442. * @see https://doc.babylonjs.com/babylon101/height_map
  66443. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66444. */
  66445. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66446. width?: number;
  66447. height?: number;
  66448. subdivisions?: number;
  66449. minHeight?: number;
  66450. maxHeight?: number;
  66451. colorFilter?: Color3;
  66452. alphaFilter?: number;
  66453. updatable?: boolean;
  66454. onReady?: (mesh: GroundMesh) => void;
  66455. }, scene?: Nullable<Scene>): GroundMesh;
  66456. /**
  66457. * Creates a polygon mesh
  66458. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66459. * * 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
  66460. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66462. * * 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)
  66463. * * Remember you can only change the shape positions, not their number when updating a polygon
  66464. * @param name defines the name of the mesh
  66465. * @param options defines the options used to create the mesh
  66466. * @param scene defines the hosting scene
  66467. * @param earcutInjection can be used to inject your own earcut reference
  66468. * @returns the polygon mesh
  66469. */
  66470. static CreatePolygon(name: string, options: {
  66471. shape: Vector3[];
  66472. holes?: Vector3[][];
  66473. depth?: number;
  66474. faceUV?: Vector4[];
  66475. faceColors?: Color4[];
  66476. updatable?: boolean;
  66477. sideOrientation?: number;
  66478. frontUVs?: Vector4;
  66479. backUVs?: Vector4;
  66480. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66481. /**
  66482. * Creates an extruded polygon mesh, with depth in the Y direction.
  66483. * * 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)
  66484. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66485. * @param name defines the name of the mesh
  66486. * @param options defines the options used to create the mesh
  66487. * @param scene defines the hosting scene
  66488. * @param earcutInjection can be used to inject your own earcut reference
  66489. * @returns the polygon mesh
  66490. */
  66491. static ExtrudePolygon(name: string, options: {
  66492. shape: Vector3[];
  66493. holes?: Vector3[][];
  66494. depth?: number;
  66495. faceUV?: Vector4[];
  66496. faceColors?: Color4[];
  66497. updatable?: boolean;
  66498. sideOrientation?: number;
  66499. frontUVs?: Vector4;
  66500. backUVs?: Vector4;
  66501. wrap?: boolean;
  66502. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66503. /**
  66504. * Creates a tube mesh.
  66505. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66506. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66507. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66508. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66509. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66510. * * 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)
  66511. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66512. * * 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
  66513. * * 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
  66514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66515. * * 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
  66516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66518. * @param name defines the name of the mesh
  66519. * @param options defines the options used to create the mesh
  66520. * @param scene defines the hosting scene
  66521. * @returns the tube mesh
  66522. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66523. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66524. */
  66525. static CreateTube(name: string, options: {
  66526. path: Vector3[];
  66527. radius?: number;
  66528. tessellation?: number;
  66529. radiusFunction?: {
  66530. (i: number, distance: number): number;
  66531. };
  66532. cap?: number;
  66533. arc?: number;
  66534. updatable?: boolean;
  66535. sideOrientation?: number;
  66536. frontUVs?: Vector4;
  66537. backUVs?: Vector4;
  66538. instance?: Mesh;
  66539. invertUV?: boolean;
  66540. }, scene?: Nullable<Scene>): Mesh;
  66541. /**
  66542. * Creates a polyhedron mesh
  66543. * * 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
  66544. * * The parameter `size` (positive float, default 1) sets the polygon size
  66545. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66546. * * 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`
  66547. * * 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
  66548. * * 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)`)
  66549. * * 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
  66550. * * 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
  66551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66554. * @param name defines the name of the mesh
  66555. * @param options defines the options used to create the mesh
  66556. * @param scene defines the hosting scene
  66557. * @returns the polyhedron mesh
  66558. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66559. */
  66560. static CreatePolyhedron(name: string, options: {
  66561. type?: number;
  66562. size?: number;
  66563. sizeX?: number;
  66564. sizeY?: number;
  66565. sizeZ?: number;
  66566. custom?: any;
  66567. faceUV?: Vector4[];
  66568. faceColors?: Color4[];
  66569. flat?: boolean;
  66570. updatable?: boolean;
  66571. sideOrientation?: number;
  66572. frontUVs?: Vector4;
  66573. backUVs?: Vector4;
  66574. }, scene?: Nullable<Scene>): Mesh;
  66575. /**
  66576. * Creates a decal mesh.
  66577. * 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
  66578. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66579. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66580. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66581. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66582. * @param name defines the name of the mesh
  66583. * @param sourceMesh defines the mesh where the decal must be applied
  66584. * @param options defines the options used to create the mesh
  66585. * @param scene defines the hosting scene
  66586. * @returns the decal mesh
  66587. * @see https://doc.babylonjs.com/how_to/decals
  66588. */
  66589. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66590. position?: Vector3;
  66591. normal?: Vector3;
  66592. size?: Vector3;
  66593. angle?: number;
  66594. }): Mesh;
  66595. /**
  66596. * Creates a Capsule Mesh
  66597. * @param name defines the name of the mesh.
  66598. * @param options the constructors options used to shape the mesh.
  66599. * @param scene defines the scene the mesh is scoped to.
  66600. * @returns the capsule mesh
  66601. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66602. */
  66603. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66604. }
  66605. }
  66606. declare module BABYLON {
  66607. /**
  66608. * A simplifier interface for future simplification implementations
  66609. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66610. */
  66611. export interface ISimplifier {
  66612. /**
  66613. * Simplification of a given mesh according to the given settings.
  66614. * Since this requires computation, it is assumed that the function runs async.
  66615. * @param settings The settings of the simplification, including quality and distance
  66616. * @param successCallback A callback that will be called after the mesh was simplified.
  66617. * @param errorCallback in case of an error, this callback will be called. optional.
  66618. */
  66619. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66620. }
  66621. /**
  66622. * Expected simplification settings.
  66623. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66624. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66625. */
  66626. export interface ISimplificationSettings {
  66627. /**
  66628. * Gets or sets the expected quality
  66629. */
  66630. quality: number;
  66631. /**
  66632. * Gets or sets the distance when this optimized version should be used
  66633. */
  66634. distance: number;
  66635. /**
  66636. * Gets an already optimized mesh
  66637. */
  66638. optimizeMesh?: boolean;
  66639. }
  66640. /**
  66641. * Class used to specify simplification options
  66642. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66643. */
  66644. export class SimplificationSettings implements ISimplificationSettings {
  66645. /** expected quality */
  66646. quality: number;
  66647. /** distance when this optimized version should be used */
  66648. distance: number;
  66649. /** already optimized mesh */
  66650. optimizeMesh?: boolean | undefined;
  66651. /**
  66652. * Creates a SimplificationSettings
  66653. * @param quality expected quality
  66654. * @param distance distance when this optimized version should be used
  66655. * @param optimizeMesh already optimized mesh
  66656. */
  66657. constructor(
  66658. /** expected quality */
  66659. quality: number,
  66660. /** distance when this optimized version should be used */
  66661. distance: number,
  66662. /** already optimized mesh */
  66663. optimizeMesh?: boolean | undefined);
  66664. }
  66665. /**
  66666. * Interface used to define a simplification task
  66667. */
  66668. export interface ISimplificationTask {
  66669. /**
  66670. * Array of settings
  66671. */
  66672. settings: Array<ISimplificationSettings>;
  66673. /**
  66674. * Simplification type
  66675. */
  66676. simplificationType: SimplificationType;
  66677. /**
  66678. * Mesh to simplify
  66679. */
  66680. mesh: Mesh;
  66681. /**
  66682. * Callback called on success
  66683. */
  66684. successCallback?: () => void;
  66685. /**
  66686. * Defines if parallel processing can be used
  66687. */
  66688. parallelProcessing: boolean;
  66689. }
  66690. /**
  66691. * Queue used to order the simplification tasks
  66692. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66693. */
  66694. export class SimplificationQueue {
  66695. private _simplificationArray;
  66696. /**
  66697. * Gets a boolean indicating that the process is still running
  66698. */
  66699. running: boolean;
  66700. /**
  66701. * Creates a new queue
  66702. */
  66703. constructor();
  66704. /**
  66705. * Adds a new simplification task
  66706. * @param task defines a task to add
  66707. */
  66708. addTask(task: ISimplificationTask): void;
  66709. /**
  66710. * Execute next task
  66711. */
  66712. executeNext(): void;
  66713. /**
  66714. * Execute a simplification task
  66715. * @param task defines the task to run
  66716. */
  66717. runSimplification(task: ISimplificationTask): void;
  66718. private getSimplifier;
  66719. }
  66720. /**
  66721. * The implemented types of simplification
  66722. * At the moment only Quadratic Error Decimation is implemented
  66723. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66724. */
  66725. export enum SimplificationType {
  66726. /** Quadratic error decimation */
  66727. QUADRATIC = 0
  66728. }
  66729. /**
  66730. * An implementation of the Quadratic Error simplification algorithm.
  66731. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66732. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66733. * @author RaananW
  66734. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66735. */
  66736. export class QuadraticErrorSimplification implements ISimplifier {
  66737. private _mesh;
  66738. private triangles;
  66739. private vertices;
  66740. private references;
  66741. private _reconstructedMesh;
  66742. /** Gets or sets the number pf sync interations */
  66743. syncIterations: number;
  66744. /** Gets or sets the aggressiveness of the simplifier */
  66745. aggressiveness: number;
  66746. /** Gets or sets the number of allowed iterations for decimation */
  66747. decimationIterations: number;
  66748. /** Gets or sets the espilon to use for bounding box computation */
  66749. boundingBoxEpsilon: number;
  66750. /**
  66751. * Creates a new QuadraticErrorSimplification
  66752. * @param _mesh defines the target mesh
  66753. */
  66754. constructor(_mesh: Mesh);
  66755. /**
  66756. * Simplification of a given mesh according to the given settings.
  66757. * Since this requires computation, it is assumed that the function runs async.
  66758. * @param settings The settings of the simplification, including quality and distance
  66759. * @param successCallback A callback that will be called after the mesh was simplified.
  66760. */
  66761. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66762. private runDecimation;
  66763. private initWithMesh;
  66764. private init;
  66765. private reconstructMesh;
  66766. private initDecimatedMesh;
  66767. private isFlipped;
  66768. private updateTriangles;
  66769. private identifyBorder;
  66770. private updateMesh;
  66771. private vertexError;
  66772. private calculateError;
  66773. }
  66774. }
  66775. declare module BABYLON {
  66776. interface Scene {
  66777. /** @hidden (Backing field) */
  66778. _simplificationQueue: SimplificationQueue;
  66779. /**
  66780. * Gets or sets the simplification queue attached to the scene
  66781. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66782. */
  66783. simplificationQueue: SimplificationQueue;
  66784. }
  66785. interface Mesh {
  66786. /**
  66787. * Simplify the mesh according to the given array of settings.
  66788. * Function will return immediately and will simplify async
  66789. * @param settings a collection of simplification settings
  66790. * @param parallelProcessing should all levels calculate parallel or one after the other
  66791. * @param simplificationType the type of simplification to run
  66792. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66793. * @returns the current mesh
  66794. */
  66795. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66796. }
  66797. /**
  66798. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66799. * created in a scene
  66800. */
  66801. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66802. /**
  66803. * The component name helpfull to identify the component in the list of scene components.
  66804. */
  66805. readonly name: string;
  66806. /**
  66807. * The scene the component belongs to.
  66808. */
  66809. scene: Scene;
  66810. /**
  66811. * Creates a new instance of the component for the given scene
  66812. * @param scene Defines the scene to register the component in
  66813. */
  66814. constructor(scene: Scene);
  66815. /**
  66816. * Registers the component in a given scene
  66817. */
  66818. register(): void;
  66819. /**
  66820. * Rebuilds the elements related to this component in case of
  66821. * context lost for instance.
  66822. */
  66823. rebuild(): void;
  66824. /**
  66825. * Disposes the component and the associated ressources
  66826. */
  66827. dispose(): void;
  66828. private _beforeCameraUpdate;
  66829. }
  66830. }
  66831. declare module BABYLON {
  66832. interface Mesh {
  66833. /**
  66834. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66835. */
  66836. thinInstanceEnablePicking: boolean;
  66837. /**
  66838. * Creates a new thin instance
  66839. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66840. * @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
  66841. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66842. */
  66843. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66844. /**
  66845. * Adds the transformation (matrix) of the current mesh as a thin instance
  66846. * @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
  66847. * @returns the thin instance index number
  66848. */
  66849. thinInstanceAddSelf(refresh: boolean): number;
  66850. /**
  66851. * Registers a custom attribute to be used with thin instances
  66852. * @param kind name of the attribute
  66853. * @param stride size in floats of the attribute
  66854. */
  66855. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66856. /**
  66857. * Sets the matrix of a thin instance
  66858. * @param index index of the thin instance
  66859. * @param matrix matrix to set
  66860. * @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
  66861. */
  66862. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66863. /**
  66864. * Sets the value of a custom attribute for a thin instance
  66865. * @param kind name of the attribute
  66866. * @param index index of the thin instance
  66867. * @param value value to set
  66868. * @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
  66869. */
  66870. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66871. /**
  66872. * 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.
  66873. */
  66874. thinInstanceCount: number;
  66875. /**
  66876. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66877. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66878. * @param buffer buffer to set
  66879. * @param stride size in floats of each value of the buffer
  66880. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66881. */
  66882. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66883. /**
  66884. * Gets the list of world matrices
  66885. * @return an array containing all the world matrices from the thin instances
  66886. */
  66887. thinInstanceGetWorldMatrices(): Matrix[];
  66888. /**
  66889. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66890. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66891. */
  66892. thinInstanceBufferUpdated(kind: string): void;
  66893. /**
  66894. * Applies a partial update to a buffer directly on the GPU
  66895. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  66896. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66897. * @param data the data to set in the GPU buffer
  66898. * @param offset the offset in the GPU buffer where to update the data
  66899. */
  66900. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66901. /**
  66902. * Refreshes the bounding info, taking into account all the thin instances defined
  66903. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66904. */
  66905. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66906. /** @hidden */
  66907. _thinInstanceInitializeUserStorage(): void;
  66908. /** @hidden */
  66909. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66910. /** @hidden */
  66911. _userThinInstanceBuffersStorage: {
  66912. data: {
  66913. [key: string]: Float32Array;
  66914. };
  66915. sizes: {
  66916. [key: string]: number;
  66917. };
  66918. vertexBuffers: {
  66919. [key: string]: Nullable<VertexBuffer>;
  66920. };
  66921. strides: {
  66922. [key: string]: number;
  66923. };
  66924. };
  66925. }
  66926. }
  66927. declare module BABYLON {
  66928. /**
  66929. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66930. */
  66931. export interface INavigationEnginePlugin {
  66932. /**
  66933. * plugin name
  66934. */
  66935. name: string;
  66936. /**
  66937. * Creates a navigation mesh
  66938. * @param meshes array of all the geometry used to compute the navigatio mesh
  66939. * @param parameters bunch of parameters used to filter geometry
  66940. */
  66941. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66942. /**
  66943. * Create a navigation mesh debug mesh
  66944. * @param scene is where the mesh will be added
  66945. * @returns debug display mesh
  66946. */
  66947. createDebugNavMesh(scene: Scene): Mesh;
  66948. /**
  66949. * Get a navigation mesh constrained position, closest to the parameter position
  66950. * @param position world position
  66951. * @returns the closest point to position constrained by the navigation mesh
  66952. */
  66953. getClosestPoint(position: Vector3): Vector3;
  66954. /**
  66955. * Get a navigation mesh constrained position, closest to the parameter position
  66956. * @param position world position
  66957. * @param result output the closest point to position constrained by the navigation mesh
  66958. */
  66959. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66960. /**
  66961. * Get a navigation mesh constrained position, within a particular radius
  66962. * @param position world position
  66963. * @param maxRadius the maximum distance to the constrained world position
  66964. * @returns the closest point to position constrained by the navigation mesh
  66965. */
  66966. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66967. /**
  66968. * Get a navigation mesh constrained position, within a particular radius
  66969. * @param position world position
  66970. * @param maxRadius the maximum distance to the constrained world position
  66971. * @param result output the closest point to position constrained by the navigation mesh
  66972. */
  66973. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66974. /**
  66975. * Compute the final position from a segment made of destination-position
  66976. * @param position world position
  66977. * @param destination world position
  66978. * @returns the resulting point along the navmesh
  66979. */
  66980. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66981. /**
  66982. * Compute the final position from a segment made of destination-position
  66983. * @param position world position
  66984. * @param destination world position
  66985. * @param result output the resulting point along the navmesh
  66986. */
  66987. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66988. /**
  66989. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66990. * @param start world position
  66991. * @param end world position
  66992. * @returns array containing world position composing the path
  66993. */
  66994. computePath(start: Vector3, end: Vector3): Vector3[];
  66995. /**
  66996. * If this plugin is supported
  66997. * @returns true if plugin is supported
  66998. */
  66999. isSupported(): boolean;
  67000. /**
  67001. * Create a new Crowd so you can add agents
  67002. * @param maxAgents the maximum agent count in the crowd
  67003. * @param maxAgentRadius the maximum radius an agent can have
  67004. * @param scene to attach the crowd to
  67005. * @returns the crowd you can add agents to
  67006. */
  67007. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67008. /**
  67009. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67010. * The queries will try to find a solution within those bounds
  67011. * default is (1,1,1)
  67012. * @param extent x,y,z value that define the extent around the queries point of reference
  67013. */
  67014. setDefaultQueryExtent(extent: Vector3): void;
  67015. /**
  67016. * Get the Bounding box extent specified by setDefaultQueryExtent
  67017. * @returns the box extent values
  67018. */
  67019. getDefaultQueryExtent(): Vector3;
  67020. /**
  67021. * build the navmesh from a previously saved state using getNavmeshData
  67022. * @param data the Uint8Array returned by getNavmeshData
  67023. */
  67024. buildFromNavmeshData(data: Uint8Array): void;
  67025. /**
  67026. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67027. * @returns data the Uint8Array that can be saved and reused
  67028. */
  67029. getNavmeshData(): Uint8Array;
  67030. /**
  67031. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67032. * @param result output the box extent values
  67033. */
  67034. getDefaultQueryExtentToRef(result: Vector3): void;
  67035. /**
  67036. * Release all resources
  67037. */
  67038. dispose(): void;
  67039. }
  67040. /**
  67041. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67042. */
  67043. export interface ICrowd {
  67044. /**
  67045. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67046. * You can attach anything to that node. The node position is updated in the scene update tick.
  67047. * @param pos world position that will be constrained by the navigation mesh
  67048. * @param parameters agent parameters
  67049. * @param transform hooked to the agent that will be update by the scene
  67050. * @returns agent index
  67051. */
  67052. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67053. /**
  67054. * Returns the agent position in world space
  67055. * @param index agent index returned by addAgent
  67056. * @returns world space position
  67057. */
  67058. getAgentPosition(index: number): Vector3;
  67059. /**
  67060. * Gets the agent position result in world space
  67061. * @param index agent index returned by addAgent
  67062. * @param result output world space position
  67063. */
  67064. getAgentPositionToRef(index: number, result: Vector3): void;
  67065. /**
  67066. * Gets the agent velocity in world space
  67067. * @param index agent index returned by addAgent
  67068. * @returns world space velocity
  67069. */
  67070. getAgentVelocity(index: number): Vector3;
  67071. /**
  67072. * Gets the agent velocity result in world space
  67073. * @param index agent index returned by addAgent
  67074. * @param result output world space velocity
  67075. */
  67076. getAgentVelocityToRef(index: number, result: Vector3): void;
  67077. /**
  67078. * remove a particular agent previously created
  67079. * @param index agent index returned by addAgent
  67080. */
  67081. removeAgent(index: number): void;
  67082. /**
  67083. * get the list of all agents attached to this crowd
  67084. * @returns list of agent indices
  67085. */
  67086. getAgents(): number[];
  67087. /**
  67088. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67089. * @param deltaTime in seconds
  67090. */
  67091. update(deltaTime: number): void;
  67092. /**
  67093. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67094. * @param index agent index returned by addAgent
  67095. * @param destination targeted world position
  67096. */
  67097. agentGoto(index: number, destination: Vector3): void;
  67098. /**
  67099. * Teleport the agent to a new position
  67100. * @param index agent index returned by addAgent
  67101. * @param destination targeted world position
  67102. */
  67103. agentTeleport(index: number, destination: Vector3): void;
  67104. /**
  67105. * Update agent parameters
  67106. * @param index agent index returned by addAgent
  67107. * @param parameters agent parameters
  67108. */
  67109. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67110. /**
  67111. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67112. * The queries will try to find a solution within those bounds
  67113. * default is (1,1,1)
  67114. * @param extent x,y,z value that define the extent around the queries point of reference
  67115. */
  67116. setDefaultQueryExtent(extent: Vector3): void;
  67117. /**
  67118. * Get the Bounding box extent specified by setDefaultQueryExtent
  67119. * @returns the box extent values
  67120. */
  67121. getDefaultQueryExtent(): Vector3;
  67122. /**
  67123. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67124. * @param result output the box extent values
  67125. */
  67126. getDefaultQueryExtentToRef(result: Vector3): void;
  67127. /**
  67128. * Release all resources
  67129. */
  67130. dispose(): void;
  67131. }
  67132. /**
  67133. * Configures an agent
  67134. */
  67135. export interface IAgentParameters {
  67136. /**
  67137. * Agent radius. [Limit: >= 0]
  67138. */
  67139. radius: number;
  67140. /**
  67141. * Agent height. [Limit: > 0]
  67142. */
  67143. height: number;
  67144. /**
  67145. * Maximum allowed acceleration. [Limit: >= 0]
  67146. */
  67147. maxAcceleration: number;
  67148. /**
  67149. * Maximum allowed speed. [Limit: >= 0]
  67150. */
  67151. maxSpeed: number;
  67152. /**
  67153. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67154. */
  67155. collisionQueryRange: number;
  67156. /**
  67157. * The path visibility optimization range. [Limit: > 0]
  67158. */
  67159. pathOptimizationRange: number;
  67160. /**
  67161. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67162. */
  67163. separationWeight: number;
  67164. }
  67165. /**
  67166. * Configures the navigation mesh creation
  67167. */
  67168. export interface INavMeshParameters {
  67169. /**
  67170. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67171. */
  67172. cs: number;
  67173. /**
  67174. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67175. */
  67176. ch: number;
  67177. /**
  67178. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67179. */
  67180. walkableSlopeAngle: number;
  67181. /**
  67182. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67183. * be considered walkable. [Limit: >= 3] [Units: vx]
  67184. */
  67185. walkableHeight: number;
  67186. /**
  67187. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67188. */
  67189. walkableClimb: number;
  67190. /**
  67191. * The distance to erode/shrink the walkable area of the heightfield away from
  67192. * obstructions. [Limit: >=0] [Units: vx]
  67193. */
  67194. walkableRadius: number;
  67195. /**
  67196. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67197. */
  67198. maxEdgeLen: number;
  67199. /**
  67200. * The maximum distance a simplfied contour's border edges should deviate
  67201. * the original raw contour. [Limit: >=0] [Units: vx]
  67202. */
  67203. maxSimplificationError: number;
  67204. /**
  67205. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67206. */
  67207. minRegionArea: number;
  67208. /**
  67209. * Any regions with a span count smaller than this value will, if possible,
  67210. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67211. */
  67212. mergeRegionArea: number;
  67213. /**
  67214. * The maximum number of vertices allowed for polygons generated during the
  67215. * contour to polygon conversion process. [Limit: >= 3]
  67216. */
  67217. maxVertsPerPoly: number;
  67218. /**
  67219. * Sets the sampling distance to use when generating the detail mesh.
  67220. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67221. */
  67222. detailSampleDist: number;
  67223. /**
  67224. * The maximum distance the detail mesh surface should deviate from heightfield
  67225. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67226. */
  67227. detailSampleMaxError: number;
  67228. }
  67229. }
  67230. declare module BABYLON {
  67231. /**
  67232. * RecastJS navigation plugin
  67233. */
  67234. export class RecastJSPlugin implements INavigationEnginePlugin {
  67235. /**
  67236. * Reference to the Recast library
  67237. */
  67238. bjsRECAST: any;
  67239. /**
  67240. * plugin name
  67241. */
  67242. name: string;
  67243. /**
  67244. * the first navmesh created. We might extend this to support multiple navmeshes
  67245. */
  67246. navMesh: any;
  67247. /**
  67248. * Initializes the recastJS plugin
  67249. * @param recastInjection can be used to inject your own recast reference
  67250. */
  67251. constructor(recastInjection?: any);
  67252. /**
  67253. * Creates a navigation mesh
  67254. * @param meshes array of all the geometry used to compute the navigatio mesh
  67255. * @param parameters bunch of parameters used to filter geometry
  67256. */
  67257. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67258. /**
  67259. * Create a navigation mesh debug mesh
  67260. * @param scene is where the mesh will be added
  67261. * @returns debug display mesh
  67262. */
  67263. createDebugNavMesh(scene: Scene): Mesh;
  67264. /**
  67265. * Get a navigation mesh constrained position, closest to the parameter position
  67266. * @param position world position
  67267. * @returns the closest point to position constrained by the navigation mesh
  67268. */
  67269. getClosestPoint(position: Vector3): Vector3;
  67270. /**
  67271. * Get a navigation mesh constrained position, closest to the parameter position
  67272. * @param position world position
  67273. * @param result output the closest point to position constrained by the navigation mesh
  67274. */
  67275. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67276. /**
  67277. * Get a navigation mesh constrained position, within a particular radius
  67278. * @param position world position
  67279. * @param maxRadius the maximum distance to the constrained world position
  67280. * @returns the closest point to position constrained by the navigation mesh
  67281. */
  67282. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67283. /**
  67284. * Get a navigation mesh constrained position, within a particular radius
  67285. * @param position world position
  67286. * @param maxRadius the maximum distance to the constrained world position
  67287. * @param result output the closest point to position constrained by the navigation mesh
  67288. */
  67289. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67290. /**
  67291. * Compute the final position from a segment made of destination-position
  67292. * @param position world position
  67293. * @param destination world position
  67294. * @returns the resulting point along the navmesh
  67295. */
  67296. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67297. /**
  67298. * Compute the final position from a segment made of destination-position
  67299. * @param position world position
  67300. * @param destination world position
  67301. * @param result output the resulting point along the navmesh
  67302. */
  67303. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67304. /**
  67305. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67306. * @param start world position
  67307. * @param end world position
  67308. * @returns array containing world position composing the path
  67309. */
  67310. computePath(start: Vector3, end: Vector3): Vector3[];
  67311. /**
  67312. * Create a new Crowd so you can add agents
  67313. * @param maxAgents the maximum agent count in the crowd
  67314. * @param maxAgentRadius the maximum radius an agent can have
  67315. * @param scene to attach the crowd to
  67316. * @returns the crowd you can add agents to
  67317. */
  67318. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67319. /**
  67320. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67321. * The queries will try to find a solution within those bounds
  67322. * default is (1,1,1)
  67323. * @param extent x,y,z value that define the extent around the queries point of reference
  67324. */
  67325. setDefaultQueryExtent(extent: Vector3): void;
  67326. /**
  67327. * Get the Bounding box extent specified by setDefaultQueryExtent
  67328. * @returns the box extent values
  67329. */
  67330. getDefaultQueryExtent(): Vector3;
  67331. /**
  67332. * build the navmesh from a previously saved state using getNavmeshData
  67333. * @param data the Uint8Array returned by getNavmeshData
  67334. */
  67335. buildFromNavmeshData(data: Uint8Array): void;
  67336. /**
  67337. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67338. * @returns data the Uint8Array that can be saved and reused
  67339. */
  67340. getNavmeshData(): Uint8Array;
  67341. /**
  67342. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67343. * @param result output the box extent values
  67344. */
  67345. getDefaultQueryExtentToRef(result: Vector3): void;
  67346. /**
  67347. * Disposes
  67348. */
  67349. dispose(): void;
  67350. /**
  67351. * If this plugin is supported
  67352. * @returns true if plugin is supported
  67353. */
  67354. isSupported(): boolean;
  67355. }
  67356. /**
  67357. * Recast detour crowd implementation
  67358. */
  67359. export class RecastJSCrowd implements ICrowd {
  67360. /**
  67361. * Recast/detour plugin
  67362. */
  67363. bjsRECASTPlugin: RecastJSPlugin;
  67364. /**
  67365. * Link to the detour crowd
  67366. */
  67367. recastCrowd: any;
  67368. /**
  67369. * One transform per agent
  67370. */
  67371. transforms: TransformNode[];
  67372. /**
  67373. * All agents created
  67374. */
  67375. agents: number[];
  67376. /**
  67377. * Link to the scene is kept to unregister the crowd from the scene
  67378. */
  67379. private _scene;
  67380. /**
  67381. * Observer for crowd updates
  67382. */
  67383. private _onBeforeAnimationsObserver;
  67384. /**
  67385. * Constructor
  67386. * @param plugin recastJS plugin
  67387. * @param maxAgents the maximum agent count in the crowd
  67388. * @param maxAgentRadius the maximum radius an agent can have
  67389. * @param scene to attach the crowd to
  67390. * @returns the crowd you can add agents to
  67391. */
  67392. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67393. /**
  67394. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67395. * You can attach anything to that node. The node position is updated in the scene update tick.
  67396. * @param pos world position that will be constrained by the navigation mesh
  67397. * @param parameters agent parameters
  67398. * @param transform hooked to the agent that will be update by the scene
  67399. * @returns agent index
  67400. */
  67401. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67402. /**
  67403. * Returns the agent position in world space
  67404. * @param index agent index returned by addAgent
  67405. * @returns world space position
  67406. */
  67407. getAgentPosition(index: number): Vector3;
  67408. /**
  67409. * Returns the agent position result in world space
  67410. * @param index agent index returned by addAgent
  67411. * @param result output world space position
  67412. */
  67413. getAgentPositionToRef(index: number, result: Vector3): void;
  67414. /**
  67415. * Returns the agent velocity in world space
  67416. * @param index agent index returned by addAgent
  67417. * @returns world space velocity
  67418. */
  67419. getAgentVelocity(index: number): Vector3;
  67420. /**
  67421. * Returns the agent velocity result in world space
  67422. * @param index agent index returned by addAgent
  67423. * @param result output world space velocity
  67424. */
  67425. getAgentVelocityToRef(index: number, result: Vector3): void;
  67426. /**
  67427. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67428. * @param index agent index returned by addAgent
  67429. * @param destination targeted world position
  67430. */
  67431. agentGoto(index: number, destination: Vector3): void;
  67432. /**
  67433. * Teleport the agent to a new position
  67434. * @param index agent index returned by addAgent
  67435. * @param destination targeted world position
  67436. */
  67437. agentTeleport(index: number, destination: Vector3): void;
  67438. /**
  67439. * Update agent parameters
  67440. * @param index agent index returned by addAgent
  67441. * @param parameters agent parameters
  67442. */
  67443. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67444. /**
  67445. * remove a particular agent previously created
  67446. * @param index agent index returned by addAgent
  67447. */
  67448. removeAgent(index: number): void;
  67449. /**
  67450. * get the list of all agents attached to this crowd
  67451. * @returns list of agent indices
  67452. */
  67453. getAgents(): number[];
  67454. /**
  67455. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67456. * @param deltaTime in seconds
  67457. */
  67458. update(deltaTime: number): void;
  67459. /**
  67460. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67461. * The queries will try to find a solution within those bounds
  67462. * default is (1,1,1)
  67463. * @param extent x,y,z value that define the extent around the queries point of reference
  67464. */
  67465. setDefaultQueryExtent(extent: Vector3): void;
  67466. /**
  67467. * Get the Bounding box extent specified by setDefaultQueryExtent
  67468. * @returns the box extent values
  67469. */
  67470. getDefaultQueryExtent(): Vector3;
  67471. /**
  67472. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67473. * @param result output the box extent values
  67474. */
  67475. getDefaultQueryExtentToRef(result: Vector3): void;
  67476. /**
  67477. * Release all resources
  67478. */
  67479. dispose(): void;
  67480. }
  67481. }
  67482. declare module BABYLON {
  67483. /**
  67484. * Class used to enable access to IndexedDB
  67485. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67486. */
  67487. export class Database implements IOfflineProvider {
  67488. private _callbackManifestChecked;
  67489. private _currentSceneUrl;
  67490. private _db;
  67491. private _enableSceneOffline;
  67492. private _enableTexturesOffline;
  67493. private _manifestVersionFound;
  67494. private _mustUpdateRessources;
  67495. private _hasReachedQuota;
  67496. private _isSupported;
  67497. private _idbFactory;
  67498. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67499. private static IsUASupportingBlobStorage;
  67500. /**
  67501. * Gets a boolean indicating if Database storate is enabled (off by default)
  67502. */
  67503. static IDBStorageEnabled: boolean;
  67504. /**
  67505. * Gets a boolean indicating if scene must be saved in the database
  67506. */
  67507. get enableSceneOffline(): boolean;
  67508. /**
  67509. * Gets a boolean indicating if textures must be saved in the database
  67510. */
  67511. get enableTexturesOffline(): boolean;
  67512. /**
  67513. * Creates a new Database
  67514. * @param urlToScene defines the url to load the scene
  67515. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67516. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67517. */
  67518. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67519. private static _ParseURL;
  67520. private static _ReturnFullUrlLocation;
  67521. private _checkManifestFile;
  67522. /**
  67523. * Open the database and make it available
  67524. * @param successCallback defines the callback to call on success
  67525. * @param errorCallback defines the callback to call on error
  67526. */
  67527. open(successCallback: () => void, errorCallback: () => void): void;
  67528. /**
  67529. * Loads an image from the database
  67530. * @param url defines the url to load from
  67531. * @param image defines the target DOM image
  67532. */
  67533. loadImage(url: string, image: HTMLImageElement): void;
  67534. private _loadImageFromDBAsync;
  67535. private _saveImageIntoDBAsync;
  67536. private _checkVersionFromDB;
  67537. private _loadVersionFromDBAsync;
  67538. private _saveVersionIntoDBAsync;
  67539. /**
  67540. * Loads a file from database
  67541. * @param url defines the URL to load from
  67542. * @param sceneLoaded defines a callback to call on success
  67543. * @param progressCallBack defines a callback to call when progress changed
  67544. * @param errorCallback defines a callback to call on error
  67545. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67546. */
  67547. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67548. private _loadFileAsync;
  67549. private _saveFileAsync;
  67550. /**
  67551. * Validates if xhr data is correct
  67552. * @param xhr defines the request to validate
  67553. * @param dataType defines the expected data type
  67554. * @returns true if data is correct
  67555. */
  67556. private static _ValidateXHRData;
  67557. }
  67558. }
  67559. declare module BABYLON {
  67560. /** @hidden */
  67561. export var gpuUpdateParticlesPixelShader: {
  67562. name: string;
  67563. shader: string;
  67564. };
  67565. }
  67566. declare module BABYLON {
  67567. /** @hidden */
  67568. export var gpuUpdateParticlesVertexShader: {
  67569. name: string;
  67570. shader: string;
  67571. };
  67572. }
  67573. declare module BABYLON {
  67574. /** @hidden */
  67575. export var clipPlaneFragmentDeclaration2: {
  67576. name: string;
  67577. shader: string;
  67578. };
  67579. }
  67580. declare module BABYLON {
  67581. /** @hidden */
  67582. export var gpuRenderParticlesPixelShader: {
  67583. name: string;
  67584. shader: string;
  67585. };
  67586. }
  67587. declare module BABYLON {
  67588. /** @hidden */
  67589. export var clipPlaneVertexDeclaration2: {
  67590. name: string;
  67591. shader: string;
  67592. };
  67593. }
  67594. declare module BABYLON {
  67595. /** @hidden */
  67596. export var gpuRenderParticlesVertexShader: {
  67597. name: string;
  67598. shader: string;
  67599. };
  67600. }
  67601. declare module BABYLON {
  67602. /**
  67603. * This represents a GPU particle system in Babylon
  67604. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67605. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67606. */
  67607. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67608. /**
  67609. * The layer mask we are rendering the particles through.
  67610. */
  67611. layerMask: number;
  67612. private _capacity;
  67613. private _activeCount;
  67614. private _currentActiveCount;
  67615. private _accumulatedCount;
  67616. private _renderEffect;
  67617. private _updateEffect;
  67618. private _buffer0;
  67619. private _buffer1;
  67620. private _spriteBuffer;
  67621. private _updateVAO;
  67622. private _renderVAO;
  67623. private _targetIndex;
  67624. private _sourceBuffer;
  67625. private _targetBuffer;
  67626. private _currentRenderId;
  67627. private _started;
  67628. private _stopped;
  67629. private _timeDelta;
  67630. private _randomTexture;
  67631. private _randomTexture2;
  67632. private _attributesStrideSize;
  67633. private _updateEffectOptions;
  67634. private _randomTextureSize;
  67635. private _actualFrame;
  67636. private _customEffect;
  67637. private readonly _rawTextureWidth;
  67638. /**
  67639. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67640. */
  67641. static get IsSupported(): boolean;
  67642. /**
  67643. * An event triggered when the system is disposed.
  67644. */
  67645. onDisposeObservable: Observable<IParticleSystem>;
  67646. /**
  67647. * Gets the maximum number of particles active at the same time.
  67648. * @returns The max number of active particles.
  67649. */
  67650. getCapacity(): number;
  67651. /**
  67652. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67653. * to override the particles.
  67654. */
  67655. forceDepthWrite: boolean;
  67656. /**
  67657. * Gets or set the number of active particles
  67658. */
  67659. get activeParticleCount(): number;
  67660. set activeParticleCount(value: number);
  67661. private _preWarmDone;
  67662. /**
  67663. * Specifies if the particles are updated in emitter local space or world space.
  67664. */
  67665. isLocal: boolean;
  67666. /** Gets or sets a matrix to use to compute projection */
  67667. defaultProjectionMatrix: Matrix;
  67668. /**
  67669. * Is this system ready to be used/rendered
  67670. * @return true if the system is ready
  67671. */
  67672. isReady(): boolean;
  67673. /**
  67674. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67675. * @returns True if it has been started, otherwise false.
  67676. */
  67677. isStarted(): boolean;
  67678. /**
  67679. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67680. * @returns True if it has been stopped, otherwise false.
  67681. */
  67682. isStopped(): boolean;
  67683. /**
  67684. * Gets a boolean indicating that the system is stopping
  67685. * @returns true if the system is currently stopping
  67686. */
  67687. isStopping(): boolean;
  67688. /**
  67689. * Gets the number of particles active at the same time.
  67690. * @returns The number of active particles.
  67691. */
  67692. getActiveCount(): number;
  67693. /**
  67694. * Starts the particle system and begins to emit
  67695. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67696. */
  67697. start(delay?: number): void;
  67698. /**
  67699. * Stops the particle system.
  67700. */
  67701. stop(): void;
  67702. /**
  67703. * Remove all active particles
  67704. */
  67705. reset(): void;
  67706. /**
  67707. * Returns the string "GPUParticleSystem"
  67708. * @returns a string containing the class name
  67709. */
  67710. getClassName(): string;
  67711. /**
  67712. * Gets the custom effect used to render the particles
  67713. * @param blendMode Blend mode for which the effect should be retrieved
  67714. * @returns The effect
  67715. */
  67716. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67717. /**
  67718. * Sets the custom effect used to render the particles
  67719. * @param effect The effect to set
  67720. * @param blendMode Blend mode for which the effect should be set
  67721. */
  67722. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67723. /** @hidden */
  67724. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67725. /**
  67726. * Observable that will be called just before the particles are drawn
  67727. */
  67728. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67729. /**
  67730. * Gets the name of the particle vertex shader
  67731. */
  67732. get vertexShaderName(): string;
  67733. private _colorGradientsTexture;
  67734. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67735. /**
  67736. * Adds a new color gradient
  67737. * @param gradient defines the gradient to use (between 0 and 1)
  67738. * @param color1 defines the color to affect to the specified gradient
  67739. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67740. * @returns the current particle system
  67741. */
  67742. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67743. private _refreshColorGradient;
  67744. /** Force the system to rebuild all gradients that need to be resync */
  67745. forceRefreshGradients(): void;
  67746. /**
  67747. * Remove a specific color gradient
  67748. * @param gradient defines the gradient to remove
  67749. * @returns the current particle system
  67750. */
  67751. removeColorGradient(gradient: number): GPUParticleSystem;
  67752. private _angularSpeedGradientsTexture;
  67753. private _sizeGradientsTexture;
  67754. private _velocityGradientsTexture;
  67755. private _limitVelocityGradientsTexture;
  67756. private _dragGradientsTexture;
  67757. private _addFactorGradient;
  67758. /**
  67759. * Adds a new size gradient
  67760. * @param gradient defines the gradient to use (between 0 and 1)
  67761. * @param factor defines the size factor to affect to the specified gradient
  67762. * @returns the current particle system
  67763. */
  67764. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67765. /**
  67766. * Remove a specific size gradient
  67767. * @param gradient defines the gradient to remove
  67768. * @returns the current particle system
  67769. */
  67770. removeSizeGradient(gradient: number): GPUParticleSystem;
  67771. private _refreshFactorGradient;
  67772. /**
  67773. * Adds a new angular speed gradient
  67774. * @param gradient defines the gradient to use (between 0 and 1)
  67775. * @param factor defines the angular speed to affect to the specified gradient
  67776. * @returns the current particle system
  67777. */
  67778. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67779. /**
  67780. * Remove a specific angular speed gradient
  67781. * @param gradient defines the gradient to remove
  67782. * @returns the current particle system
  67783. */
  67784. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67785. /**
  67786. * Adds a new velocity gradient
  67787. * @param gradient defines the gradient to use (between 0 and 1)
  67788. * @param factor defines the velocity to affect to the specified gradient
  67789. * @returns the current particle system
  67790. */
  67791. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67792. /**
  67793. * Remove a specific velocity gradient
  67794. * @param gradient defines the gradient to remove
  67795. * @returns the current particle system
  67796. */
  67797. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67798. /**
  67799. * Adds a new limit velocity gradient
  67800. * @param gradient defines the gradient to use (between 0 and 1)
  67801. * @param factor defines the limit velocity value to affect to the specified gradient
  67802. * @returns the current particle system
  67803. */
  67804. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67805. /**
  67806. * Remove a specific limit velocity gradient
  67807. * @param gradient defines the gradient to remove
  67808. * @returns the current particle system
  67809. */
  67810. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67811. /**
  67812. * Adds a new drag gradient
  67813. * @param gradient defines the gradient to use (between 0 and 1)
  67814. * @param factor defines the drag value to affect to the specified gradient
  67815. * @returns the current particle system
  67816. */
  67817. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67818. /**
  67819. * Remove a specific drag gradient
  67820. * @param gradient defines the gradient to remove
  67821. * @returns the current particle system
  67822. */
  67823. removeDragGradient(gradient: number): GPUParticleSystem;
  67824. /**
  67825. * Not supported by GPUParticleSystem
  67826. * @param gradient defines the gradient to use (between 0 and 1)
  67827. * @param factor defines the emit rate value to affect to the specified gradient
  67828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67829. * @returns the current particle system
  67830. */
  67831. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67832. /**
  67833. * Not supported by GPUParticleSystem
  67834. * @param gradient defines the gradient to remove
  67835. * @returns the current particle system
  67836. */
  67837. removeEmitRateGradient(gradient: number): IParticleSystem;
  67838. /**
  67839. * Not supported by GPUParticleSystem
  67840. * @param gradient defines the gradient to use (between 0 and 1)
  67841. * @param factor defines the start size value to affect to the specified gradient
  67842. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67843. * @returns the current particle system
  67844. */
  67845. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67846. /**
  67847. * Not supported by GPUParticleSystem
  67848. * @param gradient defines the gradient to remove
  67849. * @returns the current particle system
  67850. */
  67851. removeStartSizeGradient(gradient: number): IParticleSystem;
  67852. /**
  67853. * Not supported by GPUParticleSystem
  67854. * @param gradient defines the gradient to use (between 0 and 1)
  67855. * @param min defines the color remap minimal range
  67856. * @param max defines the color remap maximal range
  67857. * @returns the current particle system
  67858. */
  67859. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67860. /**
  67861. * Not supported by GPUParticleSystem
  67862. * @param gradient defines the gradient to remove
  67863. * @returns the current particle system
  67864. */
  67865. removeColorRemapGradient(): IParticleSystem;
  67866. /**
  67867. * Not supported by GPUParticleSystem
  67868. * @param gradient defines the gradient to use (between 0 and 1)
  67869. * @param min defines the alpha remap minimal range
  67870. * @param max defines the alpha remap maximal range
  67871. * @returns the current particle system
  67872. */
  67873. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67874. /**
  67875. * Not supported by GPUParticleSystem
  67876. * @param gradient defines the gradient to remove
  67877. * @returns the current particle system
  67878. */
  67879. removeAlphaRemapGradient(): IParticleSystem;
  67880. /**
  67881. * Not supported by GPUParticleSystem
  67882. * @param gradient defines the gradient to use (between 0 and 1)
  67883. * @param color defines the color to affect to the specified gradient
  67884. * @returns the current particle system
  67885. */
  67886. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67887. /**
  67888. * Not supported by GPUParticleSystem
  67889. * @param gradient defines the gradient to remove
  67890. * @returns the current particle system
  67891. */
  67892. removeRampGradient(): IParticleSystem;
  67893. /**
  67894. * Not supported by GPUParticleSystem
  67895. * @returns the list of ramp gradients
  67896. */
  67897. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67898. /**
  67899. * Not supported by GPUParticleSystem
  67900. * Gets or sets a boolean indicating that ramp gradients must be used
  67901. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67902. */
  67903. get useRampGradients(): boolean;
  67904. set useRampGradients(value: boolean);
  67905. /**
  67906. * Not supported by GPUParticleSystem
  67907. * @param gradient defines the gradient to use (between 0 and 1)
  67908. * @param factor defines the life time factor to affect to the specified gradient
  67909. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67910. * @returns the current particle system
  67911. */
  67912. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67913. /**
  67914. * Not supported by GPUParticleSystem
  67915. * @param gradient defines the gradient to remove
  67916. * @returns the current particle system
  67917. */
  67918. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67919. /**
  67920. * Instantiates a GPU particle system.
  67921. * 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.
  67922. * @param name The name of the particle system
  67923. * @param options The options used to create the system
  67924. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67925. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67926. * @param customEffect a custom effect used to change the way particles are rendered by default
  67927. */
  67928. constructor(name: string, options: Partial<{
  67929. capacity: number;
  67930. randomTextureSize: number;
  67931. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67932. protected _reset(): void;
  67933. private _createUpdateVAO;
  67934. private _createRenderVAO;
  67935. private _initialize;
  67936. /** @hidden */
  67937. _recreateUpdateEffect(): void;
  67938. private _getEffect;
  67939. /**
  67940. * Fill the defines array according to the current settings of the particle system
  67941. * @param defines Array to be updated
  67942. * @param blendMode blend mode to take into account when updating the array
  67943. */
  67944. fillDefines(defines: Array<string>, blendMode?: number): void;
  67945. /**
  67946. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67947. * @param uniforms Uniforms array to fill
  67948. * @param attributes Attributes array to fill
  67949. * @param samplers Samplers array to fill
  67950. */
  67951. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67952. /** @hidden */
  67953. _recreateRenderEffect(): Effect;
  67954. /**
  67955. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67956. * @param preWarm defines if we are in the pre-warmimg phase
  67957. */
  67958. animate(preWarm?: boolean): void;
  67959. private _createFactorGradientTexture;
  67960. private _createSizeGradientTexture;
  67961. private _createAngularSpeedGradientTexture;
  67962. private _createVelocityGradientTexture;
  67963. private _createLimitVelocityGradientTexture;
  67964. private _createDragGradientTexture;
  67965. private _createColorGradientTexture;
  67966. /**
  67967. * Renders the particle system in its current state
  67968. * @param preWarm defines if the system should only update the particles but not render them
  67969. * @returns the current number of particles
  67970. */
  67971. render(preWarm?: boolean): number;
  67972. /**
  67973. * Rebuilds the particle system
  67974. */
  67975. rebuild(): void;
  67976. private _releaseBuffers;
  67977. private _releaseVAOs;
  67978. /**
  67979. * Disposes the particle system and free the associated resources
  67980. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67981. */
  67982. dispose(disposeTexture?: boolean): void;
  67983. /**
  67984. * Clones the particle system.
  67985. * @param name The name of the cloned object
  67986. * @param newEmitter The new emitter to use
  67987. * @returns the cloned particle system
  67988. */
  67989. clone(name: string, newEmitter: any): GPUParticleSystem;
  67990. /**
  67991. * Serializes the particle system to a JSON object
  67992. * @param serializeTexture defines if the texture must be serialized as well
  67993. * @returns the JSON object
  67994. */
  67995. serialize(serializeTexture?: boolean): any;
  67996. /**
  67997. * Parses a JSON object to create a GPU particle system.
  67998. * @param parsedParticleSystem The JSON object to parse
  67999. * @param sceneOrEngine The scene or the engine to create the particle system in
  68000. * @param rootUrl The root url to use to load external dependencies like texture
  68001. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68002. * @returns the parsed GPU particle system
  68003. */
  68004. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68005. }
  68006. }
  68007. declare module BABYLON {
  68008. /**
  68009. * Represents a set of particle systems working together to create a specific effect
  68010. */
  68011. export class ParticleSystemSet implements IDisposable {
  68012. /**
  68013. * Gets or sets base Assets URL
  68014. */
  68015. static BaseAssetsUrl: string;
  68016. private _emitterCreationOptions;
  68017. private _emitterNode;
  68018. /**
  68019. * Gets the particle system list
  68020. */
  68021. systems: IParticleSystem[];
  68022. /**
  68023. * Gets the emitter node used with this set
  68024. */
  68025. get emitterNode(): Nullable<TransformNode>;
  68026. /**
  68027. * Creates a new emitter mesh as a sphere
  68028. * @param options defines the options used to create the sphere
  68029. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68030. * @param scene defines the hosting scene
  68031. */
  68032. setEmitterAsSphere(options: {
  68033. diameter: number;
  68034. segments: number;
  68035. color: Color3;
  68036. }, renderingGroupId: number, scene: Scene): void;
  68037. /**
  68038. * Starts all particle systems of the set
  68039. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68040. */
  68041. start(emitter?: AbstractMesh): void;
  68042. /**
  68043. * Release all associated resources
  68044. */
  68045. dispose(): void;
  68046. /**
  68047. * Serialize the set into a JSON compatible object
  68048. * @param serializeTexture defines if the texture must be serialized as well
  68049. * @returns a JSON compatible representation of the set
  68050. */
  68051. serialize(serializeTexture?: boolean): any;
  68052. /**
  68053. * Parse a new ParticleSystemSet from a serialized source
  68054. * @param data defines a JSON compatible representation of the set
  68055. * @param scene defines the hosting scene
  68056. * @param gpu defines if we want GPU particles or CPU particles
  68057. * @returns a new ParticleSystemSet
  68058. */
  68059. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68060. }
  68061. }
  68062. declare module BABYLON {
  68063. /**
  68064. * This class is made for on one-liner static method to help creating particle system set.
  68065. */
  68066. export class ParticleHelper {
  68067. /**
  68068. * Gets or sets base Assets URL
  68069. */
  68070. static BaseAssetsUrl: string;
  68071. /** Define the Url to load snippets */
  68072. static SnippetUrl: string;
  68073. /**
  68074. * Create a default particle system that you can tweak
  68075. * @param emitter defines the emitter to use
  68076. * @param capacity defines the system capacity (default is 500 particles)
  68077. * @param scene defines the hosting scene
  68078. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68079. * @returns the new Particle system
  68080. */
  68081. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68082. /**
  68083. * This is the main static method (one-liner) of this helper to create different particle systems
  68084. * @param type This string represents the type to the particle system to create
  68085. * @param scene The scene where the particle system should live
  68086. * @param gpu If the system will use gpu
  68087. * @returns the ParticleSystemSet created
  68088. */
  68089. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68090. /**
  68091. * Static function used to export a particle system to a ParticleSystemSet variable.
  68092. * Please note that the emitter shape is not exported
  68093. * @param systems defines the particle systems to export
  68094. * @returns the created particle system set
  68095. */
  68096. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68097. /**
  68098. * Creates a particle system from a snippet saved in a remote file
  68099. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68100. * @param url defines the url to load from
  68101. * @param scene defines the hosting scene
  68102. * @param gpu If the system will use gpu
  68103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68104. * @returns a promise that will resolve to the new particle system
  68105. */
  68106. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68107. /**
  68108. * Creates a particle system from a snippet saved by the particle system editor
  68109. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68110. * @param scene defines the hosting scene
  68111. * @param gpu If the system will use gpu
  68112. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68113. * @returns a promise that will resolve to the new particle system
  68114. */
  68115. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68116. }
  68117. }
  68118. declare module BABYLON {
  68119. interface Engine {
  68120. /**
  68121. * Create an effect to use with particle systems.
  68122. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68123. * the particle system for which you want to create a custom effect in the last parameter
  68124. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68125. * @param uniformsNames defines a list of attribute names
  68126. * @param samplers defines an array of string used to represent textures
  68127. * @param defines defines the string containing the defines to use to compile the shaders
  68128. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68129. * @param onCompiled defines a function to call when the effect creation is successful
  68130. * @param onError defines a function to call when the effect creation has failed
  68131. * @param particleSystem the particle system you want to create the effect for
  68132. * @returns the new Effect
  68133. */
  68134. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68135. }
  68136. interface Mesh {
  68137. /**
  68138. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68139. * @returns an array of IParticleSystem
  68140. */
  68141. getEmittedParticleSystems(): IParticleSystem[];
  68142. /**
  68143. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68144. * @returns an array of IParticleSystem
  68145. */
  68146. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68147. }
  68148. }
  68149. declare module BABYLON {
  68150. /** Defines the 4 color options */
  68151. export enum PointColor {
  68152. /** color value */
  68153. Color = 2,
  68154. /** uv value */
  68155. UV = 1,
  68156. /** random value */
  68157. Random = 0,
  68158. /** stated value */
  68159. Stated = 3
  68160. }
  68161. /**
  68162. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68163. * 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.
  68164. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68165. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68166. *
  68167. * Full documentation here : TO BE ENTERED
  68168. */
  68169. export class PointsCloudSystem implements IDisposable {
  68170. /**
  68171. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68172. * Example : var p = SPS.particles[i];
  68173. */
  68174. particles: CloudPoint[];
  68175. /**
  68176. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68177. */
  68178. nbParticles: number;
  68179. /**
  68180. * This a counter for your own usage. It's not set by any SPS functions.
  68181. */
  68182. counter: number;
  68183. /**
  68184. * The PCS name. This name is also given to the underlying mesh.
  68185. */
  68186. name: string;
  68187. /**
  68188. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68189. */
  68190. mesh: Mesh;
  68191. /**
  68192. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68193. * Please read :
  68194. */
  68195. vars: any;
  68196. /**
  68197. * @hidden
  68198. */
  68199. _size: number;
  68200. private _scene;
  68201. private _promises;
  68202. private _positions;
  68203. private _indices;
  68204. private _normals;
  68205. private _colors;
  68206. private _uvs;
  68207. private _indices32;
  68208. private _positions32;
  68209. private _colors32;
  68210. private _uvs32;
  68211. private _updatable;
  68212. private _isVisibilityBoxLocked;
  68213. private _alwaysVisible;
  68214. private _groups;
  68215. private _groupCounter;
  68216. private _computeParticleColor;
  68217. private _computeParticleTexture;
  68218. private _computeParticleRotation;
  68219. private _computeBoundingBox;
  68220. private _isReady;
  68221. /**
  68222. * Creates a PCS (Points Cloud System) object
  68223. * @param name (String) is the PCS name, this will be the underlying mesh name
  68224. * @param pointSize (number) is the size for each point
  68225. * @param scene (Scene) is the scene in which the PCS is added
  68226. * @param options defines the options of the PCS e.g.
  68227. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68228. */
  68229. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68230. updatable?: boolean;
  68231. });
  68232. /**
  68233. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68234. * If no points were added to the PCS, the returned mesh is just a single point.
  68235. * @returns a promise for the created mesh
  68236. */
  68237. buildMeshAsync(): Promise<Mesh>;
  68238. /**
  68239. * @hidden
  68240. */
  68241. private _buildMesh;
  68242. private _addParticle;
  68243. private _randomUnitVector;
  68244. private _getColorIndicesForCoord;
  68245. private _setPointsColorOrUV;
  68246. private _colorFromTexture;
  68247. private _calculateDensity;
  68248. /**
  68249. * Adds points to the PCS in random positions within a unit sphere
  68250. * @param nb (positive integer) the number of particles to be created from this model
  68251. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68252. * @returns the number of groups in the system
  68253. */
  68254. addPoints(nb: number, pointFunction?: any): number;
  68255. /**
  68256. * Adds points to the PCS from the surface of the model shape
  68257. * @param mesh is any Mesh object that will be used as a surface model for the points
  68258. * @param nb (positive integer) the number of particles to be created from this model
  68259. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68260. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68261. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68262. * @returns the number of groups in the system
  68263. */
  68264. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68265. /**
  68266. * Adds points to the PCS inside the model shape
  68267. * @param mesh is any Mesh object that will be used as a surface model for the points
  68268. * @param nb (positive integer) the number of particles to be created from this model
  68269. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68270. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68271. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68272. * @returns the number of groups in the system
  68273. */
  68274. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68275. /**
  68276. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68277. * This method calls `updateParticle()` for each particle of the SPS.
  68278. * For an animated SPS, it is usually called within the render loop.
  68279. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68280. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68281. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68282. * @returns the PCS.
  68283. */
  68284. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68285. /**
  68286. * Disposes the PCS.
  68287. */
  68288. dispose(): void;
  68289. /**
  68290. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68291. * doc :
  68292. * @returns the PCS.
  68293. */
  68294. refreshVisibleSize(): PointsCloudSystem;
  68295. /**
  68296. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68297. * @param size the size (float) of the visibility box
  68298. * note : this doesn't lock the PCS mesh bounding box.
  68299. * doc :
  68300. */
  68301. setVisibilityBox(size: number): void;
  68302. /**
  68303. * Gets whether the PCS is always visible or not
  68304. * doc :
  68305. */
  68306. get isAlwaysVisible(): boolean;
  68307. /**
  68308. * Sets the PCS as always visible or not
  68309. * doc :
  68310. */
  68311. set isAlwaysVisible(val: boolean);
  68312. /**
  68313. * Tells to `setParticles()` to compute the particle rotations or not
  68314. * Default value : false. The PCS is faster when it's set to false
  68315. * Note : particle rotations are only applied to parent particles
  68316. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68317. */
  68318. set computeParticleRotation(val: boolean);
  68319. /**
  68320. * Tells to `setParticles()` to compute the particle colors or not.
  68321. * Default value : true. The PCS is faster when it's set to false.
  68322. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68323. */
  68324. set computeParticleColor(val: boolean);
  68325. set computeParticleTexture(val: boolean);
  68326. /**
  68327. * Gets if `setParticles()` computes the particle colors or not.
  68328. * Default value : false. The PCS is faster when it's set to false.
  68329. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68330. */
  68331. get computeParticleColor(): boolean;
  68332. /**
  68333. * Gets if `setParticles()` computes the particle textures or not.
  68334. * Default value : false. The PCS is faster when it's set to false.
  68335. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68336. */
  68337. get computeParticleTexture(): boolean;
  68338. /**
  68339. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68340. */
  68341. set computeBoundingBox(val: boolean);
  68342. /**
  68343. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68344. */
  68345. get computeBoundingBox(): boolean;
  68346. /**
  68347. * This function does nothing. It may be overwritten to set all the particle first values.
  68348. * The PCS doesn't call this function, you may have to call it by your own.
  68349. * doc :
  68350. */
  68351. initParticles(): void;
  68352. /**
  68353. * This function does nothing. It may be overwritten to recycle a particle
  68354. * The PCS doesn't call this function, you can to call it
  68355. * doc :
  68356. * @param particle The particle to recycle
  68357. * @returns the recycled particle
  68358. */
  68359. recycleParticle(particle: CloudPoint): CloudPoint;
  68360. /**
  68361. * Updates a particle : this function should be overwritten by the user.
  68362. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68363. * doc :
  68364. * @example : just set a particle position or velocity and recycle conditions
  68365. * @param particle The particle to update
  68366. * @returns the updated particle
  68367. */
  68368. updateParticle(particle: CloudPoint): CloudPoint;
  68369. /**
  68370. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68371. * This does nothing and may be overwritten by the user.
  68372. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68373. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68374. * @param update the boolean update value actually passed to setParticles()
  68375. */
  68376. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68377. /**
  68378. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68379. * This will be passed three parameters.
  68380. * This does nothing and may be overwritten by the user.
  68381. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68382. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68383. * @param update the boolean update value actually passed to setParticles()
  68384. */
  68385. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /**
  68390. * Represents one particle of a points cloud system.
  68391. */
  68392. export class CloudPoint {
  68393. /**
  68394. * particle global index
  68395. */
  68396. idx: number;
  68397. /**
  68398. * The color of the particle
  68399. */
  68400. color: Nullable<Color4>;
  68401. /**
  68402. * The world space position of the particle.
  68403. */
  68404. position: Vector3;
  68405. /**
  68406. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68407. */
  68408. rotation: Vector3;
  68409. /**
  68410. * The world space rotation quaternion of the particle.
  68411. */
  68412. rotationQuaternion: Nullable<Quaternion>;
  68413. /**
  68414. * The uv of the particle.
  68415. */
  68416. uv: Nullable<Vector2>;
  68417. /**
  68418. * The current speed of the particle.
  68419. */
  68420. velocity: Vector3;
  68421. /**
  68422. * The pivot point in the particle local space.
  68423. */
  68424. pivot: Vector3;
  68425. /**
  68426. * Must the particle be translated from its pivot point in its local space ?
  68427. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68428. * Default : false
  68429. */
  68430. translateFromPivot: boolean;
  68431. /**
  68432. * Index of this particle in the global "positions" array (Internal use)
  68433. * @hidden
  68434. */
  68435. _pos: number;
  68436. /**
  68437. * @hidden Index of this particle in the global "indices" array (Internal use)
  68438. */
  68439. _ind: number;
  68440. /**
  68441. * Group this particle belongs to
  68442. */
  68443. _group: PointsGroup;
  68444. /**
  68445. * Group id of this particle
  68446. */
  68447. groupId: number;
  68448. /**
  68449. * Index of the particle in its group id (Internal use)
  68450. */
  68451. idxInGroup: number;
  68452. /**
  68453. * @hidden Particle BoundingInfo object (Internal use)
  68454. */
  68455. _boundingInfo: BoundingInfo;
  68456. /**
  68457. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68458. */
  68459. _pcs: PointsCloudSystem;
  68460. /**
  68461. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68462. */
  68463. _stillInvisible: boolean;
  68464. /**
  68465. * @hidden Last computed particle rotation matrix
  68466. */
  68467. _rotationMatrix: number[];
  68468. /**
  68469. * Parent particle Id, if any.
  68470. * Default null.
  68471. */
  68472. parentId: Nullable<number>;
  68473. /**
  68474. * @hidden Internal global position in the PCS.
  68475. */
  68476. _globalPosition: Vector3;
  68477. /**
  68478. * Creates a Point Cloud object.
  68479. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68480. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68481. * @param group (PointsGroup) is the group the particle belongs to
  68482. * @param groupId (integer) is the group identifier in the PCS.
  68483. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68484. * @param pcs defines the PCS it is associated to
  68485. */
  68486. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68487. /**
  68488. * get point size
  68489. */
  68490. get size(): Vector3;
  68491. /**
  68492. * Set point size
  68493. */
  68494. set size(scale: Vector3);
  68495. /**
  68496. * Legacy support, changed quaternion to rotationQuaternion
  68497. */
  68498. get quaternion(): Nullable<Quaternion>;
  68499. /**
  68500. * Legacy support, changed quaternion to rotationQuaternion
  68501. */
  68502. set quaternion(q: Nullable<Quaternion>);
  68503. /**
  68504. * Returns a boolean. True if the particle intersects a mesh, else false
  68505. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68506. * @param target is the object (point or mesh) what the intersection is computed against
  68507. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68508. * @returns true if it intersects
  68509. */
  68510. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68511. /**
  68512. * get the rotation matrix of the particle
  68513. * @hidden
  68514. */
  68515. getRotationMatrix(m: Matrix): void;
  68516. }
  68517. /**
  68518. * Represents a group of points in a points cloud system
  68519. * * PCS internal tool, don't use it manually.
  68520. */
  68521. export class PointsGroup {
  68522. /**
  68523. * The group id
  68524. * @hidden
  68525. */
  68526. groupID: number;
  68527. /**
  68528. * image data for group (internal use)
  68529. * @hidden
  68530. */
  68531. _groupImageData: Nullable<ArrayBufferView>;
  68532. /**
  68533. * Image Width (internal use)
  68534. * @hidden
  68535. */
  68536. _groupImgWidth: number;
  68537. /**
  68538. * Image Height (internal use)
  68539. * @hidden
  68540. */
  68541. _groupImgHeight: number;
  68542. /**
  68543. * Custom position function (internal use)
  68544. * @hidden
  68545. */
  68546. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68547. /**
  68548. * density per facet for surface points
  68549. * @hidden
  68550. */
  68551. _groupDensity: number[];
  68552. /**
  68553. * Only when points are colored by texture carries pointer to texture list array
  68554. * @hidden
  68555. */
  68556. _textureNb: number;
  68557. /**
  68558. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68559. * PCS internal tool, don't use it manually.
  68560. * @hidden
  68561. */
  68562. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68563. }
  68564. }
  68565. declare module BABYLON {
  68566. interface Scene {
  68567. /** @hidden (Backing field) */
  68568. _physicsEngine: Nullable<IPhysicsEngine>;
  68569. /** @hidden */
  68570. _physicsTimeAccumulator: number;
  68571. /**
  68572. * Gets the current physics engine
  68573. * @returns a IPhysicsEngine or null if none attached
  68574. */
  68575. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68576. /**
  68577. * Enables physics to the current scene
  68578. * @param gravity defines the scene's gravity for the physics engine
  68579. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68580. * @return a boolean indicating if the physics engine was initialized
  68581. */
  68582. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68583. /**
  68584. * Disables and disposes the physics engine associated with the scene
  68585. */
  68586. disablePhysicsEngine(): void;
  68587. /**
  68588. * Gets a boolean indicating if there is an active physics engine
  68589. * @returns a boolean indicating if there is an active physics engine
  68590. */
  68591. isPhysicsEnabled(): boolean;
  68592. /**
  68593. * Deletes a physics compound impostor
  68594. * @param compound defines the compound to delete
  68595. */
  68596. deleteCompoundImpostor(compound: any): void;
  68597. /**
  68598. * An event triggered when physic simulation is about to be run
  68599. */
  68600. onBeforePhysicsObservable: Observable<Scene>;
  68601. /**
  68602. * An event triggered when physic simulation has been done
  68603. */
  68604. onAfterPhysicsObservable: Observable<Scene>;
  68605. }
  68606. interface AbstractMesh {
  68607. /** @hidden */
  68608. _physicsImpostor: Nullable<PhysicsImpostor>;
  68609. /**
  68610. * Gets or sets impostor used for physic simulation
  68611. * @see https://doc.babylonjs.com/features/physics_engine
  68612. */
  68613. physicsImpostor: Nullable<PhysicsImpostor>;
  68614. /**
  68615. * Gets the current physics impostor
  68616. * @see https://doc.babylonjs.com/features/physics_engine
  68617. * @returns a physics impostor or null
  68618. */
  68619. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68620. /** Apply a physic impulse to the mesh
  68621. * @param force defines the force to apply
  68622. * @param contactPoint defines where to apply the force
  68623. * @returns the current mesh
  68624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68625. */
  68626. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68627. /**
  68628. * Creates a physic joint between two meshes
  68629. * @param otherMesh defines the other mesh to use
  68630. * @param pivot1 defines the pivot to use on this mesh
  68631. * @param pivot2 defines the pivot to use on the other mesh
  68632. * @param options defines additional options (can be plugin dependent)
  68633. * @returns the current mesh
  68634. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68635. */
  68636. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68637. /** @hidden */
  68638. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68639. }
  68640. /**
  68641. * Defines the physics engine scene component responsible to manage a physics engine
  68642. */
  68643. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68644. /**
  68645. * The component name helpful to identify the component in the list of scene components.
  68646. */
  68647. readonly name: string;
  68648. /**
  68649. * The scene the component belongs to.
  68650. */
  68651. scene: Scene;
  68652. /**
  68653. * Creates a new instance of the component for the given scene
  68654. * @param scene Defines the scene to register the component in
  68655. */
  68656. constructor(scene: Scene);
  68657. /**
  68658. * Registers the component in a given scene
  68659. */
  68660. register(): void;
  68661. /**
  68662. * Rebuilds the elements related to this component in case of
  68663. * context lost for instance.
  68664. */
  68665. rebuild(): void;
  68666. /**
  68667. * Disposes the component and the associated ressources
  68668. */
  68669. dispose(): void;
  68670. }
  68671. }
  68672. declare module BABYLON {
  68673. /**
  68674. * A helper for physics simulations
  68675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68676. */
  68677. export class PhysicsHelper {
  68678. private _scene;
  68679. private _physicsEngine;
  68680. /**
  68681. * Initializes the Physics helper
  68682. * @param scene Babylon.js scene
  68683. */
  68684. constructor(scene: Scene);
  68685. /**
  68686. * Applies a radial explosion impulse
  68687. * @param origin the origin of the explosion
  68688. * @param radiusOrEventOptions the radius or the options of radial explosion
  68689. * @param strength the explosion strength
  68690. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68691. * @returns A physics radial explosion event, or null
  68692. */
  68693. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68694. /**
  68695. * Applies a radial explosion force
  68696. * @param origin the origin of the explosion
  68697. * @param radiusOrEventOptions the radius or the options of radial explosion
  68698. * @param strength the explosion strength
  68699. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68700. * @returns A physics radial explosion event, or null
  68701. */
  68702. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68703. /**
  68704. * Creates a gravitational field
  68705. * @param origin the origin of the explosion
  68706. * @param radiusOrEventOptions the radius or the options of radial explosion
  68707. * @param strength the explosion strength
  68708. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68709. * @returns A physics gravitational field event, or null
  68710. */
  68711. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68712. /**
  68713. * Creates a physics updraft event
  68714. * @param origin the origin of the updraft
  68715. * @param radiusOrEventOptions the radius or the options of the updraft
  68716. * @param strength the strength of the updraft
  68717. * @param height the height of the updraft
  68718. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68719. * @returns A physics updraft event, or null
  68720. */
  68721. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68722. /**
  68723. * Creates a physics vortex event
  68724. * @param origin the of the vortex
  68725. * @param radiusOrEventOptions the radius or the options of the vortex
  68726. * @param strength the strength of the vortex
  68727. * @param height the height of the vortex
  68728. * @returns a Physics vortex event, or null
  68729. * A physics vortex event or null
  68730. */
  68731. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68732. }
  68733. /**
  68734. * Represents a physics radial explosion event
  68735. */
  68736. class PhysicsRadialExplosionEvent {
  68737. private _scene;
  68738. private _options;
  68739. private _sphere;
  68740. private _dataFetched;
  68741. /**
  68742. * Initializes a radial explosioin event
  68743. * @param _scene BabylonJS scene
  68744. * @param _options The options for the vortex event
  68745. */
  68746. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68747. /**
  68748. * Returns the data related to the radial explosion event (sphere).
  68749. * @returns The radial explosion event data
  68750. */
  68751. getData(): PhysicsRadialExplosionEventData;
  68752. /**
  68753. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68754. * @param impostor A physics imposter
  68755. * @param origin the origin of the explosion
  68756. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68757. */
  68758. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68759. /**
  68760. * Triggers affecterd impostors callbacks
  68761. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68762. */
  68763. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68764. /**
  68765. * Disposes the sphere.
  68766. * @param force Specifies if the sphere should be disposed by force
  68767. */
  68768. dispose(force?: boolean): void;
  68769. /*** Helpers ***/
  68770. private _prepareSphere;
  68771. private _intersectsWithSphere;
  68772. }
  68773. /**
  68774. * Represents a gravitational field event
  68775. */
  68776. class PhysicsGravitationalFieldEvent {
  68777. private _physicsHelper;
  68778. private _scene;
  68779. private _origin;
  68780. private _options;
  68781. private _tickCallback;
  68782. private _sphere;
  68783. private _dataFetched;
  68784. /**
  68785. * Initializes the physics gravitational field event
  68786. * @param _physicsHelper A physics helper
  68787. * @param _scene BabylonJS scene
  68788. * @param _origin The origin position of the gravitational field event
  68789. * @param _options The options for the vortex event
  68790. */
  68791. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68792. /**
  68793. * Returns the data related to the gravitational field event (sphere).
  68794. * @returns A gravitational field event
  68795. */
  68796. getData(): PhysicsGravitationalFieldEventData;
  68797. /**
  68798. * Enables the gravitational field.
  68799. */
  68800. enable(): void;
  68801. /**
  68802. * Disables the gravitational field.
  68803. */
  68804. disable(): void;
  68805. /**
  68806. * Disposes the sphere.
  68807. * @param force The force to dispose from the gravitational field event
  68808. */
  68809. dispose(force?: boolean): void;
  68810. private _tick;
  68811. }
  68812. /**
  68813. * Represents a physics updraft event
  68814. */
  68815. class PhysicsUpdraftEvent {
  68816. private _scene;
  68817. private _origin;
  68818. private _options;
  68819. private _physicsEngine;
  68820. private _originTop;
  68821. private _originDirection;
  68822. private _tickCallback;
  68823. private _cylinder;
  68824. private _cylinderPosition;
  68825. private _dataFetched;
  68826. /**
  68827. * Initializes the physics updraft event
  68828. * @param _scene BabylonJS scene
  68829. * @param _origin The origin position of the updraft
  68830. * @param _options The options for the updraft event
  68831. */
  68832. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68833. /**
  68834. * Returns the data related to the updraft event (cylinder).
  68835. * @returns A physics updraft event
  68836. */
  68837. getData(): PhysicsUpdraftEventData;
  68838. /**
  68839. * Enables the updraft.
  68840. */
  68841. enable(): void;
  68842. /**
  68843. * Disables the updraft.
  68844. */
  68845. disable(): void;
  68846. /**
  68847. * Disposes the cylinder.
  68848. * @param force Specifies if the updraft should be disposed by force
  68849. */
  68850. dispose(force?: boolean): void;
  68851. private getImpostorHitData;
  68852. private _tick;
  68853. /*** Helpers ***/
  68854. private _prepareCylinder;
  68855. private _intersectsWithCylinder;
  68856. }
  68857. /**
  68858. * Represents a physics vortex event
  68859. */
  68860. class PhysicsVortexEvent {
  68861. private _scene;
  68862. private _origin;
  68863. private _options;
  68864. private _physicsEngine;
  68865. private _originTop;
  68866. private _tickCallback;
  68867. private _cylinder;
  68868. private _cylinderPosition;
  68869. private _dataFetched;
  68870. /**
  68871. * Initializes the physics vortex event
  68872. * @param _scene The BabylonJS scene
  68873. * @param _origin The origin position of the vortex
  68874. * @param _options The options for the vortex event
  68875. */
  68876. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68877. /**
  68878. * Returns the data related to the vortex event (cylinder).
  68879. * @returns The physics vortex event data
  68880. */
  68881. getData(): PhysicsVortexEventData;
  68882. /**
  68883. * Enables the vortex.
  68884. */
  68885. enable(): void;
  68886. /**
  68887. * Disables the cortex.
  68888. */
  68889. disable(): void;
  68890. /**
  68891. * Disposes the sphere.
  68892. * @param force
  68893. */
  68894. dispose(force?: boolean): void;
  68895. private getImpostorHitData;
  68896. private _tick;
  68897. /*** Helpers ***/
  68898. private _prepareCylinder;
  68899. private _intersectsWithCylinder;
  68900. }
  68901. /**
  68902. * Options fot the radial explosion event
  68903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68904. */
  68905. export class PhysicsRadialExplosionEventOptions {
  68906. /**
  68907. * The radius of the sphere for the radial explosion.
  68908. */
  68909. radius: number;
  68910. /**
  68911. * The strenth of the explosion.
  68912. */
  68913. strength: number;
  68914. /**
  68915. * The strenght of the force in correspondence to the distance of the affected object
  68916. */
  68917. falloff: PhysicsRadialImpulseFalloff;
  68918. /**
  68919. * Sphere options for the radial explosion.
  68920. */
  68921. sphere: {
  68922. segments: number;
  68923. diameter: number;
  68924. };
  68925. /**
  68926. * Sphere options for the radial explosion.
  68927. */
  68928. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68929. }
  68930. /**
  68931. * Options fot the updraft event
  68932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68933. */
  68934. export class PhysicsUpdraftEventOptions {
  68935. /**
  68936. * The radius of the cylinder for the vortex
  68937. */
  68938. radius: number;
  68939. /**
  68940. * The strenth of the updraft.
  68941. */
  68942. strength: number;
  68943. /**
  68944. * The height of the cylinder for the updraft.
  68945. */
  68946. height: number;
  68947. /**
  68948. * The mode for the the updraft.
  68949. */
  68950. updraftMode: PhysicsUpdraftMode;
  68951. }
  68952. /**
  68953. * Options fot the vortex event
  68954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68955. */
  68956. export class PhysicsVortexEventOptions {
  68957. /**
  68958. * The radius of the cylinder for the vortex
  68959. */
  68960. radius: number;
  68961. /**
  68962. * The strenth of the vortex.
  68963. */
  68964. strength: number;
  68965. /**
  68966. * The height of the cylinder for the vortex.
  68967. */
  68968. height: number;
  68969. /**
  68970. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68971. */
  68972. centripetalForceThreshold: number;
  68973. /**
  68974. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68975. */
  68976. centripetalForceMultiplier: number;
  68977. /**
  68978. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68979. */
  68980. centrifugalForceMultiplier: number;
  68981. /**
  68982. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68983. */
  68984. updraftForceMultiplier: number;
  68985. }
  68986. /**
  68987. * The strenght of the force in correspondence to the distance of the affected object
  68988. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68989. */
  68990. export enum PhysicsRadialImpulseFalloff {
  68991. /** Defines that impulse is constant in strength across it's whole radius */
  68992. Constant = 0,
  68993. /** Defines that impulse gets weaker if it's further from the origin */
  68994. Linear = 1
  68995. }
  68996. /**
  68997. * The strength of the force in correspondence to the distance of the affected object
  68998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68999. */
  69000. export enum PhysicsUpdraftMode {
  69001. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69002. Center = 0,
  69003. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69004. Perpendicular = 1
  69005. }
  69006. /**
  69007. * Interface for a physics hit data
  69008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69009. */
  69010. export interface PhysicsHitData {
  69011. /**
  69012. * The force applied at the contact point
  69013. */
  69014. force: Vector3;
  69015. /**
  69016. * The contact point
  69017. */
  69018. contactPoint: Vector3;
  69019. /**
  69020. * The distance from the origin to the contact point
  69021. */
  69022. distanceFromOrigin: number;
  69023. }
  69024. /**
  69025. * Interface for radial explosion event data
  69026. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69027. */
  69028. export interface PhysicsRadialExplosionEventData {
  69029. /**
  69030. * A sphere used for the radial explosion event
  69031. */
  69032. sphere: Mesh;
  69033. }
  69034. /**
  69035. * Interface for gravitational field event data
  69036. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69037. */
  69038. export interface PhysicsGravitationalFieldEventData {
  69039. /**
  69040. * A sphere mesh used for the gravitational field event
  69041. */
  69042. sphere: Mesh;
  69043. }
  69044. /**
  69045. * Interface for updraft event data
  69046. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69047. */
  69048. export interface PhysicsUpdraftEventData {
  69049. /**
  69050. * A cylinder used for the updraft event
  69051. */
  69052. cylinder: Mesh;
  69053. }
  69054. /**
  69055. * Interface for vortex event data
  69056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69057. */
  69058. export interface PhysicsVortexEventData {
  69059. /**
  69060. * A cylinder used for the vortex event
  69061. */
  69062. cylinder: Mesh;
  69063. }
  69064. /**
  69065. * Interface for an affected physics impostor
  69066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69067. */
  69068. export interface PhysicsAffectedImpostorWithData {
  69069. /**
  69070. * The impostor affected by the effect
  69071. */
  69072. impostor: PhysicsImpostor;
  69073. /**
  69074. * The data about the hit/horce from the explosion
  69075. */
  69076. hitData: PhysicsHitData;
  69077. }
  69078. }
  69079. declare module BABYLON {
  69080. /** @hidden */
  69081. export var blackAndWhitePixelShader: {
  69082. name: string;
  69083. shader: string;
  69084. };
  69085. }
  69086. declare module BABYLON {
  69087. /**
  69088. * Post process used to render in black and white
  69089. */
  69090. export class BlackAndWhitePostProcess extends PostProcess {
  69091. /**
  69092. * Linear about to convert he result to black and white (default: 1)
  69093. */
  69094. degree: number;
  69095. /**
  69096. * Gets a string identifying the name of the class
  69097. * @returns "BlackAndWhitePostProcess" string
  69098. */
  69099. getClassName(): string;
  69100. /**
  69101. * Creates a black and white post process
  69102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69103. * @param name The name of the effect.
  69104. * @param options The required width/height ratio to downsize to before computing the render pass.
  69105. * @param camera The camera to apply the render pass to.
  69106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69107. * @param engine The engine which the post process will be applied. (default: current engine)
  69108. * @param reusable If the post process can be reused on the same frame. (default: false)
  69109. */
  69110. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69111. /** @hidden */
  69112. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69113. }
  69114. }
  69115. declare module BABYLON {
  69116. /**
  69117. * This represents a set of one or more post processes in Babylon.
  69118. * A post process can be used to apply a shader to a texture after it is rendered.
  69119. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69120. */
  69121. export class PostProcessRenderEffect {
  69122. private _postProcesses;
  69123. private _getPostProcesses;
  69124. private _singleInstance;
  69125. private _cameras;
  69126. private _indicesForCamera;
  69127. /**
  69128. * Name of the effect
  69129. * @hidden
  69130. */
  69131. _name: string;
  69132. /**
  69133. * Instantiates a post process render effect.
  69134. * A post process can be used to apply a shader to a texture after it is rendered.
  69135. * @param engine The engine the effect is tied to
  69136. * @param name The name of the effect
  69137. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69138. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69139. */
  69140. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69141. /**
  69142. * Checks if all the post processes in the effect are supported.
  69143. */
  69144. get isSupported(): boolean;
  69145. /**
  69146. * Updates the current state of the effect
  69147. * @hidden
  69148. */
  69149. _update(): void;
  69150. /**
  69151. * Attaches the effect on cameras
  69152. * @param cameras The camera to attach to.
  69153. * @hidden
  69154. */
  69155. _attachCameras(cameras: Camera): void;
  69156. /**
  69157. * Attaches the effect on cameras
  69158. * @param cameras The camera to attach to.
  69159. * @hidden
  69160. */
  69161. _attachCameras(cameras: Camera[]): void;
  69162. /**
  69163. * Detaches the effect on cameras
  69164. * @param cameras The camera to detatch from.
  69165. * @hidden
  69166. */
  69167. _detachCameras(cameras: Camera): void;
  69168. /**
  69169. * Detatches the effect on cameras
  69170. * @param cameras The camera to detatch from.
  69171. * @hidden
  69172. */
  69173. _detachCameras(cameras: Camera[]): void;
  69174. /**
  69175. * Enables the effect on given cameras
  69176. * @param cameras The camera to enable.
  69177. * @hidden
  69178. */
  69179. _enable(cameras: Camera): void;
  69180. /**
  69181. * Enables the effect on given cameras
  69182. * @param cameras The camera to enable.
  69183. * @hidden
  69184. */
  69185. _enable(cameras: Nullable<Camera[]>): void;
  69186. /**
  69187. * Disables the effect on the given cameras
  69188. * @param cameras The camera to disable.
  69189. * @hidden
  69190. */
  69191. _disable(cameras: Camera): void;
  69192. /**
  69193. * Disables the effect on the given cameras
  69194. * @param cameras The camera to disable.
  69195. * @hidden
  69196. */
  69197. _disable(cameras: Nullable<Camera[]>): void;
  69198. /**
  69199. * Gets a list of the post processes contained in the effect.
  69200. * @param camera The camera to get the post processes on.
  69201. * @returns The list of the post processes in the effect.
  69202. */
  69203. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69204. }
  69205. }
  69206. declare module BABYLON {
  69207. /** @hidden */
  69208. export var extractHighlightsPixelShader: {
  69209. name: string;
  69210. shader: string;
  69211. };
  69212. }
  69213. declare module BABYLON {
  69214. /**
  69215. * 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.
  69216. */
  69217. export class ExtractHighlightsPostProcess extends PostProcess {
  69218. /**
  69219. * The luminance threshold, pixels below this value will be set to black.
  69220. */
  69221. threshold: number;
  69222. /** @hidden */
  69223. _exposure: number;
  69224. /**
  69225. * Post process which has the input texture to be used when performing highlight extraction
  69226. * @hidden
  69227. */
  69228. _inputPostProcess: Nullable<PostProcess>;
  69229. /**
  69230. * Gets a string identifying the name of the class
  69231. * @returns "ExtractHighlightsPostProcess" string
  69232. */
  69233. getClassName(): string;
  69234. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69235. }
  69236. }
  69237. declare module BABYLON {
  69238. /** @hidden */
  69239. export var bloomMergePixelShader: {
  69240. name: string;
  69241. shader: string;
  69242. };
  69243. }
  69244. declare module BABYLON {
  69245. /**
  69246. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69247. */
  69248. export class BloomMergePostProcess extends PostProcess {
  69249. /** Weight of the bloom to be added to the original input. */
  69250. weight: number;
  69251. /**
  69252. * Gets a string identifying the name of the class
  69253. * @returns "BloomMergePostProcess" string
  69254. */
  69255. getClassName(): string;
  69256. /**
  69257. * Creates a new instance of @see BloomMergePostProcess
  69258. * @param name The name of the effect.
  69259. * @param originalFromInput Post process which's input will be used for the merge.
  69260. * @param blurred Blurred highlights post process which's output will be used.
  69261. * @param weight Weight of the bloom to be added to the original input.
  69262. * @param options The required width/height ratio to downsize to before computing the render pass.
  69263. * @param camera The camera to apply the render pass to.
  69264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69265. * @param engine The engine which the post process will be applied. (default: current engine)
  69266. * @param reusable If the post process can be reused on the same frame. (default: false)
  69267. * @param textureType Type of textures used when performing the post process. (default: 0)
  69268. * @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)
  69269. */
  69270. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69271. /** Weight of the bloom to be added to the original input. */
  69272. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69273. }
  69274. }
  69275. declare module BABYLON {
  69276. /**
  69277. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69278. */
  69279. export class BloomEffect extends PostProcessRenderEffect {
  69280. private bloomScale;
  69281. /**
  69282. * @hidden Internal
  69283. */
  69284. _effects: Array<PostProcess>;
  69285. /**
  69286. * @hidden Internal
  69287. */
  69288. _downscale: ExtractHighlightsPostProcess;
  69289. private _blurX;
  69290. private _blurY;
  69291. private _merge;
  69292. /**
  69293. * The luminance threshold to find bright areas of the image to bloom.
  69294. */
  69295. get threshold(): number;
  69296. set threshold(value: number);
  69297. /**
  69298. * The strength of the bloom.
  69299. */
  69300. get weight(): number;
  69301. set weight(value: number);
  69302. /**
  69303. * Specifies the size of the bloom blur kernel, relative to the final output size
  69304. */
  69305. get kernel(): number;
  69306. set kernel(value: number);
  69307. /**
  69308. * Creates a new instance of @see BloomEffect
  69309. * @param scene The scene the effect belongs to.
  69310. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69311. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69312. * @param bloomWeight The the strength of bloom.
  69313. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69314. * @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)
  69315. */
  69316. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69317. /**
  69318. * Disposes each of the internal effects for a given camera.
  69319. * @param camera The camera to dispose the effect on.
  69320. */
  69321. disposeEffects(camera: Camera): void;
  69322. /**
  69323. * @hidden Internal
  69324. */
  69325. _updateEffects(): void;
  69326. /**
  69327. * Internal
  69328. * @returns if all the contained post processes are ready.
  69329. * @hidden
  69330. */
  69331. _isReady(): boolean;
  69332. }
  69333. }
  69334. declare module BABYLON {
  69335. /** @hidden */
  69336. export var chromaticAberrationPixelShader: {
  69337. name: string;
  69338. shader: string;
  69339. };
  69340. }
  69341. declare module BABYLON {
  69342. /**
  69343. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69344. */
  69345. export class ChromaticAberrationPostProcess extends PostProcess {
  69346. /**
  69347. * The amount of seperation of rgb channels (default: 30)
  69348. */
  69349. aberrationAmount: number;
  69350. /**
  69351. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69352. */
  69353. radialIntensity: number;
  69354. /**
  69355. * 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))
  69356. */
  69357. direction: Vector2;
  69358. /**
  69359. * 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))
  69360. */
  69361. centerPosition: Vector2;
  69362. /** The width of the screen to apply the effect on */
  69363. screenWidth: number;
  69364. /** The height of the screen to apply the effect on */
  69365. screenHeight: number;
  69366. /**
  69367. * Gets a string identifying the name of the class
  69368. * @returns "ChromaticAberrationPostProcess" string
  69369. */
  69370. getClassName(): string;
  69371. /**
  69372. * Creates a new instance ChromaticAberrationPostProcess
  69373. * @param name The name of the effect.
  69374. * @param screenWidth The width of the screen to apply the effect on.
  69375. * @param screenHeight The height of the screen to apply the effect on.
  69376. * @param options The required width/height ratio to downsize to before computing the render pass.
  69377. * @param camera The camera to apply the render pass to.
  69378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69379. * @param engine The engine which the post process will be applied. (default: current engine)
  69380. * @param reusable If the post process can be reused on the same frame. (default: false)
  69381. * @param textureType Type of textures used when performing the post process. (default: 0)
  69382. * @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)
  69383. */
  69384. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69385. /** @hidden */
  69386. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69387. }
  69388. }
  69389. declare module BABYLON {
  69390. /** @hidden */
  69391. export var circleOfConfusionPixelShader: {
  69392. name: string;
  69393. shader: string;
  69394. };
  69395. }
  69396. declare module BABYLON {
  69397. /**
  69398. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69399. */
  69400. export class CircleOfConfusionPostProcess extends PostProcess {
  69401. /**
  69402. * 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.
  69403. */
  69404. lensSize: number;
  69405. /**
  69406. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69407. */
  69408. fStop: number;
  69409. /**
  69410. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69411. */
  69412. focusDistance: number;
  69413. /**
  69414. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69415. */
  69416. focalLength: number;
  69417. /**
  69418. * Gets a string identifying the name of the class
  69419. * @returns "CircleOfConfusionPostProcess" string
  69420. */
  69421. getClassName(): string;
  69422. private _depthTexture;
  69423. /**
  69424. * Creates a new instance CircleOfConfusionPostProcess
  69425. * @param name The name of the effect.
  69426. * @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.
  69427. * @param options The required width/height ratio to downsize to before computing the render pass.
  69428. * @param camera The camera to apply the render pass to.
  69429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69430. * @param engine The engine which the post process will be applied. (default: current engine)
  69431. * @param reusable If the post process can be reused on the same frame. (default: false)
  69432. * @param textureType Type of textures used when performing the post process. (default: 0)
  69433. * @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)
  69434. */
  69435. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69436. /**
  69437. * 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.
  69438. */
  69439. set depthTexture(value: RenderTargetTexture);
  69440. }
  69441. }
  69442. declare module BABYLON {
  69443. /** @hidden */
  69444. export var colorCorrectionPixelShader: {
  69445. name: string;
  69446. shader: string;
  69447. };
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. *
  69452. * This post-process allows the modification of rendered colors by using
  69453. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69454. *
  69455. * The object needs to be provided an url to a texture containing the color
  69456. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69457. * Use an image editing software to tweak the LUT to match your needs.
  69458. *
  69459. * For an example of a color LUT, see here:
  69460. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69461. * For explanations on color grading, see here:
  69462. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69463. *
  69464. */
  69465. export class ColorCorrectionPostProcess extends PostProcess {
  69466. private _colorTableTexture;
  69467. /**
  69468. * Gets the color table url used to create the LUT texture
  69469. */
  69470. colorTableUrl: string;
  69471. /**
  69472. * Gets a string identifying the name of the class
  69473. * @returns "ColorCorrectionPostProcess" string
  69474. */
  69475. getClassName(): string;
  69476. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69477. /** @hidden */
  69478. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69479. }
  69480. }
  69481. declare module BABYLON {
  69482. /** @hidden */
  69483. export var convolutionPixelShader: {
  69484. name: string;
  69485. shader: string;
  69486. };
  69487. }
  69488. declare module BABYLON {
  69489. /**
  69490. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69491. * input texture to perform effects such as edge detection or sharpening
  69492. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69493. */
  69494. export class ConvolutionPostProcess extends PostProcess {
  69495. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69496. kernel: number[];
  69497. /**
  69498. * Gets a string identifying the name of the class
  69499. * @returns "ConvolutionPostProcess" string
  69500. */
  69501. getClassName(): string;
  69502. /**
  69503. * Creates a new instance ConvolutionPostProcess
  69504. * @param name The name of the effect.
  69505. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69506. * @param options The required width/height ratio to downsize to before computing the render pass.
  69507. * @param camera The camera to apply the render pass to.
  69508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69509. * @param engine The engine which the post process will be applied. (default: current engine)
  69510. * @param reusable If the post process can be reused on the same frame. (default: false)
  69511. * @param textureType Type of textures used when performing the post process. (default: 0)
  69512. */
  69513. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69514. /** @hidden */
  69515. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69516. /**
  69517. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69518. */
  69519. static EdgeDetect0Kernel: number[];
  69520. /**
  69521. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69522. */
  69523. static EdgeDetect1Kernel: number[];
  69524. /**
  69525. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69526. */
  69527. static EdgeDetect2Kernel: number[];
  69528. /**
  69529. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69530. */
  69531. static SharpenKernel: number[];
  69532. /**
  69533. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69534. */
  69535. static EmbossKernel: number[];
  69536. /**
  69537. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69538. */
  69539. static GaussianKernel: number[];
  69540. }
  69541. }
  69542. declare module BABYLON {
  69543. /**
  69544. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69545. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69546. * based on samples that have a large difference in distance than the center pixel.
  69547. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69548. */
  69549. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69550. /**
  69551. * The direction the blur should be applied
  69552. */
  69553. direction: Vector2;
  69554. /**
  69555. * Gets a string identifying the name of the class
  69556. * @returns "DepthOfFieldBlurPostProcess" string
  69557. */
  69558. getClassName(): string;
  69559. /**
  69560. * Creates a new instance CircleOfConfusionPostProcess
  69561. * @param name The name of the effect.
  69562. * @param scene The scene the effect belongs to.
  69563. * @param direction The direction the blur should be applied.
  69564. * @param kernel The size of the kernel used to blur.
  69565. * @param options The required width/height ratio to downsize to before computing the render pass.
  69566. * @param camera The camera to apply the render pass to.
  69567. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69568. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69570. * @param engine The engine which the post process will be applied. (default: current engine)
  69571. * @param reusable If the post process can be reused on the same frame. (default: false)
  69572. * @param textureType Type of textures used when performing the post process. (default: 0)
  69573. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  69574. */
  69575. constructor(name: string, 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);
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /** @hidden */
  69580. export var depthOfFieldMergePixelShader: {
  69581. name: string;
  69582. shader: string;
  69583. };
  69584. }
  69585. declare module BABYLON {
  69586. /**
  69587. * Options to be set when merging outputs from the default pipeline.
  69588. */
  69589. export class DepthOfFieldMergePostProcessOptions {
  69590. /**
  69591. * The original image to merge on top of
  69592. */
  69593. originalFromInput: PostProcess;
  69594. /**
  69595. * Parameters to perform the merge of the depth of field effect
  69596. */
  69597. depthOfField?: {
  69598. circleOfConfusion: PostProcess;
  69599. blurSteps: Array<PostProcess>;
  69600. };
  69601. /**
  69602. * Parameters to perform the merge of bloom effect
  69603. */
  69604. bloom?: {
  69605. blurred: PostProcess;
  69606. weight: number;
  69607. };
  69608. }
  69609. /**
  69610. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69611. */
  69612. export class DepthOfFieldMergePostProcess extends PostProcess {
  69613. private blurSteps;
  69614. /**
  69615. * Gets a string identifying the name of the class
  69616. * @returns "DepthOfFieldMergePostProcess" string
  69617. */
  69618. getClassName(): string;
  69619. /**
  69620. * Creates a new instance of DepthOfFieldMergePostProcess
  69621. * @param name The name of the effect.
  69622. * @param originalFromInput Post process which's input will be used for the merge.
  69623. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69624. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69625. * @param options The required width/height ratio to downsize to before computing the render pass.
  69626. * @param camera The camera to apply the render pass to.
  69627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69628. * @param engine The engine which the post process will be applied. (default: current engine)
  69629. * @param reusable If the post process can be reused on the same frame. (default: false)
  69630. * @param textureType Type of textures used when performing the post process. (default: 0)
  69631. * @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)
  69632. */
  69633. 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);
  69634. /**
  69635. * Updates the effect with the current post process compile time values and recompiles the shader.
  69636. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69637. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69638. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69639. * @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
  69640. * @param onCompiled Called when the shader has been compiled.
  69641. * @param onError Called if there is an error when compiling a shader.
  69642. */
  69643. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69644. }
  69645. }
  69646. declare module BABYLON {
  69647. /**
  69648. * Specifies the level of max blur that should be applied when using the depth of field effect
  69649. */
  69650. export enum DepthOfFieldEffectBlurLevel {
  69651. /**
  69652. * Subtle blur
  69653. */
  69654. Low = 0,
  69655. /**
  69656. * Medium blur
  69657. */
  69658. Medium = 1,
  69659. /**
  69660. * Large blur
  69661. */
  69662. High = 2
  69663. }
  69664. /**
  69665. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69666. */
  69667. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69668. private _circleOfConfusion;
  69669. /**
  69670. * @hidden Internal, blurs from high to low
  69671. */
  69672. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69673. private _depthOfFieldBlurY;
  69674. private _dofMerge;
  69675. /**
  69676. * @hidden Internal post processes in depth of field effect
  69677. */
  69678. _effects: Array<PostProcess>;
  69679. /**
  69680. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69681. */
  69682. set focalLength(value: number);
  69683. get focalLength(): number;
  69684. /**
  69685. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69686. */
  69687. set fStop(value: number);
  69688. get fStop(): number;
  69689. /**
  69690. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69691. */
  69692. set focusDistance(value: number);
  69693. get focusDistance(): number;
  69694. /**
  69695. * 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.
  69696. */
  69697. set lensSize(value: number);
  69698. get lensSize(): number;
  69699. /**
  69700. * Creates a new instance DepthOfFieldEffect
  69701. * @param scene The scene the effect belongs to.
  69702. * @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.
  69703. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69704. * @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)
  69705. */
  69706. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69707. /**
  69708. * Get the current class name of the current effet
  69709. * @returns "DepthOfFieldEffect"
  69710. */
  69711. getClassName(): string;
  69712. /**
  69713. * 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.
  69714. */
  69715. set depthTexture(value: RenderTargetTexture);
  69716. /**
  69717. * Disposes each of the internal effects for a given camera.
  69718. * @param camera The camera to dispose the effect on.
  69719. */
  69720. disposeEffects(camera: Camera): void;
  69721. /**
  69722. * @hidden Internal
  69723. */
  69724. _updateEffects(): void;
  69725. /**
  69726. * Internal
  69727. * @returns if all the contained post processes are ready.
  69728. * @hidden
  69729. */
  69730. _isReady(): boolean;
  69731. }
  69732. }
  69733. declare module BABYLON {
  69734. /** @hidden */
  69735. export var displayPassPixelShader: {
  69736. name: string;
  69737. shader: string;
  69738. };
  69739. }
  69740. declare module BABYLON {
  69741. /**
  69742. * DisplayPassPostProcess which produces an output the same as it's input
  69743. */
  69744. export class DisplayPassPostProcess extends PostProcess {
  69745. /**
  69746. * Gets a string identifying the name of the class
  69747. * @returns "DisplayPassPostProcess" string
  69748. */
  69749. getClassName(): string;
  69750. /**
  69751. * Creates the DisplayPassPostProcess
  69752. * @param name The name of the effect.
  69753. * @param options The required width/height ratio to downsize to before computing the render pass.
  69754. * @param camera The camera to apply the render pass to.
  69755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69756. * @param engine The engine which the post process will be applied. (default: current engine)
  69757. * @param reusable If the post process can be reused on the same frame. (default: false)
  69758. */
  69759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69760. /** @hidden */
  69761. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69762. }
  69763. }
  69764. declare module BABYLON {
  69765. /** @hidden */
  69766. export var filterPixelShader: {
  69767. name: string;
  69768. shader: string;
  69769. };
  69770. }
  69771. declare module BABYLON {
  69772. /**
  69773. * Applies a kernel filter to the image
  69774. */
  69775. export class FilterPostProcess extends PostProcess {
  69776. /** The matrix to be applied to the image */
  69777. kernelMatrix: Matrix;
  69778. /**
  69779. * Gets a string identifying the name of the class
  69780. * @returns "FilterPostProcess" string
  69781. */
  69782. getClassName(): string;
  69783. /**
  69784. *
  69785. * @param name The name of the effect.
  69786. * @param kernelMatrix The matrix to be applied to the image
  69787. * @param options The required width/height ratio to downsize to before computing the render pass.
  69788. * @param camera The camera to apply the render pass to.
  69789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69790. * @param engine The engine which the post process will be applied. (default: current engine)
  69791. * @param reusable If the post process can be reused on the same frame. (default: false)
  69792. */
  69793. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69794. /** @hidden */
  69795. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69796. }
  69797. }
  69798. declare module BABYLON {
  69799. /** @hidden */
  69800. export var fxaaPixelShader: {
  69801. name: string;
  69802. shader: string;
  69803. };
  69804. }
  69805. declare module BABYLON {
  69806. /** @hidden */
  69807. export var fxaaVertexShader: {
  69808. name: string;
  69809. shader: string;
  69810. };
  69811. }
  69812. declare module BABYLON {
  69813. /**
  69814. * Fxaa post process
  69815. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69816. */
  69817. export class FxaaPostProcess extends PostProcess {
  69818. /**
  69819. * Gets a string identifying the name of the class
  69820. * @returns "FxaaPostProcess" string
  69821. */
  69822. getClassName(): string;
  69823. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69824. private _getDefines;
  69825. /** @hidden */
  69826. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69827. }
  69828. }
  69829. declare module BABYLON {
  69830. /** @hidden */
  69831. export var grainPixelShader: {
  69832. name: string;
  69833. shader: string;
  69834. };
  69835. }
  69836. declare module BABYLON {
  69837. /**
  69838. * The GrainPostProcess adds noise to the image at mid luminance levels
  69839. */
  69840. export class GrainPostProcess extends PostProcess {
  69841. /**
  69842. * The intensity of the grain added (default: 30)
  69843. */
  69844. intensity: number;
  69845. /**
  69846. * If the grain should be randomized on every frame
  69847. */
  69848. animated: boolean;
  69849. /**
  69850. * Gets a string identifying the name of the class
  69851. * @returns "GrainPostProcess" string
  69852. */
  69853. getClassName(): string;
  69854. /**
  69855. * Creates a new instance of @see GrainPostProcess
  69856. * @param name The name of the effect.
  69857. * @param options The required width/height ratio to downsize to before computing the render pass.
  69858. * @param camera The camera to apply the render pass to.
  69859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69860. * @param engine The engine which the post process will be applied. (default: current engine)
  69861. * @param reusable If the post process can be reused on the same frame. (default: false)
  69862. * @param textureType Type of textures used when performing the post process. (default: 0)
  69863. * @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)
  69864. */
  69865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69866. /** @hidden */
  69867. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69868. }
  69869. }
  69870. declare module BABYLON {
  69871. /** @hidden */
  69872. export var highlightsPixelShader: {
  69873. name: string;
  69874. shader: string;
  69875. };
  69876. }
  69877. declare module BABYLON {
  69878. /**
  69879. * Extracts highlights from the image
  69880. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69881. */
  69882. export class HighlightsPostProcess extends PostProcess {
  69883. /**
  69884. * Gets a string identifying the name of the class
  69885. * @returns "HighlightsPostProcess" string
  69886. */
  69887. getClassName(): string;
  69888. /**
  69889. * Extracts highlights from the image
  69890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69891. * @param name The name of the effect.
  69892. * @param options The required width/height ratio to downsize to before computing the render pass.
  69893. * @param camera The camera to apply the render pass to.
  69894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69895. * @param engine The engine which the post process will be applied. (default: current engine)
  69896. * @param reusable If the post process can be reused on the same frame. (default: false)
  69897. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69898. */
  69899. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. /** @hidden */
  69904. export var mrtFragmentDeclaration: {
  69905. name: string;
  69906. shader: string;
  69907. };
  69908. }
  69909. declare module BABYLON {
  69910. /** @hidden */
  69911. export var geometryPixelShader: {
  69912. name: string;
  69913. shader: string;
  69914. };
  69915. }
  69916. declare module BABYLON {
  69917. /** @hidden */
  69918. export var geometryVertexShader: {
  69919. name: string;
  69920. shader: string;
  69921. };
  69922. }
  69923. declare module BABYLON {
  69924. /** @hidden */
  69925. interface ISavedTransformationMatrix {
  69926. world: Matrix;
  69927. viewProjection: Matrix;
  69928. }
  69929. /**
  69930. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69931. */
  69932. export class GeometryBufferRenderer {
  69933. /**
  69934. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69935. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69936. */
  69937. static readonly POSITION_TEXTURE_TYPE: number;
  69938. /**
  69939. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69940. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69941. */
  69942. static readonly VELOCITY_TEXTURE_TYPE: number;
  69943. /**
  69944. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69945. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69946. */
  69947. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69948. /**
  69949. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69950. * in order to compute objects velocities when enableVelocity is set to "true"
  69951. * @hidden
  69952. */
  69953. _previousTransformationMatrices: {
  69954. [index: number]: ISavedTransformationMatrix;
  69955. };
  69956. /**
  69957. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69958. * in order to compute objects velocities when enableVelocity is set to "true"
  69959. * @hidden
  69960. */
  69961. _previousBonesTransformationMatrices: {
  69962. [index: number]: Float32Array;
  69963. };
  69964. /**
  69965. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69966. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69967. */
  69968. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69969. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69970. renderTransparentMeshes: boolean;
  69971. private _scene;
  69972. private _resizeObserver;
  69973. private _multiRenderTarget;
  69974. private _ratio;
  69975. private _enablePosition;
  69976. private _enableVelocity;
  69977. private _enableReflectivity;
  69978. private _positionIndex;
  69979. private _velocityIndex;
  69980. private _reflectivityIndex;
  69981. protected _effect: Effect;
  69982. protected _cachedDefines: string;
  69983. /**
  69984. * Set the render list (meshes to be rendered) used in the G buffer.
  69985. */
  69986. set renderList(meshes: Mesh[]);
  69987. /**
  69988. * Gets wether or not G buffer are supported by the running hardware.
  69989. * This requires draw buffer supports
  69990. */
  69991. get isSupported(): boolean;
  69992. /**
  69993. * Returns the index of the given texture type in the G-Buffer textures array
  69994. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69995. * @returns the index of the given texture type in the G-Buffer textures array
  69996. */
  69997. getTextureIndex(textureType: number): number;
  69998. /**
  69999. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70000. */
  70001. get enablePosition(): boolean;
  70002. /**
  70003. * Sets whether or not objects positions are enabled for the G buffer.
  70004. */
  70005. set enablePosition(enable: boolean);
  70006. /**
  70007. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70008. */
  70009. get enableVelocity(): boolean;
  70010. /**
  70011. * Sets wether or not objects velocities are enabled for the G buffer.
  70012. */
  70013. set enableVelocity(enable: boolean);
  70014. /**
  70015. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70016. */
  70017. get enableReflectivity(): boolean;
  70018. /**
  70019. * Sets wether or not objects roughness are enabled for the G buffer.
  70020. */
  70021. set enableReflectivity(enable: boolean);
  70022. /**
  70023. * Gets the scene associated with the buffer.
  70024. */
  70025. get scene(): Scene;
  70026. /**
  70027. * Gets the ratio used by the buffer during its creation.
  70028. * How big is the buffer related to the main canvas.
  70029. */
  70030. get ratio(): number;
  70031. /** @hidden */
  70032. static _SceneComponentInitialization: (scene: Scene) => void;
  70033. /**
  70034. * Creates a new G Buffer for the scene
  70035. * @param scene The scene the buffer belongs to
  70036. * @param ratio How big is the buffer related to the main canvas.
  70037. */
  70038. constructor(scene: Scene, ratio?: number);
  70039. /**
  70040. * Checks wether everything is ready to render a submesh to the G buffer.
  70041. * @param subMesh the submesh to check readiness for
  70042. * @param useInstances is the mesh drawn using instance or not
  70043. * @returns true if ready otherwise false
  70044. */
  70045. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70046. /**
  70047. * Gets the current underlying G Buffer.
  70048. * @returns the buffer
  70049. */
  70050. getGBuffer(): MultiRenderTarget;
  70051. /**
  70052. * Gets the number of samples used to render the buffer (anti aliasing).
  70053. */
  70054. get samples(): number;
  70055. /**
  70056. * Sets the number of samples used to render the buffer (anti aliasing).
  70057. */
  70058. set samples(value: number);
  70059. /**
  70060. * Disposes the renderer and frees up associated resources.
  70061. */
  70062. dispose(): void;
  70063. protected _createRenderTargets(): void;
  70064. private _copyBonesTransformationMatrices;
  70065. }
  70066. }
  70067. declare module BABYLON {
  70068. interface Scene {
  70069. /** @hidden (Backing field) */
  70070. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70071. /**
  70072. * Gets or Sets the current geometry buffer associated to the scene.
  70073. */
  70074. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70075. /**
  70076. * Enables a GeometryBufferRender and associates it with the scene
  70077. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70078. * @returns the GeometryBufferRenderer
  70079. */
  70080. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70081. /**
  70082. * Disables the GeometryBufferRender associated with the scene
  70083. */
  70084. disableGeometryBufferRenderer(): void;
  70085. }
  70086. /**
  70087. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70088. * in several rendering techniques.
  70089. */
  70090. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70091. /**
  70092. * The component name helpful to identify the component in the list of scene components.
  70093. */
  70094. readonly name: string;
  70095. /**
  70096. * The scene the component belongs to.
  70097. */
  70098. scene: Scene;
  70099. /**
  70100. * Creates a new instance of the component for the given scene
  70101. * @param scene Defines the scene to register the component in
  70102. */
  70103. constructor(scene: Scene);
  70104. /**
  70105. * Registers the component in a given scene
  70106. */
  70107. register(): void;
  70108. /**
  70109. * Rebuilds the elements related to this component in case of
  70110. * context lost for instance.
  70111. */
  70112. rebuild(): void;
  70113. /**
  70114. * Disposes the component and the associated ressources
  70115. */
  70116. dispose(): void;
  70117. private _gatherRenderTargets;
  70118. }
  70119. }
  70120. declare module BABYLON {
  70121. /** @hidden */
  70122. export var motionBlurPixelShader: {
  70123. name: string;
  70124. shader: string;
  70125. };
  70126. }
  70127. declare module BABYLON {
  70128. /**
  70129. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70130. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70131. * As an example, all you have to do is to create the post-process:
  70132. * var mb = new BABYLON.MotionBlurPostProcess(
  70133. * 'mb', // The name of the effect.
  70134. * scene, // The scene containing the objects to blur according to their velocity.
  70135. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70136. * camera // The camera to apply the render pass to.
  70137. * );
  70138. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70139. */
  70140. export class MotionBlurPostProcess extends PostProcess {
  70141. /**
  70142. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70143. */
  70144. motionStrength: number;
  70145. /**
  70146. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70147. */
  70148. get motionBlurSamples(): number;
  70149. /**
  70150. * Sets the number of iterations to be used for motion blur quality
  70151. */
  70152. set motionBlurSamples(samples: number);
  70153. private _motionBlurSamples;
  70154. private _geometryBufferRenderer;
  70155. /**
  70156. * Gets a string identifying the name of the class
  70157. * @returns "MotionBlurPostProcess" string
  70158. */
  70159. getClassName(): string;
  70160. /**
  70161. * Creates a new instance MotionBlurPostProcess
  70162. * @param name The name of the effect.
  70163. * @param scene The scene containing the objects to blur according to their velocity.
  70164. * @param options The required width/height ratio to downsize to before computing the render pass.
  70165. * @param camera The camera to apply the render pass to.
  70166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70167. * @param engine The engine which the post process will be applied. (default: current engine)
  70168. * @param reusable If the post process can be reused on the same frame. (default: false)
  70169. * @param textureType Type of textures used when performing the post process. (default: 0)
  70170. * @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)
  70171. */
  70172. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70173. /**
  70174. * Excludes the given skinned mesh from computing bones velocities.
  70175. * 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.
  70176. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70177. */
  70178. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70179. /**
  70180. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70181. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70182. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70183. */
  70184. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70185. /**
  70186. * Disposes the post process.
  70187. * @param camera The camera to dispose the post process on.
  70188. */
  70189. dispose(camera?: Camera): void;
  70190. /** @hidden */
  70191. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70192. }
  70193. }
  70194. declare module BABYLON {
  70195. /** @hidden */
  70196. export var refractionPixelShader: {
  70197. name: string;
  70198. shader: string;
  70199. };
  70200. }
  70201. declare module BABYLON {
  70202. /**
  70203. * Post process which applies a refractin texture
  70204. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70205. */
  70206. export class RefractionPostProcess extends PostProcess {
  70207. private _refTexture;
  70208. private _ownRefractionTexture;
  70209. /** the base color of the refraction (used to taint the rendering) */
  70210. color: Color3;
  70211. /** simulated refraction depth */
  70212. depth: number;
  70213. /** the coefficient of the base color (0 to remove base color tainting) */
  70214. colorLevel: number;
  70215. /** Gets the url used to load the refraction texture */
  70216. refractionTextureUrl: string;
  70217. /**
  70218. * Gets or sets the refraction texture
  70219. * Please note that you are responsible for disposing the texture if you set it manually
  70220. */
  70221. get refractionTexture(): Texture;
  70222. set refractionTexture(value: Texture);
  70223. /**
  70224. * Gets a string identifying the name of the class
  70225. * @returns "RefractionPostProcess" string
  70226. */
  70227. getClassName(): string;
  70228. /**
  70229. * Initializes the RefractionPostProcess
  70230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70231. * @param name The name of the effect.
  70232. * @param refractionTextureUrl Url of the refraction texture to use
  70233. * @param color the base color of the refraction (used to taint the rendering)
  70234. * @param depth simulated refraction depth
  70235. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70236. * @param camera The camera to apply the render pass to.
  70237. * @param options The required width/height ratio to downsize to before computing the render pass.
  70238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70239. * @param engine The engine which the post process will be applied. (default: current engine)
  70240. * @param reusable If the post process can be reused on the same frame. (default: false)
  70241. */
  70242. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70243. /**
  70244. * Disposes of the post process
  70245. * @param camera Camera to dispose post process on
  70246. */
  70247. dispose(camera: Camera): void;
  70248. /** @hidden */
  70249. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70250. }
  70251. }
  70252. declare module BABYLON {
  70253. /** @hidden */
  70254. export var sharpenPixelShader: {
  70255. name: string;
  70256. shader: string;
  70257. };
  70258. }
  70259. declare module BABYLON {
  70260. /**
  70261. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70262. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70263. */
  70264. export class SharpenPostProcess extends PostProcess {
  70265. /**
  70266. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70267. */
  70268. colorAmount: number;
  70269. /**
  70270. * How much sharpness should be applied (default: 0.3)
  70271. */
  70272. edgeAmount: number;
  70273. /**
  70274. * Gets a string identifying the name of the class
  70275. * @returns "SharpenPostProcess" string
  70276. */
  70277. getClassName(): string;
  70278. /**
  70279. * Creates a new instance ConvolutionPostProcess
  70280. * @param name The name of the effect.
  70281. * @param options The required width/height ratio to downsize to before computing the render pass.
  70282. * @param camera The camera to apply the render pass to.
  70283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70284. * @param engine The engine which the post process will be applied. (default: current engine)
  70285. * @param reusable If the post process can be reused on the same frame. (default: false)
  70286. * @param textureType Type of textures used when performing the post process. (default: 0)
  70287. * @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)
  70288. */
  70289. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70290. /** @hidden */
  70291. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70292. }
  70293. }
  70294. declare module BABYLON {
  70295. /**
  70296. * PostProcessRenderPipeline
  70297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70298. */
  70299. export class PostProcessRenderPipeline {
  70300. private engine;
  70301. private _renderEffects;
  70302. private _renderEffectsForIsolatedPass;
  70303. /**
  70304. * List of inspectable custom properties (used by the Inspector)
  70305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70306. */
  70307. inspectableCustomProperties: IInspectable[];
  70308. /**
  70309. * @hidden
  70310. */
  70311. protected _cameras: Camera[];
  70312. /** @hidden */
  70313. _name: string;
  70314. /**
  70315. * Gets pipeline name
  70316. */
  70317. get name(): string;
  70318. /** Gets the list of attached cameras */
  70319. get cameras(): Camera[];
  70320. /**
  70321. * Initializes a PostProcessRenderPipeline
  70322. * @param engine engine to add the pipeline to
  70323. * @param name name of the pipeline
  70324. */
  70325. constructor(engine: Engine, name: string);
  70326. /**
  70327. * Gets the class name
  70328. * @returns "PostProcessRenderPipeline"
  70329. */
  70330. getClassName(): string;
  70331. /**
  70332. * If all the render effects in the pipeline are supported
  70333. */
  70334. get isSupported(): boolean;
  70335. /**
  70336. * Adds an effect to the pipeline
  70337. * @param renderEffect the effect to add
  70338. */
  70339. addEffect(renderEffect: PostProcessRenderEffect): void;
  70340. /** @hidden */
  70341. _rebuild(): void;
  70342. /** @hidden */
  70343. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70344. /** @hidden */
  70345. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70346. /** @hidden */
  70347. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70348. /** @hidden */
  70349. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70350. /** @hidden */
  70351. _attachCameras(cameras: Camera, unique: boolean): void;
  70352. /** @hidden */
  70353. _attachCameras(cameras: Camera[], unique: boolean): void;
  70354. /** @hidden */
  70355. _detachCameras(cameras: Camera): void;
  70356. /** @hidden */
  70357. _detachCameras(cameras: Nullable<Camera[]>): void;
  70358. /** @hidden */
  70359. _update(): void;
  70360. /** @hidden */
  70361. _reset(): void;
  70362. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70363. /**
  70364. * Sets the required values to the prepass renderer.
  70365. * @param prePassRenderer defines the prepass renderer to setup.
  70366. * @returns true if the pre pass is needed.
  70367. */
  70368. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70369. /**
  70370. * Disposes of the pipeline
  70371. */
  70372. dispose(): void;
  70373. }
  70374. }
  70375. declare module BABYLON {
  70376. /**
  70377. * PostProcessRenderPipelineManager class
  70378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70379. */
  70380. export class PostProcessRenderPipelineManager {
  70381. private _renderPipelines;
  70382. /**
  70383. * Initializes a PostProcessRenderPipelineManager
  70384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70385. */
  70386. constructor();
  70387. /**
  70388. * Gets the list of supported render pipelines
  70389. */
  70390. get supportedPipelines(): PostProcessRenderPipeline[];
  70391. /**
  70392. * Adds a pipeline to the manager
  70393. * @param renderPipeline The pipeline to add
  70394. */
  70395. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70396. /**
  70397. * Attaches a camera to the pipeline
  70398. * @param renderPipelineName The name of the pipeline to attach to
  70399. * @param cameras the camera to attach
  70400. * @param unique if the camera can be attached multiple times to the pipeline
  70401. */
  70402. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70403. /**
  70404. * Detaches a camera from the pipeline
  70405. * @param renderPipelineName The name of the pipeline to detach from
  70406. * @param cameras the camera to detach
  70407. */
  70408. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70409. /**
  70410. * Enables an effect by name on a pipeline
  70411. * @param renderPipelineName the name of the pipeline to enable the effect in
  70412. * @param renderEffectName the name of the effect to enable
  70413. * @param cameras the cameras that the effect should be enabled on
  70414. */
  70415. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70416. /**
  70417. * Disables an effect by name on a pipeline
  70418. * @param renderPipelineName the name of the pipeline to disable the effect in
  70419. * @param renderEffectName the name of the effect to disable
  70420. * @param cameras the cameras that the effect should be disabled on
  70421. */
  70422. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70423. /**
  70424. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70425. */
  70426. update(): void;
  70427. /** @hidden */
  70428. _rebuild(): void;
  70429. /**
  70430. * Disposes of the manager and pipelines
  70431. */
  70432. dispose(): void;
  70433. }
  70434. }
  70435. declare module BABYLON {
  70436. interface Scene {
  70437. /** @hidden (Backing field) */
  70438. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70439. /**
  70440. * Gets the postprocess render pipeline manager
  70441. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70442. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70443. */
  70444. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70445. }
  70446. /**
  70447. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70448. */
  70449. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70450. /**
  70451. * The component name helpfull to identify the component in the list of scene components.
  70452. */
  70453. readonly name: string;
  70454. /**
  70455. * The scene the component belongs to.
  70456. */
  70457. scene: Scene;
  70458. /**
  70459. * Creates a new instance of the component for the given scene
  70460. * @param scene Defines the scene to register the component in
  70461. */
  70462. constructor(scene: Scene);
  70463. /**
  70464. * Registers the component in a given scene
  70465. */
  70466. register(): void;
  70467. /**
  70468. * Rebuilds the elements related to this component in case of
  70469. * context lost for instance.
  70470. */
  70471. rebuild(): void;
  70472. /**
  70473. * Disposes the component and the associated ressources
  70474. */
  70475. dispose(): void;
  70476. private _gatherRenderTargets;
  70477. }
  70478. }
  70479. declare module BABYLON {
  70480. /**
  70481. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70482. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70483. */
  70484. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70485. private _scene;
  70486. private _camerasToBeAttached;
  70487. /**
  70488. * ID of the sharpen post process,
  70489. */
  70490. private readonly SharpenPostProcessId;
  70491. /**
  70492. * @ignore
  70493. * ID of the image processing post process;
  70494. */
  70495. readonly ImageProcessingPostProcessId: string;
  70496. /**
  70497. * @ignore
  70498. * ID of the Fast Approximate Anti-Aliasing post process;
  70499. */
  70500. readonly FxaaPostProcessId: string;
  70501. /**
  70502. * ID of the chromatic aberration post process,
  70503. */
  70504. private readonly ChromaticAberrationPostProcessId;
  70505. /**
  70506. * ID of the grain post process
  70507. */
  70508. private readonly GrainPostProcessId;
  70509. /**
  70510. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70511. */
  70512. sharpen: SharpenPostProcess;
  70513. private _sharpenEffect;
  70514. private bloom;
  70515. /**
  70516. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70517. */
  70518. depthOfField: DepthOfFieldEffect;
  70519. /**
  70520. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70521. */
  70522. fxaa: FxaaPostProcess;
  70523. /**
  70524. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70525. */
  70526. imageProcessing: ImageProcessingPostProcess;
  70527. /**
  70528. * Chromatic aberration post process which will shift rgb colors in the image
  70529. */
  70530. chromaticAberration: ChromaticAberrationPostProcess;
  70531. private _chromaticAberrationEffect;
  70532. /**
  70533. * Grain post process which add noise to the image
  70534. */
  70535. grain: GrainPostProcess;
  70536. private _grainEffect;
  70537. /**
  70538. * Glow post process which adds a glow to emissive areas of the image
  70539. */
  70540. private _glowLayer;
  70541. /**
  70542. * Animations which can be used to tweak settings over a period of time
  70543. */
  70544. animations: Animation[];
  70545. private _imageProcessingConfigurationObserver;
  70546. private _sharpenEnabled;
  70547. private _bloomEnabled;
  70548. private _depthOfFieldEnabled;
  70549. private _depthOfFieldBlurLevel;
  70550. private _fxaaEnabled;
  70551. private _imageProcessingEnabled;
  70552. private _defaultPipelineTextureType;
  70553. private _bloomScale;
  70554. private _chromaticAberrationEnabled;
  70555. private _grainEnabled;
  70556. private _buildAllowed;
  70557. /**
  70558. * Gets active scene
  70559. */
  70560. get scene(): Scene;
  70561. /**
  70562. * Enable or disable the sharpen process from the pipeline
  70563. */
  70564. set sharpenEnabled(enabled: boolean);
  70565. get sharpenEnabled(): boolean;
  70566. private _resizeObserver;
  70567. private _hardwareScaleLevel;
  70568. private _bloomKernel;
  70569. /**
  70570. * Specifies the size of the bloom blur kernel, relative to the final output size
  70571. */
  70572. get bloomKernel(): number;
  70573. set bloomKernel(value: number);
  70574. /**
  70575. * Specifies the weight of the bloom in the final rendering
  70576. */
  70577. private _bloomWeight;
  70578. /**
  70579. * Specifies the luma threshold for the area that will be blurred by the bloom
  70580. */
  70581. private _bloomThreshold;
  70582. private _hdr;
  70583. /**
  70584. * The strength of the bloom.
  70585. */
  70586. set bloomWeight(value: number);
  70587. get bloomWeight(): number;
  70588. /**
  70589. * The strength of the bloom.
  70590. */
  70591. set bloomThreshold(value: number);
  70592. get bloomThreshold(): number;
  70593. /**
  70594. * The scale of the bloom, lower value will provide better performance.
  70595. */
  70596. set bloomScale(value: number);
  70597. get bloomScale(): number;
  70598. /**
  70599. * Enable or disable the bloom from the pipeline
  70600. */
  70601. set bloomEnabled(enabled: boolean);
  70602. get bloomEnabled(): boolean;
  70603. private _rebuildBloom;
  70604. /**
  70605. * If the depth of field is enabled.
  70606. */
  70607. get depthOfFieldEnabled(): boolean;
  70608. set depthOfFieldEnabled(enabled: boolean);
  70609. /**
  70610. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70611. */
  70612. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70613. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70614. /**
  70615. * If the anti aliasing is enabled.
  70616. */
  70617. set fxaaEnabled(enabled: boolean);
  70618. get fxaaEnabled(): boolean;
  70619. private _samples;
  70620. /**
  70621. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70622. */
  70623. set samples(sampleCount: number);
  70624. get samples(): number;
  70625. /**
  70626. * If image processing is enabled.
  70627. */
  70628. set imageProcessingEnabled(enabled: boolean);
  70629. get imageProcessingEnabled(): boolean;
  70630. /**
  70631. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70632. */
  70633. set glowLayerEnabled(enabled: boolean);
  70634. get glowLayerEnabled(): boolean;
  70635. /**
  70636. * Gets the glow layer (or null if not defined)
  70637. */
  70638. get glowLayer(): Nullable<GlowLayer>;
  70639. /**
  70640. * Enable or disable the chromaticAberration process from the pipeline
  70641. */
  70642. set chromaticAberrationEnabled(enabled: boolean);
  70643. get chromaticAberrationEnabled(): boolean;
  70644. /**
  70645. * Enable or disable the grain process from the pipeline
  70646. */
  70647. set grainEnabled(enabled: boolean);
  70648. get grainEnabled(): boolean;
  70649. /**
  70650. * @constructor
  70651. * @param name - The rendering pipeline name (default: "")
  70652. * @param hdr - If high dynamic range textures should be used (default: true)
  70653. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70654. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70655. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70656. */
  70657. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70658. /**
  70659. * Get the class name
  70660. * @returns "DefaultRenderingPipeline"
  70661. */
  70662. getClassName(): string;
  70663. /**
  70664. * Force the compilation of the entire pipeline.
  70665. */
  70666. prepare(): void;
  70667. private _hasCleared;
  70668. private _prevPostProcess;
  70669. private _prevPrevPostProcess;
  70670. private _setAutoClearAndTextureSharing;
  70671. private _depthOfFieldSceneObserver;
  70672. private _buildPipeline;
  70673. private _disposePostProcesses;
  70674. /**
  70675. * Adds a camera to the pipeline
  70676. * @param camera the camera to be added
  70677. */
  70678. addCamera(camera: Camera): void;
  70679. /**
  70680. * Removes a camera from the pipeline
  70681. * @param camera the camera to remove
  70682. */
  70683. removeCamera(camera: Camera): void;
  70684. /**
  70685. * Dispose of the pipeline and stop all post processes
  70686. */
  70687. dispose(): void;
  70688. /**
  70689. * Serialize the rendering pipeline (Used when exporting)
  70690. * @returns the serialized object
  70691. */
  70692. serialize(): any;
  70693. /**
  70694. * Parse the serialized pipeline
  70695. * @param source Source pipeline.
  70696. * @param scene The scene to load the pipeline to.
  70697. * @param rootUrl The URL of the serialized pipeline.
  70698. * @returns An instantiated pipeline from the serialized object.
  70699. */
  70700. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70701. }
  70702. }
  70703. declare module BABYLON {
  70704. /** @hidden */
  70705. export var lensHighlightsPixelShader: {
  70706. name: string;
  70707. shader: string;
  70708. };
  70709. }
  70710. declare module BABYLON {
  70711. /** @hidden */
  70712. export var depthOfFieldPixelShader: {
  70713. name: string;
  70714. shader: string;
  70715. };
  70716. }
  70717. declare module BABYLON {
  70718. /**
  70719. * BABYLON.JS Chromatic Aberration GLSL Shader
  70720. * Author: Olivier Guyot
  70721. * Separates very slightly R, G and B colors on the edges of the screen
  70722. * Inspired by Francois Tarlier & Martins Upitis
  70723. */
  70724. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70725. /**
  70726. * @ignore
  70727. * The chromatic aberration PostProcess id in the pipeline
  70728. */
  70729. LensChromaticAberrationEffect: string;
  70730. /**
  70731. * @ignore
  70732. * The highlights enhancing PostProcess id in the pipeline
  70733. */
  70734. HighlightsEnhancingEffect: string;
  70735. /**
  70736. * @ignore
  70737. * The depth-of-field PostProcess id in the pipeline
  70738. */
  70739. LensDepthOfFieldEffect: string;
  70740. private _scene;
  70741. private _depthTexture;
  70742. private _grainTexture;
  70743. private _chromaticAberrationPostProcess;
  70744. private _highlightsPostProcess;
  70745. private _depthOfFieldPostProcess;
  70746. private _edgeBlur;
  70747. private _grainAmount;
  70748. private _chromaticAberration;
  70749. private _distortion;
  70750. private _highlightsGain;
  70751. private _highlightsThreshold;
  70752. private _dofDistance;
  70753. private _dofAperture;
  70754. private _dofDarken;
  70755. private _dofPentagon;
  70756. private _blurNoise;
  70757. /**
  70758. * @constructor
  70759. *
  70760. * Effect parameters are as follow:
  70761. * {
  70762. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70763. * edge_blur: number; // from 0 to x (1 for realism)
  70764. * distortion: number; // from 0 to x (1 for realism)
  70765. * grain_amount: number; // from 0 to 1
  70766. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70767. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70768. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70769. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70770. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70771. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70772. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70773. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70774. * }
  70775. * Note: if an effect parameter is unset, effect is disabled
  70776. *
  70777. * @param name The rendering pipeline name
  70778. * @param parameters - An object containing all parameters (see above)
  70779. * @param scene The scene linked to this pipeline
  70780. * @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)
  70781. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70782. */
  70783. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70784. /**
  70785. * Get the class name
  70786. * @returns "LensRenderingPipeline"
  70787. */
  70788. getClassName(): string;
  70789. /**
  70790. * Gets associated scene
  70791. */
  70792. get scene(): Scene;
  70793. /**
  70794. * Gets or sets the edge blur
  70795. */
  70796. get edgeBlur(): number;
  70797. set edgeBlur(value: number);
  70798. /**
  70799. * Gets or sets the grain amount
  70800. */
  70801. get grainAmount(): number;
  70802. set grainAmount(value: number);
  70803. /**
  70804. * Gets or sets the chromatic aberration amount
  70805. */
  70806. get chromaticAberration(): number;
  70807. set chromaticAberration(value: number);
  70808. /**
  70809. * Gets or sets the depth of field aperture
  70810. */
  70811. get dofAperture(): number;
  70812. set dofAperture(value: number);
  70813. /**
  70814. * Gets or sets the edge distortion
  70815. */
  70816. get edgeDistortion(): number;
  70817. set edgeDistortion(value: number);
  70818. /**
  70819. * Gets or sets the depth of field distortion
  70820. */
  70821. get dofDistortion(): number;
  70822. set dofDistortion(value: number);
  70823. /**
  70824. * Gets or sets the darken out of focus amount
  70825. */
  70826. get darkenOutOfFocus(): number;
  70827. set darkenOutOfFocus(value: number);
  70828. /**
  70829. * Gets or sets a boolean indicating if blur noise is enabled
  70830. */
  70831. get blurNoise(): boolean;
  70832. set blurNoise(value: boolean);
  70833. /**
  70834. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70835. */
  70836. get pentagonBokeh(): boolean;
  70837. set pentagonBokeh(value: boolean);
  70838. /**
  70839. * Gets or sets the highlight grain amount
  70840. */
  70841. get highlightsGain(): number;
  70842. set highlightsGain(value: number);
  70843. /**
  70844. * Gets or sets the highlight threshold
  70845. */
  70846. get highlightsThreshold(): number;
  70847. set highlightsThreshold(value: number);
  70848. /**
  70849. * Sets the amount of blur at the edges
  70850. * @param amount blur amount
  70851. */
  70852. setEdgeBlur(amount: number): void;
  70853. /**
  70854. * Sets edge blur to 0
  70855. */
  70856. disableEdgeBlur(): void;
  70857. /**
  70858. * Sets the amout of grain
  70859. * @param amount Amount of grain
  70860. */
  70861. setGrainAmount(amount: number): void;
  70862. /**
  70863. * Set grain amount to 0
  70864. */
  70865. disableGrain(): void;
  70866. /**
  70867. * Sets the chromatic aberration amount
  70868. * @param amount amount of chromatic aberration
  70869. */
  70870. setChromaticAberration(amount: number): void;
  70871. /**
  70872. * Sets chromatic aberration amount to 0
  70873. */
  70874. disableChromaticAberration(): void;
  70875. /**
  70876. * Sets the EdgeDistortion amount
  70877. * @param amount amount of EdgeDistortion
  70878. */
  70879. setEdgeDistortion(amount: number): void;
  70880. /**
  70881. * Sets edge distortion to 0
  70882. */
  70883. disableEdgeDistortion(): void;
  70884. /**
  70885. * Sets the FocusDistance amount
  70886. * @param amount amount of FocusDistance
  70887. */
  70888. setFocusDistance(amount: number): void;
  70889. /**
  70890. * Disables depth of field
  70891. */
  70892. disableDepthOfField(): void;
  70893. /**
  70894. * Sets the Aperture amount
  70895. * @param amount amount of Aperture
  70896. */
  70897. setAperture(amount: number): void;
  70898. /**
  70899. * Sets the DarkenOutOfFocus amount
  70900. * @param amount amount of DarkenOutOfFocus
  70901. */
  70902. setDarkenOutOfFocus(amount: number): void;
  70903. private _pentagonBokehIsEnabled;
  70904. /**
  70905. * Creates a pentagon bokeh effect
  70906. */
  70907. enablePentagonBokeh(): void;
  70908. /**
  70909. * Disables the pentagon bokeh effect
  70910. */
  70911. disablePentagonBokeh(): void;
  70912. /**
  70913. * Enables noise blur
  70914. */
  70915. enableNoiseBlur(): void;
  70916. /**
  70917. * Disables noise blur
  70918. */
  70919. disableNoiseBlur(): void;
  70920. /**
  70921. * Sets the HighlightsGain amount
  70922. * @param amount amount of HighlightsGain
  70923. */
  70924. setHighlightsGain(amount: number): void;
  70925. /**
  70926. * Sets the HighlightsThreshold amount
  70927. * @param amount amount of HighlightsThreshold
  70928. */
  70929. setHighlightsThreshold(amount: number): void;
  70930. /**
  70931. * Disables highlights
  70932. */
  70933. disableHighlights(): void;
  70934. /**
  70935. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70936. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70937. */
  70938. dispose(disableDepthRender?: boolean): void;
  70939. private _createChromaticAberrationPostProcess;
  70940. private _createHighlightsPostProcess;
  70941. private _createDepthOfFieldPostProcess;
  70942. private _createGrainTexture;
  70943. }
  70944. }
  70945. declare module BABYLON {
  70946. /**
  70947. * Contains all parameters needed for the prepass to perform
  70948. * screen space subsurface scattering
  70949. */
  70950. export class SSAO2Configuration implements PrePassEffectConfiguration {
  70951. /**
  70952. * Is subsurface enabled
  70953. */
  70954. enabled: boolean;
  70955. /**
  70956. * Name of the configuration
  70957. */
  70958. name: string;
  70959. /**
  70960. * Textures that should be present in the MRT for this effect to work
  70961. */
  70962. readonly texturesRequired: number[];
  70963. /**
  70964. * Builds a ssao2 configuration object
  70965. * @param scene The scene
  70966. */
  70967. constructor();
  70968. /**
  70969. * Disposes the configuration
  70970. */
  70971. dispose(): void;
  70972. }
  70973. }
  70974. declare module BABYLON {
  70975. /** @hidden */
  70976. export var ssao2PixelShader: {
  70977. name: string;
  70978. shader: string;
  70979. };
  70980. }
  70981. declare module BABYLON {
  70982. /** @hidden */
  70983. export var ssaoCombinePixelShader: {
  70984. name: string;
  70985. shader: string;
  70986. };
  70987. }
  70988. declare module BABYLON {
  70989. /**
  70990. * Render pipeline to produce ssao effect
  70991. */
  70992. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70993. /**
  70994. * @ignore
  70995. * The PassPostProcess id in the pipeline that contains the original scene color
  70996. */
  70997. SSAOOriginalSceneColorEffect: string;
  70998. /**
  70999. * @ignore
  71000. * The SSAO PostProcess id in the pipeline
  71001. */
  71002. SSAORenderEffect: string;
  71003. /**
  71004. * @ignore
  71005. * The horizontal blur PostProcess id in the pipeline
  71006. */
  71007. SSAOBlurHRenderEffect: string;
  71008. /**
  71009. * @ignore
  71010. * The vertical blur PostProcess id in the pipeline
  71011. */
  71012. SSAOBlurVRenderEffect: string;
  71013. /**
  71014. * @ignore
  71015. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71016. */
  71017. SSAOCombineRenderEffect: string;
  71018. /**
  71019. * The output strength of the SSAO post-process. Default value is 1.0.
  71020. */
  71021. totalStrength: number;
  71022. /**
  71023. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71024. */
  71025. maxZ: number;
  71026. /**
  71027. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71028. */
  71029. minZAspect: number;
  71030. private _samples;
  71031. /**
  71032. * Number of samples used for the SSAO calculations. Default value is 8
  71033. */
  71034. set samples(n: number);
  71035. get samples(): number;
  71036. private _textureSamples;
  71037. /**
  71038. * Number of samples to use for antialiasing
  71039. */
  71040. set textureSamples(n: number);
  71041. get textureSamples(): number;
  71042. /**
  71043. * Force rendering the geometry through geometry buffer
  71044. */
  71045. private _forceGeometryBuffer;
  71046. /**
  71047. * Ratio object used for SSAO ratio and blur ratio
  71048. */
  71049. private _ratio;
  71050. /**
  71051. * Dynamically generated sphere sampler.
  71052. */
  71053. private _sampleSphere;
  71054. private _ssao2PrePassConfiguration;
  71055. /**
  71056. * Blur filter offsets
  71057. */
  71058. private _samplerOffsets;
  71059. private _expensiveBlur;
  71060. /**
  71061. * If bilateral blur should be used
  71062. */
  71063. set expensiveBlur(b: boolean);
  71064. get expensiveBlur(): boolean;
  71065. /**
  71066. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71067. */
  71068. radius: number;
  71069. /**
  71070. * The base color of the SSAO post-process
  71071. * The final result is "base + ssao" between [0, 1]
  71072. */
  71073. base: number;
  71074. /**
  71075. * Support test.
  71076. */
  71077. static get IsSupported(): boolean;
  71078. private _scene;
  71079. private _randomTexture;
  71080. private _originalColorPostProcess;
  71081. private _ssaoPostProcess;
  71082. private _blurHPostProcess;
  71083. private _blurVPostProcess;
  71084. private _ssaoCombinePostProcess;
  71085. private _prePassRenderer;
  71086. /**
  71087. * Gets active scene
  71088. */
  71089. get scene(): Scene;
  71090. /**
  71091. * @constructor
  71092. * @param name The rendering pipeline name
  71093. * @param scene The scene linked to this pipeline
  71094. * @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 }
  71095. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71096. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71097. */
  71098. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71099. /**
  71100. * Get the class name
  71101. * @returns "SSAO2RenderingPipeline"
  71102. */
  71103. getClassName(): string;
  71104. /**
  71105. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71106. */
  71107. dispose(disableGeometryBufferRenderer?: boolean): void;
  71108. private _createBlurPostProcess;
  71109. /** @hidden */
  71110. _rebuild(): void;
  71111. private _bits;
  71112. private _radicalInverse_VdC;
  71113. private _hammersley;
  71114. private _hemisphereSample_uniform;
  71115. private _generateHemisphere;
  71116. private _getDefinesForSSAO;
  71117. private _createSSAOPostProcess;
  71118. private _createSSAOCombinePostProcess;
  71119. private _createRandomTexture;
  71120. /**
  71121. * Serialize the rendering pipeline (Used when exporting)
  71122. * @returns the serialized object
  71123. */
  71124. serialize(): any;
  71125. /**
  71126. * Parse the serialized pipeline
  71127. * @param source Source pipeline.
  71128. * @param scene The scene to load the pipeline to.
  71129. * @param rootUrl The URL of the serialized pipeline.
  71130. * @returns An instantiated pipeline from the serialized object.
  71131. */
  71132. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71133. /**
  71134. * Sets the required values to the prepass renderer.
  71135. * @param prePassRenderer defines the prepass renderer to setup
  71136. * @returns true if the pre pass is needed.
  71137. */
  71138. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71139. }
  71140. }
  71141. declare module BABYLON {
  71142. /** @hidden */
  71143. export var ssaoPixelShader: {
  71144. name: string;
  71145. shader: string;
  71146. };
  71147. }
  71148. declare module BABYLON {
  71149. /**
  71150. * Render pipeline to produce ssao effect
  71151. */
  71152. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71153. /**
  71154. * @ignore
  71155. * The PassPostProcess id in the pipeline that contains the original scene color
  71156. */
  71157. SSAOOriginalSceneColorEffect: string;
  71158. /**
  71159. * @ignore
  71160. * The SSAO PostProcess id in the pipeline
  71161. */
  71162. SSAORenderEffect: string;
  71163. /**
  71164. * @ignore
  71165. * The horizontal blur PostProcess id in the pipeline
  71166. */
  71167. SSAOBlurHRenderEffect: string;
  71168. /**
  71169. * @ignore
  71170. * The vertical blur PostProcess id in the pipeline
  71171. */
  71172. SSAOBlurVRenderEffect: string;
  71173. /**
  71174. * @ignore
  71175. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71176. */
  71177. SSAOCombineRenderEffect: string;
  71178. /**
  71179. * The output strength of the SSAO post-process. Default value is 1.0.
  71180. */
  71181. totalStrength: number;
  71182. /**
  71183. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71184. */
  71185. radius: number;
  71186. /**
  71187. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71188. * Must not be equal to fallOff and superior to fallOff.
  71189. * Default value is 0.0075
  71190. */
  71191. area: number;
  71192. /**
  71193. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71194. * Must not be equal to area and inferior to area.
  71195. * Default value is 0.000001
  71196. */
  71197. fallOff: number;
  71198. /**
  71199. * The base color of the SSAO post-process
  71200. * The final result is "base + ssao" between [0, 1]
  71201. */
  71202. base: number;
  71203. private _scene;
  71204. private _depthTexture;
  71205. private _randomTexture;
  71206. private _originalColorPostProcess;
  71207. private _ssaoPostProcess;
  71208. private _blurHPostProcess;
  71209. private _blurVPostProcess;
  71210. private _ssaoCombinePostProcess;
  71211. private _firstUpdate;
  71212. /**
  71213. * Gets active scene
  71214. */
  71215. get scene(): Scene;
  71216. /**
  71217. * @constructor
  71218. * @param name - The rendering pipeline name
  71219. * @param scene - The scene linked to this pipeline
  71220. * @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 }
  71221. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71222. */
  71223. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71224. /**
  71225. * Get the class name
  71226. * @returns "SSAORenderingPipeline"
  71227. */
  71228. getClassName(): string;
  71229. /**
  71230. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71231. */
  71232. dispose(disableDepthRender?: boolean): void;
  71233. private _createBlurPostProcess;
  71234. /** @hidden */
  71235. _rebuild(): void;
  71236. private _createSSAOPostProcess;
  71237. private _createSSAOCombinePostProcess;
  71238. private _createRandomTexture;
  71239. }
  71240. }
  71241. declare module BABYLON {
  71242. /** @hidden */
  71243. export var screenSpaceReflectionPixelShader: {
  71244. name: string;
  71245. shader: string;
  71246. };
  71247. }
  71248. declare module BABYLON {
  71249. /**
  71250. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71251. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71252. */
  71253. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71254. /**
  71255. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71256. */
  71257. threshold: number;
  71258. /**
  71259. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71260. */
  71261. strength: number;
  71262. /**
  71263. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71264. */
  71265. reflectionSpecularFalloffExponent: number;
  71266. /**
  71267. * 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]
  71268. */
  71269. step: number;
  71270. /**
  71271. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71272. */
  71273. roughnessFactor: number;
  71274. private _geometryBufferRenderer;
  71275. private _enableSmoothReflections;
  71276. private _reflectionSamples;
  71277. private _smoothSteps;
  71278. /**
  71279. * Gets a string identifying the name of the class
  71280. * @returns "ScreenSpaceReflectionPostProcess" string
  71281. */
  71282. getClassName(): string;
  71283. /**
  71284. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71285. * @param name The name of the effect.
  71286. * @param scene The scene containing the objects to calculate reflections.
  71287. * @param options The required width/height ratio to downsize to before computing the render pass.
  71288. * @param camera The camera to apply the render pass to.
  71289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71290. * @param engine The engine which the post process will be applied. (default: current engine)
  71291. * @param reusable If the post process can be reused on the same frame. (default: false)
  71292. * @param textureType Type of textures used when performing the post process. (default: 0)
  71293. * @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)
  71294. */
  71295. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71296. /**
  71297. * Gets wether or not smoothing reflections is enabled.
  71298. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71299. */
  71300. get enableSmoothReflections(): boolean;
  71301. /**
  71302. * Sets wether or not smoothing reflections is enabled.
  71303. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71304. */
  71305. set enableSmoothReflections(enabled: boolean);
  71306. /**
  71307. * Gets the number of samples taken while computing reflections. More samples count is high,
  71308. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71309. */
  71310. get reflectionSamples(): number;
  71311. /**
  71312. * Sets the number of samples taken while computing reflections. More samples count is high,
  71313. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71314. */
  71315. set reflectionSamples(samples: number);
  71316. /**
  71317. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71318. * more the post-process will require GPU power and can generate a drop in FPS.
  71319. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71320. */
  71321. get smoothSteps(): number;
  71322. set smoothSteps(steps: number);
  71323. private _updateEffectDefines;
  71324. /** @hidden */
  71325. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71326. }
  71327. }
  71328. declare module BABYLON {
  71329. /** @hidden */
  71330. export var standardPixelShader: {
  71331. name: string;
  71332. shader: string;
  71333. };
  71334. }
  71335. declare module BABYLON {
  71336. /**
  71337. * Standard rendering pipeline
  71338. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71339. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71340. */
  71341. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71342. /**
  71343. * Public members
  71344. */
  71345. /**
  71346. * Post-process which contains the original scene color before the pipeline applies all the effects
  71347. */
  71348. originalPostProcess: Nullable<PostProcess>;
  71349. /**
  71350. * Post-process used to down scale an image x4
  71351. */
  71352. downSampleX4PostProcess: Nullable<PostProcess>;
  71353. /**
  71354. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71355. */
  71356. brightPassPostProcess: Nullable<PostProcess>;
  71357. /**
  71358. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71359. */
  71360. blurHPostProcesses: PostProcess[];
  71361. /**
  71362. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71363. */
  71364. blurVPostProcesses: PostProcess[];
  71365. /**
  71366. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71367. */
  71368. textureAdderPostProcess: Nullable<PostProcess>;
  71369. /**
  71370. * Post-process used to create volumetric lighting effect
  71371. */
  71372. volumetricLightPostProcess: Nullable<PostProcess>;
  71373. /**
  71374. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71375. */
  71376. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71377. /**
  71378. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71379. */
  71380. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71381. /**
  71382. * Post-process used to merge the volumetric light effect and the real scene color
  71383. */
  71384. volumetricLightMergePostProces: Nullable<PostProcess>;
  71385. /**
  71386. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71387. */
  71388. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71389. /**
  71390. * Base post-process used to calculate the average luminance of the final image for HDR
  71391. */
  71392. luminancePostProcess: Nullable<PostProcess>;
  71393. /**
  71394. * Post-processes used to create down sample post-processes in order to get
  71395. * the average luminance of the final image for HDR
  71396. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71397. */
  71398. luminanceDownSamplePostProcesses: PostProcess[];
  71399. /**
  71400. * Post-process used to create a HDR effect (light adaptation)
  71401. */
  71402. hdrPostProcess: Nullable<PostProcess>;
  71403. /**
  71404. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71405. */
  71406. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71407. /**
  71408. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71409. */
  71410. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71411. /**
  71412. * Post-process used to merge the final HDR post-process and the real scene color
  71413. */
  71414. hdrFinalPostProcess: Nullable<PostProcess>;
  71415. /**
  71416. * Post-process used to create a lens flare effect
  71417. */
  71418. lensFlarePostProcess: Nullable<PostProcess>;
  71419. /**
  71420. * Post-process that merges the result of the lens flare post-process and the real scene color
  71421. */
  71422. lensFlareComposePostProcess: Nullable<PostProcess>;
  71423. /**
  71424. * Post-process used to create a motion blur effect
  71425. */
  71426. motionBlurPostProcess: Nullable<PostProcess>;
  71427. /**
  71428. * Post-process used to create a depth of field effect
  71429. */
  71430. depthOfFieldPostProcess: Nullable<PostProcess>;
  71431. /**
  71432. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71433. */
  71434. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71435. /**
  71436. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71437. */
  71438. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71439. /**
  71440. * Represents the brightness threshold in order to configure the illuminated surfaces
  71441. */
  71442. brightThreshold: number;
  71443. /**
  71444. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71445. */
  71446. blurWidth: number;
  71447. /**
  71448. * Sets if the blur for highlighted surfaces must be only horizontal
  71449. */
  71450. horizontalBlur: boolean;
  71451. /**
  71452. * Gets the overall exposure used by the pipeline
  71453. */
  71454. get exposure(): number;
  71455. /**
  71456. * Sets the overall exposure used by the pipeline
  71457. */
  71458. set exposure(value: number);
  71459. /**
  71460. * Texture used typically to simulate "dirty" on camera lens
  71461. */
  71462. lensTexture: Nullable<Texture>;
  71463. /**
  71464. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71465. */
  71466. volumetricLightCoefficient: number;
  71467. /**
  71468. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71469. */
  71470. volumetricLightPower: number;
  71471. /**
  71472. * Used the set the blur intensity to smooth the volumetric lights
  71473. */
  71474. volumetricLightBlurScale: number;
  71475. /**
  71476. * Light (spot or directional) used to generate the volumetric lights rays
  71477. * The source light must have a shadow generate so the pipeline can get its
  71478. * depth map
  71479. */
  71480. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71481. /**
  71482. * For eye adaptation, represents the minimum luminance the eye can see
  71483. */
  71484. hdrMinimumLuminance: number;
  71485. /**
  71486. * For eye adaptation, represents the decrease luminance speed
  71487. */
  71488. hdrDecreaseRate: number;
  71489. /**
  71490. * For eye adaptation, represents the increase luminance speed
  71491. */
  71492. hdrIncreaseRate: number;
  71493. /**
  71494. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71495. */
  71496. get hdrAutoExposure(): boolean;
  71497. /**
  71498. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71499. */
  71500. set hdrAutoExposure(value: boolean);
  71501. /**
  71502. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71503. */
  71504. lensColorTexture: Nullable<Texture>;
  71505. /**
  71506. * The overall strengh for the lens flare effect
  71507. */
  71508. lensFlareStrength: number;
  71509. /**
  71510. * Dispersion coefficient for lens flare ghosts
  71511. */
  71512. lensFlareGhostDispersal: number;
  71513. /**
  71514. * Main lens flare halo width
  71515. */
  71516. lensFlareHaloWidth: number;
  71517. /**
  71518. * Based on the lens distortion effect, defines how much the lens flare result
  71519. * is distorted
  71520. */
  71521. lensFlareDistortionStrength: number;
  71522. /**
  71523. * Configures the blur intensity used for for lens flare (halo)
  71524. */
  71525. lensFlareBlurWidth: number;
  71526. /**
  71527. * Lens star texture must be used to simulate rays on the flares and is available
  71528. * in the documentation
  71529. */
  71530. lensStarTexture: Nullable<Texture>;
  71531. /**
  71532. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71533. * flare effect by taking account of the dirt texture
  71534. */
  71535. lensFlareDirtTexture: Nullable<Texture>;
  71536. /**
  71537. * Represents the focal length for the depth of field effect
  71538. */
  71539. depthOfFieldDistance: number;
  71540. /**
  71541. * Represents the blur intensity for the blurred part of the depth of field effect
  71542. */
  71543. depthOfFieldBlurWidth: number;
  71544. /**
  71545. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71546. */
  71547. get motionStrength(): number;
  71548. /**
  71549. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71550. */
  71551. set motionStrength(strength: number);
  71552. /**
  71553. * Gets wether or not the motion blur post-process is object based or screen based.
  71554. */
  71555. get objectBasedMotionBlur(): boolean;
  71556. /**
  71557. * Sets wether or not the motion blur post-process should be object based or screen based
  71558. */
  71559. set objectBasedMotionBlur(value: boolean);
  71560. /**
  71561. * List of animations for the pipeline (IAnimatable implementation)
  71562. */
  71563. animations: Animation[];
  71564. /**
  71565. * Private members
  71566. */
  71567. private _scene;
  71568. private _currentDepthOfFieldSource;
  71569. private _basePostProcess;
  71570. private _fixedExposure;
  71571. private _currentExposure;
  71572. private _hdrAutoExposure;
  71573. private _hdrCurrentLuminance;
  71574. private _motionStrength;
  71575. private _isObjectBasedMotionBlur;
  71576. private _floatTextureType;
  71577. private _camerasToBeAttached;
  71578. private _ratio;
  71579. private _bloomEnabled;
  71580. private _depthOfFieldEnabled;
  71581. private _vlsEnabled;
  71582. private _lensFlareEnabled;
  71583. private _hdrEnabled;
  71584. private _motionBlurEnabled;
  71585. private _fxaaEnabled;
  71586. private _screenSpaceReflectionsEnabled;
  71587. private _motionBlurSamples;
  71588. private _volumetricLightStepsCount;
  71589. private _samples;
  71590. /**
  71591. * @ignore
  71592. * Specifies if the bloom pipeline is enabled
  71593. */
  71594. get BloomEnabled(): boolean;
  71595. set BloomEnabled(enabled: boolean);
  71596. /**
  71597. * @ignore
  71598. * Specifies if the depth of field pipeline is enabed
  71599. */
  71600. get DepthOfFieldEnabled(): boolean;
  71601. set DepthOfFieldEnabled(enabled: boolean);
  71602. /**
  71603. * @ignore
  71604. * Specifies if the lens flare pipeline is enabed
  71605. */
  71606. get LensFlareEnabled(): boolean;
  71607. set LensFlareEnabled(enabled: boolean);
  71608. /**
  71609. * @ignore
  71610. * Specifies if the HDR pipeline is enabled
  71611. */
  71612. get HDREnabled(): boolean;
  71613. set HDREnabled(enabled: boolean);
  71614. /**
  71615. * @ignore
  71616. * Specifies if the volumetric lights scattering effect is enabled
  71617. */
  71618. get VLSEnabled(): boolean;
  71619. set VLSEnabled(enabled: boolean);
  71620. /**
  71621. * @ignore
  71622. * Specifies if the motion blur effect is enabled
  71623. */
  71624. get MotionBlurEnabled(): boolean;
  71625. set MotionBlurEnabled(enabled: boolean);
  71626. /**
  71627. * Specifies if anti-aliasing is enabled
  71628. */
  71629. get fxaaEnabled(): boolean;
  71630. set fxaaEnabled(enabled: boolean);
  71631. /**
  71632. * Specifies if screen space reflections are enabled.
  71633. */
  71634. get screenSpaceReflectionsEnabled(): boolean;
  71635. set screenSpaceReflectionsEnabled(enabled: boolean);
  71636. /**
  71637. * Specifies the number of steps used to calculate the volumetric lights
  71638. * Typically in interval [50, 200]
  71639. */
  71640. get volumetricLightStepsCount(): number;
  71641. set volumetricLightStepsCount(count: number);
  71642. /**
  71643. * Specifies the number of samples used for the motion blur effect
  71644. * Typically in interval [16, 64]
  71645. */
  71646. get motionBlurSamples(): number;
  71647. set motionBlurSamples(samples: number);
  71648. /**
  71649. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71650. */
  71651. get samples(): number;
  71652. set samples(sampleCount: number);
  71653. /**
  71654. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71655. * @constructor
  71656. * @param name The rendering pipeline name
  71657. * @param scene The scene linked to this pipeline
  71658. * @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)
  71659. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71660. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71661. */
  71662. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71663. private _buildPipeline;
  71664. private _createDownSampleX4PostProcess;
  71665. private _createBrightPassPostProcess;
  71666. private _createBlurPostProcesses;
  71667. private _createTextureAdderPostProcess;
  71668. private _createVolumetricLightPostProcess;
  71669. private _createLuminancePostProcesses;
  71670. private _createHdrPostProcess;
  71671. private _createLensFlarePostProcess;
  71672. private _createDepthOfFieldPostProcess;
  71673. private _createMotionBlurPostProcess;
  71674. private _getDepthTexture;
  71675. private _disposePostProcesses;
  71676. /**
  71677. * Dispose of the pipeline and stop all post processes
  71678. */
  71679. dispose(): void;
  71680. /**
  71681. * Serialize the rendering pipeline (Used when exporting)
  71682. * @returns the serialized object
  71683. */
  71684. serialize(): any;
  71685. /**
  71686. * Parse the serialized pipeline
  71687. * @param source Source pipeline.
  71688. * @param scene The scene to load the pipeline to.
  71689. * @param rootUrl The URL of the serialized pipeline.
  71690. * @returns An instantiated pipeline from the serialized object.
  71691. */
  71692. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71693. /**
  71694. * Luminance steps
  71695. */
  71696. static LuminanceSteps: number;
  71697. }
  71698. }
  71699. declare module BABYLON {
  71700. /** @hidden */
  71701. export var stereoscopicInterlacePixelShader: {
  71702. name: string;
  71703. shader: string;
  71704. };
  71705. }
  71706. declare module BABYLON {
  71707. /**
  71708. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71709. */
  71710. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71711. private _stepSize;
  71712. private _passedProcess;
  71713. /**
  71714. * Gets a string identifying the name of the class
  71715. * @returns "StereoscopicInterlacePostProcessI" string
  71716. */
  71717. getClassName(): string;
  71718. /**
  71719. * Initializes a StereoscopicInterlacePostProcessI
  71720. * @param name The name of the effect.
  71721. * @param rigCameras The rig cameras to be appled to the post process
  71722. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71723. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71725. * @param engine The engine which the post process will be applied. (default: current engine)
  71726. * @param reusable If the post process can be reused on the same frame. (default: false)
  71727. */
  71728. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71729. }
  71730. /**
  71731. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71732. */
  71733. export class StereoscopicInterlacePostProcess extends PostProcess {
  71734. private _stepSize;
  71735. private _passedProcess;
  71736. /**
  71737. * Gets a string identifying the name of the class
  71738. * @returns "StereoscopicInterlacePostProcess" string
  71739. */
  71740. getClassName(): string;
  71741. /**
  71742. * Initializes a StereoscopicInterlacePostProcess
  71743. * @param name The name of the effect.
  71744. * @param rigCameras The rig cameras to be appled to the post process
  71745. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71747. * @param engine The engine which the post process will be applied. (default: current engine)
  71748. * @param reusable If the post process can be reused on the same frame. (default: false)
  71749. */
  71750. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71751. }
  71752. }
  71753. declare module BABYLON {
  71754. /** @hidden */
  71755. export var tonemapPixelShader: {
  71756. name: string;
  71757. shader: string;
  71758. };
  71759. }
  71760. declare module BABYLON {
  71761. /** Defines operator used for tonemapping */
  71762. export enum TonemappingOperator {
  71763. /** Hable */
  71764. Hable = 0,
  71765. /** Reinhard */
  71766. Reinhard = 1,
  71767. /** HejiDawson */
  71768. HejiDawson = 2,
  71769. /** Photographic */
  71770. Photographic = 3
  71771. }
  71772. /**
  71773. * Defines a post process to apply tone mapping
  71774. */
  71775. export class TonemapPostProcess extends PostProcess {
  71776. private _operator;
  71777. /** Defines the required exposure adjustement */
  71778. exposureAdjustment: number;
  71779. /**
  71780. * Gets a string identifying the name of the class
  71781. * @returns "TonemapPostProcess" string
  71782. */
  71783. getClassName(): string;
  71784. /**
  71785. * Creates a new TonemapPostProcess
  71786. * @param name defines the name of the postprocess
  71787. * @param _operator defines the operator to use
  71788. * @param exposureAdjustment defines the required exposure adjustement
  71789. * @param camera defines the camera to use (can be null)
  71790. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71791. * @param engine defines the hosting engine (can be ignore if camera is set)
  71792. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71793. */
  71794. constructor(name: string, _operator: TonemappingOperator,
  71795. /** Defines the required exposure adjustement */
  71796. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71797. }
  71798. }
  71799. declare module BABYLON {
  71800. /** @hidden */
  71801. export var volumetricLightScatteringPixelShader: {
  71802. name: string;
  71803. shader: string;
  71804. };
  71805. }
  71806. declare module BABYLON {
  71807. /** @hidden */
  71808. export var volumetricLightScatteringPassVertexShader: {
  71809. name: string;
  71810. shader: string;
  71811. };
  71812. }
  71813. declare module BABYLON {
  71814. /** @hidden */
  71815. export var volumetricLightScatteringPassPixelShader: {
  71816. name: string;
  71817. shader: string;
  71818. };
  71819. }
  71820. declare module BABYLON {
  71821. /**
  71822. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71823. */
  71824. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71825. private _volumetricLightScatteringPass;
  71826. private _volumetricLightScatteringRTT;
  71827. private _viewPort;
  71828. private _screenCoordinates;
  71829. private _cachedDefines;
  71830. /**
  71831. * If not undefined, the mesh position is computed from the attached node position
  71832. */
  71833. attachedNode: {
  71834. position: Vector3;
  71835. };
  71836. /**
  71837. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71838. */
  71839. customMeshPosition: Vector3;
  71840. /**
  71841. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71842. */
  71843. useCustomMeshPosition: boolean;
  71844. /**
  71845. * If the post-process should inverse the light scattering direction
  71846. */
  71847. invert: boolean;
  71848. /**
  71849. * The internal mesh used by the post-process
  71850. */
  71851. mesh: Mesh;
  71852. /**
  71853. * @hidden
  71854. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71855. */
  71856. get useDiffuseColor(): boolean;
  71857. set useDiffuseColor(useDiffuseColor: boolean);
  71858. /**
  71859. * Array containing the excluded meshes not rendered in the internal pass
  71860. */
  71861. excludedMeshes: AbstractMesh[];
  71862. /**
  71863. * Controls the overall intensity of the post-process
  71864. */
  71865. exposure: number;
  71866. /**
  71867. * Dissipates each sample's contribution in range [0, 1]
  71868. */
  71869. decay: number;
  71870. /**
  71871. * Controls the overall intensity of each sample
  71872. */
  71873. weight: number;
  71874. /**
  71875. * Controls the density of each sample
  71876. */
  71877. density: number;
  71878. /**
  71879. * @constructor
  71880. * @param name The post-process name
  71881. * @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)
  71882. * @param camera The camera that the post-process will be attached to
  71883. * @param mesh The mesh used to create the light scattering
  71884. * @param samples The post-process quality, default 100
  71885. * @param samplingModeThe post-process filtering mode
  71886. * @param engine The babylon engine
  71887. * @param reusable If the post-process is reusable
  71888. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71889. */
  71890. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71891. /**
  71892. * Returns the string "VolumetricLightScatteringPostProcess"
  71893. * @returns "VolumetricLightScatteringPostProcess"
  71894. */
  71895. getClassName(): string;
  71896. private _isReady;
  71897. /**
  71898. * Sets the new light position for light scattering effect
  71899. * @param position The new custom light position
  71900. */
  71901. setCustomMeshPosition(position: Vector3): void;
  71902. /**
  71903. * Returns the light position for light scattering effect
  71904. * @return Vector3 The custom light position
  71905. */
  71906. getCustomMeshPosition(): Vector3;
  71907. /**
  71908. * Disposes the internal assets and detaches the post-process from the camera
  71909. */
  71910. dispose(camera: Camera): void;
  71911. /**
  71912. * Returns the render target texture used by the post-process
  71913. * @return the render target texture used by the post-process
  71914. */
  71915. getPass(): RenderTargetTexture;
  71916. private _meshExcluded;
  71917. private _createPass;
  71918. private _updateMeshScreenCoordinates;
  71919. /**
  71920. * Creates a default mesh for the Volumeric Light Scattering post-process
  71921. * @param name The mesh name
  71922. * @param scene The scene where to create the mesh
  71923. * @return the default mesh
  71924. */
  71925. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71926. }
  71927. }
  71928. declare module BABYLON {
  71929. /** @hidden */
  71930. export var screenSpaceCurvaturePixelShader: {
  71931. name: string;
  71932. shader: string;
  71933. };
  71934. }
  71935. declare module BABYLON {
  71936. /**
  71937. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71938. */
  71939. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71940. /**
  71941. * Defines how much ridge the curvature effect displays.
  71942. */
  71943. ridge: number;
  71944. /**
  71945. * Defines how much valley the curvature effect displays.
  71946. */
  71947. valley: number;
  71948. private _geometryBufferRenderer;
  71949. /**
  71950. * Gets a string identifying the name of the class
  71951. * @returns "ScreenSpaceCurvaturePostProcess" string
  71952. */
  71953. getClassName(): string;
  71954. /**
  71955. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71956. * @param name The name of the effect.
  71957. * @param scene The scene containing the objects to blur according to their velocity.
  71958. * @param options The required width/height ratio to downsize to before computing the render pass.
  71959. * @param camera The camera to apply the render pass to.
  71960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71961. * @param engine The engine which the post process will be applied. (default: current engine)
  71962. * @param reusable If the post process can be reused on the same frame. (default: false)
  71963. * @param textureType Type of textures used when performing the post process. (default: 0)
  71964. * @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)
  71965. */
  71966. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71967. /**
  71968. * Support test.
  71969. */
  71970. static get IsSupported(): boolean;
  71971. /** @hidden */
  71972. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71973. }
  71974. }
  71975. declare module BABYLON {
  71976. interface Scene {
  71977. /** @hidden (Backing field) */
  71978. _boundingBoxRenderer: BoundingBoxRenderer;
  71979. /** @hidden (Backing field) */
  71980. _forceShowBoundingBoxes: boolean;
  71981. /**
  71982. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71983. */
  71984. forceShowBoundingBoxes: boolean;
  71985. /**
  71986. * Gets the bounding box renderer associated with the scene
  71987. * @returns a BoundingBoxRenderer
  71988. */
  71989. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71990. }
  71991. interface AbstractMesh {
  71992. /** @hidden (Backing field) */
  71993. _showBoundingBox: boolean;
  71994. /**
  71995. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71996. */
  71997. showBoundingBox: boolean;
  71998. }
  71999. /**
  72000. * Component responsible of rendering the bounding box of the meshes in a scene.
  72001. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72002. */
  72003. export class BoundingBoxRenderer implements ISceneComponent {
  72004. /**
  72005. * The component name helpfull to identify the component in the list of scene components.
  72006. */
  72007. readonly name: string;
  72008. /**
  72009. * The scene the component belongs to.
  72010. */
  72011. scene: Scene;
  72012. /**
  72013. * Color of the bounding box lines placed in front of an object
  72014. */
  72015. frontColor: Color3;
  72016. /**
  72017. * Color of the bounding box lines placed behind an object
  72018. */
  72019. backColor: Color3;
  72020. /**
  72021. * Defines if the renderer should show the back lines or not
  72022. */
  72023. showBackLines: boolean;
  72024. /**
  72025. * Observable raised before rendering a bounding box
  72026. */
  72027. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72028. /**
  72029. * Observable raised after rendering a bounding box
  72030. */
  72031. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72032. /**
  72033. * @hidden
  72034. */
  72035. renderList: SmartArray<BoundingBox>;
  72036. private _colorShader;
  72037. private _vertexBuffers;
  72038. private _indexBuffer;
  72039. private _fillIndexBuffer;
  72040. private _fillIndexData;
  72041. /**
  72042. * Instantiates a new bounding box renderer in a scene.
  72043. * @param scene the scene the renderer renders in
  72044. */
  72045. constructor(scene: Scene);
  72046. /**
  72047. * Registers the component in a given scene
  72048. */
  72049. register(): void;
  72050. private _evaluateSubMesh;
  72051. private _activeMesh;
  72052. private _prepareRessources;
  72053. private _createIndexBuffer;
  72054. /**
  72055. * Rebuilds the elements related to this component in case of
  72056. * context lost for instance.
  72057. */
  72058. rebuild(): void;
  72059. /**
  72060. * @hidden
  72061. */
  72062. reset(): void;
  72063. /**
  72064. * Render the bounding boxes of a specific rendering group
  72065. * @param renderingGroupId defines the rendering group to render
  72066. */
  72067. render(renderingGroupId: number): void;
  72068. /**
  72069. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72070. * @param mesh Define the mesh to render the occlusion bounding box for
  72071. */
  72072. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72073. /**
  72074. * Dispose and release the resources attached to this renderer.
  72075. */
  72076. dispose(): void;
  72077. }
  72078. }
  72079. declare module BABYLON {
  72080. interface Scene {
  72081. /** @hidden (Backing field) */
  72082. _depthRenderer: {
  72083. [id: string]: DepthRenderer;
  72084. };
  72085. /**
  72086. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72087. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72088. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72089. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72090. * @returns the created depth renderer
  72091. */
  72092. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72093. /**
  72094. * Disables a depth renderer for a given camera
  72095. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72096. */
  72097. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72098. }
  72099. /**
  72100. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72101. * in several rendering techniques.
  72102. */
  72103. export class DepthRendererSceneComponent implements ISceneComponent {
  72104. /**
  72105. * The component name helpfull to identify the component in the list of scene components.
  72106. */
  72107. readonly name: string;
  72108. /**
  72109. * The scene the component belongs to.
  72110. */
  72111. scene: Scene;
  72112. /**
  72113. * Creates a new instance of the component for the given scene
  72114. * @param scene Defines the scene to register the component in
  72115. */
  72116. constructor(scene: Scene);
  72117. /**
  72118. * Registers the component in a given scene
  72119. */
  72120. register(): void;
  72121. /**
  72122. * Rebuilds the elements related to this component in case of
  72123. * context lost for instance.
  72124. */
  72125. rebuild(): void;
  72126. /**
  72127. * Disposes the component and the associated ressources
  72128. */
  72129. dispose(): void;
  72130. private _gatherRenderTargets;
  72131. private _gatherActiveCameraRenderTargets;
  72132. }
  72133. }
  72134. declare module BABYLON {
  72135. interface AbstractScene {
  72136. /** @hidden (Backing field) */
  72137. _prePassRenderer: Nullable<PrePassRenderer>;
  72138. /**
  72139. * Gets or Sets the current prepass renderer associated to the scene.
  72140. */
  72141. prePassRenderer: Nullable<PrePassRenderer>;
  72142. /**
  72143. * Enables the prepass and associates it with the scene
  72144. * @returns the PrePassRenderer
  72145. */
  72146. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72147. /**
  72148. * Disables the prepass associated with the scene
  72149. */
  72150. disablePrePassRenderer(): void;
  72151. }
  72152. /**
  72153. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72154. * in several rendering techniques.
  72155. */
  72156. export class PrePassRendererSceneComponent implements ISceneComponent {
  72157. /**
  72158. * The component name helpful to identify the component in the list of scene components.
  72159. */
  72160. readonly name: string;
  72161. /**
  72162. * The scene the component belongs to.
  72163. */
  72164. scene: Scene;
  72165. /**
  72166. * Creates a new instance of the component for the given scene
  72167. * @param scene Defines the scene to register the component in
  72168. */
  72169. constructor(scene: Scene);
  72170. /**
  72171. * Registers the component in a given scene
  72172. */
  72173. register(): void;
  72174. private _beforeCameraDraw;
  72175. private _afterCameraDraw;
  72176. private _beforeClearStage;
  72177. /**
  72178. * Rebuilds the elements related to this component in case of
  72179. * context lost for instance.
  72180. */
  72181. rebuild(): void;
  72182. /**
  72183. * Disposes the component and the associated ressources
  72184. */
  72185. dispose(): void;
  72186. }
  72187. }
  72188. declare module BABYLON {
  72189. /** @hidden */
  72190. export var fibonacci: {
  72191. name: string;
  72192. shader: string;
  72193. };
  72194. }
  72195. declare module BABYLON {
  72196. /** @hidden */
  72197. export var diffusionProfile: {
  72198. name: string;
  72199. shader: string;
  72200. };
  72201. }
  72202. declare module BABYLON {
  72203. /** @hidden */
  72204. export var subSurfaceScatteringPixelShader: {
  72205. name: string;
  72206. shader: string;
  72207. };
  72208. }
  72209. declare module BABYLON {
  72210. /**
  72211. * Sub surface scattering post process
  72212. */
  72213. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72214. /**
  72215. * Gets a string identifying the name of the class
  72216. * @returns "SubSurfaceScatteringPostProcess" string
  72217. */
  72218. getClassName(): string;
  72219. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72220. }
  72221. }
  72222. declare module BABYLON {
  72223. /**
  72224. * Contains all parameters needed for the prepass to perform
  72225. * screen space subsurface scattering
  72226. */
  72227. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72228. /** @hidden */
  72229. static _SceneComponentInitialization: (scene: Scene) => void;
  72230. private _ssDiffusionS;
  72231. private _ssFilterRadii;
  72232. private _ssDiffusionD;
  72233. /**
  72234. * Post process to attach for screen space subsurface scattering
  72235. */
  72236. postProcess: SubSurfaceScatteringPostProcess;
  72237. /**
  72238. * Diffusion profile color for subsurface scattering
  72239. */
  72240. get ssDiffusionS(): number[];
  72241. /**
  72242. * Diffusion profile max color channel value for subsurface scattering
  72243. */
  72244. get ssDiffusionD(): number[];
  72245. /**
  72246. * Diffusion profile filter radius for subsurface scattering
  72247. */
  72248. get ssFilterRadii(): number[];
  72249. /**
  72250. * Is subsurface enabled
  72251. */
  72252. enabled: boolean;
  72253. /**
  72254. * Name of the configuration
  72255. */
  72256. name: string;
  72257. /**
  72258. * Diffusion profile colors for subsurface scattering
  72259. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72260. * See ...
  72261. * Note that you can only store up to 5 of them
  72262. */
  72263. ssDiffusionProfileColors: Color3[];
  72264. /**
  72265. * Defines the ratio real world => scene units.
  72266. * Used for subsurface scattering
  72267. */
  72268. metersPerUnit: number;
  72269. /**
  72270. * Textures that should be present in the MRT for this effect to work
  72271. */
  72272. readonly texturesRequired: number[];
  72273. private _scene;
  72274. /**
  72275. * Builds a subsurface configuration object
  72276. * @param scene The scene
  72277. */
  72278. constructor(scene: Scene);
  72279. /**
  72280. * Adds a new diffusion profile.
  72281. * Useful for more realistic subsurface scattering on diverse materials.
  72282. * @param color The color of the diffusion profile. Should be the average color of the material.
  72283. * @return The index of the diffusion profile for the material subsurface configuration
  72284. */
  72285. addDiffusionProfile(color: Color3): number;
  72286. /**
  72287. * Creates the sss post process
  72288. * @return The created post process
  72289. */
  72290. createPostProcess(): SubSurfaceScatteringPostProcess;
  72291. /**
  72292. * Deletes all diffusion profiles.
  72293. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72294. */
  72295. clearAllDiffusionProfiles(): void;
  72296. /**
  72297. * Disposes this object
  72298. */
  72299. dispose(): void;
  72300. /**
  72301. * @hidden
  72302. * https://zero-radiance.github.io/post/sampling-diffusion/
  72303. *
  72304. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72305. * ------------------------------------------------------------------------------------
  72306. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72307. * PDF[r, phi, s] = r * R[r, phi, s]
  72308. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72309. * ------------------------------------------------------------------------------------
  72310. * We importance sample the color channel with the widest scattering distance.
  72311. */
  72312. getDiffusionProfileParameters(color: Color3): number;
  72313. /**
  72314. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72315. * 'u' is the random number (the value of the CDF): [0, 1).
  72316. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72317. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72318. */
  72319. private _sampleBurleyDiffusionProfile;
  72320. }
  72321. }
  72322. declare module BABYLON {
  72323. interface AbstractScene {
  72324. /** @hidden (Backing field) */
  72325. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72326. /**
  72327. * Gets or Sets the current prepass renderer associated to the scene.
  72328. */
  72329. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72330. /**
  72331. * Enables the subsurface effect for prepass
  72332. * @returns the SubSurfaceConfiguration
  72333. */
  72334. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72335. /**
  72336. * Disables the subsurface effect for prepass
  72337. */
  72338. disableSubSurfaceForPrePass(): void;
  72339. }
  72340. /**
  72341. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72342. * in several rendering techniques.
  72343. */
  72344. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72345. /**
  72346. * The component name helpful to identify the component in the list of scene components.
  72347. */
  72348. readonly name: string;
  72349. /**
  72350. * The scene the component belongs to.
  72351. */
  72352. scene: Scene;
  72353. /**
  72354. * Creates a new instance of the component for the given scene
  72355. * @param scene Defines the scene to register the component in
  72356. */
  72357. constructor(scene: Scene);
  72358. /**
  72359. * Registers the component in a given scene
  72360. */
  72361. register(): void;
  72362. /**
  72363. * Serializes the component data to the specified json object
  72364. * @param serializationObject The object to serialize to
  72365. */
  72366. serialize(serializationObject: any): void;
  72367. /**
  72368. * Adds all the elements from the container to the scene
  72369. * @param container the container holding the elements
  72370. */
  72371. addFromContainer(container: AbstractScene): void;
  72372. /**
  72373. * Removes all the elements in the container from the scene
  72374. * @param container contains the elements to remove
  72375. * @param dispose if the removed element should be disposed (default: false)
  72376. */
  72377. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72378. /**
  72379. * Rebuilds the elements related to this component in case of
  72380. * context lost for instance.
  72381. */
  72382. rebuild(): void;
  72383. /**
  72384. * Disposes the component and the associated ressources
  72385. */
  72386. dispose(): void;
  72387. }
  72388. }
  72389. declare module BABYLON {
  72390. /** @hidden */
  72391. export var outlinePixelShader: {
  72392. name: string;
  72393. shader: string;
  72394. };
  72395. }
  72396. declare module BABYLON {
  72397. /** @hidden */
  72398. export var outlineVertexShader: {
  72399. name: string;
  72400. shader: string;
  72401. };
  72402. }
  72403. declare module BABYLON {
  72404. interface Scene {
  72405. /** @hidden */
  72406. _outlineRenderer: OutlineRenderer;
  72407. /**
  72408. * Gets the outline renderer associated with the scene
  72409. * @returns a OutlineRenderer
  72410. */
  72411. getOutlineRenderer(): OutlineRenderer;
  72412. }
  72413. interface AbstractMesh {
  72414. /** @hidden (Backing field) */
  72415. _renderOutline: boolean;
  72416. /**
  72417. * Gets or sets a boolean indicating if the outline must be rendered as well
  72418. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72419. */
  72420. renderOutline: boolean;
  72421. /** @hidden (Backing field) */
  72422. _renderOverlay: boolean;
  72423. /**
  72424. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72425. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72426. */
  72427. renderOverlay: boolean;
  72428. }
  72429. /**
  72430. * This class is responsible to draw bothe outline/overlay of meshes.
  72431. * It should not be used directly but through the available method on mesh.
  72432. */
  72433. export class OutlineRenderer implements ISceneComponent {
  72434. /**
  72435. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72436. */
  72437. private static _StencilReference;
  72438. /**
  72439. * The name of the component. Each component must have a unique name.
  72440. */
  72441. name: string;
  72442. /**
  72443. * The scene the component belongs to.
  72444. */
  72445. scene: Scene;
  72446. /**
  72447. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72448. */
  72449. zOffset: number;
  72450. private _engine;
  72451. private _effect;
  72452. private _cachedDefines;
  72453. private _savedDepthWrite;
  72454. /**
  72455. * Instantiates a new outline renderer. (There could be only one per scene).
  72456. * @param scene Defines the scene it belongs to
  72457. */
  72458. constructor(scene: Scene);
  72459. /**
  72460. * Register the component to one instance of a scene.
  72461. */
  72462. register(): void;
  72463. /**
  72464. * Rebuilds the elements related to this component in case of
  72465. * context lost for instance.
  72466. */
  72467. rebuild(): void;
  72468. /**
  72469. * Disposes the component and the associated ressources.
  72470. */
  72471. dispose(): void;
  72472. /**
  72473. * Renders the outline in the canvas.
  72474. * @param subMesh Defines the sumesh to render
  72475. * @param batch Defines the batch of meshes in case of instances
  72476. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72477. */
  72478. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72479. /**
  72480. * Returns whether or not the outline renderer is ready for a given submesh.
  72481. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72482. * @param subMesh Defines the submesh to check readyness for
  72483. * @param useInstances Defines wheter wee are trying to render instances or not
  72484. * @returns true if ready otherwise false
  72485. */
  72486. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72487. private _beforeRenderingMesh;
  72488. private _afterRenderingMesh;
  72489. }
  72490. }
  72491. declare module BABYLON {
  72492. /**
  72493. * Defines the basic options interface of a Sprite Frame Source Size.
  72494. */
  72495. export interface ISpriteJSONSpriteSourceSize {
  72496. /**
  72497. * number of the original width of the Frame
  72498. */
  72499. w: number;
  72500. /**
  72501. * number of the original height of the Frame
  72502. */
  72503. h: number;
  72504. }
  72505. /**
  72506. * Defines the basic options interface of a Sprite Frame Data.
  72507. */
  72508. export interface ISpriteJSONSpriteFrameData {
  72509. /**
  72510. * number of the x offset of the Frame
  72511. */
  72512. x: number;
  72513. /**
  72514. * number of the y offset of the Frame
  72515. */
  72516. y: number;
  72517. /**
  72518. * number of the width of the Frame
  72519. */
  72520. w: number;
  72521. /**
  72522. * number of the height of the Frame
  72523. */
  72524. h: number;
  72525. }
  72526. /**
  72527. * Defines the basic options interface of a JSON Sprite.
  72528. */
  72529. export interface ISpriteJSONSprite {
  72530. /**
  72531. * string name of the Frame
  72532. */
  72533. filename: string;
  72534. /**
  72535. * ISpriteJSONSpriteFrame basic object of the frame data
  72536. */
  72537. frame: ISpriteJSONSpriteFrameData;
  72538. /**
  72539. * boolean to flag is the frame was rotated.
  72540. */
  72541. rotated: boolean;
  72542. /**
  72543. * boolean to flag is the frame was trimmed.
  72544. */
  72545. trimmed: boolean;
  72546. /**
  72547. * ISpriteJSONSpriteFrame basic object of the source data
  72548. */
  72549. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72550. /**
  72551. * ISpriteJSONSpriteFrame basic object of the source data
  72552. */
  72553. sourceSize: ISpriteJSONSpriteSourceSize;
  72554. }
  72555. /**
  72556. * Defines the basic options interface of a JSON atlas.
  72557. */
  72558. export interface ISpriteJSONAtlas {
  72559. /**
  72560. * Array of objects that contain the frame data.
  72561. */
  72562. frames: Array<ISpriteJSONSprite>;
  72563. /**
  72564. * object basic object containing the sprite meta data.
  72565. */
  72566. meta?: object;
  72567. }
  72568. }
  72569. declare module BABYLON {
  72570. /** @hidden */
  72571. export var spriteMapPixelShader: {
  72572. name: string;
  72573. shader: string;
  72574. };
  72575. }
  72576. declare module BABYLON {
  72577. /** @hidden */
  72578. export var spriteMapVertexShader: {
  72579. name: string;
  72580. shader: string;
  72581. };
  72582. }
  72583. declare module BABYLON {
  72584. /**
  72585. * Defines the basic options interface of a SpriteMap
  72586. */
  72587. export interface ISpriteMapOptions {
  72588. /**
  72589. * Vector2 of the number of cells in the grid.
  72590. */
  72591. stageSize?: Vector2;
  72592. /**
  72593. * Vector2 of the size of the output plane in World Units.
  72594. */
  72595. outputSize?: Vector2;
  72596. /**
  72597. * Vector3 of the position of the output plane in World Units.
  72598. */
  72599. outputPosition?: Vector3;
  72600. /**
  72601. * Vector3 of the rotation of the output plane.
  72602. */
  72603. outputRotation?: Vector3;
  72604. /**
  72605. * number of layers that the system will reserve in resources.
  72606. */
  72607. layerCount?: number;
  72608. /**
  72609. * number of max animation frames a single cell will reserve in resources.
  72610. */
  72611. maxAnimationFrames?: number;
  72612. /**
  72613. * number cell index of the base tile when the system compiles.
  72614. */
  72615. baseTile?: number;
  72616. /**
  72617. * boolean flip the sprite after its been repositioned by the framing data.
  72618. */
  72619. flipU?: boolean;
  72620. /**
  72621. * Vector3 scalar of the global RGB values of the SpriteMap.
  72622. */
  72623. colorMultiply?: Vector3;
  72624. }
  72625. /**
  72626. * Defines the IDisposable interface in order to be cleanable from resources.
  72627. */
  72628. export interface ISpriteMap extends IDisposable {
  72629. /**
  72630. * String name of the SpriteMap.
  72631. */
  72632. name: string;
  72633. /**
  72634. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72635. */
  72636. atlasJSON: ISpriteJSONAtlas;
  72637. /**
  72638. * Texture of the SpriteMap.
  72639. */
  72640. spriteSheet: Texture;
  72641. /**
  72642. * The parameters to initialize the SpriteMap with.
  72643. */
  72644. options: ISpriteMapOptions;
  72645. }
  72646. /**
  72647. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72648. */
  72649. export class SpriteMap implements ISpriteMap {
  72650. /** The Name of the spriteMap */
  72651. name: string;
  72652. /** The JSON file with the frame and meta data */
  72653. atlasJSON: ISpriteJSONAtlas;
  72654. /** The systems Sprite Sheet Texture */
  72655. spriteSheet: Texture;
  72656. /** Arguments passed with the Constructor */
  72657. options: ISpriteMapOptions;
  72658. /** Public Sprite Storage array, parsed from atlasJSON */
  72659. sprites: Array<ISpriteJSONSprite>;
  72660. /** Returns the Number of Sprites in the System */
  72661. get spriteCount(): number;
  72662. /** Returns the Position of Output Plane*/
  72663. get position(): Vector3;
  72664. /** Returns the Position of Output Plane*/
  72665. set position(v: Vector3);
  72666. /** Returns the Rotation of Output Plane*/
  72667. get rotation(): Vector3;
  72668. /** Returns the Rotation of Output Plane*/
  72669. set rotation(v: Vector3);
  72670. /** Sets the AnimationMap*/
  72671. get animationMap(): RawTexture;
  72672. /** Sets the AnimationMap*/
  72673. set animationMap(v: RawTexture);
  72674. /** Scene that the SpriteMap was created in */
  72675. private _scene;
  72676. /** Texture Buffer of Float32 that holds tile frame data*/
  72677. private _frameMap;
  72678. /** Texture Buffers of Float32 that holds tileMap data*/
  72679. private _tileMaps;
  72680. /** Texture Buffer of Float32 that holds Animation Data*/
  72681. private _animationMap;
  72682. /** Custom ShaderMaterial Central to the System*/
  72683. private _material;
  72684. /** Custom ShaderMaterial Central to the System*/
  72685. private _output;
  72686. /** Systems Time Ticker*/
  72687. private _time;
  72688. /**
  72689. * Creates a new SpriteMap
  72690. * @param name defines the SpriteMaps Name
  72691. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72692. * @param spriteSheet is the Texture that the Sprites are on.
  72693. * @param options a basic deployment configuration
  72694. * @param scene The Scene that the map is deployed on
  72695. */
  72696. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72697. /**
  72698. * Returns tileID location
  72699. * @returns Vector2 the cell position ID
  72700. */
  72701. getTileID(): Vector2;
  72702. /**
  72703. * Gets the UV location of the mouse over the SpriteMap.
  72704. * @returns Vector2 the UV position of the mouse interaction
  72705. */
  72706. getMousePosition(): Vector2;
  72707. /**
  72708. * Creates the "frame" texture Buffer
  72709. * -------------------------------------
  72710. * Structure of frames
  72711. * "filename": "Falling-Water-2.png",
  72712. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72713. * "rotated": true,
  72714. * "trimmed": true,
  72715. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72716. * "sourceSize": {"w":32,"h":32}
  72717. * @returns RawTexture of the frameMap
  72718. */
  72719. private _createFrameBuffer;
  72720. /**
  72721. * Creates the tileMap texture Buffer
  72722. * @param buffer normally and array of numbers, or a false to generate from scratch
  72723. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72724. * @returns RawTexture of the tileMap
  72725. */
  72726. private _createTileBuffer;
  72727. /**
  72728. * Modifies the data of the tileMaps
  72729. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72730. * @param pos is the iVector2 Coordinates of the Tile
  72731. * @param tile The SpriteIndex of the new Tile
  72732. */
  72733. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72734. /**
  72735. * Creates the animationMap texture Buffer
  72736. * @param buffer normally and array of numbers, or a false to generate from scratch
  72737. * @returns RawTexture of the animationMap
  72738. */
  72739. private _createTileAnimationBuffer;
  72740. /**
  72741. * Modifies the data of the animationMap
  72742. * @param cellID is the Index of the Sprite
  72743. * @param _frame is the target Animation frame
  72744. * @param toCell is the Target Index of the next frame of the animation
  72745. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72746. * @param speed is a global scalar of the time variable on the map.
  72747. */
  72748. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72749. /**
  72750. * Exports the .tilemaps file
  72751. */
  72752. saveTileMaps(): void;
  72753. /**
  72754. * Imports the .tilemaps file
  72755. * @param url of the .tilemaps file
  72756. */
  72757. loadTileMaps(url: string): void;
  72758. /**
  72759. * Release associated resources
  72760. */
  72761. dispose(): void;
  72762. }
  72763. }
  72764. declare module BABYLON {
  72765. /**
  72766. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72767. * @see https://doc.babylonjs.com/babylon101/sprites
  72768. */
  72769. export class SpritePackedManager extends SpriteManager {
  72770. /** defines the packed manager's name */
  72771. name: string;
  72772. /**
  72773. * Creates a new sprite manager from a packed sprite sheet
  72774. * @param name defines the manager's name
  72775. * @param imgUrl defines the sprite sheet url
  72776. * @param capacity defines the maximum allowed number of sprites
  72777. * @param scene defines the hosting scene
  72778. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72779. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72780. * @param samplingMode defines the smapling mode to use with spritesheet
  72781. * @param fromPacked set to true; do not alter
  72782. */
  72783. constructor(
  72784. /** defines the packed manager's name */
  72785. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72786. }
  72787. }
  72788. declare module BABYLON {
  72789. /**
  72790. * Defines the list of states available for a task inside a AssetsManager
  72791. */
  72792. export enum AssetTaskState {
  72793. /**
  72794. * Initialization
  72795. */
  72796. INIT = 0,
  72797. /**
  72798. * Running
  72799. */
  72800. RUNNING = 1,
  72801. /**
  72802. * Done
  72803. */
  72804. DONE = 2,
  72805. /**
  72806. * Error
  72807. */
  72808. ERROR = 3
  72809. }
  72810. /**
  72811. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72812. */
  72813. export abstract class AbstractAssetTask {
  72814. /**
  72815. * Task name
  72816. */ name: string;
  72817. /**
  72818. * Callback called when the task is successful
  72819. */
  72820. onSuccess: (task: any) => void;
  72821. /**
  72822. * Callback called when the task is not successful
  72823. */
  72824. onError: (task: any, message?: string, exception?: any) => void;
  72825. /**
  72826. * Creates a new AssetsManager
  72827. * @param name defines the name of the task
  72828. */
  72829. constructor(
  72830. /**
  72831. * Task name
  72832. */ name: string);
  72833. private _isCompleted;
  72834. private _taskState;
  72835. private _errorObject;
  72836. /**
  72837. * Get if the task is completed
  72838. */
  72839. get isCompleted(): boolean;
  72840. /**
  72841. * Gets the current state of the task
  72842. */
  72843. get taskState(): AssetTaskState;
  72844. /**
  72845. * Gets the current error object (if task is in error)
  72846. */
  72847. get errorObject(): {
  72848. message?: string;
  72849. exception?: any;
  72850. };
  72851. /**
  72852. * Internal only
  72853. * @hidden
  72854. */
  72855. _setErrorObject(message?: string, exception?: any): void;
  72856. /**
  72857. * Execute the current task
  72858. * @param scene defines the scene where you want your assets to be loaded
  72859. * @param onSuccess is a callback called when the task is successfully executed
  72860. * @param onError is a callback called if an error occurs
  72861. */
  72862. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72863. /**
  72864. * Execute the current task
  72865. * @param scene defines the scene where you want your assets to be loaded
  72866. * @param onSuccess is a callback called when the task is successfully executed
  72867. * @param onError is a callback called if an error occurs
  72868. */
  72869. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72870. /**
  72871. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72872. * This can be used with failed tasks that have the reason for failure fixed.
  72873. */
  72874. reset(): void;
  72875. private onErrorCallback;
  72876. private onDoneCallback;
  72877. }
  72878. /**
  72879. * Define the interface used by progress events raised during assets loading
  72880. */
  72881. export interface IAssetsProgressEvent {
  72882. /**
  72883. * Defines the number of remaining tasks to process
  72884. */
  72885. remainingCount: number;
  72886. /**
  72887. * Defines the total number of tasks
  72888. */
  72889. totalCount: number;
  72890. /**
  72891. * Defines the task that was just processed
  72892. */
  72893. task: AbstractAssetTask;
  72894. }
  72895. /**
  72896. * Class used to share progress information about assets loading
  72897. */
  72898. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72899. /**
  72900. * Defines the number of remaining tasks to process
  72901. */
  72902. remainingCount: number;
  72903. /**
  72904. * Defines the total number of tasks
  72905. */
  72906. totalCount: number;
  72907. /**
  72908. * Defines the task that was just processed
  72909. */
  72910. task: AbstractAssetTask;
  72911. /**
  72912. * Creates a AssetsProgressEvent
  72913. * @param remainingCount defines the number of remaining tasks to process
  72914. * @param totalCount defines the total number of tasks
  72915. * @param task defines the task that was just processed
  72916. */
  72917. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72918. }
  72919. /**
  72920. * Define a task used by AssetsManager to load assets into a container
  72921. */
  72922. export class ContainerAssetTask extends AbstractAssetTask {
  72923. /**
  72924. * Defines the name of the task
  72925. */
  72926. name: string;
  72927. /**
  72928. * Defines the list of mesh's names you want to load
  72929. */
  72930. meshesNames: any;
  72931. /**
  72932. * Defines the root url to use as a base to load your meshes and associated resources
  72933. */
  72934. rootUrl: string;
  72935. /**
  72936. * Defines the filename or File of the scene to load from
  72937. */
  72938. sceneFilename: string | File;
  72939. /**
  72940. * Get the loaded asset container
  72941. */
  72942. loadedContainer: AssetContainer;
  72943. /**
  72944. * Gets the list of loaded meshes
  72945. */
  72946. loadedMeshes: Array<AbstractMesh>;
  72947. /**
  72948. * Gets the list of loaded particle systems
  72949. */
  72950. loadedParticleSystems: Array<IParticleSystem>;
  72951. /**
  72952. * Gets the list of loaded skeletons
  72953. */
  72954. loadedSkeletons: Array<Skeleton>;
  72955. /**
  72956. * Gets the list of loaded animation groups
  72957. */
  72958. loadedAnimationGroups: Array<AnimationGroup>;
  72959. /**
  72960. * Callback called when the task is successful
  72961. */
  72962. onSuccess: (task: ContainerAssetTask) => void;
  72963. /**
  72964. * Callback called when the task is successful
  72965. */
  72966. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72967. /**
  72968. * Creates a new ContainerAssetTask
  72969. * @param name defines the name of the task
  72970. * @param meshesNames defines the list of mesh's names you want to load
  72971. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72972. * @param sceneFilename defines the filename or File of the scene to load from
  72973. */
  72974. constructor(
  72975. /**
  72976. * Defines the name of the task
  72977. */
  72978. name: string,
  72979. /**
  72980. * Defines the list of mesh's names you want to load
  72981. */
  72982. meshesNames: any,
  72983. /**
  72984. * Defines the root url to use as a base to load your meshes and associated resources
  72985. */
  72986. rootUrl: string,
  72987. /**
  72988. * Defines the filename or File of the scene to load from
  72989. */
  72990. sceneFilename: string | File);
  72991. /**
  72992. * Execute the current task
  72993. * @param scene defines the scene where you want your assets to be loaded
  72994. * @param onSuccess is a callback called when the task is successfully executed
  72995. * @param onError is a callback called if an error occurs
  72996. */
  72997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72998. }
  72999. /**
  73000. * Define a task used by AssetsManager to load meshes
  73001. */
  73002. export class MeshAssetTask extends AbstractAssetTask {
  73003. /**
  73004. * Defines the name of the task
  73005. */
  73006. name: string;
  73007. /**
  73008. * Defines the list of mesh's names you want to load
  73009. */
  73010. meshesNames: any;
  73011. /**
  73012. * Defines the root url to use as a base to load your meshes and associated resources
  73013. */
  73014. rootUrl: string;
  73015. /**
  73016. * Defines the filename or File of the scene to load from
  73017. */
  73018. sceneFilename: string | File;
  73019. /**
  73020. * Gets the list of loaded meshes
  73021. */
  73022. loadedMeshes: Array<AbstractMesh>;
  73023. /**
  73024. * Gets the list of loaded particle systems
  73025. */
  73026. loadedParticleSystems: Array<IParticleSystem>;
  73027. /**
  73028. * Gets the list of loaded skeletons
  73029. */
  73030. loadedSkeletons: Array<Skeleton>;
  73031. /**
  73032. * Gets the list of loaded animation groups
  73033. */
  73034. loadedAnimationGroups: Array<AnimationGroup>;
  73035. /**
  73036. * Callback called when the task is successful
  73037. */
  73038. onSuccess: (task: MeshAssetTask) => void;
  73039. /**
  73040. * Callback called when the task is successful
  73041. */
  73042. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73043. /**
  73044. * Creates a new MeshAssetTask
  73045. * @param name defines the name of the task
  73046. * @param meshesNames defines the list of mesh's names you want to load
  73047. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73048. * @param sceneFilename defines the filename or File of the scene to load from
  73049. */
  73050. constructor(
  73051. /**
  73052. * Defines the name of the task
  73053. */
  73054. name: string,
  73055. /**
  73056. * Defines the list of mesh's names you want to load
  73057. */
  73058. meshesNames: any,
  73059. /**
  73060. * Defines the root url to use as a base to load your meshes and associated resources
  73061. */
  73062. rootUrl: string,
  73063. /**
  73064. * Defines the filename or File of the scene to load from
  73065. */
  73066. sceneFilename: string | File);
  73067. /**
  73068. * Execute the current task
  73069. * @param scene defines the scene where you want your assets to be loaded
  73070. * @param onSuccess is a callback called when the task is successfully executed
  73071. * @param onError is a callback called if an error occurs
  73072. */
  73073. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73074. }
  73075. /**
  73076. * Define a task used by AssetsManager to load text content
  73077. */
  73078. export class TextFileAssetTask extends AbstractAssetTask {
  73079. /**
  73080. * Defines the name of the task
  73081. */
  73082. name: string;
  73083. /**
  73084. * Defines the location of the file to load
  73085. */
  73086. url: string;
  73087. /**
  73088. * Gets the loaded text string
  73089. */
  73090. text: string;
  73091. /**
  73092. * Callback called when the task is successful
  73093. */
  73094. onSuccess: (task: TextFileAssetTask) => void;
  73095. /**
  73096. * Callback called when the task is successful
  73097. */
  73098. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73099. /**
  73100. * Creates a new TextFileAssetTask object
  73101. * @param name defines the name of the task
  73102. * @param url defines the location of the file to load
  73103. */
  73104. constructor(
  73105. /**
  73106. * Defines the name of the task
  73107. */
  73108. name: string,
  73109. /**
  73110. * Defines the location of the file to load
  73111. */
  73112. url: string);
  73113. /**
  73114. * Execute the current task
  73115. * @param scene defines the scene where you want your assets to be loaded
  73116. * @param onSuccess is a callback called when the task is successfully executed
  73117. * @param onError is a callback called if an error occurs
  73118. */
  73119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73120. }
  73121. /**
  73122. * Define a task used by AssetsManager to load binary data
  73123. */
  73124. export class BinaryFileAssetTask extends AbstractAssetTask {
  73125. /**
  73126. * Defines the name of the task
  73127. */
  73128. name: string;
  73129. /**
  73130. * Defines the location of the file to load
  73131. */
  73132. url: string;
  73133. /**
  73134. * Gets the lodaded data (as an array buffer)
  73135. */
  73136. data: ArrayBuffer;
  73137. /**
  73138. * Callback called when the task is successful
  73139. */
  73140. onSuccess: (task: BinaryFileAssetTask) => void;
  73141. /**
  73142. * Callback called when the task is successful
  73143. */
  73144. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73145. /**
  73146. * Creates a new BinaryFileAssetTask object
  73147. * @param name defines the name of the new task
  73148. * @param url defines the location of the file to load
  73149. */
  73150. constructor(
  73151. /**
  73152. * Defines the name of the task
  73153. */
  73154. name: string,
  73155. /**
  73156. * Defines the location of the file to load
  73157. */
  73158. url: string);
  73159. /**
  73160. * Execute the current task
  73161. * @param scene defines the scene where you want your assets to be loaded
  73162. * @param onSuccess is a callback called when the task is successfully executed
  73163. * @param onError is a callback called if an error occurs
  73164. */
  73165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73166. }
  73167. /**
  73168. * Define a task used by AssetsManager to load images
  73169. */
  73170. export class ImageAssetTask extends AbstractAssetTask {
  73171. /**
  73172. * Defines the name of the task
  73173. */
  73174. name: string;
  73175. /**
  73176. * Defines the location of the image to load
  73177. */
  73178. url: string;
  73179. /**
  73180. * Gets the loaded images
  73181. */
  73182. image: HTMLImageElement;
  73183. /**
  73184. * Callback called when the task is successful
  73185. */
  73186. onSuccess: (task: ImageAssetTask) => void;
  73187. /**
  73188. * Callback called when the task is successful
  73189. */
  73190. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73191. /**
  73192. * Creates a new ImageAssetTask
  73193. * @param name defines the name of the task
  73194. * @param url defines the location of the image to load
  73195. */
  73196. constructor(
  73197. /**
  73198. * Defines the name of the task
  73199. */
  73200. name: string,
  73201. /**
  73202. * Defines the location of the image to load
  73203. */
  73204. url: string);
  73205. /**
  73206. * Execute the current task
  73207. * @param scene defines the scene where you want your assets to be loaded
  73208. * @param onSuccess is a callback called when the task is successfully executed
  73209. * @param onError is a callback called if an error occurs
  73210. */
  73211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73212. }
  73213. /**
  73214. * Defines the interface used by texture loading tasks
  73215. */
  73216. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73217. /**
  73218. * Gets the loaded texture
  73219. */
  73220. texture: TEX;
  73221. }
  73222. /**
  73223. * Define a task used by AssetsManager to load 2D textures
  73224. */
  73225. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73226. /**
  73227. * Defines the name of the task
  73228. */
  73229. name: string;
  73230. /**
  73231. * Defines the location of the file to load
  73232. */
  73233. url: string;
  73234. /**
  73235. * Defines if mipmap should not be generated (default is false)
  73236. */
  73237. noMipmap?: boolean | undefined;
  73238. /**
  73239. * Defines if texture must be inverted on Y axis (default is true)
  73240. */
  73241. invertY: boolean;
  73242. /**
  73243. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73244. */
  73245. samplingMode: number;
  73246. /**
  73247. * Gets the loaded texture
  73248. */
  73249. texture: Texture;
  73250. /**
  73251. * Callback called when the task is successful
  73252. */
  73253. onSuccess: (task: TextureAssetTask) => void;
  73254. /**
  73255. * Callback called when the task is successful
  73256. */
  73257. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73258. /**
  73259. * Creates a new TextureAssetTask object
  73260. * @param name defines the name of the task
  73261. * @param url defines the location of the file to load
  73262. * @param noMipmap defines if mipmap should not be generated (default is false)
  73263. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73264. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73265. */
  73266. constructor(
  73267. /**
  73268. * Defines the name of the task
  73269. */
  73270. name: string,
  73271. /**
  73272. * Defines the location of the file to load
  73273. */
  73274. url: string,
  73275. /**
  73276. * Defines if mipmap should not be generated (default is false)
  73277. */
  73278. noMipmap?: boolean | undefined,
  73279. /**
  73280. * Defines if texture must be inverted on Y axis (default is true)
  73281. */
  73282. invertY?: boolean,
  73283. /**
  73284. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73285. */
  73286. samplingMode?: number);
  73287. /**
  73288. * Execute the current task
  73289. * @param scene defines the scene where you want your assets to be loaded
  73290. * @param onSuccess is a callback called when the task is successfully executed
  73291. * @param onError is a callback called if an error occurs
  73292. */
  73293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73294. }
  73295. /**
  73296. * Define a task used by AssetsManager to load cube textures
  73297. */
  73298. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73299. /**
  73300. * Defines the name of the task
  73301. */
  73302. name: string;
  73303. /**
  73304. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73305. */
  73306. url: string;
  73307. /**
  73308. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73309. */
  73310. extensions?: string[] | undefined;
  73311. /**
  73312. * Defines if mipmaps should not be generated (default is false)
  73313. */
  73314. noMipmap?: boolean | undefined;
  73315. /**
  73316. * Defines the explicit list of files (undefined by default)
  73317. */
  73318. files?: string[] | undefined;
  73319. /**
  73320. * Gets the loaded texture
  73321. */
  73322. texture: CubeTexture;
  73323. /**
  73324. * Callback called when the task is successful
  73325. */
  73326. onSuccess: (task: CubeTextureAssetTask) => void;
  73327. /**
  73328. * Callback called when the task is successful
  73329. */
  73330. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73331. /**
  73332. * Creates a new CubeTextureAssetTask
  73333. * @param name defines the name of the task
  73334. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73335. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73336. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73337. * @param files defines the explicit list of files (undefined by default)
  73338. */
  73339. constructor(
  73340. /**
  73341. * Defines the name of the task
  73342. */
  73343. name: string,
  73344. /**
  73345. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73346. */
  73347. url: string,
  73348. /**
  73349. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73350. */
  73351. extensions?: string[] | undefined,
  73352. /**
  73353. * Defines if mipmaps should not be generated (default is false)
  73354. */
  73355. noMipmap?: boolean | undefined,
  73356. /**
  73357. * Defines the explicit list of files (undefined by default)
  73358. */
  73359. files?: string[] | undefined);
  73360. /**
  73361. * Execute the current task
  73362. * @param scene defines the scene where you want your assets to be loaded
  73363. * @param onSuccess is a callback called when the task is successfully executed
  73364. * @param onError is a callback called if an error occurs
  73365. */
  73366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73367. }
  73368. /**
  73369. * Define a task used by AssetsManager to load HDR cube textures
  73370. */
  73371. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73372. /**
  73373. * Defines the name of the task
  73374. */
  73375. name: string;
  73376. /**
  73377. * Defines the location of the file to load
  73378. */
  73379. url: string;
  73380. /**
  73381. * Defines the desired size (the more it increases the longer the generation will be)
  73382. */
  73383. size: number;
  73384. /**
  73385. * Defines if mipmaps should not be generated (default is false)
  73386. */
  73387. noMipmap: boolean;
  73388. /**
  73389. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73390. */
  73391. generateHarmonics: boolean;
  73392. /**
  73393. * 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)
  73394. */
  73395. gammaSpace: boolean;
  73396. /**
  73397. * Internal Use Only
  73398. */
  73399. reserved: boolean;
  73400. /**
  73401. * Gets the loaded texture
  73402. */
  73403. texture: HDRCubeTexture;
  73404. /**
  73405. * Callback called when the task is successful
  73406. */
  73407. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73408. /**
  73409. * Callback called when the task is successful
  73410. */
  73411. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73412. /**
  73413. * Creates a new HDRCubeTextureAssetTask object
  73414. * @param name defines the name of the task
  73415. * @param url defines the location of the file to load
  73416. * @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.
  73417. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73418. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73419. * @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)
  73420. * @param reserved Internal use only
  73421. */
  73422. constructor(
  73423. /**
  73424. * Defines the name of the task
  73425. */
  73426. name: string,
  73427. /**
  73428. * Defines the location of the file to load
  73429. */
  73430. url: string,
  73431. /**
  73432. * Defines the desired size (the more it increases the longer the generation will be)
  73433. */
  73434. size: number,
  73435. /**
  73436. * Defines if mipmaps should not be generated (default is false)
  73437. */
  73438. noMipmap?: boolean,
  73439. /**
  73440. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73441. */
  73442. generateHarmonics?: boolean,
  73443. /**
  73444. * 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)
  73445. */
  73446. gammaSpace?: boolean,
  73447. /**
  73448. * Internal Use Only
  73449. */
  73450. reserved?: boolean);
  73451. /**
  73452. * Execute the current task
  73453. * @param scene defines the scene where you want your assets to be loaded
  73454. * @param onSuccess is a callback called when the task is successfully executed
  73455. * @param onError is a callback called if an error occurs
  73456. */
  73457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73458. }
  73459. /**
  73460. * Define a task used by AssetsManager to load Equirectangular cube textures
  73461. */
  73462. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73463. /**
  73464. * Defines the name of the task
  73465. */
  73466. name: string;
  73467. /**
  73468. * Defines the location of the file to load
  73469. */
  73470. url: string;
  73471. /**
  73472. * Defines the desired size (the more it increases the longer the generation will be)
  73473. */
  73474. size: number;
  73475. /**
  73476. * Defines if mipmaps should not be generated (default is false)
  73477. */
  73478. noMipmap: boolean;
  73479. /**
  73480. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73481. * but the standard material would require them in Gamma space) (default is true)
  73482. */
  73483. gammaSpace: boolean;
  73484. /**
  73485. * Gets the loaded texture
  73486. */
  73487. texture: EquiRectangularCubeTexture;
  73488. /**
  73489. * Callback called when the task is successful
  73490. */
  73491. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73492. /**
  73493. * Callback called when the task is successful
  73494. */
  73495. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73496. /**
  73497. * Creates a new EquiRectangularCubeTextureAssetTask object
  73498. * @param name defines the name of the task
  73499. * @param url defines the location of the file to load
  73500. * @param size defines the desired size (the more it increases the longer the generation will be)
  73501. * If the size is omitted this implies you are using a preprocessed cubemap.
  73502. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73503. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73504. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73505. * (default is true)
  73506. */
  73507. constructor(
  73508. /**
  73509. * Defines the name of the task
  73510. */
  73511. name: string,
  73512. /**
  73513. * Defines the location of the file to load
  73514. */
  73515. url: string,
  73516. /**
  73517. * Defines the desired size (the more it increases the longer the generation will be)
  73518. */
  73519. size: number,
  73520. /**
  73521. * Defines if mipmaps should not be generated (default is false)
  73522. */
  73523. noMipmap?: boolean,
  73524. /**
  73525. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73526. * but the standard material would require them in Gamma space) (default is true)
  73527. */
  73528. gammaSpace?: boolean);
  73529. /**
  73530. * Execute the current task
  73531. * @param scene defines the scene where you want your assets to be loaded
  73532. * @param onSuccess is a callback called when the task is successfully executed
  73533. * @param onError is a callback called if an error occurs
  73534. */
  73535. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73536. }
  73537. /**
  73538. * This class can be used to easily import assets into a scene
  73539. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73540. */
  73541. export class AssetsManager {
  73542. private _scene;
  73543. private _isLoading;
  73544. protected _tasks: AbstractAssetTask[];
  73545. protected _waitingTasksCount: number;
  73546. protected _totalTasksCount: number;
  73547. /**
  73548. * Callback called when all tasks are processed
  73549. */
  73550. onFinish: (tasks: AbstractAssetTask[]) => void;
  73551. /**
  73552. * Callback called when a task is successful
  73553. */
  73554. onTaskSuccess: (task: AbstractAssetTask) => void;
  73555. /**
  73556. * Callback called when a task had an error
  73557. */
  73558. onTaskError: (task: AbstractAssetTask) => void;
  73559. /**
  73560. * Callback called when a task is done (whatever the result is)
  73561. */
  73562. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73563. /**
  73564. * Observable called when all tasks are processed
  73565. */
  73566. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73567. /**
  73568. * Observable called when a task had an error
  73569. */
  73570. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73571. /**
  73572. * Observable called when all tasks were executed
  73573. */
  73574. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73575. /**
  73576. * Observable called when a task is done (whatever the result is)
  73577. */
  73578. onProgressObservable: Observable<IAssetsProgressEvent>;
  73579. /**
  73580. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73581. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73582. */
  73583. useDefaultLoadingScreen: boolean;
  73584. /**
  73585. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73586. * when all assets have been downloaded.
  73587. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73588. */
  73589. autoHideLoadingUI: boolean;
  73590. /**
  73591. * Creates a new AssetsManager
  73592. * @param scene defines the scene to work on
  73593. */
  73594. constructor(scene: Scene);
  73595. /**
  73596. * Add a ContainerAssetTask to the list of active tasks
  73597. * @param taskName defines the name of the new task
  73598. * @param meshesNames defines the name of meshes to load
  73599. * @param rootUrl defines the root url to use to locate files
  73600. * @param sceneFilename defines the filename of the scene file
  73601. * @returns a new ContainerAssetTask object
  73602. */
  73603. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73604. /**
  73605. * Add a MeshAssetTask to the list of active tasks
  73606. * @param taskName defines the name of the new task
  73607. * @param meshesNames defines the name of meshes to load
  73608. * @param rootUrl defines the root url to use to locate files
  73609. * @param sceneFilename defines the filename of the scene file
  73610. * @returns a new MeshAssetTask object
  73611. */
  73612. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73613. /**
  73614. * Add a TextFileAssetTask to the list of active tasks
  73615. * @param taskName defines the name of the new task
  73616. * @param url defines the url of the file to load
  73617. * @returns a new TextFileAssetTask object
  73618. */
  73619. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73620. /**
  73621. * Add a BinaryFileAssetTask to the list of active tasks
  73622. * @param taskName defines the name of the new task
  73623. * @param url defines the url of the file to load
  73624. * @returns a new BinaryFileAssetTask object
  73625. */
  73626. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73627. /**
  73628. * Add a ImageAssetTask to the list of active tasks
  73629. * @param taskName defines the name of the new task
  73630. * @param url defines the url of the file to load
  73631. * @returns a new ImageAssetTask object
  73632. */
  73633. addImageTask(taskName: string, url: string): ImageAssetTask;
  73634. /**
  73635. * Add a TextureAssetTask to the list of active tasks
  73636. * @param taskName defines the name of the new task
  73637. * @param url defines the url of the file to load
  73638. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73639. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73640. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73641. * @returns a new TextureAssetTask object
  73642. */
  73643. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73644. /**
  73645. * Add a CubeTextureAssetTask to the list of active tasks
  73646. * @param taskName defines the name of the new task
  73647. * @param url defines the url of the file to load
  73648. * @param extensions defines the extension to use to load the cube map (can be null)
  73649. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73650. * @param files defines the list of files to load (can be null)
  73651. * @returns a new CubeTextureAssetTask object
  73652. */
  73653. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73654. /**
  73655. *
  73656. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73657. * @param taskName defines the name of the new task
  73658. * @param url defines the url of the file to load
  73659. * @param size defines the size you want for the cubemap (can be null)
  73660. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73661. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73662. * @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)
  73663. * @param reserved Internal use only
  73664. * @returns a new HDRCubeTextureAssetTask object
  73665. */
  73666. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73667. /**
  73668. *
  73669. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73670. * @param taskName defines the name of the new task
  73671. * @param url defines the url of the file to load
  73672. * @param size defines the size you want for the cubemap (can be null)
  73673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73674. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73675. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73676. * @returns a new EquiRectangularCubeTextureAssetTask object
  73677. */
  73678. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73679. /**
  73680. * Remove a task from the assets manager.
  73681. * @param task the task to remove
  73682. */
  73683. removeTask(task: AbstractAssetTask): void;
  73684. private _decreaseWaitingTasksCount;
  73685. private _runTask;
  73686. /**
  73687. * Reset the AssetsManager and remove all tasks
  73688. * @return the current instance of the AssetsManager
  73689. */
  73690. reset(): AssetsManager;
  73691. /**
  73692. * Start the loading process
  73693. * @return the current instance of the AssetsManager
  73694. */
  73695. load(): AssetsManager;
  73696. /**
  73697. * Start the loading process as an async operation
  73698. * @return a promise returning the list of failed tasks
  73699. */
  73700. loadAsync(): Promise<void>;
  73701. }
  73702. }
  73703. declare module BABYLON {
  73704. /**
  73705. * Wrapper class for promise with external resolve and reject.
  73706. */
  73707. export class Deferred<T> {
  73708. /**
  73709. * The promise associated with this deferred object.
  73710. */
  73711. readonly promise: Promise<T>;
  73712. private _resolve;
  73713. private _reject;
  73714. /**
  73715. * The resolve method of the promise associated with this deferred object.
  73716. */
  73717. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73718. /**
  73719. * The reject method of the promise associated with this deferred object.
  73720. */
  73721. get reject(): (reason?: any) => void;
  73722. /**
  73723. * Constructor for this deferred object.
  73724. */
  73725. constructor();
  73726. }
  73727. }
  73728. declare module BABYLON {
  73729. /**
  73730. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73731. */
  73732. export class MeshExploder {
  73733. private _centerMesh;
  73734. private _meshes;
  73735. private _meshesOrigins;
  73736. private _toCenterVectors;
  73737. private _scaledDirection;
  73738. private _newPosition;
  73739. private _centerPosition;
  73740. /**
  73741. * Explodes meshes from a center mesh.
  73742. * @param meshes The meshes to explode.
  73743. * @param centerMesh The mesh to be center of explosion.
  73744. */
  73745. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73746. private _setCenterMesh;
  73747. /**
  73748. * Get class name
  73749. * @returns "MeshExploder"
  73750. */
  73751. getClassName(): string;
  73752. /**
  73753. * "Exploded meshes"
  73754. * @returns Array of meshes with the centerMesh at index 0.
  73755. */
  73756. getMeshes(): Array<Mesh>;
  73757. /**
  73758. * Explodes meshes giving a specific direction
  73759. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73760. */
  73761. explode(direction?: number): void;
  73762. }
  73763. }
  73764. declare module BABYLON {
  73765. /**
  73766. * Class used to help managing file picking and drag'n'drop
  73767. */
  73768. export class FilesInput {
  73769. /**
  73770. * List of files ready to be loaded
  73771. */
  73772. static get FilesToLoad(): {
  73773. [key: string]: File;
  73774. };
  73775. /**
  73776. * Callback called when a file is processed
  73777. */
  73778. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73779. private _engine;
  73780. private _currentScene;
  73781. private _sceneLoadedCallback;
  73782. private _progressCallback;
  73783. private _additionalRenderLoopLogicCallback;
  73784. private _textureLoadingCallback;
  73785. private _startingProcessingFilesCallback;
  73786. private _onReloadCallback;
  73787. private _errorCallback;
  73788. private _elementToMonitor;
  73789. private _sceneFileToLoad;
  73790. private _filesToLoad;
  73791. /**
  73792. * Creates a new FilesInput
  73793. * @param engine defines the rendering engine
  73794. * @param scene defines the hosting scene
  73795. * @param sceneLoadedCallback callback called when scene is loaded
  73796. * @param progressCallback callback called to track progress
  73797. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73798. * @param textureLoadingCallback callback called when a texture is loading
  73799. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73800. * @param onReloadCallback callback called when a reload is requested
  73801. * @param errorCallback callback call if an error occurs
  73802. */
  73803. 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>);
  73804. private _dragEnterHandler;
  73805. private _dragOverHandler;
  73806. private _dropHandler;
  73807. /**
  73808. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73809. * @param elementToMonitor defines the DOM element to track
  73810. */
  73811. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73812. /** Gets the current list of files to load */
  73813. get filesToLoad(): File[];
  73814. /**
  73815. * Release all associated resources
  73816. */
  73817. dispose(): void;
  73818. private renderFunction;
  73819. private drag;
  73820. private drop;
  73821. private _traverseFolder;
  73822. private _processFiles;
  73823. /**
  73824. * Load files from a drop event
  73825. * @param event defines the drop event to use as source
  73826. */
  73827. loadFiles(event: any): void;
  73828. private _processReload;
  73829. /**
  73830. * Reload the current scene from the loaded files
  73831. */
  73832. reload(): void;
  73833. }
  73834. }
  73835. declare module BABYLON {
  73836. /**
  73837. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73838. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73839. */
  73840. export class SceneOptimization {
  73841. /**
  73842. * Defines the priority of this optimization (0 by default which means first in the list)
  73843. */
  73844. priority: number;
  73845. /**
  73846. * Gets a string describing the action executed by the current optimization
  73847. * @returns description string
  73848. */
  73849. getDescription(): string;
  73850. /**
  73851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73852. * @param scene defines the current scene where to apply this optimization
  73853. * @param optimizer defines the current optimizer
  73854. * @returns true if everything that can be done was applied
  73855. */
  73856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73857. /**
  73858. * Creates the SceneOptimization object
  73859. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73860. * @param desc defines the description associated with the optimization
  73861. */
  73862. constructor(
  73863. /**
  73864. * Defines the priority of this optimization (0 by default which means first in the list)
  73865. */
  73866. priority?: number);
  73867. }
  73868. /**
  73869. * Defines an optimization used to reduce the size of render target textures
  73870. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73871. */
  73872. export class TextureOptimization extends SceneOptimization {
  73873. /**
  73874. * Defines the priority of this optimization (0 by default which means first in the list)
  73875. */
  73876. priority: number;
  73877. /**
  73878. * 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
  73879. */
  73880. maximumSize: number;
  73881. /**
  73882. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73883. */
  73884. step: number;
  73885. /**
  73886. * Gets a string describing the action executed by the current optimization
  73887. * @returns description string
  73888. */
  73889. getDescription(): string;
  73890. /**
  73891. * Creates the TextureOptimization object
  73892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73893. * @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
  73894. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73895. */
  73896. constructor(
  73897. /**
  73898. * Defines the priority of this optimization (0 by default which means first in the list)
  73899. */
  73900. priority?: number,
  73901. /**
  73902. * 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
  73903. */
  73904. maximumSize?: number,
  73905. /**
  73906. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73907. */
  73908. step?: number);
  73909. /**
  73910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73911. * @param scene defines the current scene where to apply this optimization
  73912. * @param optimizer defines the current optimizer
  73913. * @returns true if everything that can be done was applied
  73914. */
  73915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73916. }
  73917. /**
  73918. * Defines an optimization used to increase or decrease the rendering resolution
  73919. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73920. */
  73921. export class HardwareScalingOptimization extends SceneOptimization {
  73922. /**
  73923. * Defines the priority of this optimization (0 by default which means first in the list)
  73924. */
  73925. priority: number;
  73926. /**
  73927. * Defines the maximum scale to use (2 by default)
  73928. */
  73929. maximumScale: number;
  73930. /**
  73931. * Defines the step to use between two passes (0.5 by default)
  73932. */
  73933. step: number;
  73934. private _currentScale;
  73935. private _directionOffset;
  73936. /**
  73937. * Gets a string describing the action executed by the current optimization
  73938. * @return description string
  73939. */
  73940. getDescription(): string;
  73941. /**
  73942. * Creates the HardwareScalingOptimization object
  73943. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73944. * @param maximumScale defines the maximum scale to use (2 by default)
  73945. * @param step defines the step to use between two passes (0.5 by default)
  73946. */
  73947. constructor(
  73948. /**
  73949. * Defines the priority of this optimization (0 by default which means first in the list)
  73950. */
  73951. priority?: number,
  73952. /**
  73953. * Defines the maximum scale to use (2 by default)
  73954. */
  73955. maximumScale?: number,
  73956. /**
  73957. * Defines the step to use between two passes (0.5 by default)
  73958. */
  73959. step?: number);
  73960. /**
  73961. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73962. * @param scene defines the current scene where to apply this optimization
  73963. * @param optimizer defines the current optimizer
  73964. * @returns true if everything that can be done was applied
  73965. */
  73966. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73967. }
  73968. /**
  73969. * Defines an optimization used to remove shadows
  73970. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73971. */
  73972. export class ShadowsOptimization extends SceneOptimization {
  73973. /**
  73974. * Gets a string describing the action executed by the current optimization
  73975. * @return description string
  73976. */
  73977. getDescription(): string;
  73978. /**
  73979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73980. * @param scene defines the current scene where to apply this optimization
  73981. * @param optimizer defines the current optimizer
  73982. * @returns true if everything that can be done was applied
  73983. */
  73984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73985. }
  73986. /**
  73987. * Defines an optimization used to turn post-processes off
  73988. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73989. */
  73990. export class PostProcessesOptimization extends SceneOptimization {
  73991. /**
  73992. * Gets a string describing the action executed by the current optimization
  73993. * @return description string
  73994. */
  73995. getDescription(): string;
  73996. /**
  73997. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73998. * @param scene defines the current scene where to apply this optimization
  73999. * @param optimizer defines the current optimizer
  74000. * @returns true if everything that can be done was applied
  74001. */
  74002. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74003. }
  74004. /**
  74005. * Defines an optimization used to turn lens flares off
  74006. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74007. */
  74008. export class LensFlaresOptimization extends SceneOptimization {
  74009. /**
  74010. * Gets a string describing the action executed by the current optimization
  74011. * @return description string
  74012. */
  74013. getDescription(): string;
  74014. /**
  74015. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74016. * @param scene defines the current scene where to apply this optimization
  74017. * @param optimizer defines the current optimizer
  74018. * @returns true if everything that can be done was applied
  74019. */
  74020. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74021. }
  74022. /**
  74023. * Defines an optimization based on user defined callback.
  74024. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74025. */
  74026. export class CustomOptimization extends SceneOptimization {
  74027. /**
  74028. * Callback called to apply the custom optimization.
  74029. */
  74030. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74031. /**
  74032. * Callback called to get custom description
  74033. */
  74034. onGetDescription: () => string;
  74035. /**
  74036. * Gets a string describing the action executed by the current optimization
  74037. * @returns description string
  74038. */
  74039. getDescription(): string;
  74040. /**
  74041. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74042. * @param scene defines the current scene where to apply this optimization
  74043. * @param optimizer defines the current optimizer
  74044. * @returns true if everything that can be done was applied
  74045. */
  74046. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74047. }
  74048. /**
  74049. * Defines an optimization used to turn particles off
  74050. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74051. */
  74052. export class ParticlesOptimization extends SceneOptimization {
  74053. /**
  74054. * Gets a string describing the action executed by the current optimization
  74055. * @return description string
  74056. */
  74057. getDescription(): string;
  74058. /**
  74059. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74060. * @param scene defines the current scene where to apply this optimization
  74061. * @param optimizer defines the current optimizer
  74062. * @returns true if everything that can be done was applied
  74063. */
  74064. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74065. }
  74066. /**
  74067. * Defines an optimization used to turn render targets off
  74068. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74069. */
  74070. export class RenderTargetsOptimization extends SceneOptimization {
  74071. /**
  74072. * Gets a string describing the action executed by the current optimization
  74073. * @return description string
  74074. */
  74075. getDescription(): string;
  74076. /**
  74077. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74078. * @param scene defines the current scene where to apply this optimization
  74079. * @param optimizer defines the current optimizer
  74080. * @returns true if everything that can be done was applied
  74081. */
  74082. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74083. }
  74084. /**
  74085. * Defines an optimization used to merge meshes with compatible materials
  74086. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74087. */
  74088. export class MergeMeshesOptimization extends SceneOptimization {
  74089. private static _UpdateSelectionTree;
  74090. /**
  74091. * Gets or sets a boolean which defines if optimization octree has to be updated
  74092. */
  74093. static get UpdateSelectionTree(): boolean;
  74094. /**
  74095. * Gets or sets a boolean which defines if optimization octree has to be updated
  74096. */
  74097. static set UpdateSelectionTree(value: boolean);
  74098. /**
  74099. * Gets a string describing the action executed by the current optimization
  74100. * @return description string
  74101. */
  74102. getDescription(): string;
  74103. private _canBeMerged;
  74104. /**
  74105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74106. * @param scene defines the current scene where to apply this optimization
  74107. * @param optimizer defines the current optimizer
  74108. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74109. * @returns true if everything that can be done was applied
  74110. */
  74111. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74112. }
  74113. /**
  74114. * Defines a list of options used by SceneOptimizer
  74115. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74116. */
  74117. export class SceneOptimizerOptions {
  74118. /**
  74119. * Defines the target frame rate to reach (60 by default)
  74120. */
  74121. targetFrameRate: number;
  74122. /**
  74123. * Defines the interval between two checkes (2000ms by default)
  74124. */
  74125. trackerDuration: number;
  74126. /**
  74127. * Gets the list of optimizations to apply
  74128. */
  74129. optimizations: SceneOptimization[];
  74130. /**
  74131. * Creates a new list of options used by SceneOptimizer
  74132. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74133. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74134. */
  74135. constructor(
  74136. /**
  74137. * Defines the target frame rate to reach (60 by default)
  74138. */
  74139. targetFrameRate?: number,
  74140. /**
  74141. * Defines the interval between two checkes (2000ms by default)
  74142. */
  74143. trackerDuration?: number);
  74144. /**
  74145. * Add a new optimization
  74146. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74147. * @returns the current SceneOptimizerOptions
  74148. */
  74149. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74150. /**
  74151. * Add a new custom optimization
  74152. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74153. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74155. * @returns the current SceneOptimizerOptions
  74156. */
  74157. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74158. /**
  74159. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74160. * @param targetFrameRate defines the target frame rate (60 by default)
  74161. * @returns a SceneOptimizerOptions object
  74162. */
  74163. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74164. /**
  74165. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74166. * @param targetFrameRate defines the target frame rate (60 by default)
  74167. * @returns a SceneOptimizerOptions object
  74168. */
  74169. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74170. /**
  74171. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74172. * @param targetFrameRate defines the target frame rate (60 by default)
  74173. * @returns a SceneOptimizerOptions object
  74174. */
  74175. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74176. }
  74177. /**
  74178. * Class used to run optimizations in order to reach a target frame rate
  74179. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74180. */
  74181. export class SceneOptimizer implements IDisposable {
  74182. private _isRunning;
  74183. private _options;
  74184. private _scene;
  74185. private _currentPriorityLevel;
  74186. private _targetFrameRate;
  74187. private _trackerDuration;
  74188. private _currentFrameRate;
  74189. private _sceneDisposeObserver;
  74190. private _improvementMode;
  74191. /**
  74192. * Defines an observable called when the optimizer reaches the target frame rate
  74193. */
  74194. onSuccessObservable: Observable<SceneOptimizer>;
  74195. /**
  74196. * Defines an observable called when the optimizer enables an optimization
  74197. */
  74198. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74199. /**
  74200. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74201. */
  74202. onFailureObservable: Observable<SceneOptimizer>;
  74203. /**
  74204. * Gets a boolean indicating if the optimizer is in improvement mode
  74205. */
  74206. get isInImprovementMode(): boolean;
  74207. /**
  74208. * Gets the current priority level (0 at start)
  74209. */
  74210. get currentPriorityLevel(): number;
  74211. /**
  74212. * Gets the current frame rate checked by the SceneOptimizer
  74213. */
  74214. get currentFrameRate(): number;
  74215. /**
  74216. * Gets or sets the current target frame rate (60 by default)
  74217. */
  74218. get targetFrameRate(): number;
  74219. /**
  74220. * Gets or sets the current target frame rate (60 by default)
  74221. */
  74222. set targetFrameRate(value: number);
  74223. /**
  74224. * Gets or sets the current interval between two checks (every 2000ms by default)
  74225. */
  74226. get trackerDuration(): number;
  74227. /**
  74228. * Gets or sets the current interval between two checks (every 2000ms by default)
  74229. */
  74230. set trackerDuration(value: number);
  74231. /**
  74232. * Gets the list of active optimizations
  74233. */
  74234. get optimizations(): SceneOptimization[];
  74235. /**
  74236. * Creates a new SceneOptimizer
  74237. * @param scene defines the scene to work on
  74238. * @param options defines the options to use with the SceneOptimizer
  74239. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74240. * @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)
  74241. */
  74242. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74243. /**
  74244. * Stops the current optimizer
  74245. */
  74246. stop(): void;
  74247. /**
  74248. * Reset the optimizer to initial step (current priority level = 0)
  74249. */
  74250. reset(): void;
  74251. /**
  74252. * Start the optimizer. By default it will try to reach a specific framerate
  74253. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74254. */
  74255. start(): void;
  74256. private _checkCurrentState;
  74257. /**
  74258. * Release all resources
  74259. */
  74260. dispose(): void;
  74261. /**
  74262. * Helper function to create a SceneOptimizer with one single line of code
  74263. * @param scene defines the scene to work on
  74264. * @param options defines the options to use with the SceneOptimizer
  74265. * @param onSuccess defines a callback to call on success
  74266. * @param onFailure defines a callback to call on failure
  74267. * @returns the new SceneOptimizer object
  74268. */
  74269. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74270. }
  74271. }
  74272. declare module BABYLON {
  74273. /**
  74274. * Class used to serialize a scene into a string
  74275. */
  74276. export class SceneSerializer {
  74277. /**
  74278. * Clear cache used by a previous serialization
  74279. */
  74280. static ClearCache(): void;
  74281. /**
  74282. * Serialize a scene into a JSON compatible object
  74283. * @param scene defines the scene to serialize
  74284. * @returns a JSON compatible object
  74285. */
  74286. static Serialize(scene: Scene): any;
  74287. /**
  74288. * Serialize a mesh into a JSON compatible object
  74289. * @param toSerialize defines the mesh to serialize
  74290. * @param withParents defines if parents must be serialized as well
  74291. * @param withChildren defines if children must be serialized as well
  74292. * @returns a JSON compatible object
  74293. */
  74294. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74295. }
  74296. }
  74297. declare module BABYLON {
  74298. /**
  74299. * Class used to host texture specific utilities
  74300. */
  74301. export class TextureTools {
  74302. /**
  74303. * Uses the GPU to create a copy texture rescaled at a given size
  74304. * @param texture Texture to copy from
  74305. * @param width defines the desired width
  74306. * @param height defines the desired height
  74307. * @param useBilinearMode defines if bilinear mode has to be used
  74308. * @return the generated texture
  74309. */
  74310. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /**
  74315. * This represents the different options available for the video capture.
  74316. */
  74317. export interface VideoRecorderOptions {
  74318. /** Defines the mime type of the video. */
  74319. mimeType: string;
  74320. /** Defines the FPS the video should be recorded at. */
  74321. fps: number;
  74322. /** Defines the chunk size for the recording data. */
  74323. recordChunckSize: number;
  74324. /** The audio tracks to attach to the recording. */
  74325. audioTracks?: MediaStreamTrack[];
  74326. }
  74327. /**
  74328. * This can help with recording videos from BabylonJS.
  74329. * This is based on the available WebRTC functionalities of the browser.
  74330. *
  74331. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74332. */
  74333. export class VideoRecorder {
  74334. private static readonly _defaultOptions;
  74335. /**
  74336. * Returns whether or not the VideoRecorder is available in your browser.
  74337. * @param engine Defines the Babylon Engine.
  74338. * @returns true if supported otherwise false.
  74339. */
  74340. static IsSupported(engine: Engine): boolean;
  74341. private readonly _options;
  74342. private _canvas;
  74343. private _mediaRecorder;
  74344. private _recordedChunks;
  74345. private _fileName;
  74346. private _resolve;
  74347. private _reject;
  74348. /**
  74349. * True when a recording is already in progress.
  74350. */
  74351. get isRecording(): boolean;
  74352. /**
  74353. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74354. * @param engine Defines the BabylonJS Engine you wish to record.
  74355. * @param options Defines options that can be used to customize the capture.
  74356. */
  74357. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74358. /**
  74359. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74360. */
  74361. stopRecording(): void;
  74362. /**
  74363. * Starts recording the canvas for a max duration specified in parameters.
  74364. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74365. * If null no automatic download will start and you can rely on the promise to get the data back.
  74366. * @param maxDuration Defines the maximum recording time in seconds.
  74367. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74368. * @return A promise callback at the end of the recording with the video data in Blob.
  74369. */
  74370. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74371. /**
  74372. * Releases internal resources used during the recording.
  74373. */
  74374. dispose(): void;
  74375. private _handleDataAvailable;
  74376. private _handleError;
  74377. private _handleStop;
  74378. }
  74379. }
  74380. declare module BABYLON {
  74381. /**
  74382. * Class containing a set of static utilities functions for screenshots
  74383. */
  74384. export class ScreenshotTools {
  74385. /**
  74386. * Captures a screenshot of the current rendering
  74387. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74388. * @param engine defines the rendering engine
  74389. * @param camera defines the source camera
  74390. * @param size This parameter can be set to a single number or to an object with the
  74391. * following (optional) properties: precision, width, height. If a single number is passed,
  74392. * it will be used for both width and height. If an object is passed, the screenshot size
  74393. * will be derived from the parameters. The precision property is a multiplier allowing
  74394. * rendering at a higher or lower resolution
  74395. * @param successCallback defines the callback receives a single parameter which contains the
  74396. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74397. * src parameter of an <img> to display it
  74398. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74399. * Check your browser for supported MIME types
  74400. */
  74401. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74402. /**
  74403. * Captures a screenshot of the current rendering
  74404. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74405. * @param engine defines the rendering engine
  74406. * @param camera defines the source camera
  74407. * @param size This parameter can be set to a single number or to an object with the
  74408. * following (optional) properties: precision, width, height. If a single number is passed,
  74409. * it will be used for both width and height. If an object is passed, the screenshot size
  74410. * will be derived from the parameters. The precision property is a multiplier allowing
  74411. * rendering at a higher or lower resolution
  74412. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74413. * Check your browser for supported MIME types
  74414. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74415. * to the src parameter of an <img> to display it
  74416. */
  74417. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74418. /**
  74419. * Generates an image screenshot from the specified camera.
  74420. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74421. * @param engine The engine to use for rendering
  74422. * @param camera The camera to use for rendering
  74423. * @param size This parameter can be set to a single number or to an object with the
  74424. * following (optional) properties: precision, width, height. If a single number is passed,
  74425. * it will be used for both width and height. If an object is passed, the screenshot size
  74426. * will be derived from the parameters. The precision property is a multiplier allowing
  74427. * rendering at a higher or lower resolution
  74428. * @param successCallback The callback receives a single parameter which contains the
  74429. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74430. * src parameter of an <img> to display it
  74431. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74432. * Check your browser for supported MIME types
  74433. * @param samples Texture samples (default: 1)
  74434. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74435. * @param fileName A name for for the downloaded file.
  74436. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74437. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74438. */
  74439. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  74440. /**
  74441. * Generates an image screenshot from the specified camera.
  74442. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74443. * @param engine The engine to use for rendering
  74444. * @param camera The camera to use for rendering
  74445. * @param size This parameter can be set to a single number or to an object with the
  74446. * following (optional) properties: precision, width, height. If a single number is passed,
  74447. * it will be used for both width and height. If an object is passed, the screenshot size
  74448. * will be derived from the parameters. The precision property is a multiplier allowing
  74449. * rendering at a higher or lower resolution
  74450. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74451. * Check your browser for supported MIME types
  74452. * @param samples Texture samples (default: 1)
  74453. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74454. * @param fileName A name for for the downloaded file.
  74455. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74456. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74457. * to the src parameter of an <img> to display it
  74458. */
  74459. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74460. /**
  74461. * Gets height and width for screenshot size
  74462. * @private
  74463. */
  74464. private static _getScreenshotSize;
  74465. }
  74466. }
  74467. declare module BABYLON {
  74468. /**
  74469. * Interface for a data buffer
  74470. */
  74471. export interface IDataBuffer {
  74472. /**
  74473. * Reads bytes from the data buffer.
  74474. * @param byteOffset The byte offset to read
  74475. * @param byteLength The byte length to read
  74476. * @returns A promise that resolves when the bytes are read
  74477. */
  74478. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74479. /**
  74480. * The byte length of the buffer.
  74481. */
  74482. readonly byteLength: number;
  74483. }
  74484. /**
  74485. * Utility class for reading from a data buffer
  74486. */
  74487. export class DataReader {
  74488. /**
  74489. * The data buffer associated with this data reader.
  74490. */
  74491. readonly buffer: IDataBuffer;
  74492. /**
  74493. * The current byte offset from the beginning of the data buffer.
  74494. */
  74495. byteOffset: number;
  74496. private _dataView;
  74497. private _dataByteOffset;
  74498. /**
  74499. * Constructor
  74500. * @param buffer The buffer to read
  74501. */
  74502. constructor(buffer: IDataBuffer);
  74503. /**
  74504. * Loads the given byte length.
  74505. * @param byteLength The byte length to load
  74506. * @returns A promise that resolves when the load is complete
  74507. */
  74508. loadAsync(byteLength: number): Promise<void>;
  74509. /**
  74510. * Read a unsigned 32-bit integer from the currently loaded data range.
  74511. * @returns The 32-bit integer read
  74512. */
  74513. readUint32(): number;
  74514. /**
  74515. * Read a byte array from the currently loaded data range.
  74516. * @param byteLength The byte length to read
  74517. * @returns The byte array read
  74518. */
  74519. readUint8Array(byteLength: number): Uint8Array;
  74520. /**
  74521. * Read a string from the currently loaded data range.
  74522. * @param byteLength The byte length to read
  74523. * @returns The string read
  74524. */
  74525. readString(byteLength: number): string;
  74526. /**
  74527. * Skips the given byte length the currently loaded data range.
  74528. * @param byteLength The byte length to skip
  74529. */
  74530. skipBytes(byteLength: number): void;
  74531. }
  74532. }
  74533. declare module BABYLON {
  74534. /**
  74535. * Class for storing data to local storage if available or in-memory storage otherwise
  74536. */
  74537. export class DataStorage {
  74538. private static _Storage;
  74539. private static _GetStorage;
  74540. /**
  74541. * Reads a string from the data storage
  74542. * @param key The key to read
  74543. * @param defaultValue The value if the key doesn't exist
  74544. * @returns The string value
  74545. */
  74546. static ReadString(key: string, defaultValue: string): string;
  74547. /**
  74548. * Writes a string to the data storage
  74549. * @param key The key to write
  74550. * @param value The value to write
  74551. */
  74552. static WriteString(key: string, value: string): void;
  74553. /**
  74554. * Reads a boolean from the data storage
  74555. * @param key The key to read
  74556. * @param defaultValue The value if the key doesn't exist
  74557. * @returns The boolean value
  74558. */
  74559. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74560. /**
  74561. * Writes a boolean to the data storage
  74562. * @param key The key to write
  74563. * @param value The value to write
  74564. */
  74565. static WriteBoolean(key: string, value: boolean): void;
  74566. /**
  74567. * Reads a number from the data storage
  74568. * @param key The key to read
  74569. * @param defaultValue The value if the key doesn't exist
  74570. * @returns The number value
  74571. */
  74572. static ReadNumber(key: string, defaultValue: number): number;
  74573. /**
  74574. * Writes a number to the data storage
  74575. * @param key The key to write
  74576. * @param value The value to write
  74577. */
  74578. static WriteNumber(key: string, value: number): void;
  74579. }
  74580. }
  74581. declare module BABYLON {
  74582. /**
  74583. * Class used to record delta files between 2 scene states
  74584. */
  74585. export class SceneRecorder {
  74586. private _trackedScene;
  74587. private _savedJSON;
  74588. /**
  74589. * Track a given scene. This means the current scene state will be considered the original state
  74590. * @param scene defines the scene to track
  74591. */
  74592. track(scene: Scene): void;
  74593. /**
  74594. * Get the delta between current state and original state
  74595. * @returns a string containing the delta
  74596. */
  74597. getDelta(): any;
  74598. private _compareArray;
  74599. private _compareObjects;
  74600. private _compareCollections;
  74601. private static GetShadowGeneratorById;
  74602. /**
  74603. * Apply a given delta to a given scene
  74604. * @param deltaJSON defines the JSON containing the delta
  74605. * @param scene defines the scene to apply the delta to
  74606. */
  74607. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74608. private static _ApplyPropertiesToEntity;
  74609. private static _ApplyDeltaForEntity;
  74610. }
  74611. }
  74612. declare module BABYLON {
  74613. /**
  74614. * A 3D trajectory consisting of an order list of vectors describing a
  74615. * path of motion through 3D space.
  74616. */
  74617. export class Trajectory {
  74618. private _points;
  74619. private readonly _segmentLength;
  74620. /**
  74621. * Serialize to JSON.
  74622. * @returns serialized JSON string
  74623. */
  74624. serialize(): string;
  74625. /**
  74626. * Deserialize from JSON.
  74627. * @param json serialized JSON string
  74628. * @returns deserialized Trajectory
  74629. */
  74630. static Deserialize(json: string): Trajectory;
  74631. /**
  74632. * Create a new empty Trajectory.
  74633. * @param segmentLength radius of discretization for Trajectory points
  74634. */
  74635. constructor(segmentLength?: number);
  74636. /**
  74637. * Get the length of the Trajectory.
  74638. * @returns length of the Trajectory
  74639. */
  74640. getLength(): number;
  74641. /**
  74642. * Append a new point to the Trajectory.
  74643. * NOTE: This implementation has many allocations.
  74644. * @param point point to append to the Trajectory
  74645. */
  74646. add(point: DeepImmutable<Vector3>): void;
  74647. /**
  74648. * Create a new Trajectory with a segment length chosen to make it
  74649. * probable that the new Trajectory will have a specified number of
  74650. * segments. This operation is imprecise.
  74651. * @param targetResolution number of segments desired
  74652. * @returns new Trajectory with approximately the requested number of segments
  74653. */
  74654. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74655. /**
  74656. * Convert Trajectory segments into tokenized representation. This
  74657. * representation is an array of numbers where each nth number is the
  74658. * index of the token which is most similar to the nth segment of the
  74659. * Trajectory.
  74660. * @param tokens list of vectors which serve as discrete tokens
  74661. * @returns list of indices of most similar token per segment
  74662. */
  74663. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74664. private static _forwardDir;
  74665. private static _inverseFromVec;
  74666. private static _upDir;
  74667. private static _fromToVec;
  74668. private static _lookMatrix;
  74669. /**
  74670. * Transform the rotation (i.e., direction) of a segment to isolate
  74671. * the relative transformation represented by the segment. This operation
  74672. * may or may not succeed due to singularities in the equations that define
  74673. * motion relativity in this context.
  74674. * @param priorVec the origin of the prior segment
  74675. * @param fromVec the origin of the current segment
  74676. * @param toVec the destination of the current segment
  74677. * @param result reference to output variable
  74678. * @returns whether or not transformation was successful
  74679. */
  74680. private static _transformSegmentDirToRef;
  74681. private static _bestMatch;
  74682. private static _score;
  74683. private static _bestScore;
  74684. /**
  74685. * Determine which token vector is most similar to the
  74686. * segment vector.
  74687. * @param segment segment vector
  74688. * @param tokens token vector list
  74689. * @returns index of the most similar token to the segment
  74690. */
  74691. private static _tokenizeSegment;
  74692. }
  74693. /**
  74694. * Class representing a set of known, named trajectories to which Trajectories can be
  74695. * added and using which Trajectories can be recognized.
  74696. */
  74697. export class TrajectoryClassifier {
  74698. private _maximumAllowableMatchCost;
  74699. private _vector3Alphabet;
  74700. private _levenshteinAlphabet;
  74701. private _nameToDescribedTrajectory;
  74702. /**
  74703. * Serialize to JSON.
  74704. * @returns JSON serialization
  74705. */
  74706. serialize(): string;
  74707. /**
  74708. * Deserialize from JSON.
  74709. * @param json JSON serialization
  74710. * @returns deserialized TrajectorySet
  74711. */
  74712. static Deserialize(json: string): TrajectoryClassifier;
  74713. /**
  74714. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  74715. * VERY naive, need to be generating these things from known
  74716. * sets. Better version later, probably eliminating this one.
  74717. * @returns auto-generated TrajectorySet
  74718. */
  74719. static Generate(): TrajectoryClassifier;
  74720. private constructor();
  74721. /**
  74722. * Add a new Trajectory to the set with a given name.
  74723. * @param trajectory new Trajectory to be added
  74724. * @param classification name to which to add the Trajectory
  74725. */
  74726. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  74727. /**
  74728. * Remove a known named trajectory and all Trajectories associated with it.
  74729. * @param classification name to remove
  74730. * @returns whether anything was removed
  74731. */
  74732. deleteClassification(classification: string): boolean;
  74733. /**
  74734. * Attempt to recognize a Trajectory from among all the classifications
  74735. * already known to the classifier.
  74736. * @param trajectory Trajectory to be recognized
  74737. * @returns classification of Trajectory if recognized, null otherwise
  74738. */
  74739. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  74740. }
  74741. }
  74742. declare module BABYLON {
  74743. /**
  74744. * An interface for all Hit test features
  74745. */
  74746. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74747. /**
  74748. * Triggered when new babylon (transformed) hit test results are available
  74749. */
  74750. onHitTestResultObservable: Observable<T[]>;
  74751. }
  74752. /**
  74753. * Options used for hit testing
  74754. */
  74755. export interface IWebXRLegacyHitTestOptions {
  74756. /**
  74757. * Only test when user interacted with the scene. Default - hit test every frame
  74758. */
  74759. testOnPointerDownOnly?: boolean;
  74760. /**
  74761. * The node to use to transform the local results to world coordinates
  74762. */
  74763. worldParentNode?: TransformNode;
  74764. }
  74765. /**
  74766. * Interface defining the babylon result of raycasting/hit-test
  74767. */
  74768. export interface IWebXRLegacyHitResult {
  74769. /**
  74770. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74771. */
  74772. transformationMatrix: Matrix;
  74773. /**
  74774. * The native hit test result
  74775. */
  74776. xrHitResult: XRHitResult | XRHitTestResult;
  74777. }
  74778. /**
  74779. * The currently-working hit-test module.
  74780. * Hit test (or Ray-casting) is used to interact with the real world.
  74781. * For further information read here - https://github.com/immersive-web/hit-test
  74782. */
  74783. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74784. /**
  74785. * options to use when constructing this feature
  74786. */
  74787. readonly options: IWebXRLegacyHitTestOptions;
  74788. private _direction;
  74789. private _mat;
  74790. private _onSelectEnabled;
  74791. private _origin;
  74792. /**
  74793. * The module's name
  74794. */
  74795. static readonly Name: string;
  74796. /**
  74797. * The (Babylon) version of this module.
  74798. * This is an integer representing the implementation version.
  74799. * This number does not correspond to the WebXR specs version
  74800. */
  74801. static readonly Version: number;
  74802. /**
  74803. * Populated with the last native XR Hit Results
  74804. */
  74805. lastNativeXRHitResults: XRHitResult[];
  74806. /**
  74807. * Triggered when new babylon (transformed) hit test results are available
  74808. */
  74809. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74810. /**
  74811. * Creates a new instance of the (legacy version) hit test feature
  74812. * @param _xrSessionManager an instance of WebXRSessionManager
  74813. * @param options options to use when constructing this feature
  74814. */
  74815. constructor(_xrSessionManager: WebXRSessionManager,
  74816. /**
  74817. * options to use when constructing this feature
  74818. */
  74819. options?: IWebXRLegacyHitTestOptions);
  74820. /**
  74821. * execute a hit test with an XR Ray
  74822. *
  74823. * @param xrSession a native xrSession that will execute this hit test
  74824. * @param xrRay the ray (position and direction) to use for ray-casting
  74825. * @param referenceSpace native XR reference space to use for the hit-test
  74826. * @param filter filter function that will filter the results
  74827. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74828. */
  74829. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74830. /**
  74831. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74832. * @param event the (select) event to use to select with
  74833. * @param referenceSpace the reference space to use for this hit test
  74834. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74835. */
  74836. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74837. /**
  74838. * attach this feature
  74839. * Will usually be called by the features manager
  74840. *
  74841. * @returns true if successful.
  74842. */
  74843. attach(): boolean;
  74844. /**
  74845. * detach this feature.
  74846. * Will usually be called by the features manager
  74847. *
  74848. * @returns true if successful.
  74849. */
  74850. detach(): boolean;
  74851. /**
  74852. * Dispose this feature and all of the resources attached
  74853. */
  74854. dispose(): void;
  74855. protected _onXRFrame(frame: XRFrame): void;
  74856. private _onHitTestResults;
  74857. private _onSelect;
  74858. }
  74859. }
  74860. declare module BABYLON {
  74861. /**
  74862. * Options used for hit testing (version 2)
  74863. */
  74864. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74865. /**
  74866. * Do not create a permanent hit test. Will usually be used when only
  74867. * transient inputs are needed.
  74868. */
  74869. disablePermanentHitTest?: boolean;
  74870. /**
  74871. * Enable transient (for example touch-based) hit test inspections
  74872. */
  74873. enableTransientHitTest?: boolean;
  74874. /**
  74875. * Offset ray for the permanent hit test
  74876. */
  74877. offsetRay?: Vector3;
  74878. /**
  74879. * Offset ray for the transient hit test
  74880. */
  74881. transientOffsetRay?: Vector3;
  74882. /**
  74883. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74884. */
  74885. useReferenceSpace?: boolean;
  74886. /**
  74887. * Override the default entity type(s) of the hit-test result
  74888. */
  74889. entityTypes?: XRHitTestTrackableType[];
  74890. }
  74891. /**
  74892. * Interface defining the babylon result of hit-test
  74893. */
  74894. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74895. /**
  74896. * The input source that generated this hit test (if transient)
  74897. */
  74898. inputSource?: XRInputSource;
  74899. /**
  74900. * Is this a transient hit test
  74901. */
  74902. isTransient?: boolean;
  74903. /**
  74904. * Position of the hit test result
  74905. */
  74906. position: Vector3;
  74907. /**
  74908. * Rotation of the hit test result
  74909. */
  74910. rotationQuaternion: Quaternion;
  74911. /**
  74912. * The native hit test result
  74913. */
  74914. xrHitResult: XRHitTestResult;
  74915. }
  74916. /**
  74917. * The currently-working hit-test module.
  74918. * Hit test (or Ray-casting) is used to interact with the real world.
  74919. * For further information read here - https://github.com/immersive-web/hit-test
  74920. *
  74921. * Tested on chrome (mobile) 80.
  74922. */
  74923. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74924. /**
  74925. * options to use when constructing this feature
  74926. */
  74927. readonly options: IWebXRHitTestOptions;
  74928. private _tmpMat;
  74929. private _tmpPos;
  74930. private _tmpQuat;
  74931. private _transientXrHitTestSource;
  74932. private _xrHitTestSource;
  74933. private initHitTestSource;
  74934. /**
  74935. * The module's name
  74936. */
  74937. static readonly Name: string;
  74938. /**
  74939. * The (Babylon) version of this module.
  74940. * This is an integer representing the implementation version.
  74941. * This number does not correspond to the WebXR specs version
  74942. */
  74943. static readonly Version: number;
  74944. /**
  74945. * When set to true, each hit test will have its own position/rotation objects
  74946. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74947. * the developers will clone them or copy them as they see fit.
  74948. */
  74949. autoCloneTransformation: boolean;
  74950. /**
  74951. * Triggered when new babylon (transformed) hit test results are available
  74952. * Note - this will be called when results come back from the device. It can be an empty array!!
  74953. */
  74954. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74955. /**
  74956. * Use this to temporarily pause hit test checks.
  74957. */
  74958. paused: boolean;
  74959. /**
  74960. * Creates a new instance of the hit test feature
  74961. * @param _xrSessionManager an instance of WebXRSessionManager
  74962. * @param options options to use when constructing this feature
  74963. */
  74964. constructor(_xrSessionManager: WebXRSessionManager,
  74965. /**
  74966. * options to use when constructing this feature
  74967. */
  74968. options?: IWebXRHitTestOptions);
  74969. /**
  74970. * attach this feature
  74971. * Will usually be called by the features manager
  74972. *
  74973. * @returns true if successful.
  74974. */
  74975. attach(): boolean;
  74976. /**
  74977. * detach this feature.
  74978. * Will usually be called by the features manager
  74979. *
  74980. * @returns true if successful.
  74981. */
  74982. detach(): boolean;
  74983. /**
  74984. * Dispose this feature and all of the resources attached
  74985. */
  74986. dispose(): void;
  74987. protected _onXRFrame(frame: XRFrame): void;
  74988. private _processWebXRHitTestResult;
  74989. }
  74990. }
  74991. declare module BABYLON {
  74992. /**
  74993. * Configuration options of the anchor system
  74994. */
  74995. export interface IWebXRAnchorSystemOptions {
  74996. /**
  74997. * a node that will be used to convert local to world coordinates
  74998. */
  74999. worldParentNode?: TransformNode;
  75000. /**
  75001. * If set to true a reference of the created anchors will be kept until the next session starts
  75002. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75003. */
  75004. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75005. }
  75006. /**
  75007. * A babylon container for an XR Anchor
  75008. */
  75009. export interface IWebXRAnchor {
  75010. /**
  75011. * A babylon-assigned ID for this anchor
  75012. */
  75013. id: number;
  75014. /**
  75015. * Transformation matrix to apply to an object attached to this anchor
  75016. */
  75017. transformationMatrix: Matrix;
  75018. /**
  75019. * The native anchor object
  75020. */
  75021. xrAnchor: XRAnchor;
  75022. /**
  75023. * if defined, this object will be constantly updated by the anchor's position and rotation
  75024. */
  75025. attachedNode?: TransformNode;
  75026. }
  75027. /**
  75028. * An implementation of the anchor system for WebXR.
  75029. * For further information see https://github.com/immersive-web/anchors/
  75030. */
  75031. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75032. private _options;
  75033. private _lastFrameDetected;
  75034. private _trackedAnchors;
  75035. private _referenceSpaceForFrameAnchors;
  75036. private _futureAnchors;
  75037. /**
  75038. * The module's name
  75039. */
  75040. static readonly Name: string;
  75041. /**
  75042. * The (Babylon) version of this module.
  75043. * This is an integer representing the implementation version.
  75044. * This number does not correspond to the WebXR specs version
  75045. */
  75046. static readonly Version: number;
  75047. /**
  75048. * Observers registered here will be executed when a new anchor was added to the session
  75049. */
  75050. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75051. /**
  75052. * Observers registered here will be executed when an anchor was removed from the session
  75053. */
  75054. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75055. /**
  75056. * Observers registered here will be executed when an existing anchor updates
  75057. * This can execute N times every frame
  75058. */
  75059. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75060. /**
  75061. * Set the reference space to use for anchor creation, when not using a hit test.
  75062. * Will default to the session's reference space if not defined
  75063. */
  75064. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75065. /**
  75066. * constructs a new anchor system
  75067. * @param _xrSessionManager an instance of WebXRSessionManager
  75068. * @param _options configuration object for this feature
  75069. */
  75070. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75071. private _tmpVector;
  75072. private _tmpQuaternion;
  75073. private _populateTmpTransformation;
  75074. /**
  75075. * Create a new anchor point using a hit test result at a specific point in the scene
  75076. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75077. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75078. *
  75079. * @param hitTestResult The hit test result to use for this anchor creation
  75080. * @param position an optional position offset for this anchor
  75081. * @param rotationQuaternion an optional rotation offset for this anchor
  75082. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75083. */
  75084. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75085. /**
  75086. * Add a new anchor at a specific position and rotation
  75087. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75088. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75089. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75090. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75091. *
  75092. * @param position the position in which to add an anchor
  75093. * @param rotationQuaternion an optional rotation for the anchor transformation
  75094. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75095. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75096. */
  75097. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75098. /**
  75099. * detach this feature.
  75100. * Will usually be called by the features manager
  75101. *
  75102. * @returns true if successful.
  75103. */
  75104. detach(): boolean;
  75105. /**
  75106. * Dispose this feature and all of the resources attached
  75107. */
  75108. dispose(): void;
  75109. protected _onXRFrame(frame: XRFrame): void;
  75110. /**
  75111. * avoiding using Array.find for global support.
  75112. * @param xrAnchor the plane to find in the array
  75113. */
  75114. private _findIndexInAnchorArray;
  75115. private _updateAnchorWithXRFrame;
  75116. private _createAnchorAtTransformation;
  75117. }
  75118. }
  75119. declare module BABYLON {
  75120. /**
  75121. * Options used in the plane detector module
  75122. */
  75123. export interface IWebXRPlaneDetectorOptions {
  75124. /**
  75125. * The node to use to transform the local results to world coordinates
  75126. */
  75127. worldParentNode?: TransformNode;
  75128. /**
  75129. * If set to true a reference of the created planes will be kept until the next session starts
  75130. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75131. */
  75132. doNotRemovePlanesOnSessionEnded?: boolean;
  75133. }
  75134. /**
  75135. * A babylon interface for a WebXR plane.
  75136. * A Plane is actually a polygon, built from N points in space
  75137. *
  75138. * Supported in chrome 79, not supported in canary 81 ATM
  75139. */
  75140. export interface IWebXRPlane {
  75141. /**
  75142. * a babylon-assigned ID for this polygon
  75143. */
  75144. id: number;
  75145. /**
  75146. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75147. */
  75148. polygonDefinition: Array<Vector3>;
  75149. /**
  75150. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75151. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75152. */
  75153. transformationMatrix: Matrix;
  75154. /**
  75155. * the native xr-plane object
  75156. */
  75157. xrPlane: XRPlane;
  75158. }
  75159. /**
  75160. * The plane detector is used to detect planes in the real world when in AR
  75161. * For more information see https://github.com/immersive-web/real-world-geometry/
  75162. */
  75163. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75164. private _options;
  75165. private _detectedPlanes;
  75166. private _enabled;
  75167. private _lastFrameDetected;
  75168. /**
  75169. * The module's name
  75170. */
  75171. static readonly Name: string;
  75172. /**
  75173. * The (Babylon) version of this module.
  75174. * This is an integer representing the implementation version.
  75175. * This number does not correspond to the WebXR specs version
  75176. */
  75177. static readonly Version: number;
  75178. /**
  75179. * Observers registered here will be executed when a new plane was added to the session
  75180. */
  75181. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75182. /**
  75183. * Observers registered here will be executed when a plane is no longer detected in the session
  75184. */
  75185. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75186. /**
  75187. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75188. * This can execute N times every frame
  75189. */
  75190. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75191. /**
  75192. * construct a new Plane Detector
  75193. * @param _xrSessionManager an instance of xr Session manager
  75194. * @param _options configuration to use when constructing this feature
  75195. */
  75196. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75197. /**
  75198. * detach this feature.
  75199. * Will usually be called by the features manager
  75200. *
  75201. * @returns true if successful.
  75202. */
  75203. detach(): boolean;
  75204. /**
  75205. * Dispose this feature and all of the resources attached
  75206. */
  75207. dispose(): void;
  75208. protected _onXRFrame(frame: XRFrame): void;
  75209. private _init;
  75210. private _updatePlaneWithXRPlane;
  75211. /**
  75212. * avoiding using Array.find for global support.
  75213. * @param xrPlane the plane to find in the array
  75214. */
  75215. private findIndexInPlaneArray;
  75216. }
  75217. }
  75218. declare module BABYLON {
  75219. /**
  75220. * Options interface for the background remover plugin
  75221. */
  75222. export interface IWebXRBackgroundRemoverOptions {
  75223. /**
  75224. * Further background meshes to disable when entering AR
  75225. */
  75226. backgroundMeshes?: AbstractMesh[];
  75227. /**
  75228. * flags to configure the removal of the environment helper.
  75229. * If not set, the entire background will be removed. If set, flags should be set as well.
  75230. */
  75231. environmentHelperRemovalFlags?: {
  75232. /**
  75233. * Should the skybox be removed (default false)
  75234. */
  75235. skyBox?: boolean;
  75236. /**
  75237. * Should the ground be removed (default false)
  75238. */
  75239. ground?: boolean;
  75240. };
  75241. /**
  75242. * don't disable the environment helper
  75243. */
  75244. ignoreEnvironmentHelper?: boolean;
  75245. }
  75246. /**
  75247. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75248. */
  75249. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75250. /**
  75251. * read-only options to be used in this module
  75252. */
  75253. readonly options: IWebXRBackgroundRemoverOptions;
  75254. /**
  75255. * The module's name
  75256. */
  75257. static readonly Name: string;
  75258. /**
  75259. * The (Babylon) version of this module.
  75260. * This is an integer representing the implementation version.
  75261. * This number does not correspond to the WebXR specs version
  75262. */
  75263. static readonly Version: number;
  75264. /**
  75265. * registered observers will be triggered when the background state changes
  75266. */
  75267. onBackgroundStateChangedObservable: Observable<boolean>;
  75268. /**
  75269. * constructs a new background remover module
  75270. * @param _xrSessionManager the session manager for this module
  75271. * @param options read-only options to be used in this module
  75272. */
  75273. constructor(_xrSessionManager: WebXRSessionManager,
  75274. /**
  75275. * read-only options to be used in this module
  75276. */
  75277. options?: IWebXRBackgroundRemoverOptions);
  75278. /**
  75279. * attach this feature
  75280. * Will usually be called by the features manager
  75281. *
  75282. * @returns true if successful.
  75283. */
  75284. attach(): boolean;
  75285. /**
  75286. * detach this feature.
  75287. * Will usually be called by the features manager
  75288. *
  75289. * @returns true if successful.
  75290. */
  75291. detach(): boolean;
  75292. /**
  75293. * Dispose this feature and all of the resources attached
  75294. */
  75295. dispose(): void;
  75296. protected _onXRFrame(_xrFrame: XRFrame): void;
  75297. private _setBackgroundState;
  75298. }
  75299. }
  75300. declare module BABYLON {
  75301. /**
  75302. * Options for the controller physics feature
  75303. */
  75304. export class IWebXRControllerPhysicsOptions {
  75305. /**
  75306. * Should the headset get its own impostor
  75307. */
  75308. enableHeadsetImpostor?: boolean;
  75309. /**
  75310. * Optional parameters for the headset impostor
  75311. */
  75312. headsetImpostorParams?: {
  75313. /**
  75314. * The type of impostor to create. Default is sphere
  75315. */
  75316. impostorType: number;
  75317. /**
  75318. * the size of the impostor. Defaults to 10cm
  75319. */
  75320. impostorSize?: number | {
  75321. width: number;
  75322. height: number;
  75323. depth: number;
  75324. };
  75325. /**
  75326. * Friction definitions
  75327. */
  75328. friction?: number;
  75329. /**
  75330. * Restitution
  75331. */
  75332. restitution?: number;
  75333. };
  75334. /**
  75335. * The physics properties of the future impostors
  75336. */
  75337. physicsProperties?: {
  75338. /**
  75339. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75340. * Note that this requires a physics engine that supports mesh impostors!
  75341. */
  75342. useControllerMesh?: boolean;
  75343. /**
  75344. * The type of impostor to create. Default is sphere
  75345. */
  75346. impostorType?: number;
  75347. /**
  75348. * the size of the impostor. Defaults to 10cm
  75349. */
  75350. impostorSize?: number | {
  75351. width: number;
  75352. height: number;
  75353. depth: number;
  75354. };
  75355. /**
  75356. * Friction definitions
  75357. */
  75358. friction?: number;
  75359. /**
  75360. * Restitution
  75361. */
  75362. restitution?: number;
  75363. };
  75364. /**
  75365. * the xr input to use with this pointer selection
  75366. */
  75367. xrInput: WebXRInput;
  75368. }
  75369. /**
  75370. * Add physics impostor to your webxr controllers,
  75371. * including naive calculation of their linear and angular velocity
  75372. */
  75373. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75374. private readonly _options;
  75375. private _attachController;
  75376. private _controllers;
  75377. private _debugMode;
  75378. private _delta;
  75379. private _headsetImpostor?;
  75380. private _headsetMesh?;
  75381. private _lastTimestamp;
  75382. private _tmpQuaternion;
  75383. private _tmpVector;
  75384. /**
  75385. * The module's name
  75386. */
  75387. static readonly Name: string;
  75388. /**
  75389. * The (Babylon) version of this module.
  75390. * This is an integer representing the implementation version.
  75391. * This number does not correspond to the webxr specs version
  75392. */
  75393. static readonly Version: number;
  75394. /**
  75395. * Construct a new Controller Physics Feature
  75396. * @param _xrSessionManager the corresponding xr session manager
  75397. * @param _options options to create this feature with
  75398. */
  75399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75400. /**
  75401. * @hidden
  75402. * enable debugging - will show console outputs and the impostor mesh
  75403. */
  75404. _enablePhysicsDebug(): void;
  75405. /**
  75406. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75407. * @param xrController the controller to add
  75408. */
  75409. addController(xrController: WebXRInputSource): void;
  75410. /**
  75411. * attach this feature
  75412. * Will usually be called by the features manager
  75413. *
  75414. * @returns true if successful.
  75415. */
  75416. attach(): boolean;
  75417. /**
  75418. * detach this feature.
  75419. * Will usually be called by the features manager
  75420. *
  75421. * @returns true if successful.
  75422. */
  75423. detach(): boolean;
  75424. /**
  75425. * Get the headset impostor, if enabled
  75426. * @returns the impostor
  75427. */
  75428. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75429. /**
  75430. * Get the physics impostor of a specific controller.
  75431. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75432. * @param controller the controller or the controller id of which to get the impostor
  75433. * @returns the impostor or null
  75434. */
  75435. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75436. /**
  75437. * Update the physics properties provided in the constructor
  75438. * @param newProperties the new properties object
  75439. */
  75440. setPhysicsProperties(newProperties: {
  75441. impostorType?: number;
  75442. impostorSize?: number | {
  75443. width: number;
  75444. height: number;
  75445. depth: number;
  75446. };
  75447. friction?: number;
  75448. restitution?: number;
  75449. }): void;
  75450. protected _onXRFrame(_xrFrame: any): void;
  75451. private _detachController;
  75452. }
  75453. }
  75454. declare module BABYLON {
  75455. /**
  75456. * A babylon interface for a "WebXR" feature point.
  75457. * Represents the position and confidence value of a given feature point.
  75458. */
  75459. export interface IWebXRFeaturePoint {
  75460. /**
  75461. * Represents the position of the feature point in world space.
  75462. */
  75463. position: Vector3;
  75464. /**
  75465. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75466. */
  75467. confidenceValue: number;
  75468. }
  75469. /**
  75470. * The feature point system is used to detect feature points from real world geometry.
  75471. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75472. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75473. */
  75474. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75475. private _enabled;
  75476. private _featurePointCloud;
  75477. /**
  75478. * The module's name
  75479. */
  75480. static readonly Name: string;
  75481. /**
  75482. * The (Babylon) version of this module.
  75483. * This is an integer representing the implementation version.
  75484. * This number does not correspond to the WebXR specs version
  75485. */
  75486. static readonly Version: number;
  75487. /**
  75488. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75489. * Will notify the observers about which feature points have been added.
  75490. */
  75491. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75492. /**
  75493. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75494. * Will notify the observers about which feature points have been updated.
  75495. */
  75496. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75497. /**
  75498. * The current feature point cloud maintained across frames.
  75499. */
  75500. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75501. /**
  75502. * construct the feature point system
  75503. * @param _xrSessionManager an instance of xr Session manager
  75504. */
  75505. constructor(_xrSessionManager: WebXRSessionManager);
  75506. /**
  75507. * Detach this feature.
  75508. * Will usually be called by the features manager
  75509. *
  75510. * @returns true if successful.
  75511. */
  75512. detach(): boolean;
  75513. /**
  75514. * Dispose this feature and all of the resources attached
  75515. */
  75516. dispose(): void;
  75517. /**
  75518. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75519. */
  75520. protected _onXRFrame(frame: XRFrame): void;
  75521. /**
  75522. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75523. */
  75524. private _init;
  75525. }
  75526. }
  75527. declare module BABYLON {
  75528. /**
  75529. * Configuration interface for the hand tracking feature
  75530. */
  75531. export interface IWebXRHandTrackingOptions {
  75532. /**
  75533. * The xrInput that will be used as source for new hands
  75534. */
  75535. xrInput: WebXRInput;
  75536. /**
  75537. * Configuration object for the joint meshes
  75538. */
  75539. jointMeshes?: {
  75540. /**
  75541. * Should the meshes created be invisible (defaults to false)
  75542. */
  75543. invisible?: boolean;
  75544. /**
  75545. * A source mesh to be used to create instances. Defaults to a sphere.
  75546. * This mesh will be the source for all other (25) meshes.
  75547. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75548. */
  75549. sourceMesh?: Mesh;
  75550. /**
  75551. * Should the source mesh stay visible. Defaults to false
  75552. */
  75553. keepOriginalVisible?: boolean;
  75554. /**
  75555. * Scale factor for all instances (defaults to 2)
  75556. */
  75557. scaleFactor?: number;
  75558. /**
  75559. * Should each instance have its own physics impostor
  75560. */
  75561. enablePhysics?: boolean;
  75562. /**
  75563. * If enabled, override default physics properties
  75564. */
  75565. physicsProps?: {
  75566. friction?: number;
  75567. restitution?: number;
  75568. impostorType?: number;
  75569. };
  75570. /**
  75571. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75572. */
  75573. handMesh?: AbstractMesh;
  75574. };
  75575. }
  75576. /**
  75577. * Parts of the hands divided to writs and finger names
  75578. */
  75579. export const enum HandPart {
  75580. /**
  75581. * HandPart - Wrist
  75582. */
  75583. WRIST = "wrist",
  75584. /**
  75585. * HandPart - The THumb
  75586. */
  75587. THUMB = "thumb",
  75588. /**
  75589. * HandPart - Index finger
  75590. */
  75591. INDEX = "index",
  75592. /**
  75593. * HandPart - Middle finger
  75594. */
  75595. MIDDLE = "middle",
  75596. /**
  75597. * HandPart - Ring finger
  75598. */
  75599. RING = "ring",
  75600. /**
  75601. * HandPart - Little finger
  75602. */
  75603. LITTLE = "little"
  75604. }
  75605. /**
  75606. * Representing a single hand (with its corresponding native XRHand object)
  75607. */
  75608. export class WebXRHand implements IDisposable {
  75609. /** the controller to which the hand correlates */
  75610. readonly xrController: WebXRInputSource;
  75611. /** the meshes to be used to track the hand joints */
  75612. readonly trackedMeshes: AbstractMesh[];
  75613. /**
  75614. * Hand-parts definition (key is HandPart)
  75615. */
  75616. handPartsDefinition: {
  75617. [key: string]: number[];
  75618. };
  75619. /**
  75620. * Populate the HandPartsDefinition object.
  75621. * This is called as a side effect since certain browsers don't have XRHand defined.
  75622. */
  75623. private generateHandPartsDefinition;
  75624. /**
  75625. * Construct a new hand object
  75626. * @param xrController the controller to which the hand correlates
  75627. * @param trackedMeshes the meshes to be used to track the hand joints
  75628. */
  75629. constructor(
  75630. /** the controller to which the hand correlates */
  75631. xrController: WebXRInputSource,
  75632. /** the meshes to be used to track the hand joints */
  75633. trackedMeshes: AbstractMesh[]);
  75634. /**
  75635. * Update this hand from the latest xr frame
  75636. * @param xrFrame xrFrame to update from
  75637. * @param referenceSpace The current viewer reference space
  75638. * @param scaleFactor optional scale factor for the meshes
  75639. */
  75640. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75641. /**
  75642. * Get meshes of part of the hand
  75643. * @param part the part of hand to get
  75644. * @returns An array of meshes that correlate to the hand part requested
  75645. */
  75646. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75647. /**
  75648. * Dispose this Hand object
  75649. */
  75650. dispose(): void;
  75651. }
  75652. /**
  75653. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75654. */
  75655. export class WebXRHandTracking extends WebXRAbstractFeature {
  75656. /**
  75657. * options to use when constructing this feature
  75658. */
  75659. readonly options: IWebXRHandTrackingOptions;
  75660. private static _idCounter;
  75661. /**
  75662. * The module's name
  75663. */
  75664. static readonly Name: string;
  75665. /**
  75666. * The (Babylon) version of this module.
  75667. * This is an integer representing the implementation version.
  75668. * This number does not correspond to the WebXR specs version
  75669. */
  75670. static readonly Version: number;
  75671. /**
  75672. * This observable will notify registered observers when a new hand object was added and initialized
  75673. */
  75674. onHandAddedObservable: Observable<WebXRHand>;
  75675. /**
  75676. * This observable will notify its observers right before the hand object is disposed
  75677. */
  75678. onHandRemovedObservable: Observable<WebXRHand>;
  75679. private _hands;
  75680. /**
  75681. * Creates a new instance of the hit test feature
  75682. * @param _xrSessionManager an instance of WebXRSessionManager
  75683. * @param options options to use when constructing this feature
  75684. */
  75685. constructor(_xrSessionManager: WebXRSessionManager,
  75686. /**
  75687. * options to use when constructing this feature
  75688. */
  75689. options: IWebXRHandTrackingOptions);
  75690. /**
  75691. * Check if the needed objects are defined.
  75692. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75693. */
  75694. isCompatible(): boolean;
  75695. /**
  75696. * attach this feature
  75697. * Will usually be called by the features manager
  75698. *
  75699. * @returns true if successful.
  75700. */
  75701. attach(): boolean;
  75702. /**
  75703. * detach this feature.
  75704. * Will usually be called by the features manager
  75705. *
  75706. * @returns true if successful.
  75707. */
  75708. detach(): boolean;
  75709. /**
  75710. * Dispose this feature and all of the resources attached
  75711. */
  75712. dispose(): void;
  75713. /**
  75714. * Get the hand object according to the controller id
  75715. * @param controllerId the controller id to which we want to get the hand
  75716. * @returns null if not found or the WebXRHand object if found
  75717. */
  75718. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75719. /**
  75720. * Get a hand object according to the requested handedness
  75721. * @param handedness the handedness to request
  75722. * @returns null if not found or the WebXRHand object if found
  75723. */
  75724. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75725. protected _onXRFrame(_xrFrame: XRFrame): void;
  75726. private _attachHand;
  75727. private _detachHand;
  75728. }
  75729. }
  75730. declare module BABYLON {
  75731. /**
  75732. * The motion controller class for all microsoft mixed reality controllers
  75733. */
  75734. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75735. protected readonly _mapping: {
  75736. defaultButton: {
  75737. valueNodeName: string;
  75738. unpressedNodeName: string;
  75739. pressedNodeName: string;
  75740. };
  75741. defaultAxis: {
  75742. valueNodeName: string;
  75743. minNodeName: string;
  75744. maxNodeName: string;
  75745. };
  75746. buttons: {
  75747. "xr-standard-trigger": {
  75748. rootNodeName: string;
  75749. componentProperty: string;
  75750. states: string[];
  75751. };
  75752. "xr-standard-squeeze": {
  75753. rootNodeName: string;
  75754. componentProperty: string;
  75755. states: string[];
  75756. };
  75757. "xr-standard-touchpad": {
  75758. rootNodeName: string;
  75759. labelAnchorNodeName: string;
  75760. touchPointNodeName: string;
  75761. };
  75762. "xr-standard-thumbstick": {
  75763. rootNodeName: string;
  75764. componentProperty: string;
  75765. states: string[];
  75766. };
  75767. };
  75768. axes: {
  75769. "xr-standard-touchpad": {
  75770. "x-axis": {
  75771. rootNodeName: string;
  75772. };
  75773. "y-axis": {
  75774. rootNodeName: string;
  75775. };
  75776. };
  75777. "xr-standard-thumbstick": {
  75778. "x-axis": {
  75779. rootNodeName: string;
  75780. };
  75781. "y-axis": {
  75782. rootNodeName: string;
  75783. };
  75784. };
  75785. };
  75786. };
  75787. /**
  75788. * The base url used to load the left and right controller models
  75789. */
  75790. static MODEL_BASE_URL: string;
  75791. /**
  75792. * The name of the left controller model file
  75793. */
  75794. static MODEL_LEFT_FILENAME: string;
  75795. /**
  75796. * The name of the right controller model file
  75797. */
  75798. static MODEL_RIGHT_FILENAME: string;
  75799. profileId: string;
  75800. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75801. protected _getFilenameAndPath(): {
  75802. filename: string;
  75803. path: string;
  75804. };
  75805. protected _getModelLoadingConstraints(): boolean;
  75806. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75807. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75808. protected _updateModel(): void;
  75809. }
  75810. }
  75811. declare module BABYLON {
  75812. /**
  75813. * The motion controller class for oculus touch (quest, rift).
  75814. * This class supports legacy mapping as well the standard xr mapping
  75815. */
  75816. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75817. private _forceLegacyControllers;
  75818. private _modelRootNode;
  75819. /**
  75820. * The base url used to load the left and right controller models
  75821. */
  75822. static MODEL_BASE_URL: string;
  75823. /**
  75824. * The name of the left controller model file
  75825. */
  75826. static MODEL_LEFT_FILENAME: string;
  75827. /**
  75828. * The name of the right controller model file
  75829. */
  75830. static MODEL_RIGHT_FILENAME: string;
  75831. /**
  75832. * Base Url for the Quest controller model.
  75833. */
  75834. static QUEST_MODEL_BASE_URL: string;
  75835. profileId: string;
  75836. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75837. protected _getFilenameAndPath(): {
  75838. filename: string;
  75839. path: string;
  75840. };
  75841. protected _getModelLoadingConstraints(): boolean;
  75842. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75843. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75844. protected _updateModel(): void;
  75845. /**
  75846. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75847. * between the touch and touch 2.
  75848. */
  75849. private _isQuest;
  75850. }
  75851. }
  75852. declare module BABYLON {
  75853. /**
  75854. * The motion controller class for the standard HTC-Vive controllers
  75855. */
  75856. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75857. private _modelRootNode;
  75858. /**
  75859. * The base url used to load the left and right controller models
  75860. */
  75861. static MODEL_BASE_URL: string;
  75862. /**
  75863. * File name for the controller model.
  75864. */
  75865. static MODEL_FILENAME: string;
  75866. profileId: string;
  75867. /**
  75868. * Create a new Vive motion controller object
  75869. * @param scene the scene to use to create this controller
  75870. * @param gamepadObject the corresponding gamepad object
  75871. * @param handedness the handedness of the controller
  75872. */
  75873. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75874. protected _getFilenameAndPath(): {
  75875. filename: string;
  75876. path: string;
  75877. };
  75878. protected _getModelLoadingConstraints(): boolean;
  75879. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75880. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75881. protected _updateModel(): void;
  75882. }
  75883. }
  75884. declare module BABYLON {
  75885. /**
  75886. * A cursor which tracks a point on a path
  75887. */
  75888. export class PathCursor {
  75889. private path;
  75890. /**
  75891. * Stores path cursor callbacks for when an onchange event is triggered
  75892. */
  75893. private _onchange;
  75894. /**
  75895. * The value of the path cursor
  75896. */
  75897. value: number;
  75898. /**
  75899. * The animation array of the path cursor
  75900. */
  75901. animations: Animation[];
  75902. /**
  75903. * Initializes the path cursor
  75904. * @param path The path to track
  75905. */
  75906. constructor(path: Path2);
  75907. /**
  75908. * Gets the cursor point on the path
  75909. * @returns A point on the path cursor at the cursor location
  75910. */
  75911. getPoint(): Vector3;
  75912. /**
  75913. * Moves the cursor ahead by the step amount
  75914. * @param step The amount to move the cursor forward
  75915. * @returns This path cursor
  75916. */
  75917. moveAhead(step?: number): PathCursor;
  75918. /**
  75919. * Moves the cursor behind by the step amount
  75920. * @param step The amount to move the cursor back
  75921. * @returns This path cursor
  75922. */
  75923. moveBack(step?: number): PathCursor;
  75924. /**
  75925. * Moves the cursor by the step amount
  75926. * If the step amount is greater than one, an exception is thrown
  75927. * @param step The amount to move the cursor
  75928. * @returns This path cursor
  75929. */
  75930. move(step: number): PathCursor;
  75931. /**
  75932. * Ensures that the value is limited between zero and one
  75933. * @returns This path cursor
  75934. */
  75935. private ensureLimits;
  75936. /**
  75937. * Runs onchange callbacks on change (used by the animation engine)
  75938. * @returns This path cursor
  75939. */
  75940. private raiseOnChange;
  75941. /**
  75942. * Executes a function on change
  75943. * @param f A path cursor onchange callback
  75944. * @returns This path cursor
  75945. */
  75946. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75947. }
  75948. }
  75949. declare module BABYLON {
  75950. /** @hidden */
  75951. export var blurPixelShader: {
  75952. name: string;
  75953. shader: string;
  75954. };
  75955. }
  75956. declare module BABYLON {
  75957. /** @hidden */
  75958. export var pointCloudVertexDeclaration: {
  75959. name: string;
  75960. shader: string;
  75961. };
  75962. }
  75963. // Mixins
  75964. interface Window {
  75965. mozIndexedDB: IDBFactory;
  75966. webkitIndexedDB: IDBFactory;
  75967. msIndexedDB: IDBFactory;
  75968. webkitURL: typeof URL;
  75969. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75970. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75971. WebGLRenderingContext: WebGLRenderingContext;
  75972. MSGesture: MSGesture;
  75973. CANNON: any;
  75974. AudioContext: AudioContext;
  75975. webkitAudioContext: AudioContext;
  75976. PointerEvent: any;
  75977. Math: Math;
  75978. Uint8Array: Uint8ArrayConstructor;
  75979. Float32Array: Float32ArrayConstructor;
  75980. mozURL: typeof URL;
  75981. msURL: typeof URL;
  75982. VRFrameData: any; // WebVR, from specs 1.1
  75983. DracoDecoderModule: any;
  75984. setImmediate(handler: (...args: any[]) => void): number;
  75985. }
  75986. interface HTMLCanvasElement {
  75987. requestPointerLock(): void;
  75988. msRequestPointerLock?(): void;
  75989. mozRequestPointerLock?(): void;
  75990. webkitRequestPointerLock?(): void;
  75991. /** Track wether a record is in progress */
  75992. isRecording: boolean;
  75993. /** Capture Stream method defined by some browsers */
  75994. captureStream(fps?: number): MediaStream;
  75995. }
  75996. interface CanvasRenderingContext2D {
  75997. msImageSmoothingEnabled: boolean;
  75998. }
  75999. interface MouseEvent {
  76000. mozMovementX: number;
  76001. mozMovementY: number;
  76002. webkitMovementX: number;
  76003. webkitMovementY: number;
  76004. msMovementX: number;
  76005. msMovementY: number;
  76006. }
  76007. interface Navigator {
  76008. mozGetVRDevices: (any: any) => any;
  76009. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76010. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76011. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76012. webkitGetGamepads(): Gamepad[];
  76013. msGetGamepads(): Gamepad[];
  76014. webkitGamepads(): Gamepad[];
  76015. }
  76016. interface HTMLVideoElement {
  76017. mozSrcObject: any;
  76018. }
  76019. interface Math {
  76020. fround(x: number): number;
  76021. imul(a: number, b: number): number;
  76022. }
  76023. interface WebGLRenderingContext {
  76024. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76025. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76026. vertexAttribDivisor(index: number, divisor: number): void;
  76027. createVertexArray(): any;
  76028. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76029. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76030. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76031. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76032. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76033. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76034. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76035. // Queries
  76036. createQuery(): WebGLQuery;
  76037. deleteQuery(query: WebGLQuery): void;
  76038. beginQuery(target: number, query: WebGLQuery): void;
  76039. endQuery(target: number): void;
  76040. getQueryParameter(query: WebGLQuery, pname: number): any;
  76041. getQuery(target: number, pname: number): any;
  76042. MAX_SAMPLES: number;
  76043. RGBA8: number;
  76044. READ_FRAMEBUFFER: number;
  76045. DRAW_FRAMEBUFFER: number;
  76046. UNIFORM_BUFFER: number;
  76047. HALF_FLOAT_OES: number;
  76048. RGBA16F: number;
  76049. RGBA32F: number;
  76050. R32F: number;
  76051. RG32F: number;
  76052. RGB32F: number;
  76053. R16F: number;
  76054. RG16F: number;
  76055. RGB16F: number;
  76056. RED: number;
  76057. RG: number;
  76058. R8: number;
  76059. RG8: number;
  76060. UNSIGNED_INT_24_8: number;
  76061. DEPTH24_STENCIL8: number;
  76062. MIN: number;
  76063. MAX: number;
  76064. /* Multiple Render Targets */
  76065. drawBuffers(buffers: number[]): void;
  76066. readBuffer(src: number): void;
  76067. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76068. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76069. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76070. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76071. // Occlusion Query
  76072. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76073. ANY_SAMPLES_PASSED: number;
  76074. QUERY_RESULT_AVAILABLE: number;
  76075. QUERY_RESULT: number;
  76076. }
  76077. interface WebGLProgram {
  76078. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76079. }
  76080. interface EXT_disjoint_timer_query {
  76081. QUERY_COUNTER_BITS_EXT: number;
  76082. TIME_ELAPSED_EXT: number;
  76083. TIMESTAMP_EXT: number;
  76084. GPU_DISJOINT_EXT: number;
  76085. QUERY_RESULT_EXT: number;
  76086. QUERY_RESULT_AVAILABLE_EXT: number;
  76087. queryCounterEXT(query: WebGLQuery, target: number): void;
  76088. createQueryEXT(): WebGLQuery;
  76089. beginQueryEXT(target: number, query: WebGLQuery): void;
  76090. endQueryEXT(target: number): void;
  76091. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76092. deleteQueryEXT(query: WebGLQuery): void;
  76093. }
  76094. interface WebGLUniformLocation {
  76095. _currentState: any;
  76096. }
  76097. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76098. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76099. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76100. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76101. interface WebGLRenderingContext {
  76102. readonly RASTERIZER_DISCARD: number;
  76103. readonly DEPTH_COMPONENT24: number;
  76104. readonly TEXTURE_3D: number;
  76105. readonly TEXTURE_2D_ARRAY: number;
  76106. readonly TEXTURE_COMPARE_FUNC: number;
  76107. readonly TEXTURE_COMPARE_MODE: number;
  76108. readonly COMPARE_REF_TO_TEXTURE: number;
  76109. readonly TEXTURE_WRAP_R: number;
  76110. readonly HALF_FLOAT: number;
  76111. readonly RGB8: number;
  76112. readonly RED_INTEGER: number;
  76113. readonly RG_INTEGER: number;
  76114. readonly RGB_INTEGER: number;
  76115. readonly RGBA_INTEGER: number;
  76116. readonly R8_SNORM: number;
  76117. readonly RG8_SNORM: number;
  76118. readonly RGB8_SNORM: number;
  76119. readonly RGBA8_SNORM: number;
  76120. readonly R8I: number;
  76121. readonly RG8I: number;
  76122. readonly RGB8I: number;
  76123. readonly RGBA8I: number;
  76124. readonly R8UI: number;
  76125. readonly RG8UI: number;
  76126. readonly RGB8UI: number;
  76127. readonly RGBA8UI: number;
  76128. readonly R16I: number;
  76129. readonly RG16I: number;
  76130. readonly RGB16I: number;
  76131. readonly RGBA16I: number;
  76132. readonly R16UI: number;
  76133. readonly RG16UI: number;
  76134. readonly RGB16UI: number;
  76135. readonly RGBA16UI: number;
  76136. readonly R32I: number;
  76137. readonly RG32I: number;
  76138. readonly RGB32I: number;
  76139. readonly RGBA32I: number;
  76140. readonly R32UI: number;
  76141. readonly RG32UI: number;
  76142. readonly RGB32UI: number;
  76143. readonly RGBA32UI: number;
  76144. readonly RGB10_A2UI: number;
  76145. readonly R11F_G11F_B10F: number;
  76146. readonly RGB9_E5: number;
  76147. readonly RGB10_A2: number;
  76148. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76149. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76150. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76151. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76152. readonly DEPTH_COMPONENT32F: number;
  76153. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76154. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76155. 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;
  76156. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76157. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76158. readonly TRANSFORM_FEEDBACK: number;
  76159. readonly INTERLEAVED_ATTRIBS: number;
  76160. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76161. createTransformFeedback(): WebGLTransformFeedback;
  76162. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76163. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76164. beginTransformFeedback(primitiveMode: number): void;
  76165. endTransformFeedback(): void;
  76166. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76167. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76168. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76169. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76170. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76171. }
  76172. interface ImageBitmap {
  76173. readonly width: number;
  76174. readonly height: number;
  76175. close(): void;
  76176. }
  76177. interface WebGLQuery extends WebGLObject {
  76178. }
  76179. declare var WebGLQuery: {
  76180. prototype: WebGLQuery;
  76181. new(): WebGLQuery;
  76182. };
  76183. interface WebGLSampler extends WebGLObject {
  76184. }
  76185. declare var WebGLSampler: {
  76186. prototype: WebGLSampler;
  76187. new(): WebGLSampler;
  76188. };
  76189. interface WebGLSync extends WebGLObject {
  76190. }
  76191. declare var WebGLSync: {
  76192. prototype: WebGLSync;
  76193. new(): WebGLSync;
  76194. };
  76195. interface WebGLTransformFeedback extends WebGLObject {
  76196. }
  76197. declare var WebGLTransformFeedback: {
  76198. prototype: WebGLTransformFeedback;
  76199. new(): WebGLTransformFeedback;
  76200. };
  76201. interface WebGLVertexArrayObject extends WebGLObject {
  76202. }
  76203. declare var WebGLVertexArrayObject: {
  76204. prototype: WebGLVertexArrayObject;
  76205. new(): WebGLVertexArrayObject;
  76206. };
  76207. // Type definitions for WebVR API
  76208. // Project: https://w3c.github.io/webvr/
  76209. // Definitions by: six a <https://github.com/lostfictions>
  76210. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76211. interface VRDisplay extends EventTarget {
  76212. /**
  76213. * Dictionary of capabilities describing the VRDisplay.
  76214. */
  76215. readonly capabilities: VRDisplayCapabilities;
  76216. /**
  76217. * z-depth defining the far plane of the eye view frustum
  76218. * enables mapping of values in the render target depth
  76219. * attachment to scene coordinates. Initially set to 10000.0.
  76220. */
  76221. depthFar: number;
  76222. /**
  76223. * z-depth defining the near plane of the eye view frustum
  76224. * enables mapping of values in the render target depth
  76225. * attachment to scene coordinates. Initially set to 0.01.
  76226. */
  76227. depthNear: number;
  76228. /**
  76229. * An identifier for this distinct VRDisplay. Used as an
  76230. * association point in the Gamepad API.
  76231. */
  76232. readonly displayId: number;
  76233. /**
  76234. * A display name, a user-readable name identifying it.
  76235. */
  76236. readonly displayName: string;
  76237. readonly isConnected: boolean;
  76238. readonly isPresenting: boolean;
  76239. /**
  76240. * If this VRDisplay supports room-scale experiences, the optional
  76241. * stage attribute contains details on the room-scale parameters.
  76242. */
  76243. readonly stageParameters: VRStageParameters | null;
  76244. /**
  76245. * Passing the value returned by `requestAnimationFrame` to
  76246. * `cancelAnimationFrame` will unregister the callback.
  76247. * @param handle Define the hanle of the request to cancel
  76248. */
  76249. cancelAnimationFrame(handle: number): void;
  76250. /**
  76251. * Stops presenting to the VRDisplay.
  76252. * @returns a promise to know when it stopped
  76253. */
  76254. exitPresent(): Promise<void>;
  76255. /**
  76256. * Return the current VREyeParameters for the given eye.
  76257. * @param whichEye Define the eye we want the parameter for
  76258. * @returns the eye parameters
  76259. */
  76260. getEyeParameters(whichEye: string): VREyeParameters;
  76261. /**
  76262. * Populates the passed VRFrameData with the information required to render
  76263. * the current frame.
  76264. * @param frameData Define the data structure to populate
  76265. * @returns true if ok otherwise false
  76266. */
  76267. getFrameData(frameData: VRFrameData): boolean;
  76268. /**
  76269. * Get the layers currently being presented.
  76270. * @returns the list of VR layers
  76271. */
  76272. getLayers(): VRLayer[];
  76273. /**
  76274. * Return a VRPose containing the future predicted pose of the VRDisplay
  76275. * when the current frame will be presented. The value returned will not
  76276. * change until JavaScript has returned control to the browser.
  76277. *
  76278. * The VRPose will contain the position, orientation, velocity,
  76279. * and acceleration of each of these properties.
  76280. * @returns the pose object
  76281. */
  76282. getPose(): VRPose;
  76283. /**
  76284. * Return the current instantaneous pose of the VRDisplay, with no
  76285. * prediction applied.
  76286. * @returns the current instantaneous pose
  76287. */
  76288. getImmediatePose(): VRPose;
  76289. /**
  76290. * The callback passed to `requestAnimationFrame` will be called
  76291. * any time a new frame should be rendered. When the VRDisplay is
  76292. * presenting the callback will be called at the native refresh
  76293. * rate of the HMD. When not presenting this function acts
  76294. * identically to how window.requestAnimationFrame acts. Content should
  76295. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76296. * asynchronously from other displays and at differing refresh rates.
  76297. * @param callback Define the eaction to run next frame
  76298. * @returns the request handle it
  76299. */
  76300. requestAnimationFrame(callback: FrameRequestCallback): number;
  76301. /**
  76302. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76303. * Repeat calls while already presenting will update the VRLayers being displayed.
  76304. * @param layers Define the list of layer to present
  76305. * @returns a promise to know when the request has been fulfilled
  76306. */
  76307. requestPresent(layers: VRLayer[]): Promise<void>;
  76308. /**
  76309. * Reset the pose for this display, treating its current position and
  76310. * orientation as the "origin/zero" values. VRPose.position,
  76311. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76312. * updated when calling resetPose(). This should be called in only
  76313. * sitting-space experiences.
  76314. */
  76315. resetPose(): void;
  76316. /**
  76317. * The VRLayer provided to the VRDisplay will be captured and presented
  76318. * in the HMD. Calling this function has the same effect on the source
  76319. * canvas as any other operation that uses its source image, and canvases
  76320. * created without preserveDrawingBuffer set to true will be cleared.
  76321. * @param pose Define the pose to submit
  76322. */
  76323. submitFrame(pose?: VRPose): void;
  76324. }
  76325. declare var VRDisplay: {
  76326. prototype: VRDisplay;
  76327. new(): VRDisplay;
  76328. };
  76329. interface VRLayer {
  76330. leftBounds?: number[] | Float32Array | null;
  76331. rightBounds?: number[] | Float32Array | null;
  76332. source?: HTMLCanvasElement | null;
  76333. }
  76334. interface VRDisplayCapabilities {
  76335. readonly canPresent: boolean;
  76336. readonly hasExternalDisplay: boolean;
  76337. readonly hasOrientation: boolean;
  76338. readonly hasPosition: boolean;
  76339. readonly maxLayers: number;
  76340. }
  76341. interface VREyeParameters {
  76342. /** @deprecated */
  76343. readonly fieldOfView: VRFieldOfView;
  76344. readonly offset: Float32Array;
  76345. readonly renderHeight: number;
  76346. readonly renderWidth: number;
  76347. }
  76348. interface VRFieldOfView {
  76349. readonly downDegrees: number;
  76350. readonly leftDegrees: number;
  76351. readonly rightDegrees: number;
  76352. readonly upDegrees: number;
  76353. }
  76354. interface VRFrameData {
  76355. readonly leftProjectionMatrix: Float32Array;
  76356. readonly leftViewMatrix: Float32Array;
  76357. readonly pose: VRPose;
  76358. readonly rightProjectionMatrix: Float32Array;
  76359. readonly rightViewMatrix: Float32Array;
  76360. readonly timestamp: number;
  76361. }
  76362. interface VRPose {
  76363. readonly angularAcceleration: Float32Array | null;
  76364. readonly angularVelocity: Float32Array | null;
  76365. readonly linearAcceleration: Float32Array | null;
  76366. readonly linearVelocity: Float32Array | null;
  76367. readonly orientation: Float32Array | null;
  76368. readonly position: Float32Array | null;
  76369. readonly timestamp: number;
  76370. }
  76371. interface VRStageParameters {
  76372. sittingToStandingTransform?: Float32Array;
  76373. sizeX?: number;
  76374. sizeY?: number;
  76375. }
  76376. interface Navigator {
  76377. getVRDisplays(): Promise<VRDisplay[]>;
  76378. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76379. }
  76380. interface Window {
  76381. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76382. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76383. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76384. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76385. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76386. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76387. }
  76388. interface Gamepad {
  76389. readonly displayId: number;
  76390. }
  76391. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76392. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76393. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76394. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76395. type XRHandedness = "none" | "left" | "right";
  76396. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76397. type XREye = "none" | "left" | "right";
  76398. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76399. interface XRSpace extends EventTarget {}
  76400. interface XRRenderState {
  76401. depthNear?: number;
  76402. depthFar?: number;
  76403. inlineVerticalFieldOfView?: number;
  76404. baseLayer?: XRWebGLLayer;
  76405. }
  76406. interface XRInputSource {
  76407. handedness: XRHandedness;
  76408. targetRayMode: XRTargetRayMode;
  76409. targetRaySpace: XRSpace;
  76410. gripSpace: XRSpace | undefined;
  76411. gamepad: Gamepad | undefined;
  76412. profiles: Array<string>;
  76413. hand: XRHand | undefined;
  76414. }
  76415. interface XRSessionInit {
  76416. optionalFeatures?: string[];
  76417. requiredFeatures?: string[];
  76418. }
  76419. interface XRSession {
  76420. addEventListener: Function;
  76421. removeEventListener: Function;
  76422. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76423. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76424. requestAnimationFrame: Function;
  76425. end(): Promise<void>;
  76426. renderState: XRRenderState;
  76427. inputSources: Array<XRInputSource>;
  76428. // hit test
  76429. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76430. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76431. // legacy AR hit test
  76432. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76433. // legacy plane detection
  76434. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76435. }
  76436. interface XRReferenceSpace extends XRSpace {
  76437. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76438. onreset: any;
  76439. }
  76440. type XRPlaneSet = Set<XRPlane>;
  76441. type XRAnchorSet = Set<XRAnchor>;
  76442. interface XRFrame {
  76443. session: XRSession;
  76444. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76445. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76446. // AR
  76447. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76448. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76449. // Anchors
  76450. trackedAnchors?: XRAnchorSet;
  76451. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76452. // Planes
  76453. worldInformation: {
  76454. detectedPlanes?: XRPlaneSet;
  76455. };
  76456. // Hand tracking
  76457. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76458. }
  76459. interface XRViewerPose extends XRPose {
  76460. views: Array<XRView>;
  76461. }
  76462. interface XRPose {
  76463. transform: XRRigidTransform;
  76464. emulatedPosition: boolean;
  76465. }
  76466. interface XRWebGLLayerOptions {
  76467. antialias?: boolean;
  76468. depth?: boolean;
  76469. stencil?: boolean;
  76470. alpha?: boolean;
  76471. multiview?: boolean;
  76472. framebufferScaleFactor?: number;
  76473. }
  76474. declare var XRWebGLLayer: {
  76475. prototype: XRWebGLLayer;
  76476. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76477. };
  76478. interface XRWebGLLayer {
  76479. framebuffer: WebGLFramebuffer;
  76480. framebufferWidth: number;
  76481. framebufferHeight: number;
  76482. getViewport: Function;
  76483. }
  76484. declare class XRRigidTransform {
  76485. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76486. position: DOMPointReadOnly;
  76487. orientation: DOMPointReadOnly;
  76488. matrix: Float32Array;
  76489. inverse: XRRigidTransform;
  76490. }
  76491. interface XRView {
  76492. eye: XREye;
  76493. projectionMatrix: Float32Array;
  76494. transform: XRRigidTransform;
  76495. }
  76496. interface XRInputSourceChangeEvent {
  76497. session: XRSession;
  76498. removed: Array<XRInputSource>;
  76499. added: Array<XRInputSource>;
  76500. }
  76501. interface XRInputSourceEvent extends Event {
  76502. readonly frame: XRFrame;
  76503. readonly inputSource: XRInputSource;
  76504. }
  76505. // Experimental(er) features
  76506. declare class XRRay {
  76507. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76508. origin: DOMPointReadOnly;
  76509. direction: DOMPointReadOnly;
  76510. matrix: Float32Array;
  76511. }
  76512. declare enum XRHitTestTrackableType {
  76513. "point",
  76514. "plane",
  76515. "mesh",
  76516. }
  76517. interface XRHitResult {
  76518. hitMatrix: Float32Array;
  76519. }
  76520. interface XRTransientInputHitTestResult {
  76521. readonly inputSource: XRInputSource;
  76522. readonly results: Array<XRHitTestResult>;
  76523. }
  76524. interface XRHitTestResult {
  76525. getPose(baseSpace: XRSpace): XRPose | undefined;
  76526. // When anchor system is enabled
  76527. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76528. }
  76529. interface XRHitTestSource {
  76530. cancel(): void;
  76531. }
  76532. interface XRTransientInputHitTestSource {
  76533. cancel(): void;
  76534. }
  76535. interface XRHitTestOptionsInit {
  76536. space: XRSpace;
  76537. entityTypes?: Array<XRHitTestTrackableType>;
  76538. offsetRay?: XRRay;
  76539. }
  76540. interface XRTransientInputHitTestOptionsInit {
  76541. profile: string;
  76542. entityTypes?: Array<XRHitTestTrackableType>;
  76543. offsetRay?: XRRay;
  76544. }
  76545. interface XRAnchor {
  76546. anchorSpace: XRSpace;
  76547. delete(): void;
  76548. }
  76549. interface XRPlane {
  76550. orientation: "Horizontal" | "Vertical";
  76551. planeSpace: XRSpace;
  76552. polygon: Array<DOMPointReadOnly>;
  76553. lastChangedTime: number;
  76554. }
  76555. interface XRJointSpace extends XRSpace {}
  76556. interface XRJointPose extends XRPose {
  76557. radius: number | undefined;
  76558. }
  76559. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76560. readonly length: number;
  76561. [index: number]: XRJointSpace;
  76562. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76563. readonly WRIST: number;
  76564. readonly THUMB_METACARPAL: number;
  76565. readonly THUMB_PHALANX_PROXIMAL: number;
  76566. readonly THUMB_PHALANX_DISTAL: number;
  76567. readonly THUMB_PHALANX_TIP: number;
  76568. readonly INDEX_METACARPAL: number;
  76569. readonly INDEX_PHALANX_PROXIMAL: number;
  76570. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76571. readonly INDEX_PHALANX_DISTAL: number;
  76572. readonly INDEX_PHALANX_TIP: number;
  76573. readonly MIDDLE_METACARPAL: number;
  76574. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76575. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76576. readonly MIDDLE_PHALANX_DISTAL: number;
  76577. readonly MIDDLE_PHALANX_TIP: number;
  76578. readonly RING_METACARPAL: number;
  76579. readonly RING_PHALANX_PROXIMAL: number;
  76580. readonly RING_PHALANX_INTERMEDIATE: number;
  76581. readonly RING_PHALANX_DISTAL: number;
  76582. readonly RING_PHALANX_TIP: number;
  76583. readonly LITTLE_METACARPAL: number;
  76584. readonly LITTLE_PHALANX_PROXIMAL: number;
  76585. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76586. readonly LITTLE_PHALANX_DISTAL: number;
  76587. readonly LITTLE_PHALANX_TIP: number;
  76588. }
  76589. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76590. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76591. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76592. interface XRSession {
  76593. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76594. }
  76595. interface XRFrame {
  76596. featurePointCloud? : Array<number>;
  76597. }
  76598. /**
  76599. * @ignore
  76600. */
  76601. declare module BABYLON.GLTF2.Exporter {
  76602. }
  76603. /**
  76604. * @ignore
  76605. */
  76606. declare module BABYLON.GLTF1 {
  76607. }
  76608. declare module BABYLON.GUI {
  76609. /**
  76610. * Class used to specific a value and its associated unit
  76611. */
  76612. export class ValueAndUnit {
  76613. /** defines the unit to store */
  76614. unit: number;
  76615. /** defines a boolean indicating if the value can be negative */
  76616. negativeValueAllowed: boolean;
  76617. private _value;
  76618. private _originalUnit;
  76619. /**
  76620. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76621. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76622. */
  76623. ignoreAdaptiveScaling: boolean;
  76624. /**
  76625. * Creates a new ValueAndUnit
  76626. * @param value defines the value to store
  76627. * @param unit defines the unit to store
  76628. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76629. */
  76630. constructor(value: number,
  76631. /** defines the unit to store */
  76632. unit?: number,
  76633. /** defines a boolean indicating if the value can be negative */
  76634. negativeValueAllowed?: boolean);
  76635. /** Gets a boolean indicating if the value is a percentage */
  76636. get isPercentage(): boolean;
  76637. /** Gets a boolean indicating if the value is store as pixel */
  76638. get isPixel(): boolean;
  76639. /** Gets direct internal value */
  76640. get internalValue(): number;
  76641. /**
  76642. * Gets value as pixel
  76643. * @param host defines the root host
  76644. * @param refValue defines the reference value for percentages
  76645. * @returns the value as pixel
  76646. */
  76647. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76648. /**
  76649. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76650. * @param value defines the value to store
  76651. * @param unit defines the unit to store
  76652. * @returns the current ValueAndUnit
  76653. */
  76654. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76655. /**
  76656. * Gets the value accordingly to its unit
  76657. * @param host defines the root host
  76658. * @returns the value
  76659. */
  76660. getValue(host: AdvancedDynamicTexture): number;
  76661. /**
  76662. * Gets a string representation of the value
  76663. * @param host defines the root host
  76664. * @param decimals defines an optional number of decimals to display
  76665. * @returns a string
  76666. */
  76667. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76668. /**
  76669. * Store a value parsed from a string
  76670. * @param source defines the source string
  76671. * @returns true if the value was successfully parsed
  76672. */
  76673. fromString(source: string | number): boolean;
  76674. private static _Regex;
  76675. private static _UNITMODE_PERCENTAGE;
  76676. private static _UNITMODE_PIXEL;
  76677. /** UNITMODE_PERCENTAGE */
  76678. static get UNITMODE_PERCENTAGE(): number;
  76679. /** UNITMODE_PIXEL */
  76680. static get UNITMODE_PIXEL(): number;
  76681. }
  76682. }
  76683. declare module BABYLON.GUI {
  76684. /**
  76685. * Define a style used by control to automatically setup properties based on a template.
  76686. * Only support font related properties so far
  76687. */
  76688. export class Style implements BABYLON.IDisposable {
  76689. private _fontFamily;
  76690. private _fontStyle;
  76691. private _fontWeight;
  76692. /** @hidden */
  76693. _host: AdvancedDynamicTexture;
  76694. /** @hidden */
  76695. _fontSize: ValueAndUnit;
  76696. /**
  76697. * BABYLON.Observable raised when the style values are changed
  76698. */
  76699. onChangedObservable: BABYLON.Observable<Style>;
  76700. /**
  76701. * Creates a new style object
  76702. * @param host defines the AdvancedDynamicTexture which hosts this style
  76703. */
  76704. constructor(host: AdvancedDynamicTexture);
  76705. /**
  76706. * Gets or sets the font size
  76707. */
  76708. get fontSize(): string | number;
  76709. set fontSize(value: string | number);
  76710. /**
  76711. * Gets or sets the font family
  76712. */
  76713. get fontFamily(): string;
  76714. set fontFamily(value: string);
  76715. /**
  76716. * Gets or sets the font style
  76717. */
  76718. get fontStyle(): string;
  76719. set fontStyle(value: string);
  76720. /** Gets or sets font weight */
  76721. get fontWeight(): string;
  76722. set fontWeight(value: string);
  76723. /** Dispose all associated resources */
  76724. dispose(): void;
  76725. }
  76726. }
  76727. declare module BABYLON.GUI {
  76728. /**
  76729. * Class used to transport BABYLON.Vector2 information for pointer events
  76730. */
  76731. export class Vector2WithInfo extends BABYLON.Vector2 {
  76732. /** defines the current mouse button index */
  76733. buttonIndex: number;
  76734. /**
  76735. * Creates a new Vector2WithInfo
  76736. * @param source defines the vector2 data to transport
  76737. * @param buttonIndex defines the current mouse button index
  76738. */
  76739. constructor(source: BABYLON.Vector2,
  76740. /** defines the current mouse button index */
  76741. buttonIndex?: number);
  76742. }
  76743. /** Class used to provide 2D matrix features */
  76744. export class Matrix2D {
  76745. /** Gets the internal array of 6 floats used to store matrix data */
  76746. m: Float32Array;
  76747. /**
  76748. * Creates a new matrix
  76749. * @param m00 defines value for (0, 0)
  76750. * @param m01 defines value for (0, 1)
  76751. * @param m10 defines value for (1, 0)
  76752. * @param m11 defines value for (1, 1)
  76753. * @param m20 defines value for (2, 0)
  76754. * @param m21 defines value for (2, 1)
  76755. */
  76756. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76757. /**
  76758. * Fills the matrix from direct values
  76759. * @param m00 defines value for (0, 0)
  76760. * @param m01 defines value for (0, 1)
  76761. * @param m10 defines value for (1, 0)
  76762. * @param m11 defines value for (1, 1)
  76763. * @param m20 defines value for (2, 0)
  76764. * @param m21 defines value for (2, 1)
  76765. * @returns the current modified matrix
  76766. */
  76767. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76768. /**
  76769. * Gets matrix determinant
  76770. * @returns the determinant
  76771. */
  76772. determinant(): number;
  76773. /**
  76774. * Inverses the matrix and stores it in a target matrix
  76775. * @param result defines the target matrix
  76776. * @returns the current matrix
  76777. */
  76778. invertToRef(result: Matrix2D): Matrix2D;
  76779. /**
  76780. * Multiplies the current matrix with another one
  76781. * @param other defines the second operand
  76782. * @param result defines the target matrix
  76783. * @returns the current matrix
  76784. */
  76785. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76786. /**
  76787. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76788. * @param x defines the x coordinate to transform
  76789. * @param y defines the x coordinate to transform
  76790. * @param result defines the target vector2
  76791. * @returns the current matrix
  76792. */
  76793. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76794. /**
  76795. * Creates an identity matrix
  76796. * @returns a new matrix
  76797. */
  76798. static Identity(): Matrix2D;
  76799. /**
  76800. * Creates a translation matrix and stores it in a target matrix
  76801. * @param x defines the x coordinate of the translation
  76802. * @param y defines the y coordinate of the translation
  76803. * @param result defines the target matrix
  76804. */
  76805. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76806. /**
  76807. * Creates a scaling matrix and stores it in a target matrix
  76808. * @param x defines the x coordinate of the scaling
  76809. * @param y defines the y coordinate of the scaling
  76810. * @param result defines the target matrix
  76811. */
  76812. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76813. /**
  76814. * Creates a rotation matrix and stores it in a target matrix
  76815. * @param angle defines the rotation angle
  76816. * @param result defines the target matrix
  76817. */
  76818. static RotationToRef(angle: number, result: Matrix2D): void;
  76819. private static _TempPreTranslationMatrix;
  76820. private static _TempPostTranslationMatrix;
  76821. private static _TempRotationMatrix;
  76822. private static _TempScalingMatrix;
  76823. private static _TempCompose0;
  76824. private static _TempCompose1;
  76825. private static _TempCompose2;
  76826. /**
  76827. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76828. * @param tx defines the x coordinate of the translation
  76829. * @param ty defines the y coordinate of the translation
  76830. * @param angle defines the rotation angle
  76831. * @param scaleX defines the x coordinate of the scaling
  76832. * @param scaleY defines the y coordinate of the scaling
  76833. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76834. * @param result defines the target matrix
  76835. */
  76836. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76837. }
  76838. }
  76839. declare module BABYLON.GUI {
  76840. /**
  76841. * Class used to store 2D control sizes
  76842. */
  76843. export class Measure {
  76844. /** defines left coordinate */
  76845. left: number;
  76846. /** defines top coordinate */
  76847. top: number;
  76848. /** defines width dimension */
  76849. width: number;
  76850. /** defines height dimension */
  76851. height: number;
  76852. /**
  76853. * Creates a new measure
  76854. * @param left defines left coordinate
  76855. * @param top defines top coordinate
  76856. * @param width defines width dimension
  76857. * @param height defines height dimension
  76858. */
  76859. constructor(
  76860. /** defines left coordinate */
  76861. left: number,
  76862. /** defines top coordinate */
  76863. top: number,
  76864. /** defines width dimension */
  76865. width: number,
  76866. /** defines height dimension */
  76867. height: number);
  76868. /**
  76869. * Copy from another measure
  76870. * @param other defines the other measure to copy from
  76871. */
  76872. copyFrom(other: Measure): void;
  76873. /**
  76874. * Copy from a group of 4 floats
  76875. * @param left defines left coordinate
  76876. * @param top defines top coordinate
  76877. * @param width defines width dimension
  76878. * @param height defines height dimension
  76879. */
  76880. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76881. /**
  76882. * Computes the axis aligned bounding box measure for two given measures
  76883. * @param a Input measure
  76884. * @param b Input measure
  76885. * @param result the resulting bounding measure
  76886. */
  76887. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76888. /**
  76889. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76890. * @param transform the matrix to transform the measure before computing the AABB
  76891. * @param addX number to add to left
  76892. * @param addY number to add to top
  76893. * @param addWidth number to add to width
  76894. * @param addHeight number to add to height
  76895. * @param result the resulting AABB
  76896. */
  76897. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76898. /**
  76899. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76900. * @param transform the matrix to transform the measure before computing the AABB
  76901. * @param result the resulting AABB
  76902. */
  76903. transformToRef(transform: Matrix2D, result: Measure): void;
  76904. /**
  76905. * Check equality between this measure and another one
  76906. * @param other defines the other measures
  76907. * @returns true if both measures are equals
  76908. */
  76909. isEqualsTo(other: Measure): boolean;
  76910. /**
  76911. * Creates an empty measure
  76912. * @returns a new measure
  76913. */
  76914. static Empty(): Measure;
  76915. }
  76916. }
  76917. declare module BABYLON.GUI {
  76918. /**
  76919. * Interface used to define a control that can receive focus
  76920. */
  76921. export interface IFocusableControl {
  76922. /**
  76923. * Function called when the control receives the focus
  76924. */
  76925. onFocus(): void;
  76926. /**
  76927. * Function called when the control loses the focus
  76928. */
  76929. onBlur(): void;
  76930. /**
  76931. * Function called to let the control handle keyboard events
  76932. * @param evt defines the current keyboard event
  76933. */
  76934. processKeyboard(evt: KeyboardEvent): void;
  76935. /**
  76936. * Function called to get the list of controls that should not steal the focus from this control
  76937. * @returns an array of controls
  76938. */
  76939. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76940. }
  76941. /**
  76942. * Class used to create texture to support 2D GUI elements
  76943. * @see https://doc.babylonjs.com/how_to/gui
  76944. */
  76945. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76946. private _isDirty;
  76947. private _renderObserver;
  76948. private _resizeObserver;
  76949. private _preKeyboardObserver;
  76950. private _pointerMoveObserver;
  76951. private _pointerObserver;
  76952. private _canvasPointerOutObserver;
  76953. private _canvasBlurObserver;
  76954. private _background;
  76955. /** @hidden */
  76956. _rootContainer: Container;
  76957. /** @hidden */
  76958. _lastPickedControl: Control;
  76959. /** @hidden */
  76960. _lastControlOver: {
  76961. [pointerId: number]: Control;
  76962. };
  76963. /** @hidden */
  76964. _lastControlDown: {
  76965. [pointerId: number]: Control;
  76966. };
  76967. /** @hidden */
  76968. _capturingControl: {
  76969. [pointerId: number]: Control;
  76970. };
  76971. /** @hidden */
  76972. _shouldBlockPointer: boolean;
  76973. /** @hidden */
  76974. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76975. /** @hidden */
  76976. _linkedControls: Control[];
  76977. private _isFullscreen;
  76978. private _fullscreenViewport;
  76979. private _idealWidth;
  76980. private _idealHeight;
  76981. private _useSmallestIdeal;
  76982. private _renderAtIdealSize;
  76983. private _focusedControl;
  76984. private _blockNextFocusCheck;
  76985. private _renderScale;
  76986. private _rootElement;
  76987. private _cursorChanged;
  76988. private _defaultMousePointerId;
  76989. /** @hidden */
  76990. _numLayoutCalls: number;
  76991. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76992. get numLayoutCalls(): number;
  76993. /** @hidden */
  76994. _numRenderCalls: number;
  76995. /** Gets the number of render calls made the last time the ADT has been rendered */
  76996. get numRenderCalls(): number;
  76997. /**
  76998. * Define type to string to ensure compatibility across browsers
  76999. * Safari doesn't support DataTransfer constructor
  77000. */
  77001. private _clipboardData;
  77002. /**
  77003. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77004. */
  77005. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77006. /**
  77007. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77008. */
  77009. onControlPickedObservable: BABYLON.Observable<Control>;
  77010. /**
  77011. * BABYLON.Observable event triggered before layout is evaluated
  77012. */
  77013. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77014. /**
  77015. * BABYLON.Observable event triggered after the layout was evaluated
  77016. */
  77017. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77018. /**
  77019. * BABYLON.Observable event triggered before the texture is rendered
  77020. */
  77021. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77022. /**
  77023. * BABYLON.Observable event triggered after the texture was rendered
  77024. */
  77025. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77026. /**
  77027. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77028. */
  77029. premulAlpha: boolean;
  77030. /**
  77031. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77032. * Useful when you want more antialiasing
  77033. */
  77034. get renderScale(): number;
  77035. set renderScale(value: number);
  77036. /** Gets or sets the background color */
  77037. get background(): string;
  77038. set background(value: string);
  77039. /**
  77040. * Gets or sets the ideal width used to design controls.
  77041. * The GUI will then rescale everything accordingly
  77042. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77043. */
  77044. get idealWidth(): number;
  77045. set idealWidth(value: number);
  77046. /**
  77047. * Gets or sets the ideal height used to design controls.
  77048. * The GUI will then rescale everything accordingly
  77049. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77050. */
  77051. get idealHeight(): number;
  77052. set idealHeight(value: number);
  77053. /**
  77054. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77055. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77056. */
  77057. get useSmallestIdeal(): boolean;
  77058. set useSmallestIdeal(value: boolean);
  77059. /**
  77060. * Gets or sets a boolean indicating if adaptive scaling must be used
  77061. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77062. */
  77063. get renderAtIdealSize(): boolean;
  77064. set renderAtIdealSize(value: boolean);
  77065. /**
  77066. * Gets the ratio used when in "ideal mode"
  77067. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77068. * */
  77069. get idealRatio(): number;
  77070. /**
  77071. * Gets the underlying layer used to render the texture when in fullscreen mode
  77072. */
  77073. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77074. /**
  77075. * Gets the root container control
  77076. */
  77077. get rootContainer(): Container;
  77078. /**
  77079. * Returns an array containing the root container.
  77080. * This is mostly used to let the Inspector introspects the ADT
  77081. * @returns an array containing the rootContainer
  77082. */
  77083. getChildren(): Array<Container>;
  77084. /**
  77085. * Will return all controls that are inside this texture
  77086. * @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
  77087. * @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
  77088. * @return all child controls
  77089. */
  77090. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77091. /**
  77092. * Gets or sets the current focused control
  77093. */
  77094. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77095. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77096. /**
  77097. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77098. */
  77099. get isForeground(): boolean;
  77100. set isForeground(value: boolean);
  77101. /**
  77102. * Gets or set information about clipboardData
  77103. */
  77104. get clipboardData(): string;
  77105. set clipboardData(value: string);
  77106. /**
  77107. * Creates a new AdvancedDynamicTexture
  77108. * @param name defines the name of the texture
  77109. * @param width defines the width of the texture
  77110. * @param height defines the height of the texture
  77111. * @param scene defines the hosting scene
  77112. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77113. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77114. */
  77115. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  77116. /**
  77117. * Get the current class name of the texture useful for serialization or dynamic coding.
  77118. * @returns "AdvancedDynamicTexture"
  77119. */
  77120. getClassName(): string;
  77121. /**
  77122. * Function used to execute a function on all controls
  77123. * @param func defines the function to execute
  77124. * @param container defines the container where controls belong. If null the root container will be used
  77125. */
  77126. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77127. private _useInvalidateRectOptimization;
  77128. /**
  77129. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77130. */
  77131. get useInvalidateRectOptimization(): boolean;
  77132. set useInvalidateRectOptimization(value: boolean);
  77133. private _invalidatedRectangle;
  77134. /**
  77135. * Invalidates a rectangle area on the gui texture
  77136. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77137. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77138. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77139. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77140. */
  77141. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77142. /**
  77143. * Marks the texture as dirty forcing a complete update
  77144. */
  77145. markAsDirty(): void;
  77146. /**
  77147. * Helper function used to create a new style
  77148. * @returns a new style
  77149. * @see https://doc.babylonjs.com/how_to/gui#styles
  77150. */
  77151. createStyle(): Style;
  77152. /**
  77153. * Adds a new control to the root container
  77154. * @param control defines the control to add
  77155. * @returns the current texture
  77156. */
  77157. addControl(control: Control): AdvancedDynamicTexture;
  77158. /**
  77159. * Removes a control from the root container
  77160. * @param control defines the control to remove
  77161. * @returns the current texture
  77162. */
  77163. removeControl(control: Control): AdvancedDynamicTexture;
  77164. /**
  77165. * Release all resources
  77166. */
  77167. dispose(): void;
  77168. private _onResize;
  77169. /** @hidden */
  77170. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77171. /**
  77172. * Get screen coordinates for a vector3
  77173. * @param position defines the position to project
  77174. * @param worldMatrix defines the world matrix to use
  77175. * @returns the projected position
  77176. */
  77177. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77178. private _checkUpdate;
  77179. private _clearMeasure;
  77180. private _render;
  77181. /** @hidden */
  77182. _changeCursor(cursor: string): void;
  77183. /** @hidden */
  77184. _registerLastControlDown(control: Control, pointerId: number): void;
  77185. private _doPicking;
  77186. /** @hidden */
  77187. _cleanControlAfterRemovalFromList(list: {
  77188. [pointerId: number]: Control;
  77189. }, control: Control): void;
  77190. /** @hidden */
  77191. _cleanControlAfterRemoval(control: Control): void;
  77192. /** Attach to all scene events required to support pointer events */
  77193. attach(): void;
  77194. /** @hidden */
  77195. private onClipboardCopy;
  77196. /** @hidden */
  77197. private onClipboardCut;
  77198. /** @hidden */
  77199. private onClipboardPaste;
  77200. /**
  77201. * Register the clipboard Events onto the canvas
  77202. */
  77203. registerClipboardEvents(): void;
  77204. /**
  77205. * Unregister the clipboard Events from the canvas
  77206. */
  77207. unRegisterClipboardEvents(): void;
  77208. /**
  77209. * Connect the texture to a hosting mesh to enable interactions
  77210. * @param mesh defines the mesh to attach to
  77211. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77212. */
  77213. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77214. /**
  77215. * Move the focus to a specific control
  77216. * @param control defines the control which will receive the focus
  77217. */
  77218. moveFocusToControl(control: IFocusableControl): void;
  77219. private _manageFocus;
  77220. private _attachToOnPointerOut;
  77221. private _attachToOnBlur;
  77222. /**
  77223. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77224. * @param mesh defines the mesh which will receive the texture
  77225. * @param width defines the texture width (1024 by default)
  77226. * @param height defines the texture height (1024 by default)
  77227. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77228. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77229. * @returns a new AdvancedDynamicTexture
  77230. */
  77231. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  77232. /**
  77233. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77234. * In this mode the texture will rely on a layer for its rendering.
  77235. * This allows it to be treated like any other layer.
  77236. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77237. * LayerMask is set through advancedTexture.layer.layerMask
  77238. * @param name defines name for the texture
  77239. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77240. * @param scene defines the hsoting scene
  77241. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77242. * @returns a new AdvancedDynamicTexture
  77243. */
  77244. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77245. }
  77246. }
  77247. declare module BABYLON.GUI {
  77248. /**
  77249. * Root class used for all 2D controls
  77250. * @see https://doc.babylonjs.com/how_to/gui#controls
  77251. */
  77252. export class Control {
  77253. /** defines the name of the control */
  77254. name?: string | undefined;
  77255. /**
  77256. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77257. */
  77258. static AllowAlphaInheritance: boolean;
  77259. private _alpha;
  77260. private _alphaSet;
  77261. private _zIndex;
  77262. /** @hidden */
  77263. _host: AdvancedDynamicTexture;
  77264. /** Gets or sets the control parent */
  77265. parent: BABYLON.Nullable<Container>;
  77266. /** @hidden */
  77267. _currentMeasure: Measure;
  77268. private _fontFamily;
  77269. private _fontStyle;
  77270. private _fontWeight;
  77271. private _fontSize;
  77272. private _font;
  77273. /** @hidden */
  77274. _width: ValueAndUnit;
  77275. /** @hidden */
  77276. _height: ValueAndUnit;
  77277. /** @hidden */
  77278. protected _fontOffset: {
  77279. ascent: number;
  77280. height: number;
  77281. descent: number;
  77282. };
  77283. private _color;
  77284. private _style;
  77285. private _styleObserver;
  77286. /** @hidden */
  77287. protected _horizontalAlignment: number;
  77288. /** @hidden */
  77289. protected _verticalAlignment: number;
  77290. /** @hidden */
  77291. protected _isDirty: boolean;
  77292. /** @hidden */
  77293. protected _wasDirty: boolean;
  77294. /** @hidden */
  77295. _tempParentMeasure: Measure;
  77296. /** @hidden */
  77297. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77298. /** @hidden */
  77299. protected _cachedParentMeasure: Measure;
  77300. private _paddingLeft;
  77301. private _paddingRight;
  77302. private _paddingTop;
  77303. private _paddingBottom;
  77304. /** @hidden */
  77305. _left: ValueAndUnit;
  77306. /** @hidden */
  77307. _top: ValueAndUnit;
  77308. private _scaleX;
  77309. private _scaleY;
  77310. private _rotation;
  77311. private _transformCenterX;
  77312. private _transformCenterY;
  77313. /** @hidden */
  77314. _transformMatrix: Matrix2D;
  77315. /** @hidden */
  77316. protected _invertTransformMatrix: Matrix2D;
  77317. /** @hidden */
  77318. protected _transformedPosition: BABYLON.Vector2;
  77319. private _isMatrixDirty;
  77320. private _cachedOffsetX;
  77321. private _cachedOffsetY;
  77322. private _isVisible;
  77323. private _isHighlighted;
  77324. /** @hidden */
  77325. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77326. private _fontSet;
  77327. private _dummyVector2;
  77328. private _downCount;
  77329. private _enterCount;
  77330. private _doNotRender;
  77331. private _downPointerIds;
  77332. protected _isEnabled: boolean;
  77333. protected _disabledColor: string;
  77334. protected _disabledColorItem: string;
  77335. /** @hidden */
  77336. protected _rebuildLayout: boolean;
  77337. /** @hidden */
  77338. _customData: any;
  77339. /** @hidden */
  77340. _isClipped: boolean;
  77341. /** @hidden */
  77342. _automaticSize: boolean;
  77343. /** @hidden */
  77344. _tag: any;
  77345. /**
  77346. * 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
  77347. */
  77348. uniqueId: number;
  77349. /**
  77350. * Gets or sets an object used to store user defined information for the node
  77351. */
  77352. metadata: any;
  77353. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77354. isHitTestVisible: boolean;
  77355. /** Gets or sets a boolean indicating if the control can block pointer events */
  77356. isPointerBlocker: boolean;
  77357. /** Gets or sets a boolean indicating if the control can be focusable */
  77358. isFocusInvisible: boolean;
  77359. /**
  77360. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77361. * 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
  77362. */
  77363. clipChildren: boolean;
  77364. /**
  77365. * Gets or sets a boolean indicating that control content must be clipped
  77366. * 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
  77367. */
  77368. clipContent: boolean;
  77369. /**
  77370. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77371. */
  77372. useBitmapCache: boolean;
  77373. private _cacheData;
  77374. private _shadowOffsetX;
  77375. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77376. get shadowOffsetX(): number;
  77377. set shadowOffsetX(value: number);
  77378. private _shadowOffsetY;
  77379. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77380. get shadowOffsetY(): number;
  77381. set shadowOffsetY(value: number);
  77382. private _shadowBlur;
  77383. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77384. get shadowBlur(): number;
  77385. set shadowBlur(value: number);
  77386. private _shadowColor;
  77387. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77388. get shadowColor(): string;
  77389. set shadowColor(value: string);
  77390. /** Gets or sets the cursor to use when the control is hovered */
  77391. hoverCursor: string;
  77392. /** @hidden */
  77393. protected _linkOffsetX: ValueAndUnit;
  77394. /** @hidden */
  77395. protected _linkOffsetY: ValueAndUnit;
  77396. /** Gets the control type name */
  77397. get typeName(): string;
  77398. /**
  77399. * Get the current class name of the control.
  77400. * @returns current class name
  77401. */
  77402. getClassName(): string;
  77403. /**
  77404. * An event triggered when pointer wheel is scrolled
  77405. */
  77406. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77407. /**
  77408. * An event triggered when the pointer move over the control.
  77409. */
  77410. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77411. /**
  77412. * An event triggered when the pointer move out of the control.
  77413. */
  77414. onPointerOutObservable: BABYLON.Observable<Control>;
  77415. /**
  77416. * An event triggered when the pointer taps the control
  77417. */
  77418. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77419. /**
  77420. * An event triggered when pointer up
  77421. */
  77422. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77423. /**
  77424. * An event triggered when a control is clicked on
  77425. */
  77426. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77427. /**
  77428. * An event triggered when pointer enters the control
  77429. */
  77430. onPointerEnterObservable: BABYLON.Observable<Control>;
  77431. /**
  77432. * An event triggered when the control is marked as dirty
  77433. */
  77434. onDirtyObservable: BABYLON.Observable<Control>;
  77435. /**
  77436. * An event triggered before drawing the control
  77437. */
  77438. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77439. /**
  77440. * An event triggered after the control was drawn
  77441. */
  77442. onAfterDrawObservable: BABYLON.Observable<Control>;
  77443. /**
  77444. * An event triggered when the control has been disposed
  77445. */
  77446. onDisposeObservable: BABYLON.Observable<Control>;
  77447. /**
  77448. * Get the hosting AdvancedDynamicTexture
  77449. */
  77450. get host(): AdvancedDynamicTexture;
  77451. /** Gets or set information about font offsets (used to render and align text) */
  77452. get fontOffset(): {
  77453. ascent: number;
  77454. height: number;
  77455. descent: number;
  77456. };
  77457. set fontOffset(offset: {
  77458. ascent: number;
  77459. height: number;
  77460. descent: number;
  77461. });
  77462. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77463. get alpha(): number;
  77464. set alpha(value: number);
  77465. /**
  77466. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77467. */
  77468. get isHighlighted(): boolean;
  77469. set isHighlighted(value: boolean);
  77470. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77471. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77472. */
  77473. get scaleX(): number;
  77474. set scaleX(value: number);
  77475. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77476. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77477. */
  77478. get scaleY(): number;
  77479. set scaleY(value: number);
  77480. /** Gets or sets the rotation angle (0 by default)
  77481. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77482. */
  77483. get rotation(): number;
  77484. set rotation(value: number);
  77485. /** Gets or sets the transformation center on Y axis (0 by default)
  77486. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77487. */
  77488. get transformCenterY(): number;
  77489. set transformCenterY(value: number);
  77490. /** Gets or sets the transformation center on X axis (0 by default)
  77491. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77492. */
  77493. get transformCenterX(): number;
  77494. set transformCenterX(value: number);
  77495. /**
  77496. * Gets or sets the horizontal alignment
  77497. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77498. */
  77499. get horizontalAlignment(): number;
  77500. set horizontalAlignment(value: number);
  77501. /**
  77502. * Gets or sets the vertical alignment
  77503. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77504. */
  77505. get verticalAlignment(): number;
  77506. set verticalAlignment(value: number);
  77507. /**
  77508. * Gets or sets a fixed ratio for this control.
  77509. * When different from 0, the ratio is used to compute the "second" dimension.
  77510. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77511. * second dimension is computed as first dimension * fixedRatio
  77512. */
  77513. fixedRatio: number;
  77514. private _fixedRatioMasterIsWidth;
  77515. /**
  77516. * Gets or sets control width
  77517. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77518. */
  77519. get width(): string | number;
  77520. set width(value: string | number);
  77521. /**
  77522. * Gets or sets the control width in pixel
  77523. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77524. */
  77525. get widthInPixels(): number;
  77526. set widthInPixels(value: number);
  77527. /**
  77528. * Gets or sets control height
  77529. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77530. */
  77531. get height(): string | number;
  77532. set height(value: string | number);
  77533. /**
  77534. * Gets or sets control height in pixel
  77535. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77536. */
  77537. get heightInPixels(): number;
  77538. set heightInPixels(value: number);
  77539. /** Gets or set font family */
  77540. get fontFamily(): string;
  77541. set fontFamily(value: string);
  77542. /** Gets or sets font style */
  77543. get fontStyle(): string;
  77544. set fontStyle(value: string);
  77545. /** Gets or sets font weight */
  77546. get fontWeight(): string;
  77547. set fontWeight(value: string);
  77548. /**
  77549. * Gets or sets style
  77550. * @see https://doc.babylonjs.com/how_to/gui#styles
  77551. */
  77552. get style(): BABYLON.Nullable<Style>;
  77553. set style(value: BABYLON.Nullable<Style>);
  77554. /** @hidden */
  77555. get _isFontSizeInPercentage(): boolean;
  77556. /** Gets or sets font size in pixels */
  77557. get fontSizeInPixels(): number;
  77558. set fontSizeInPixels(value: number);
  77559. /** Gets or sets font size */
  77560. get fontSize(): string | number;
  77561. set fontSize(value: string | number);
  77562. /** Gets or sets foreground color */
  77563. get color(): string;
  77564. set color(value: string);
  77565. /** Gets or sets z index which is used to reorder controls on the z axis */
  77566. get zIndex(): number;
  77567. set zIndex(value: number);
  77568. /** Gets or sets a boolean indicating if the control can be rendered */
  77569. get notRenderable(): boolean;
  77570. set notRenderable(value: boolean);
  77571. /** Gets or sets a boolean indicating if the control is visible */
  77572. get isVisible(): boolean;
  77573. set isVisible(value: boolean);
  77574. /** Gets a boolean indicating that the control needs to update its rendering */
  77575. get isDirty(): boolean;
  77576. /**
  77577. * Gets the current linked mesh (or null if none)
  77578. */
  77579. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77580. /**
  77581. * Gets or sets a value indicating the padding to use on the left of the control
  77582. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77583. */
  77584. get paddingLeft(): string | number;
  77585. set paddingLeft(value: string | number);
  77586. /**
  77587. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77588. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77589. */
  77590. get paddingLeftInPixels(): number;
  77591. set paddingLeftInPixels(value: number);
  77592. /**
  77593. * Gets or sets a value indicating the padding to use on the right of the control
  77594. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77595. */
  77596. get paddingRight(): string | number;
  77597. set paddingRight(value: string | number);
  77598. /**
  77599. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77600. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77601. */
  77602. get paddingRightInPixels(): number;
  77603. set paddingRightInPixels(value: number);
  77604. /**
  77605. * Gets or sets a value indicating the padding to use on the top of the control
  77606. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77607. */
  77608. get paddingTop(): string | number;
  77609. set paddingTop(value: string | number);
  77610. /**
  77611. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77612. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77613. */
  77614. get paddingTopInPixels(): number;
  77615. set paddingTopInPixels(value: number);
  77616. /**
  77617. * Gets or sets a value indicating the padding to use on the bottom of the control
  77618. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77619. */
  77620. get paddingBottom(): string | number;
  77621. set paddingBottom(value: string | number);
  77622. /**
  77623. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77624. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77625. */
  77626. get paddingBottomInPixels(): number;
  77627. set paddingBottomInPixels(value: number);
  77628. /**
  77629. * Gets or sets a value indicating the left coordinate of the control
  77630. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77631. */
  77632. get left(): string | number;
  77633. set left(value: string | number);
  77634. /**
  77635. * Gets or sets a value indicating the left coordinate in pixels of the control
  77636. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77637. */
  77638. get leftInPixels(): number;
  77639. set leftInPixels(value: number);
  77640. /**
  77641. * Gets or sets a value indicating the top coordinate of the control
  77642. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77643. */
  77644. get top(): string | number;
  77645. set top(value: string | number);
  77646. /**
  77647. * Gets or sets a value indicating the top coordinate in pixels of the control
  77648. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77649. */
  77650. get topInPixels(): number;
  77651. set topInPixels(value: number);
  77652. /**
  77653. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77654. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77655. */
  77656. get linkOffsetX(): string | number;
  77657. set linkOffsetX(value: string | number);
  77658. /**
  77659. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77660. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77661. */
  77662. get linkOffsetXInPixels(): number;
  77663. set linkOffsetXInPixels(value: number);
  77664. /**
  77665. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77666. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77667. */
  77668. get linkOffsetY(): string | number;
  77669. set linkOffsetY(value: string | number);
  77670. /**
  77671. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77672. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77673. */
  77674. get linkOffsetYInPixels(): number;
  77675. set linkOffsetYInPixels(value: number);
  77676. /** Gets the center coordinate on X axis */
  77677. get centerX(): number;
  77678. /** Gets the center coordinate on Y axis */
  77679. get centerY(): number;
  77680. /** Gets or sets if control is Enabled*/
  77681. get isEnabled(): boolean;
  77682. set isEnabled(value: boolean);
  77683. /** Gets or sets background color of control if it's disabled*/
  77684. get disabledColor(): string;
  77685. set disabledColor(value: string);
  77686. /** Gets or sets front color of control if it's disabled*/
  77687. get disabledColorItem(): string;
  77688. set disabledColorItem(value: string);
  77689. /**
  77690. * Creates a new control
  77691. * @param name defines the name of the control
  77692. */
  77693. constructor(
  77694. /** defines the name of the control */
  77695. name?: string | undefined);
  77696. /** @hidden */
  77697. protected _getTypeName(): string;
  77698. /**
  77699. * Gets the first ascendant in the hierarchy of the given type
  77700. * @param className defines the required type
  77701. * @returns the ascendant or null if not found
  77702. */
  77703. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77704. /** @hidden */
  77705. _resetFontCache(): void;
  77706. /**
  77707. * Determines if a container is an ascendant of the current control
  77708. * @param container defines the container to look for
  77709. * @returns true if the container is one of the ascendant of the control
  77710. */
  77711. isAscendant(container: Control): boolean;
  77712. /**
  77713. * Gets coordinates in local control space
  77714. * @param globalCoordinates defines the coordinates to transform
  77715. * @returns the new coordinates in local space
  77716. */
  77717. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77718. /**
  77719. * Gets coordinates in local control space
  77720. * @param globalCoordinates defines the coordinates to transform
  77721. * @param result defines the target vector2 where to store the result
  77722. * @returns the current control
  77723. */
  77724. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77725. /**
  77726. * Gets coordinates in parent local control space
  77727. * @param globalCoordinates defines the coordinates to transform
  77728. * @returns the new coordinates in parent local space
  77729. */
  77730. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77731. /**
  77732. * Move the current control to a vector3 position projected onto the screen.
  77733. * @param position defines the target position
  77734. * @param scene defines the hosting scene
  77735. */
  77736. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77737. /**
  77738. * Will store all controls that have this control as ascendant in a given array
  77739. * @param results defines the array where to store the descendants
  77740. * @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
  77741. * @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
  77742. */
  77743. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77744. /**
  77745. * Will return all controls that have this control as ascendant
  77746. * @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
  77747. * @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
  77748. * @return all child controls
  77749. */
  77750. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77751. /**
  77752. * Link current control with a target mesh
  77753. * @param mesh defines the mesh to link with
  77754. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77755. */
  77756. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77757. /** @hidden */
  77758. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77759. /** @hidden */
  77760. _offsetLeft(offset: number): void;
  77761. /** @hidden */
  77762. _offsetTop(offset: number): void;
  77763. /** @hidden */
  77764. _markMatrixAsDirty(): void;
  77765. /** @hidden */
  77766. _flagDescendantsAsMatrixDirty(): void;
  77767. /** @hidden */
  77768. _intersectsRect(rect: Measure): boolean;
  77769. /** @hidden */
  77770. protected invalidateRect(): void;
  77771. /** @hidden */
  77772. _markAsDirty(force?: boolean): void;
  77773. /** @hidden */
  77774. _markAllAsDirty(): void;
  77775. /** @hidden */
  77776. _link(host: AdvancedDynamicTexture): void;
  77777. /** @hidden */
  77778. protected _transform(context?: CanvasRenderingContext2D): void;
  77779. /** @hidden */
  77780. _renderHighlight(context: CanvasRenderingContext2D): void;
  77781. /** @hidden */
  77782. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77783. /** @hidden */
  77784. protected _applyStates(context: CanvasRenderingContext2D): void;
  77785. /** @hidden */
  77786. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77787. /** @hidden */
  77788. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77789. protected _evaluateClippingState(parentMeasure: Measure): void;
  77790. /** @hidden */
  77791. _measure(): void;
  77792. /** @hidden */
  77793. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77794. /** @hidden */
  77795. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77796. /** @hidden */
  77797. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77798. /** @hidden */
  77799. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77800. private static _ClipMeasure;
  77801. private _tmpMeasureA;
  77802. private _clip;
  77803. /** @hidden */
  77804. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77805. /** @hidden */
  77806. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77807. /**
  77808. * Tests if a given coordinates belong to the current control
  77809. * @param x defines x coordinate to test
  77810. * @param y defines y coordinate to test
  77811. * @returns true if the coordinates are inside the control
  77812. */
  77813. contains(x: number, y: number): boolean;
  77814. /** @hidden */
  77815. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77816. /** @hidden */
  77817. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77818. /** @hidden */
  77819. _onPointerEnter(target: Control): boolean;
  77820. /** @hidden */
  77821. _onPointerOut(target: Control, force?: boolean): void;
  77822. /** @hidden */
  77823. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77824. /** @hidden */
  77825. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77826. /** @hidden */
  77827. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77828. /** @hidden */
  77829. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77830. /** @hidden */
  77831. _onCanvasBlur(): void;
  77832. /** @hidden */
  77833. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77834. private _prepareFont;
  77835. /** Releases associated resources */
  77836. dispose(): void;
  77837. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77838. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77839. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77840. private static _VERTICAL_ALIGNMENT_TOP;
  77841. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77842. private static _VERTICAL_ALIGNMENT_CENTER;
  77843. /** HORIZONTAL_ALIGNMENT_LEFT */
  77844. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77845. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77846. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77847. /** HORIZONTAL_ALIGNMENT_CENTER */
  77848. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77849. /** VERTICAL_ALIGNMENT_TOP */
  77850. static get VERTICAL_ALIGNMENT_TOP(): number;
  77851. /** VERTICAL_ALIGNMENT_BOTTOM */
  77852. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77853. /** VERTICAL_ALIGNMENT_CENTER */
  77854. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77855. private static _FontHeightSizes;
  77856. /** @hidden */
  77857. static _GetFontOffset(font: string): {
  77858. ascent: number;
  77859. height: number;
  77860. descent: number;
  77861. };
  77862. /**
  77863. * Creates a stack panel that can be used to render headers
  77864. * @param control defines the control to associate with the header
  77865. * @param text defines the text of the header
  77866. * @param size defines the size of the header
  77867. * @param options defines options used to configure the header
  77868. * @returns a new StackPanel
  77869. * @ignore
  77870. * @hidden
  77871. */
  77872. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77873. isHorizontal: boolean;
  77874. controlFirst: boolean;
  77875. }) => any;
  77876. /** @hidden */
  77877. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77878. }
  77879. }
  77880. declare module BABYLON.GUI {
  77881. /**
  77882. * Root class for 2D containers
  77883. * @see https://doc.babylonjs.com/how_to/gui#containers
  77884. */
  77885. export class Container extends Control {
  77886. name?: string | undefined;
  77887. /** @hidden */
  77888. _children: Control[];
  77889. /** @hidden */
  77890. protected _measureForChildren: Measure;
  77891. /** @hidden */
  77892. protected _background: string;
  77893. /** @hidden */
  77894. protected _adaptWidthToChildren: boolean;
  77895. /** @hidden */
  77896. protected _adaptHeightToChildren: boolean;
  77897. /**
  77898. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77899. */
  77900. logLayoutCycleErrors: boolean;
  77901. /**
  77902. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77903. */
  77904. maxLayoutCycle: number;
  77905. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77906. get adaptHeightToChildren(): boolean;
  77907. set adaptHeightToChildren(value: boolean);
  77908. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77909. get adaptWidthToChildren(): boolean;
  77910. set adaptWidthToChildren(value: boolean);
  77911. /** Gets or sets background color */
  77912. get background(): string;
  77913. set background(value: string);
  77914. /** Gets the list of children */
  77915. get children(): Control[];
  77916. /**
  77917. * Creates a new Container
  77918. * @param name defines the name of the container
  77919. */
  77920. constructor(name?: string | undefined);
  77921. protected _getTypeName(): string;
  77922. _flagDescendantsAsMatrixDirty(): void;
  77923. /**
  77924. * Gets a child using its name
  77925. * @param name defines the child name to look for
  77926. * @returns the child control if found
  77927. */
  77928. getChildByName(name: string): BABYLON.Nullable<Control>;
  77929. /**
  77930. * Gets a child using its type and its name
  77931. * @param name defines the child name to look for
  77932. * @param type defines the child type to look for
  77933. * @returns the child control if found
  77934. */
  77935. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77936. /**
  77937. * Search for a specific control in children
  77938. * @param control defines the control to look for
  77939. * @returns true if the control is in child list
  77940. */
  77941. containsControl(control: Control): boolean;
  77942. /**
  77943. * Adds a new control to the current container
  77944. * @param control defines the control to add
  77945. * @returns the current container
  77946. */
  77947. addControl(control: BABYLON.Nullable<Control>): Container;
  77948. /**
  77949. * Removes all controls from the current container
  77950. * @returns the current container
  77951. */
  77952. clearControls(): Container;
  77953. /**
  77954. * Removes a control from the current container
  77955. * @param control defines the control to remove
  77956. * @returns the current container
  77957. */
  77958. removeControl(control: Control): Container;
  77959. /** @hidden */
  77960. _reOrderControl(control: Control): void;
  77961. /** @hidden */
  77962. _offsetLeft(offset: number): void;
  77963. /** @hidden */
  77964. _offsetTop(offset: number): void;
  77965. /** @hidden */
  77966. _markAllAsDirty(): void;
  77967. /** @hidden */
  77968. protected _localDraw(context: CanvasRenderingContext2D): void;
  77969. /** @hidden */
  77970. _link(host: AdvancedDynamicTexture): void;
  77971. /** @hidden */
  77972. protected _beforeLayout(): void;
  77973. /** @hidden */
  77974. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77975. /** @hidden */
  77976. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77977. protected _postMeasure(): void;
  77978. /** @hidden */
  77979. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77980. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77981. /** @hidden */
  77982. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77983. /** @hidden */
  77984. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77985. /** Releases associated resources */
  77986. dispose(): void;
  77987. }
  77988. }
  77989. declare module BABYLON.GUI {
  77990. /** Class used to create rectangle container */
  77991. export class Rectangle extends Container {
  77992. name?: string | undefined;
  77993. private _thickness;
  77994. private _cornerRadius;
  77995. /** Gets or sets border thickness */
  77996. get thickness(): number;
  77997. set thickness(value: number);
  77998. /** Gets or sets the corner radius angle */
  77999. get cornerRadius(): number;
  78000. set cornerRadius(value: number);
  78001. /**
  78002. * Creates a new Rectangle
  78003. * @param name defines the control name
  78004. */
  78005. constructor(name?: string | undefined);
  78006. protected _getTypeName(): string;
  78007. protected _localDraw(context: CanvasRenderingContext2D): void;
  78008. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78009. private _drawRoundedRect;
  78010. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78011. }
  78012. }
  78013. declare module BABYLON.GUI {
  78014. /**
  78015. * Enum that determines the text-wrapping mode to use.
  78016. */
  78017. export enum TextWrapping {
  78018. /**
  78019. * Clip the text when it's larger than Control.width; this is the default mode.
  78020. */
  78021. Clip = 0,
  78022. /**
  78023. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78024. */
  78025. WordWrap = 1,
  78026. /**
  78027. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78028. */
  78029. Ellipsis = 2
  78030. }
  78031. /**
  78032. * Class used to create text block control
  78033. */
  78034. export class TextBlock extends Control {
  78035. /**
  78036. * Defines the name of the control
  78037. */
  78038. name?: string | undefined;
  78039. private _text;
  78040. private _textWrapping;
  78041. private _textHorizontalAlignment;
  78042. private _textVerticalAlignment;
  78043. private _lines;
  78044. private _resizeToFit;
  78045. private _lineSpacing;
  78046. private _outlineWidth;
  78047. private _outlineColor;
  78048. private _underline;
  78049. private _lineThrough;
  78050. /**
  78051. * An event triggered after the text is changed
  78052. */
  78053. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78054. /**
  78055. * An event triggered after the text was broken up into lines
  78056. */
  78057. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78058. /**
  78059. * Function used to split a string into words. By default, a string is split at each space character found
  78060. */
  78061. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78062. /**
  78063. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78064. */
  78065. get lines(): any[];
  78066. /**
  78067. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78068. */
  78069. get resizeToFit(): boolean;
  78070. /**
  78071. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78072. */
  78073. set resizeToFit(value: boolean);
  78074. /**
  78075. * Gets or sets a boolean indicating if text must be wrapped
  78076. */
  78077. get textWrapping(): TextWrapping | boolean;
  78078. /**
  78079. * Gets or sets a boolean indicating if text must be wrapped
  78080. */
  78081. set textWrapping(value: TextWrapping | boolean);
  78082. /**
  78083. * Gets or sets text to display
  78084. */
  78085. get text(): string;
  78086. /**
  78087. * Gets or sets text to display
  78088. */
  78089. set text(value: string);
  78090. /**
  78091. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78092. */
  78093. get textHorizontalAlignment(): number;
  78094. /**
  78095. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78096. */
  78097. set textHorizontalAlignment(value: number);
  78098. /**
  78099. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78100. */
  78101. get textVerticalAlignment(): number;
  78102. /**
  78103. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78104. */
  78105. set textVerticalAlignment(value: number);
  78106. /**
  78107. * Gets or sets line spacing value
  78108. */
  78109. set lineSpacing(value: string | number);
  78110. /**
  78111. * Gets or sets line spacing value
  78112. */
  78113. get lineSpacing(): string | number;
  78114. /**
  78115. * Gets or sets outlineWidth of the text to display
  78116. */
  78117. get outlineWidth(): number;
  78118. /**
  78119. * Gets or sets outlineWidth of the text to display
  78120. */
  78121. set outlineWidth(value: number);
  78122. /**
  78123. * Gets or sets a boolean indicating that text must have underline
  78124. */
  78125. get underline(): boolean;
  78126. /**
  78127. * Gets or sets a boolean indicating that text must have underline
  78128. */
  78129. set underline(value: boolean);
  78130. /**
  78131. * Gets or sets an boolean indicating that text must be crossed out
  78132. */
  78133. get lineThrough(): boolean;
  78134. /**
  78135. * Gets or sets an boolean indicating that text must be crossed out
  78136. */
  78137. set lineThrough(value: boolean);
  78138. /**
  78139. * Gets or sets outlineColor of the text to display
  78140. */
  78141. get outlineColor(): string;
  78142. /**
  78143. * Gets or sets outlineColor of the text to display
  78144. */
  78145. set outlineColor(value: string);
  78146. /**
  78147. * Creates a new TextBlock object
  78148. * @param name defines the name of the control
  78149. * @param text defines the text to display (emptry string by default)
  78150. */
  78151. constructor(
  78152. /**
  78153. * Defines the name of the control
  78154. */
  78155. name?: string | undefined, text?: string);
  78156. protected _getTypeName(): string;
  78157. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78158. private _drawText;
  78159. /** @hidden */
  78160. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78161. protected _applyStates(context: CanvasRenderingContext2D): void;
  78162. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78163. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78164. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78165. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78166. protected _renderLines(context: CanvasRenderingContext2D): void;
  78167. /**
  78168. * Given a width constraint applied on the text block, find the expected height
  78169. * @returns expected height
  78170. */
  78171. computeExpectedHeight(): number;
  78172. dispose(): void;
  78173. }
  78174. }
  78175. declare module BABYLON.GUI {
  78176. /**
  78177. * Class used to create 2D images
  78178. */
  78179. export class Image extends Control {
  78180. name?: string | undefined;
  78181. private _workingCanvas;
  78182. private _domImage;
  78183. private _imageWidth;
  78184. private _imageHeight;
  78185. private _loaded;
  78186. private _stretch;
  78187. private _source;
  78188. private _autoScale;
  78189. private _sourceLeft;
  78190. private _sourceTop;
  78191. private _sourceWidth;
  78192. private _sourceHeight;
  78193. private _svgAttributesComputationCompleted;
  78194. private _isSVG;
  78195. private _cellWidth;
  78196. private _cellHeight;
  78197. private _cellId;
  78198. private _populateNinePatchSlicesFromImage;
  78199. private _sliceLeft;
  78200. private _sliceRight;
  78201. private _sliceTop;
  78202. private _sliceBottom;
  78203. private _detectPointerOnOpaqueOnly;
  78204. private _imageDataCache;
  78205. /**
  78206. * BABYLON.Observable notified when the content is loaded
  78207. */
  78208. onImageLoadedObservable: BABYLON.Observable<Image>;
  78209. /**
  78210. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78211. */
  78212. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78213. /**
  78214. * Gets a boolean indicating that the content is loaded
  78215. */
  78216. get isLoaded(): boolean;
  78217. /**
  78218. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78219. */
  78220. get populateNinePatchSlicesFromImage(): boolean;
  78221. set populateNinePatchSlicesFromImage(value: boolean);
  78222. /**
  78223. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78224. * Beware using this as this will comsume more memory as the image has to be stored twice
  78225. */
  78226. get detectPointerOnOpaqueOnly(): boolean;
  78227. set detectPointerOnOpaqueOnly(value: boolean);
  78228. /**
  78229. * Gets or sets the left value for slicing (9-patch)
  78230. */
  78231. get sliceLeft(): number;
  78232. set sliceLeft(value: number);
  78233. /**
  78234. * Gets or sets the right value for slicing (9-patch)
  78235. */
  78236. get sliceRight(): number;
  78237. set sliceRight(value: number);
  78238. /**
  78239. * Gets or sets the top value for slicing (9-patch)
  78240. */
  78241. get sliceTop(): number;
  78242. set sliceTop(value: number);
  78243. /**
  78244. * Gets or sets the bottom value for slicing (9-patch)
  78245. */
  78246. get sliceBottom(): number;
  78247. set sliceBottom(value: number);
  78248. /**
  78249. * Gets or sets the left coordinate in the source image
  78250. */
  78251. get sourceLeft(): number;
  78252. set sourceLeft(value: number);
  78253. /**
  78254. * Gets or sets the top coordinate in the source image
  78255. */
  78256. get sourceTop(): number;
  78257. set sourceTop(value: number);
  78258. /**
  78259. * Gets or sets the width to capture in the source image
  78260. */
  78261. get sourceWidth(): number;
  78262. set sourceWidth(value: number);
  78263. /**
  78264. * Gets or sets the height to capture in the source image
  78265. */
  78266. get sourceHeight(): number;
  78267. set sourceHeight(value: number);
  78268. /** Indicates if the format of the image is SVG */
  78269. get isSVG(): boolean;
  78270. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78271. get svgAttributesComputationCompleted(): boolean;
  78272. /**
  78273. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78274. * @see https://doc.babylonjs.com/how_to/gui#image
  78275. */
  78276. get autoScale(): boolean;
  78277. set autoScale(value: boolean);
  78278. /** Gets or sets the streching mode used by the image */
  78279. get stretch(): number;
  78280. set stretch(value: number);
  78281. /** @hidden */
  78282. _rotate90(n: number, preserveProperties?: boolean): Image;
  78283. private _handleRotationForSVGImage;
  78284. private _rotate90SourceProperties;
  78285. /**
  78286. * Gets or sets the internal DOM image used to render the control
  78287. */
  78288. set domImage(value: HTMLImageElement);
  78289. get domImage(): HTMLImageElement;
  78290. private _onImageLoaded;
  78291. private _extractNinePatchSliceDataFromImage;
  78292. /**
  78293. * Gets or sets image source url
  78294. */
  78295. set source(value: BABYLON.Nullable<string>);
  78296. /**
  78297. * Checks for svg document with icon id present
  78298. */
  78299. private _svgCheck;
  78300. /**
  78301. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78302. * given external svg file and icon id
  78303. */
  78304. private _getSVGAttribs;
  78305. /**
  78306. * Gets or sets the cell width to use when animation sheet is enabled
  78307. * @see https://doc.babylonjs.com/how_to/gui#image
  78308. */
  78309. get cellWidth(): number;
  78310. set cellWidth(value: number);
  78311. /**
  78312. * Gets or sets the cell height to use when animation sheet is enabled
  78313. * @see https://doc.babylonjs.com/how_to/gui#image
  78314. */
  78315. get cellHeight(): number;
  78316. set cellHeight(value: number);
  78317. /**
  78318. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78319. * @see https://doc.babylonjs.com/how_to/gui#image
  78320. */
  78321. get cellId(): number;
  78322. set cellId(value: number);
  78323. /**
  78324. * Creates a new Image
  78325. * @param name defines the control name
  78326. * @param url defines the image url
  78327. */
  78328. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78329. /**
  78330. * Tests if a given coordinates belong to the current control
  78331. * @param x defines x coordinate to test
  78332. * @param y defines y coordinate to test
  78333. * @returns true if the coordinates are inside the control
  78334. */
  78335. contains(x: number, y: number): boolean;
  78336. protected _getTypeName(): string;
  78337. /** Force the control to synchronize with its content */
  78338. synchronizeSizeWithContent(): void;
  78339. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78340. private _prepareWorkingCanvasForOpaqueDetection;
  78341. private _drawImage;
  78342. _draw(context: CanvasRenderingContext2D): void;
  78343. private _renderCornerPatch;
  78344. private _renderNinePatch;
  78345. dispose(): void;
  78346. /** STRETCH_NONE */
  78347. static readonly STRETCH_NONE: number;
  78348. /** STRETCH_FILL */
  78349. static readonly STRETCH_FILL: number;
  78350. /** STRETCH_UNIFORM */
  78351. static readonly STRETCH_UNIFORM: number;
  78352. /** STRETCH_EXTEND */
  78353. static readonly STRETCH_EXTEND: number;
  78354. /** NINE_PATCH */
  78355. static readonly STRETCH_NINE_PATCH: number;
  78356. }
  78357. }
  78358. declare module BABYLON.GUI {
  78359. /**
  78360. * Class used to create 2D buttons
  78361. */
  78362. export class Button extends Rectangle {
  78363. name?: string | undefined;
  78364. /**
  78365. * Function called to generate a pointer enter animation
  78366. */
  78367. pointerEnterAnimation: () => void;
  78368. /**
  78369. * Function called to generate a pointer out animation
  78370. */
  78371. pointerOutAnimation: () => void;
  78372. /**
  78373. * Function called to generate a pointer down animation
  78374. */
  78375. pointerDownAnimation: () => void;
  78376. /**
  78377. * Function called to generate a pointer up animation
  78378. */
  78379. pointerUpAnimation: () => void;
  78380. /**
  78381. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78382. */
  78383. delegatePickingToChildren: boolean;
  78384. private _image;
  78385. /**
  78386. * Returns the image part of the button (if any)
  78387. */
  78388. get image(): BABYLON.Nullable<Image>;
  78389. private _textBlock;
  78390. /**
  78391. * Returns the image part of the button (if any)
  78392. */
  78393. get textBlock(): BABYLON.Nullable<TextBlock>;
  78394. /**
  78395. * Creates a new Button
  78396. * @param name defines the name of the button
  78397. */
  78398. constructor(name?: string | undefined);
  78399. protected _getTypeName(): string;
  78400. /** @hidden */
  78401. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78402. /** @hidden */
  78403. _onPointerEnter(target: Control): boolean;
  78404. /** @hidden */
  78405. _onPointerOut(target: Control, force?: boolean): void;
  78406. /** @hidden */
  78407. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78408. /** @hidden */
  78409. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78410. /**
  78411. * Creates a new button made with an image and a text
  78412. * @param name defines the name of the button
  78413. * @param text defines the text of the button
  78414. * @param imageUrl defines the url of the image
  78415. * @returns a new Button
  78416. */
  78417. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78418. /**
  78419. * Creates a new button made with an image
  78420. * @param name defines the name of the button
  78421. * @param imageUrl defines the url of the image
  78422. * @returns a new Button
  78423. */
  78424. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78425. /**
  78426. * Creates a new button made with a text
  78427. * @param name defines the name of the button
  78428. * @param text defines the text of the button
  78429. * @returns a new Button
  78430. */
  78431. static CreateSimpleButton(name: string, text: string): Button;
  78432. /**
  78433. * Creates a new button made with an image and a centered text
  78434. * @param name defines the name of the button
  78435. * @param text defines the text of the button
  78436. * @param imageUrl defines the url of the image
  78437. * @returns a new Button
  78438. */
  78439. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78440. }
  78441. }
  78442. declare module BABYLON.GUI {
  78443. /**
  78444. * Class used to create a 2D stack panel container
  78445. */
  78446. export class StackPanel extends Container {
  78447. name?: string | undefined;
  78448. private _isVertical;
  78449. private _manualWidth;
  78450. private _manualHeight;
  78451. private _doNotTrackManualChanges;
  78452. /**
  78453. * Gets or sets a boolean indicating that layou warnings should be ignored
  78454. */
  78455. ignoreLayoutWarnings: boolean;
  78456. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78457. get isVertical(): boolean;
  78458. set isVertical(value: boolean);
  78459. /**
  78460. * Gets or sets panel width.
  78461. * This value should not be set when in horizontal mode as it will be computed automatically
  78462. */
  78463. set width(value: string | number);
  78464. get width(): string | number;
  78465. /**
  78466. * Gets or sets panel height.
  78467. * This value should not be set when in vertical mode as it will be computed automatically
  78468. */
  78469. set height(value: string | number);
  78470. get height(): string | number;
  78471. /**
  78472. * Creates a new StackPanel
  78473. * @param name defines control name
  78474. */
  78475. constructor(name?: string | undefined);
  78476. protected _getTypeName(): string;
  78477. /** @hidden */
  78478. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78479. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78480. protected _postMeasure(): void;
  78481. }
  78482. }
  78483. declare module BABYLON.GUI {
  78484. /**
  78485. * Class used to represent a 2D checkbox
  78486. */
  78487. export class Checkbox extends Control {
  78488. name?: string | undefined;
  78489. private _isChecked;
  78490. private _background;
  78491. private _checkSizeRatio;
  78492. private _thickness;
  78493. /** Gets or sets border thickness */
  78494. get thickness(): number;
  78495. set thickness(value: number);
  78496. /**
  78497. * BABYLON.Observable raised when isChecked property changes
  78498. */
  78499. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78500. /** Gets or sets a value indicating the ratio between overall size and check size */
  78501. get checkSizeRatio(): number;
  78502. set checkSizeRatio(value: number);
  78503. /** Gets or sets background color */
  78504. get background(): string;
  78505. set background(value: string);
  78506. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78507. get isChecked(): boolean;
  78508. set isChecked(value: boolean);
  78509. /**
  78510. * Creates a new CheckBox
  78511. * @param name defines the control name
  78512. */
  78513. constructor(name?: string | undefined);
  78514. protected _getTypeName(): string;
  78515. /** @hidden */
  78516. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78517. /** @hidden */
  78518. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78519. /**
  78520. * Utility function to easily create a checkbox with a header
  78521. * @param title defines the label to use for the header
  78522. * @param onValueChanged defines the callback to call when value changes
  78523. * @returns a StackPanel containing the checkbox and a textBlock
  78524. */
  78525. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78526. }
  78527. }
  78528. declare module BABYLON.GUI {
  78529. /**
  78530. * Class used to store key control properties
  78531. */
  78532. export class KeyPropertySet {
  78533. /** Width */
  78534. width?: string;
  78535. /** Height */
  78536. height?: string;
  78537. /** Left padding */
  78538. paddingLeft?: string;
  78539. /** Right padding */
  78540. paddingRight?: string;
  78541. /** Top padding */
  78542. paddingTop?: string;
  78543. /** Bottom padding */
  78544. paddingBottom?: string;
  78545. /** Foreground color */
  78546. color?: string;
  78547. /** Background color */
  78548. background?: string;
  78549. }
  78550. /**
  78551. * Class used to create virtual keyboard
  78552. */
  78553. export class VirtualKeyboard extends StackPanel {
  78554. /** BABYLON.Observable raised when a key is pressed */
  78555. onKeyPressObservable: BABYLON.Observable<string>;
  78556. /** Gets or sets default key button width */
  78557. defaultButtonWidth: string;
  78558. /** Gets or sets default key button height */
  78559. defaultButtonHeight: string;
  78560. /** Gets or sets default key button left padding */
  78561. defaultButtonPaddingLeft: string;
  78562. /** Gets or sets default key button right padding */
  78563. defaultButtonPaddingRight: string;
  78564. /** Gets or sets default key button top padding */
  78565. defaultButtonPaddingTop: string;
  78566. /** Gets or sets default key button bottom padding */
  78567. defaultButtonPaddingBottom: string;
  78568. /** Gets or sets default key button foreground color */
  78569. defaultButtonColor: string;
  78570. /** Gets or sets default key button background color */
  78571. defaultButtonBackground: string;
  78572. /** Gets or sets shift button foreground color */
  78573. shiftButtonColor: string;
  78574. /** Gets or sets shift button thickness*/
  78575. selectedShiftThickness: number;
  78576. /** Gets shift key state */
  78577. shiftState: number;
  78578. protected _getTypeName(): string;
  78579. private _createKey;
  78580. /**
  78581. * Adds a new row of keys
  78582. * @param keys defines the list of keys to add
  78583. * @param propertySets defines the associated property sets
  78584. */
  78585. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78586. /**
  78587. * Set the shift key to a specific state
  78588. * @param shiftState defines the new shift state
  78589. */
  78590. applyShiftState(shiftState: number): void;
  78591. private _currentlyConnectedInputText;
  78592. private _connectedInputTexts;
  78593. private _onKeyPressObserver;
  78594. /** Gets the input text control currently attached to the keyboard */
  78595. get connectedInputText(): BABYLON.Nullable<InputText>;
  78596. /**
  78597. * Connects the keyboard with an input text control
  78598. *
  78599. * @param input defines the target control
  78600. */
  78601. connect(input: InputText): void;
  78602. /**
  78603. * Disconnects the keyboard from connected InputText controls
  78604. *
  78605. * @param input optionally defines a target control, otherwise all are disconnected
  78606. */
  78607. disconnect(input?: InputText): void;
  78608. private _removeConnectedInputObservables;
  78609. /**
  78610. * Release all resources
  78611. */
  78612. dispose(): void;
  78613. /**
  78614. * Creates a new keyboard using a default layout
  78615. *
  78616. * @param name defines control name
  78617. * @returns a new VirtualKeyboard
  78618. */
  78619. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78620. }
  78621. }
  78622. declare module BABYLON.GUI {
  78623. /**
  78624. * Class used to create input text control
  78625. */
  78626. export class InputText extends Control implements IFocusableControl {
  78627. name?: string | undefined;
  78628. private _text;
  78629. private _placeholderText;
  78630. private _background;
  78631. private _focusedBackground;
  78632. private _focusedColor;
  78633. private _placeholderColor;
  78634. private _thickness;
  78635. private _margin;
  78636. private _autoStretchWidth;
  78637. private _maxWidth;
  78638. private _isFocused;
  78639. private _blinkTimeout;
  78640. private _blinkIsEven;
  78641. private _cursorOffset;
  78642. private _scrollLeft;
  78643. private _textWidth;
  78644. private _clickedCoordinate;
  78645. private _deadKey;
  78646. private _addKey;
  78647. private _currentKey;
  78648. private _isTextHighlightOn;
  78649. private _textHighlightColor;
  78650. private _highligherOpacity;
  78651. private _highlightedText;
  78652. private _startHighlightIndex;
  78653. private _endHighlightIndex;
  78654. private _cursorIndex;
  78655. private _onFocusSelectAll;
  78656. private _isPointerDown;
  78657. private _onClipboardObserver;
  78658. private _onPointerDblTapObserver;
  78659. /** @hidden */
  78660. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78661. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78662. promptMessage: string;
  78663. /** Force disable prompt on mobile device */
  78664. disableMobilePrompt: boolean;
  78665. /** BABYLON.Observable raised when the text changes */
  78666. onTextChangedObservable: BABYLON.Observable<InputText>;
  78667. /** BABYLON.Observable raised just before an entered character is to be added */
  78668. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78669. /** BABYLON.Observable raised when the control gets the focus */
  78670. onFocusObservable: BABYLON.Observable<InputText>;
  78671. /** BABYLON.Observable raised when the control loses the focus */
  78672. onBlurObservable: BABYLON.Observable<InputText>;
  78673. /**Observable raised when the text is highlighted */
  78674. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78675. /**Observable raised when copy event is triggered */
  78676. onTextCopyObservable: BABYLON.Observable<InputText>;
  78677. /** BABYLON.Observable raised when cut event is triggered */
  78678. onTextCutObservable: BABYLON.Observable<InputText>;
  78679. /** BABYLON.Observable raised when paste event is triggered */
  78680. onTextPasteObservable: BABYLON.Observable<InputText>;
  78681. /** BABYLON.Observable raised when a key event was processed */
  78682. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78683. /** Gets or sets the maximum width allowed by the control */
  78684. get maxWidth(): string | number;
  78685. /** Gets the maximum width allowed by the control in pixels */
  78686. get maxWidthInPixels(): number;
  78687. set maxWidth(value: string | number);
  78688. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78689. get highligherOpacity(): number;
  78690. set highligherOpacity(value: number);
  78691. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78692. get onFocusSelectAll(): boolean;
  78693. set onFocusSelectAll(value: boolean);
  78694. /** Gets or sets the text hightlight color */
  78695. get textHighlightColor(): string;
  78696. set textHighlightColor(value: string);
  78697. /** Gets or sets control margin */
  78698. get margin(): string;
  78699. /** Gets control margin in pixels */
  78700. get marginInPixels(): number;
  78701. set margin(value: string);
  78702. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78703. get autoStretchWidth(): boolean;
  78704. set autoStretchWidth(value: boolean);
  78705. /** Gets or sets border thickness */
  78706. get thickness(): number;
  78707. set thickness(value: number);
  78708. /** Gets or sets the background color when focused */
  78709. get focusedBackground(): string;
  78710. set focusedBackground(value: string);
  78711. /** Gets or sets the background color when focused */
  78712. get focusedColor(): string;
  78713. set focusedColor(value: string);
  78714. /** Gets or sets the background color */
  78715. get background(): string;
  78716. set background(value: string);
  78717. /** Gets or sets the placeholder color */
  78718. get placeholderColor(): string;
  78719. set placeholderColor(value: string);
  78720. /** Gets or sets the text displayed when the control is empty */
  78721. get placeholderText(): string;
  78722. set placeholderText(value: string);
  78723. /** Gets or sets the dead key flag */
  78724. get deadKey(): boolean;
  78725. set deadKey(flag: boolean);
  78726. /** Gets or sets the highlight text */
  78727. get highlightedText(): string;
  78728. set highlightedText(text: string);
  78729. /** Gets or sets if the current key should be added */
  78730. get addKey(): boolean;
  78731. set addKey(flag: boolean);
  78732. /** Gets or sets the value of the current key being entered */
  78733. get currentKey(): string;
  78734. set currentKey(key: string);
  78735. /** Gets or sets the text displayed in the control */
  78736. get text(): string;
  78737. set text(value: string);
  78738. /** Gets or sets control width */
  78739. get width(): string | number;
  78740. set width(value: string | number);
  78741. /**
  78742. * Creates a new InputText
  78743. * @param name defines the control name
  78744. * @param text defines the text of the control
  78745. */
  78746. constructor(name?: string | undefined, text?: string);
  78747. /** @hidden */
  78748. onBlur(): void;
  78749. /** @hidden */
  78750. onFocus(): void;
  78751. protected _getTypeName(): string;
  78752. /**
  78753. * Function called to get the list of controls that should not steal the focus from this control
  78754. * @returns an array of controls
  78755. */
  78756. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78757. /** @hidden */
  78758. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78759. /** @hidden */
  78760. private _updateValueFromCursorIndex;
  78761. /** @hidden */
  78762. private _processDblClick;
  78763. /** @hidden */
  78764. private _selectAllText;
  78765. /**
  78766. * Handles the keyboard event
  78767. * @param evt Defines the KeyboardEvent
  78768. */
  78769. processKeyboard(evt: KeyboardEvent): void;
  78770. /** @hidden */
  78771. private _onCopyText;
  78772. /** @hidden */
  78773. private _onCutText;
  78774. /** @hidden */
  78775. private _onPasteText;
  78776. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78777. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78778. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78779. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78780. protected _beforeRenderText(text: string): string;
  78781. dispose(): void;
  78782. }
  78783. }
  78784. declare module BABYLON.GUI {
  78785. /**
  78786. * Class used to create a 2D grid container
  78787. */
  78788. export class Grid extends Container {
  78789. name?: string | undefined;
  78790. private _rowDefinitions;
  78791. private _columnDefinitions;
  78792. private _cells;
  78793. private _childControls;
  78794. /**
  78795. * Gets the number of columns
  78796. */
  78797. get columnCount(): number;
  78798. /**
  78799. * Gets the number of rows
  78800. */
  78801. get rowCount(): number;
  78802. /** Gets the list of children */
  78803. get children(): Control[];
  78804. /** Gets the list of cells (e.g. the containers) */
  78805. get cells(): {
  78806. [key: string]: Container;
  78807. };
  78808. /**
  78809. * Gets the definition of a specific row
  78810. * @param index defines the index of the row
  78811. * @returns the row definition
  78812. */
  78813. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78814. /**
  78815. * Gets the definition of a specific column
  78816. * @param index defines the index of the column
  78817. * @returns the column definition
  78818. */
  78819. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78820. /**
  78821. * Adds a new row to the grid
  78822. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78823. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78824. * @returns the current grid
  78825. */
  78826. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78827. /**
  78828. * Adds a new column to the grid
  78829. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78830. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78831. * @returns the current grid
  78832. */
  78833. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78834. /**
  78835. * Update a row definition
  78836. * @param index defines the index of the row to update
  78837. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78838. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78839. * @returns the current grid
  78840. */
  78841. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78842. /**
  78843. * Update a column definition
  78844. * @param index defines the index of the column to update
  78845. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78846. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78847. * @returns the current grid
  78848. */
  78849. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78850. /**
  78851. * Gets the list of children stored in a specific cell
  78852. * @param row defines the row to check
  78853. * @param column defines the column to check
  78854. * @returns the list of controls
  78855. */
  78856. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78857. /**
  78858. * Gets a string representing the child cell info (row x column)
  78859. * @param child defines the control to get info from
  78860. * @returns a string containing the child cell info (row x column)
  78861. */
  78862. getChildCellInfo(child: Control): string;
  78863. private _removeCell;
  78864. private _offsetCell;
  78865. /**
  78866. * Remove a column definition at specified index
  78867. * @param index defines the index of the column to remove
  78868. * @returns the current grid
  78869. */
  78870. removeColumnDefinition(index: number): Grid;
  78871. /**
  78872. * Remove a row definition at specified index
  78873. * @param index defines the index of the row to remove
  78874. * @returns the current grid
  78875. */
  78876. removeRowDefinition(index: number): Grid;
  78877. /**
  78878. * Adds a new control to the current grid
  78879. * @param control defines the control to add
  78880. * @param row defines the row where to add the control (0 by default)
  78881. * @param column defines the column where to add the control (0 by default)
  78882. * @returns the current grid
  78883. */
  78884. addControl(control: Control, row?: number, column?: number): Grid;
  78885. /**
  78886. * Removes a control from the current container
  78887. * @param control defines the control to remove
  78888. * @returns the current container
  78889. */
  78890. removeControl(control: Control): Container;
  78891. /**
  78892. * Creates a new Grid
  78893. * @param name defines control name
  78894. */
  78895. constructor(name?: string | undefined);
  78896. protected _getTypeName(): string;
  78897. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78898. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78899. _flagDescendantsAsMatrixDirty(): void;
  78900. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78901. /** Releases associated resources */
  78902. dispose(): void;
  78903. }
  78904. }
  78905. declare module BABYLON.GUI {
  78906. /** Class used to create color pickers */
  78907. export class ColorPicker extends Control {
  78908. name?: string | undefined;
  78909. private static _Epsilon;
  78910. private _colorWheelCanvas;
  78911. private _value;
  78912. private _tmpColor;
  78913. private _pointerStartedOnSquare;
  78914. private _pointerStartedOnWheel;
  78915. private _squareLeft;
  78916. private _squareTop;
  78917. private _squareSize;
  78918. private _h;
  78919. private _s;
  78920. private _v;
  78921. private _lastPointerDownID;
  78922. /**
  78923. * BABYLON.Observable raised when the value changes
  78924. */
  78925. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78926. /** Gets or sets the color of the color picker */
  78927. get value(): BABYLON.Color3;
  78928. set value(value: BABYLON.Color3);
  78929. /**
  78930. * Gets or sets control width
  78931. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78932. */
  78933. get width(): string | number;
  78934. set width(value: string | number);
  78935. /**
  78936. * Gets or sets control height
  78937. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78938. */
  78939. get height(): string | number;
  78940. /** Gets or sets control height */
  78941. set height(value: string | number);
  78942. /** Gets or sets control size */
  78943. get size(): string | number;
  78944. set size(value: string | number);
  78945. /**
  78946. * Creates a new ColorPicker
  78947. * @param name defines the control name
  78948. */
  78949. constructor(name?: string | undefined);
  78950. protected _getTypeName(): string;
  78951. /** @hidden */
  78952. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78953. private _updateSquareProps;
  78954. private _drawGradientSquare;
  78955. private _drawCircle;
  78956. private _createColorWheelCanvas;
  78957. /** @hidden */
  78958. _draw(context: CanvasRenderingContext2D): void;
  78959. private _pointerIsDown;
  78960. private _updateValueFromPointer;
  78961. private _isPointOnSquare;
  78962. private _isPointOnWheel;
  78963. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78964. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78965. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78966. _onCanvasBlur(): void;
  78967. /**
  78968. * This function expands the color picker by creating a color picker dialog with manual
  78969. * color value input and the ability to save colors into an array to be used later in
  78970. * subsequent launches of the dialogue.
  78971. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78972. * @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.
  78973. * @returns picked color as a hex string and the saved colors array as hex strings.
  78974. */
  78975. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78976. pickerWidth?: string;
  78977. pickerHeight?: string;
  78978. headerHeight?: string;
  78979. lastColor?: string;
  78980. swatchLimit?: number;
  78981. numSwatchesPerLine?: number;
  78982. savedColors?: Array<string>;
  78983. }): Promise<{
  78984. savedColors?: string[];
  78985. pickedColor: string;
  78986. }>;
  78987. }
  78988. }
  78989. declare module BABYLON.GUI {
  78990. /** Class used to create 2D ellipse containers */
  78991. export class Ellipse extends Container {
  78992. name?: string | undefined;
  78993. private _thickness;
  78994. /** Gets or sets border thickness */
  78995. get thickness(): number;
  78996. set thickness(value: number);
  78997. /**
  78998. * Creates a new Ellipse
  78999. * @param name defines the control name
  79000. */
  79001. constructor(name?: string | undefined);
  79002. protected _getTypeName(): string;
  79003. protected _localDraw(context: CanvasRenderingContext2D): void;
  79004. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79005. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79006. }
  79007. }
  79008. declare module BABYLON.GUI {
  79009. /**
  79010. * Class used to create a password control
  79011. */
  79012. export class InputPassword extends InputText {
  79013. protected _beforeRenderText(text: string): string;
  79014. }
  79015. }
  79016. declare module BABYLON.GUI {
  79017. /** Class used to render 2D lines */
  79018. export class Line extends Control {
  79019. name?: string | undefined;
  79020. private _lineWidth;
  79021. private _x1;
  79022. private _y1;
  79023. private _x2;
  79024. private _y2;
  79025. private _dash;
  79026. private _connectedControl;
  79027. private _connectedControlDirtyObserver;
  79028. /** Gets or sets the dash pattern */
  79029. get dash(): Array<number>;
  79030. set dash(value: Array<number>);
  79031. /** Gets or sets the control connected with the line end */
  79032. get connectedControl(): Control;
  79033. set connectedControl(value: Control);
  79034. /** Gets or sets start coordinates on X axis */
  79035. get x1(): string | number;
  79036. set x1(value: string | number);
  79037. /** Gets or sets start coordinates on Y axis */
  79038. get y1(): string | number;
  79039. set y1(value: string | number);
  79040. /** Gets or sets end coordinates on X axis */
  79041. get x2(): string | number;
  79042. set x2(value: string | number);
  79043. /** Gets or sets end coordinates on Y axis */
  79044. get y2(): string | number;
  79045. set y2(value: string | number);
  79046. /** Gets or sets line width */
  79047. get lineWidth(): number;
  79048. set lineWidth(value: number);
  79049. /** Gets or sets horizontal alignment */
  79050. set horizontalAlignment(value: number);
  79051. /** Gets or sets vertical alignment */
  79052. set verticalAlignment(value: number);
  79053. private get _effectiveX2();
  79054. private get _effectiveY2();
  79055. /**
  79056. * Creates a new Line
  79057. * @param name defines the control name
  79058. */
  79059. constructor(name?: string | undefined);
  79060. protected _getTypeName(): string;
  79061. _draw(context: CanvasRenderingContext2D): void;
  79062. _measure(): void;
  79063. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79064. /**
  79065. * Move one end of the line given 3D cartesian coordinates.
  79066. * @param position Targeted world position
  79067. * @param scene BABYLON.Scene
  79068. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79069. */
  79070. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79071. /**
  79072. * Move one end of the line to a position in screen absolute space.
  79073. * @param projectedPosition Position in screen absolute space (X, Y)
  79074. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79075. */
  79076. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79077. }
  79078. }
  79079. declare module BABYLON.GUI {
  79080. /**
  79081. * Class used to store a point for a MultiLine object.
  79082. * The point can be pure 2D coordinates, a mesh or a control
  79083. */
  79084. export class MultiLinePoint {
  79085. private _multiLine;
  79086. private _x;
  79087. private _y;
  79088. private _control;
  79089. private _mesh;
  79090. private _controlObserver;
  79091. private _meshObserver;
  79092. /** @hidden */
  79093. _point: BABYLON.Vector2;
  79094. /**
  79095. * Creates a new MultiLinePoint
  79096. * @param multiLine defines the source MultiLine object
  79097. */
  79098. constructor(multiLine: MultiLine);
  79099. /** Gets or sets x coordinate */
  79100. get x(): string | number;
  79101. set x(value: string | number);
  79102. /** Gets or sets y coordinate */
  79103. get y(): string | number;
  79104. set y(value: string | number);
  79105. /** Gets or sets the control associated with this point */
  79106. get control(): BABYLON.Nullable<Control>;
  79107. set control(value: BABYLON.Nullable<Control>);
  79108. /** Gets or sets the mesh associated with this point */
  79109. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79110. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79111. /** Resets links */
  79112. resetLinks(): void;
  79113. /**
  79114. * Gets a translation vector
  79115. * @returns the translation vector
  79116. */
  79117. translate(): BABYLON.Vector2;
  79118. private _translatePoint;
  79119. /** Release associated resources */
  79120. dispose(): void;
  79121. }
  79122. }
  79123. declare module BABYLON.GUI {
  79124. /**
  79125. * Class used to create multi line control
  79126. */
  79127. export class MultiLine extends Control {
  79128. name?: string | undefined;
  79129. private _lineWidth;
  79130. private _dash;
  79131. private _points;
  79132. private _minX;
  79133. private _minY;
  79134. private _maxX;
  79135. private _maxY;
  79136. /**
  79137. * Creates a new MultiLine
  79138. * @param name defines the control name
  79139. */
  79140. constructor(name?: string | undefined);
  79141. /** Gets or sets dash pattern */
  79142. get dash(): Array<number>;
  79143. set dash(value: Array<number>);
  79144. /**
  79145. * Gets point stored at specified index
  79146. * @param index defines the index to look for
  79147. * @returns the requested point if found
  79148. */
  79149. getAt(index: number): MultiLinePoint;
  79150. /** Function called when a point is updated */
  79151. onPointUpdate: () => void;
  79152. /**
  79153. * Adds new points to the point collection
  79154. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79155. * @returns the list of created MultiLinePoint
  79156. */
  79157. add(...items: (AbstractMesh | Control | {
  79158. x: string | number;
  79159. y: string | number;
  79160. })[]): MultiLinePoint[];
  79161. /**
  79162. * Adds a new point to the point collection
  79163. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79164. * @returns the created MultiLinePoint
  79165. */
  79166. push(item?: (AbstractMesh | Control | {
  79167. x: string | number;
  79168. y: string | number;
  79169. })): MultiLinePoint;
  79170. /**
  79171. * Remove a specific value or point from the active point collection
  79172. * @param value defines the value or point to remove
  79173. */
  79174. remove(value: number | MultiLinePoint): void;
  79175. /**
  79176. * Resets this object to initial state (no point)
  79177. */
  79178. reset(): void;
  79179. /**
  79180. * Resets all links
  79181. */
  79182. resetLinks(): void;
  79183. /** Gets or sets line width */
  79184. get lineWidth(): number;
  79185. set lineWidth(value: number);
  79186. set horizontalAlignment(value: number);
  79187. set verticalAlignment(value: number);
  79188. protected _getTypeName(): string;
  79189. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79191. _measure(): void;
  79192. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79193. dispose(): void;
  79194. }
  79195. }
  79196. declare module BABYLON.GUI {
  79197. /**
  79198. * Class used to create radio button controls
  79199. */
  79200. export class RadioButton extends Control {
  79201. name?: string | undefined;
  79202. private _isChecked;
  79203. private _background;
  79204. private _checkSizeRatio;
  79205. private _thickness;
  79206. /** Gets or sets border thickness */
  79207. get thickness(): number;
  79208. set thickness(value: number);
  79209. /** Gets or sets group name */
  79210. group: string;
  79211. /** BABYLON.Observable raised when isChecked is changed */
  79212. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79213. /** Gets or sets a value indicating the ratio between overall size and check size */
  79214. get checkSizeRatio(): number;
  79215. set checkSizeRatio(value: number);
  79216. /** Gets or sets background color */
  79217. get background(): string;
  79218. set background(value: string);
  79219. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79220. get isChecked(): boolean;
  79221. set isChecked(value: boolean);
  79222. /**
  79223. * Creates a new RadioButton
  79224. * @param name defines the control name
  79225. */
  79226. constructor(name?: string | undefined);
  79227. protected _getTypeName(): string;
  79228. _draw(context: CanvasRenderingContext2D): void;
  79229. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79230. /**
  79231. * Utility function to easily create a radio button with a header
  79232. * @param title defines the label to use for the header
  79233. * @param group defines the group to use for the radio button
  79234. * @param isChecked defines the initial state of the radio button
  79235. * @param onValueChanged defines the callback to call when value changes
  79236. * @returns a StackPanel containing the radio button and a textBlock
  79237. */
  79238. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79239. }
  79240. }
  79241. declare module BABYLON.GUI {
  79242. /**
  79243. * Class used to create slider controls
  79244. */
  79245. export class BaseSlider extends Control {
  79246. name?: string | undefined;
  79247. protected _thumbWidth: ValueAndUnit;
  79248. private _minimum;
  79249. private _maximum;
  79250. private _value;
  79251. private _isVertical;
  79252. protected _barOffset: ValueAndUnit;
  79253. private _isThumbClamped;
  79254. protected _displayThumb: boolean;
  79255. private _step;
  79256. private _lastPointerDownID;
  79257. protected _effectiveBarOffset: number;
  79258. protected _renderLeft: number;
  79259. protected _renderTop: number;
  79260. protected _renderWidth: number;
  79261. protected _renderHeight: number;
  79262. protected _backgroundBoxLength: number;
  79263. protected _backgroundBoxThickness: number;
  79264. protected _effectiveThumbThickness: number;
  79265. /** BABYLON.Observable raised when the sldier value changes */
  79266. onValueChangedObservable: BABYLON.Observable<number>;
  79267. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79268. get displayThumb(): boolean;
  79269. set displayThumb(value: boolean);
  79270. /** Gets or sets a step to apply to values (0 by default) */
  79271. get step(): number;
  79272. set step(value: number);
  79273. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79274. get barOffset(): string | number;
  79275. /** Gets main bar offset in pixels*/
  79276. get barOffsetInPixels(): number;
  79277. set barOffset(value: string | number);
  79278. /** Gets or sets thumb width */
  79279. get thumbWidth(): string | number;
  79280. /** Gets thumb width in pixels */
  79281. get thumbWidthInPixels(): number;
  79282. set thumbWidth(value: string | number);
  79283. /** Gets or sets minimum value */
  79284. get minimum(): number;
  79285. set minimum(value: number);
  79286. /** Gets or sets maximum value */
  79287. get maximum(): number;
  79288. set maximum(value: number);
  79289. /** Gets or sets current value */
  79290. get value(): number;
  79291. set value(value: number);
  79292. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79293. get isVertical(): boolean;
  79294. set isVertical(value: boolean);
  79295. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79296. get isThumbClamped(): boolean;
  79297. set isThumbClamped(value: boolean);
  79298. /**
  79299. * Creates a new BaseSlider
  79300. * @param name defines the control name
  79301. */
  79302. constructor(name?: string | undefined);
  79303. protected _getTypeName(): string;
  79304. protected _getThumbPosition(): number;
  79305. protected _getThumbThickness(type: string): number;
  79306. protected _prepareRenderingData(type: string): void;
  79307. private _pointerIsDown;
  79308. /** @hidden */
  79309. protected _updateValueFromPointer(x: number, y: number): void;
  79310. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79311. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79312. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79313. _onCanvasBlur(): void;
  79314. }
  79315. }
  79316. declare module BABYLON.GUI {
  79317. /**
  79318. * Class used to create slider controls
  79319. */
  79320. export class Slider extends BaseSlider {
  79321. name?: string | undefined;
  79322. private _background;
  79323. private _borderColor;
  79324. private _thumbColor;
  79325. private _isThumbCircle;
  79326. protected _displayValueBar: boolean;
  79327. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79328. get displayValueBar(): boolean;
  79329. set displayValueBar(value: boolean);
  79330. /** Gets or sets border color */
  79331. get borderColor(): string;
  79332. set borderColor(value: string);
  79333. /** Gets or sets background color */
  79334. get background(): string;
  79335. set background(value: string);
  79336. /** Gets or sets thumb's color */
  79337. get thumbColor(): string;
  79338. set thumbColor(value: string);
  79339. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79340. get isThumbCircle(): boolean;
  79341. set isThumbCircle(value: boolean);
  79342. /**
  79343. * Creates a new Slider
  79344. * @param name defines the control name
  79345. */
  79346. constructor(name?: string | undefined);
  79347. protected _getTypeName(): string;
  79348. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79349. }
  79350. }
  79351. declare module BABYLON.GUI {
  79352. /** Class used to create a RadioGroup
  79353. * which contains groups of radio buttons
  79354. */
  79355. export class SelectorGroup {
  79356. /** name of SelectorGroup */
  79357. name: string;
  79358. private _groupPanel;
  79359. private _selectors;
  79360. private _groupHeader;
  79361. /**
  79362. * Creates a new SelectorGroup
  79363. * @param name of group, used as a group heading
  79364. */
  79365. constructor(
  79366. /** name of SelectorGroup */
  79367. name: string);
  79368. /** Gets the groupPanel of the SelectorGroup */
  79369. get groupPanel(): StackPanel;
  79370. /** Gets the selectors array */
  79371. get selectors(): StackPanel[];
  79372. /** Gets and sets the group header */
  79373. get header(): string;
  79374. set header(label: string);
  79375. /** @hidden */
  79376. private _addGroupHeader;
  79377. /** @hidden*/
  79378. _getSelector(selectorNb: number): StackPanel | undefined;
  79379. /** Removes the selector at the given position
  79380. * @param selectorNb the position of the selector within the group
  79381. */
  79382. removeSelector(selectorNb: number): void;
  79383. }
  79384. /** Class used to create a CheckboxGroup
  79385. * which contains groups of checkbox buttons
  79386. */
  79387. export class CheckboxGroup extends SelectorGroup {
  79388. /** Adds a checkbox as a control
  79389. * @param text is the label for the selector
  79390. * @param func is the function called when the Selector is checked
  79391. * @param checked is true when Selector is checked
  79392. */
  79393. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79394. /** @hidden */
  79395. _setSelectorLabel(selectorNb: number, label: string): void;
  79396. /** @hidden */
  79397. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79398. /** @hidden */
  79399. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79400. /** @hidden */
  79401. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79402. }
  79403. /** Class used to create a RadioGroup
  79404. * which contains groups of radio buttons
  79405. */
  79406. export class RadioGroup extends SelectorGroup {
  79407. private _selectNb;
  79408. /** Adds a radio button as a control
  79409. * @param label is the label for the selector
  79410. * @param func is the function called when the Selector is checked
  79411. * @param checked is true when Selector is checked
  79412. */
  79413. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79414. /** @hidden */
  79415. _setSelectorLabel(selectorNb: number, label: string): void;
  79416. /** @hidden */
  79417. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79418. /** @hidden */
  79419. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79420. /** @hidden */
  79421. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79422. }
  79423. /** Class used to create a SliderGroup
  79424. * which contains groups of slider buttons
  79425. */
  79426. export class SliderGroup extends SelectorGroup {
  79427. /**
  79428. * Adds a slider to the SelectorGroup
  79429. * @param label is the label for the SliderBar
  79430. * @param func is the function called when the Slider moves
  79431. * @param unit is a string describing the units used, eg degrees or metres
  79432. * @param min is the minimum value for the Slider
  79433. * @param max is the maximum value for the Slider
  79434. * @param value is the start value for the Slider between min and max
  79435. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79436. */
  79437. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79438. /** @hidden */
  79439. _setSelectorLabel(selectorNb: number, label: string): void;
  79440. /** @hidden */
  79441. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79442. /** @hidden */
  79443. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79444. /** @hidden */
  79445. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79446. }
  79447. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79448. * @see https://doc.babylonjs.com/how_to/selector
  79449. */
  79450. export class SelectionPanel extends Rectangle {
  79451. /** name of SelectionPanel */
  79452. name: string;
  79453. /** an array of SelectionGroups */
  79454. groups: SelectorGroup[];
  79455. private _panel;
  79456. private _buttonColor;
  79457. private _buttonBackground;
  79458. private _headerColor;
  79459. private _barColor;
  79460. private _barHeight;
  79461. private _spacerHeight;
  79462. private _labelColor;
  79463. private _groups;
  79464. private _bars;
  79465. /**
  79466. * Creates a new SelectionPanel
  79467. * @param name of SelectionPanel
  79468. * @param groups is an array of SelectionGroups
  79469. */
  79470. constructor(
  79471. /** name of SelectionPanel */
  79472. name: string,
  79473. /** an array of SelectionGroups */
  79474. groups?: SelectorGroup[]);
  79475. protected _getTypeName(): string;
  79476. /** Gets or sets the headerColor */
  79477. get headerColor(): string;
  79478. set headerColor(color: string);
  79479. private _setHeaderColor;
  79480. /** Gets or sets the button color */
  79481. get buttonColor(): string;
  79482. set buttonColor(color: string);
  79483. private _setbuttonColor;
  79484. /** Gets or sets the label color */
  79485. get labelColor(): string;
  79486. set labelColor(color: string);
  79487. private _setLabelColor;
  79488. /** Gets or sets the button background */
  79489. get buttonBackground(): string;
  79490. set buttonBackground(color: string);
  79491. private _setButtonBackground;
  79492. /** Gets or sets the color of separator bar */
  79493. get barColor(): string;
  79494. set barColor(color: string);
  79495. private _setBarColor;
  79496. /** Gets or sets the height of separator bar */
  79497. get barHeight(): string;
  79498. set barHeight(value: string);
  79499. private _setBarHeight;
  79500. /** Gets or sets the height of spacers*/
  79501. get spacerHeight(): string;
  79502. set spacerHeight(value: string);
  79503. private _setSpacerHeight;
  79504. /** Adds a bar between groups */
  79505. private _addSpacer;
  79506. /** Add a group to the selection panel
  79507. * @param group is the selector group to add
  79508. */
  79509. addGroup(group: SelectorGroup): void;
  79510. /** Remove the group from the given position
  79511. * @param groupNb is the position of the group in the list
  79512. */
  79513. removeGroup(groupNb: number): void;
  79514. /** Change a group header label
  79515. * @param label is the new group header label
  79516. * @param groupNb is the number of the group to relabel
  79517. * */
  79518. setHeaderName(label: string, groupNb: number): void;
  79519. /** Change selector label to the one given
  79520. * @param label is the new selector label
  79521. * @param groupNb is the number of the groupcontaining the selector
  79522. * @param selectorNb is the number of the selector within a group to relabel
  79523. * */
  79524. relabel(label: string, groupNb: number, selectorNb: number): void;
  79525. /** For a given group position remove the selector at the given position
  79526. * @param groupNb is the number of the group to remove the selector from
  79527. * @param selectorNb is the number of the selector within the group
  79528. */
  79529. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79530. /** For a given group position of correct type add a checkbox button
  79531. * @param groupNb is the number of the group to remove the selector from
  79532. * @param label is the label for the selector
  79533. * @param func is the function called when the Selector is checked
  79534. * @param checked is true when Selector is checked
  79535. */
  79536. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79537. /** For a given group position of correct type add a radio button
  79538. * @param groupNb is the number of the group to remove the selector from
  79539. * @param label is the label for the selector
  79540. * @param func is the function called when the Selector is checked
  79541. * @param checked is true when Selector is checked
  79542. */
  79543. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79544. /**
  79545. * For a given slider group add a slider
  79546. * @param groupNb is the number of the group to add the slider to
  79547. * @param label is the label for the Slider
  79548. * @param func is the function called when the Slider moves
  79549. * @param unit is a string describing the units used, eg degrees or metres
  79550. * @param min is the minimum value for the Slider
  79551. * @param max is the maximum value for the Slider
  79552. * @param value is the start value for the Slider between min and max
  79553. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79554. */
  79555. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79556. }
  79557. }
  79558. declare module BABYLON.GUI {
  79559. /**
  79560. * Class used to hold a the container for ScrollViewer
  79561. * @hidden
  79562. */
  79563. export class _ScrollViewerWindow extends Container {
  79564. parentClientWidth: number;
  79565. parentClientHeight: number;
  79566. private _freezeControls;
  79567. private _parentMeasure;
  79568. private _oldLeft;
  79569. private _oldTop;
  79570. get freezeControls(): boolean;
  79571. set freezeControls(value: boolean);
  79572. private _bucketWidth;
  79573. private _bucketHeight;
  79574. private _buckets;
  79575. private _bucketLen;
  79576. get bucketWidth(): number;
  79577. get bucketHeight(): number;
  79578. setBucketSizes(width: number, height: number): void;
  79579. private _useBuckets;
  79580. private _makeBuckets;
  79581. private _dispatchInBuckets;
  79582. private _updateMeasures;
  79583. private _updateChildrenMeasures;
  79584. private _restoreMeasures;
  79585. /**
  79586. * Creates a new ScrollViewerWindow
  79587. * @param name of ScrollViewerWindow
  79588. */
  79589. constructor(name?: string);
  79590. protected _getTypeName(): string;
  79591. /** @hidden */
  79592. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79593. /** @hidden */
  79594. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79595. private _scrollChildren;
  79596. private _scrollChildrenWithBuckets;
  79597. /** @hidden */
  79598. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79599. protected _postMeasure(): void;
  79600. }
  79601. }
  79602. declare module BABYLON.GUI {
  79603. /**
  79604. * Class used to create slider controls
  79605. */
  79606. export class ScrollBar extends BaseSlider {
  79607. name?: string | undefined;
  79608. private _background;
  79609. private _borderColor;
  79610. private _tempMeasure;
  79611. /** Gets or sets border color */
  79612. get borderColor(): string;
  79613. set borderColor(value: string);
  79614. /** Gets or sets background color */
  79615. get background(): string;
  79616. set background(value: string);
  79617. /**
  79618. * Creates a new Slider
  79619. * @param name defines the control name
  79620. */
  79621. constructor(name?: string | undefined);
  79622. protected _getTypeName(): string;
  79623. protected _getThumbThickness(): number;
  79624. _draw(context: CanvasRenderingContext2D): void;
  79625. private _first;
  79626. private _originX;
  79627. private _originY;
  79628. /** @hidden */
  79629. protected _updateValueFromPointer(x: number, y: number): void;
  79630. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79631. }
  79632. }
  79633. declare module BABYLON.GUI {
  79634. /**
  79635. * Class used to create slider controls
  79636. */
  79637. export class ImageScrollBar extends BaseSlider {
  79638. name?: string | undefined;
  79639. private _backgroundBaseImage;
  79640. private _backgroundImage;
  79641. private _thumbImage;
  79642. private _thumbBaseImage;
  79643. private _thumbLength;
  79644. private _thumbHeight;
  79645. private _barImageHeight;
  79646. private _tempMeasure;
  79647. /** Number of 90° rotation to apply on the images when in vertical mode */
  79648. num90RotationInVerticalMode: number;
  79649. /**
  79650. * Gets or sets the image used to render the background for horizontal bar
  79651. */
  79652. get backgroundImage(): Image;
  79653. set backgroundImage(value: Image);
  79654. /**
  79655. * Gets or sets the image used to render the thumb
  79656. */
  79657. get thumbImage(): Image;
  79658. set thumbImage(value: Image);
  79659. /**
  79660. * Gets or sets the length of the thumb
  79661. */
  79662. get thumbLength(): number;
  79663. set thumbLength(value: number);
  79664. /**
  79665. * Gets or sets the height of the thumb
  79666. */
  79667. get thumbHeight(): number;
  79668. set thumbHeight(value: number);
  79669. /**
  79670. * Gets or sets the height of the bar image
  79671. */
  79672. get barImageHeight(): number;
  79673. set barImageHeight(value: number);
  79674. /**
  79675. * Creates a new ImageScrollBar
  79676. * @param name defines the control name
  79677. */
  79678. constructor(name?: string | undefined);
  79679. protected _getTypeName(): string;
  79680. protected _getThumbThickness(): number;
  79681. _draw(context: CanvasRenderingContext2D): void;
  79682. private _first;
  79683. private _originX;
  79684. private _originY;
  79685. /** @hidden */
  79686. protected _updateValueFromPointer(x: number, y: number): void;
  79687. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79688. }
  79689. }
  79690. declare module BABYLON.GUI {
  79691. /**
  79692. * Class used to hold a viewer window and sliders in a grid
  79693. */
  79694. export class ScrollViewer extends Rectangle {
  79695. private _grid;
  79696. private _horizontalBarSpace;
  79697. private _verticalBarSpace;
  79698. private _dragSpace;
  79699. private _horizontalBar;
  79700. private _verticalBar;
  79701. private _barColor;
  79702. private _barBackground;
  79703. private _barImage;
  79704. private _horizontalBarImage;
  79705. private _verticalBarImage;
  79706. private _barBackgroundImage;
  79707. private _horizontalBarBackgroundImage;
  79708. private _verticalBarBackgroundImage;
  79709. private _barSize;
  79710. private _window;
  79711. private _pointerIsOver;
  79712. private _wheelPrecision;
  79713. private _onWheelObserver;
  79714. private _clientWidth;
  79715. private _clientHeight;
  79716. private _useImageBar;
  79717. private _thumbLength;
  79718. private _thumbHeight;
  79719. private _barImageHeight;
  79720. private _horizontalBarImageHeight;
  79721. private _verticalBarImageHeight;
  79722. private _oldWindowContentsWidth;
  79723. private _oldWindowContentsHeight;
  79724. /**
  79725. * Gets the horizontal scrollbar
  79726. */
  79727. get horizontalBar(): ScrollBar | ImageScrollBar;
  79728. /**
  79729. * Gets the vertical scrollbar
  79730. */
  79731. get verticalBar(): ScrollBar | ImageScrollBar;
  79732. /**
  79733. * Adds a new control to the current container
  79734. * @param control defines the control to add
  79735. * @returns the current container
  79736. */
  79737. addControl(control: BABYLON.Nullable<Control>): Container;
  79738. /**
  79739. * Removes a control from the current container
  79740. * @param control defines the control to remove
  79741. * @returns the current container
  79742. */
  79743. removeControl(control: Control): Container;
  79744. /** Gets the list of children */
  79745. get children(): Control[];
  79746. _flagDescendantsAsMatrixDirty(): void;
  79747. /**
  79748. * Freezes or unfreezes the controls in the window.
  79749. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79750. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79751. */
  79752. get freezeControls(): boolean;
  79753. set freezeControls(value: boolean);
  79754. /** Gets the bucket width */
  79755. get bucketWidth(): number;
  79756. /** Gets the bucket height */
  79757. get bucketHeight(): number;
  79758. /**
  79759. * Sets the bucket sizes.
  79760. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79761. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79762. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79763. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79764. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79765. * used), that's why it is not enabled by default.
  79766. * @param width width of the bucket
  79767. * @param height height of the bucket
  79768. */
  79769. setBucketSizes(width: number, height: number): void;
  79770. private _forceHorizontalBar;
  79771. private _forceVerticalBar;
  79772. /**
  79773. * Forces the horizontal scroll bar to be displayed
  79774. */
  79775. get forceHorizontalBar(): boolean;
  79776. set forceHorizontalBar(value: boolean);
  79777. /**
  79778. * Forces the vertical scroll bar to be displayed
  79779. */
  79780. get forceVerticalBar(): boolean;
  79781. set forceVerticalBar(value: boolean);
  79782. /**
  79783. * Creates a new ScrollViewer
  79784. * @param name of ScrollViewer
  79785. */
  79786. constructor(name?: string, isImageBased?: boolean);
  79787. /** Reset the scroll viewer window to initial size */
  79788. resetWindow(): void;
  79789. protected _getTypeName(): string;
  79790. private _buildClientSizes;
  79791. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79792. protected _postMeasure(): void;
  79793. /**
  79794. * Gets or sets the mouse wheel precision
  79795. * from 0 to 1 with a default value of 0.05
  79796. * */
  79797. get wheelPrecision(): number;
  79798. set wheelPrecision(value: number);
  79799. /** Gets or sets the scroll bar container background color */
  79800. get scrollBackground(): string;
  79801. set scrollBackground(color: string);
  79802. /** Gets or sets the bar color */
  79803. get barColor(): string;
  79804. set barColor(color: string);
  79805. /** Gets or sets the bar image */
  79806. get thumbImage(): Image;
  79807. set thumbImage(value: Image);
  79808. /** Gets or sets the horizontal bar image */
  79809. get horizontalThumbImage(): Image;
  79810. set horizontalThumbImage(value: Image);
  79811. /** Gets or sets the vertical bar image */
  79812. get verticalThumbImage(): Image;
  79813. set verticalThumbImage(value: Image);
  79814. /** Gets or sets the size of the bar */
  79815. get barSize(): number;
  79816. set barSize(value: number);
  79817. /** Gets or sets the length of the thumb */
  79818. get thumbLength(): number;
  79819. set thumbLength(value: number);
  79820. /** Gets or sets the height of the thumb */
  79821. get thumbHeight(): number;
  79822. set thumbHeight(value: number);
  79823. /** Gets or sets the height of the bar image */
  79824. get barImageHeight(): number;
  79825. set barImageHeight(value: number);
  79826. /** Gets or sets the height of the horizontal bar image */
  79827. get horizontalBarImageHeight(): number;
  79828. set horizontalBarImageHeight(value: number);
  79829. /** Gets or sets the height of the vertical bar image */
  79830. get verticalBarImageHeight(): number;
  79831. set verticalBarImageHeight(value: number);
  79832. /** Gets or sets the bar background */
  79833. get barBackground(): string;
  79834. set barBackground(color: string);
  79835. /** Gets or sets the bar background image */
  79836. get barImage(): Image;
  79837. set barImage(value: Image);
  79838. /** Gets or sets the horizontal bar background image */
  79839. get horizontalBarImage(): Image;
  79840. set horizontalBarImage(value: Image);
  79841. /** Gets or sets the vertical bar background image */
  79842. get verticalBarImage(): Image;
  79843. set verticalBarImage(value: Image);
  79844. private _setWindowPosition;
  79845. /** @hidden */
  79846. private _updateScroller;
  79847. _link(host: AdvancedDynamicTexture): void;
  79848. /** @hidden */
  79849. private _addBar;
  79850. /** @hidden */
  79851. private _attachWheel;
  79852. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79853. /** Releases associated resources */
  79854. dispose(): void;
  79855. }
  79856. }
  79857. declare module BABYLON.GUI {
  79858. /** Class used to render a grid */
  79859. export class DisplayGrid extends Control {
  79860. name?: string | undefined;
  79861. private _cellWidth;
  79862. private _cellHeight;
  79863. private _minorLineTickness;
  79864. private _minorLineColor;
  79865. private _majorLineTickness;
  79866. private _majorLineColor;
  79867. private _majorLineFrequency;
  79868. private _background;
  79869. private _displayMajorLines;
  79870. private _displayMinorLines;
  79871. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79872. get displayMinorLines(): boolean;
  79873. set displayMinorLines(value: boolean);
  79874. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79875. get displayMajorLines(): boolean;
  79876. set displayMajorLines(value: boolean);
  79877. /** Gets or sets background color (Black by default) */
  79878. get background(): string;
  79879. set background(value: string);
  79880. /** Gets or sets the width of each cell (20 by default) */
  79881. get cellWidth(): number;
  79882. set cellWidth(value: number);
  79883. /** Gets or sets the height of each cell (20 by default) */
  79884. get cellHeight(): number;
  79885. set cellHeight(value: number);
  79886. /** Gets or sets the tickness of minor lines (1 by default) */
  79887. get minorLineTickness(): number;
  79888. set minorLineTickness(value: number);
  79889. /** Gets or sets the color of minor lines (DarkGray by default) */
  79890. get minorLineColor(): string;
  79891. set minorLineColor(value: string);
  79892. /** Gets or sets the tickness of major lines (2 by default) */
  79893. get majorLineTickness(): number;
  79894. set majorLineTickness(value: number);
  79895. /** Gets or sets the color of major lines (White by default) */
  79896. get majorLineColor(): string;
  79897. set majorLineColor(value: string);
  79898. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79899. get majorLineFrequency(): number;
  79900. set majorLineFrequency(value: number);
  79901. /**
  79902. * Creates a new GridDisplayRectangle
  79903. * @param name defines the control name
  79904. */
  79905. constructor(name?: string | undefined);
  79906. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79907. protected _getTypeName(): string;
  79908. }
  79909. }
  79910. declare module BABYLON.GUI {
  79911. /**
  79912. * Class used to create slider controls based on images
  79913. */
  79914. export class ImageBasedSlider extends BaseSlider {
  79915. name?: string | undefined;
  79916. private _backgroundImage;
  79917. private _thumbImage;
  79918. private _valueBarImage;
  79919. private _tempMeasure;
  79920. get displayThumb(): boolean;
  79921. set displayThumb(value: boolean);
  79922. /**
  79923. * Gets or sets the image used to render the background
  79924. */
  79925. get backgroundImage(): Image;
  79926. set backgroundImage(value: Image);
  79927. /**
  79928. * Gets or sets the image used to render the value bar
  79929. */
  79930. get valueBarImage(): Image;
  79931. set valueBarImage(value: Image);
  79932. /**
  79933. * Gets or sets the image used to render the thumb
  79934. */
  79935. get thumbImage(): Image;
  79936. set thumbImage(value: Image);
  79937. /**
  79938. * Creates a new ImageBasedSlider
  79939. * @param name defines the control name
  79940. */
  79941. constructor(name?: string | undefined);
  79942. protected _getTypeName(): string;
  79943. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79944. }
  79945. }
  79946. declare module BABYLON.GUI {
  79947. /**
  79948. * Forcing an export so that this code will execute
  79949. * @hidden
  79950. */
  79951. const name = "Statics";
  79952. }
  79953. declare module BABYLON.GUI {
  79954. /**
  79955. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79956. */
  79957. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79958. /**
  79959. * Define the instrumented AdvancedDynamicTexture.
  79960. */
  79961. texture: AdvancedDynamicTexture;
  79962. private _captureRenderTime;
  79963. private _renderTime;
  79964. private _captureLayoutTime;
  79965. private _layoutTime;
  79966. private _onBeginRenderObserver;
  79967. private _onEndRenderObserver;
  79968. private _onBeginLayoutObserver;
  79969. private _onEndLayoutObserver;
  79970. /**
  79971. * Gets the perf counter used to capture render time
  79972. */
  79973. get renderTimeCounter(): BABYLON.PerfCounter;
  79974. /**
  79975. * Gets the perf counter used to capture layout time
  79976. */
  79977. get layoutTimeCounter(): BABYLON.PerfCounter;
  79978. /**
  79979. * Enable or disable the render time capture
  79980. */
  79981. get captureRenderTime(): boolean;
  79982. set captureRenderTime(value: boolean);
  79983. /**
  79984. * Enable or disable the layout time capture
  79985. */
  79986. get captureLayoutTime(): boolean;
  79987. set captureLayoutTime(value: boolean);
  79988. /**
  79989. * Instantiates a new advanced dynamic texture instrumentation.
  79990. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79991. * @param texture Defines the AdvancedDynamicTexture to instrument
  79992. */
  79993. constructor(
  79994. /**
  79995. * Define the instrumented AdvancedDynamicTexture.
  79996. */
  79997. texture: AdvancedDynamicTexture);
  79998. /**
  79999. * Dispose and release associated resources.
  80000. */
  80001. dispose(): void;
  80002. }
  80003. }
  80004. declare module BABYLON.GUI {
  80005. /**
  80006. * Class used to load GUI via XML.
  80007. */
  80008. export class XmlLoader {
  80009. private _nodes;
  80010. private _nodeTypes;
  80011. private _isLoaded;
  80012. private _objectAttributes;
  80013. private _parentClass;
  80014. /**
  80015. * Create a new xml loader
  80016. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80017. */
  80018. constructor(parentClass?: null);
  80019. private _getChainElement;
  80020. private _getClassAttribute;
  80021. private _createGuiElement;
  80022. private _parseGrid;
  80023. private _parseElement;
  80024. private _prepareSourceElement;
  80025. private _parseElementsFromSource;
  80026. private _parseXml;
  80027. /**
  80028. * Gets if the loading has finished.
  80029. * @returns whether the loading has finished or not
  80030. */
  80031. isLoaded(): boolean;
  80032. /**
  80033. * Gets a loaded node / control by id.
  80034. * @param id the Controls id set in the xml
  80035. * @returns element of type Control
  80036. */
  80037. getNodeById(id: string): any;
  80038. /**
  80039. * Gets all loaded nodes / controls
  80040. * @returns Array of controls
  80041. */
  80042. getNodes(): any;
  80043. /**
  80044. * Initiates the xml layout loading
  80045. * @param xmlFile defines the xml layout to load
  80046. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80047. * @param callback defines the callback called on layout load.
  80048. */
  80049. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80050. }
  80051. }
  80052. declare module BABYLON.GUI {
  80053. /**
  80054. * Class used to create containers for controls
  80055. */
  80056. export class Container3D extends Control3D {
  80057. private _blockLayout;
  80058. /**
  80059. * Gets the list of child controls
  80060. */
  80061. protected _children: Control3D[];
  80062. /**
  80063. * Gets the list of child controls
  80064. */
  80065. get children(): Array<Control3D>;
  80066. /**
  80067. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80068. * This is helpful to optimize layout operation when adding multiple children in a row
  80069. */
  80070. get blockLayout(): boolean;
  80071. set blockLayout(value: boolean);
  80072. /**
  80073. * Creates a new container
  80074. * @param name defines the container name
  80075. */
  80076. constructor(name?: string);
  80077. /**
  80078. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80079. * @returns the current container
  80080. */
  80081. updateLayout(): Container3D;
  80082. /**
  80083. * Gets a boolean indicating if the given control is in the children of this control
  80084. * @param control defines the control to check
  80085. * @returns true if the control is in the child list
  80086. */
  80087. containsControl(control: Control3D): boolean;
  80088. /**
  80089. * Adds a control to the children of this control
  80090. * @param control defines the control to add
  80091. * @returns the current container
  80092. */
  80093. addControl(control: Control3D): Container3D;
  80094. /**
  80095. * This function will be called everytime a new control is added
  80096. */
  80097. protected _arrangeChildren(): void;
  80098. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80099. /**
  80100. * Removes a control from the children of this control
  80101. * @param control defines the control to remove
  80102. * @returns the current container
  80103. */
  80104. removeControl(control: Control3D): Container3D;
  80105. protected _getTypeName(): string;
  80106. /**
  80107. * Releases all associated resources
  80108. */
  80109. dispose(): void;
  80110. /** Control rotation will remain unchanged */
  80111. static readonly UNSET_ORIENTATION: number;
  80112. /** Control will rotate to make it look at sphere central axis */
  80113. static readonly FACEORIGIN_ORIENTATION: number;
  80114. /** Control will rotate to make it look back at sphere central axis */
  80115. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80116. /** Control will rotate to look at z axis (0, 0, 1) */
  80117. static readonly FACEFORWARD_ORIENTATION: number;
  80118. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80119. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80120. }
  80121. }
  80122. declare module BABYLON.GUI {
  80123. /**
  80124. * Class used to manage 3D user interface
  80125. * @see https://doc.babylonjs.com/how_to/gui3d
  80126. */
  80127. export class GUI3DManager implements BABYLON.IDisposable {
  80128. private _scene;
  80129. private _sceneDisposeObserver;
  80130. private _utilityLayer;
  80131. private _rootContainer;
  80132. private _pointerObserver;
  80133. private _pointerOutObserver;
  80134. /** @hidden */
  80135. _lastPickedControl: Control3D;
  80136. /** @hidden */
  80137. _lastControlOver: {
  80138. [pointerId: number]: Control3D;
  80139. };
  80140. /** @hidden */
  80141. _lastControlDown: {
  80142. [pointerId: number]: Control3D;
  80143. };
  80144. /**
  80145. * BABYLON.Observable raised when the point picked by the pointer events changed
  80146. */
  80147. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80148. /** @hidden */
  80149. _sharedMaterials: {
  80150. [key: string]: BABYLON.Material;
  80151. };
  80152. /** Gets the hosting scene */
  80153. get scene(): BABYLON.Scene;
  80154. /** Gets associated utility layer */
  80155. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80156. /**
  80157. * Creates a new GUI3DManager
  80158. * @param scene
  80159. */
  80160. constructor(scene?: BABYLON.Scene);
  80161. private _handlePointerOut;
  80162. private _doPicking;
  80163. /**
  80164. * Gets the root container
  80165. */
  80166. get rootContainer(): Container3D;
  80167. /**
  80168. * Gets a boolean indicating if the given control is in the root child list
  80169. * @param control defines the control to check
  80170. * @returns true if the control is in the root child list
  80171. */
  80172. containsControl(control: Control3D): boolean;
  80173. /**
  80174. * Adds a control to the root child list
  80175. * @param control defines the control to add
  80176. * @returns the current manager
  80177. */
  80178. addControl(control: Control3D): GUI3DManager;
  80179. /**
  80180. * Removes a control from the root child list
  80181. * @param control defines the control to remove
  80182. * @returns the current container
  80183. */
  80184. removeControl(control: Control3D): GUI3DManager;
  80185. /**
  80186. * Releases all associated resources
  80187. */
  80188. dispose(): void;
  80189. }
  80190. }
  80191. declare module BABYLON.GUI {
  80192. /**
  80193. * Class used to transport BABYLON.Vector3 information for pointer events
  80194. */
  80195. export class Vector3WithInfo extends BABYLON.Vector3 {
  80196. /** defines the current mouse button index */
  80197. buttonIndex: number;
  80198. /**
  80199. * Creates a new Vector3WithInfo
  80200. * @param source defines the vector3 data to transport
  80201. * @param buttonIndex defines the current mouse button index
  80202. */
  80203. constructor(source: BABYLON.Vector3,
  80204. /** defines the current mouse button index */
  80205. buttonIndex?: number);
  80206. }
  80207. }
  80208. declare module BABYLON.GUI {
  80209. /**
  80210. * Class used as base class for controls
  80211. */
  80212. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80213. /** Defines the control name */
  80214. name?: string | undefined;
  80215. /** @hidden */
  80216. _host: GUI3DManager;
  80217. private _node;
  80218. private _downCount;
  80219. private _enterCount;
  80220. private _downPointerIds;
  80221. private _isVisible;
  80222. /** Gets or sets the control position in world space */
  80223. get position(): BABYLON.Vector3;
  80224. set position(value: BABYLON.Vector3);
  80225. /** Gets or sets the control scaling in world space */
  80226. get scaling(): BABYLON.Vector3;
  80227. set scaling(value: BABYLON.Vector3);
  80228. /** Callback used to start pointer enter animation */
  80229. pointerEnterAnimation: () => void;
  80230. /** Callback used to start pointer out animation */
  80231. pointerOutAnimation: () => void;
  80232. /** Callback used to start pointer down animation */
  80233. pointerDownAnimation: () => void;
  80234. /** Callback used to start pointer up animation */
  80235. pointerUpAnimation: () => void;
  80236. /**
  80237. * An event triggered when the pointer move over the control
  80238. */
  80239. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80240. /**
  80241. * An event triggered when the pointer move out of the control
  80242. */
  80243. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80244. /**
  80245. * An event triggered when the pointer taps the control
  80246. */
  80247. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80248. /**
  80249. * An event triggered when pointer is up
  80250. */
  80251. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80252. /**
  80253. * An event triggered when a control is clicked on (with a mouse)
  80254. */
  80255. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80256. /**
  80257. * An event triggered when pointer enters the control
  80258. */
  80259. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80260. /**
  80261. * Gets or sets the parent container
  80262. */
  80263. parent: BABYLON.Nullable<Container3D>;
  80264. private _behaviors;
  80265. /**
  80266. * Gets the list of attached behaviors
  80267. * @see https://doc.babylonjs.com/features/behaviour
  80268. */
  80269. get behaviors(): BABYLON.Behavior<Control3D>[];
  80270. /**
  80271. * Attach a behavior to the control
  80272. * @see https://doc.babylonjs.com/features/behaviour
  80273. * @param behavior defines the behavior to attach
  80274. * @returns the current control
  80275. */
  80276. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80277. /**
  80278. * Remove an attached behavior
  80279. * @see https://doc.babylonjs.com/features/behaviour
  80280. * @param behavior defines the behavior to attach
  80281. * @returns the current control
  80282. */
  80283. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80284. /**
  80285. * Gets an attached behavior by name
  80286. * @param name defines the name of the behavior to look for
  80287. * @see https://doc.babylonjs.com/features/behaviour
  80288. * @returns null if behavior was not found else the requested behavior
  80289. */
  80290. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80291. /** Gets or sets a boolean indicating if the control is visible */
  80292. get isVisible(): boolean;
  80293. set isVisible(value: boolean);
  80294. /**
  80295. * Creates a new control
  80296. * @param name defines the control name
  80297. */
  80298. constructor(
  80299. /** Defines the control name */
  80300. name?: string | undefined);
  80301. /**
  80302. * Gets a string representing the class name
  80303. */
  80304. get typeName(): string;
  80305. /**
  80306. * Get the current class name of the control.
  80307. * @returns current class name
  80308. */
  80309. getClassName(): string;
  80310. protected _getTypeName(): string;
  80311. /**
  80312. * Gets the transform node used by this control
  80313. */
  80314. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80315. /**
  80316. * Gets the mesh used to render this control
  80317. */
  80318. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80319. /**
  80320. * Link the control as child of the given node
  80321. * @param node defines the node to link to. Use null to unlink the control
  80322. * @returns the current control
  80323. */
  80324. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80325. /** @hidden **/
  80326. _prepareNode(scene: BABYLON.Scene): void;
  80327. /**
  80328. * Node creation.
  80329. * Can be overriden by children
  80330. * @param scene defines the scene where the node must be attached
  80331. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80332. */
  80333. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80334. /**
  80335. * Affect a material to the given mesh
  80336. * @param mesh defines the mesh which will represent the control
  80337. */
  80338. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80339. /** @hidden */
  80340. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80341. /** @hidden */
  80342. _onPointerEnter(target: Control3D): boolean;
  80343. /** @hidden */
  80344. _onPointerOut(target: Control3D): void;
  80345. /** @hidden */
  80346. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80347. /** @hidden */
  80348. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80349. /** @hidden */
  80350. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80351. /** @hidden */
  80352. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80353. /** @hidden */
  80354. _disposeNode(): void;
  80355. /**
  80356. * Releases all associated resources
  80357. */
  80358. dispose(): void;
  80359. }
  80360. }
  80361. declare module BABYLON.GUI {
  80362. /**
  80363. * Class used as a root to all buttons
  80364. */
  80365. export class AbstractButton3D extends Control3D {
  80366. /**
  80367. * Creates a new button
  80368. * @param name defines the control name
  80369. */
  80370. constructor(name?: string);
  80371. protected _getTypeName(): string;
  80372. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80373. }
  80374. }
  80375. declare module BABYLON.GUI {
  80376. /**
  80377. * Class used to create a button in 3D
  80378. */
  80379. export class Button3D extends AbstractButton3D {
  80380. /** @hidden */
  80381. protected _currentMaterial: BABYLON.Material;
  80382. private _facadeTexture;
  80383. private _content;
  80384. private _contentResolution;
  80385. private _contentScaleRatio;
  80386. /**
  80387. * Gets or sets the texture resolution used to render content (512 by default)
  80388. */
  80389. get contentResolution(): BABYLON.int;
  80390. set contentResolution(value: BABYLON.int);
  80391. /**
  80392. * Gets or sets the texture scale ratio used to render content (2 by default)
  80393. */
  80394. get contentScaleRatio(): number;
  80395. set contentScaleRatio(value: number);
  80396. protected _disposeFacadeTexture(): void;
  80397. protected _resetContent(): void;
  80398. /**
  80399. * Creates a new button
  80400. * @param name defines the control name
  80401. */
  80402. constructor(name?: string);
  80403. /**
  80404. * Gets or sets the GUI 2D content used to display the button's facade
  80405. */
  80406. get content(): Control;
  80407. set content(value: Control);
  80408. /**
  80409. * Apply the facade texture (created from the content property).
  80410. * This function can be overloaded by child classes
  80411. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80412. */
  80413. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80414. protected _getTypeName(): string;
  80415. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80416. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80417. /**
  80418. * Releases all associated resources
  80419. */
  80420. dispose(): void;
  80421. }
  80422. }
  80423. declare module BABYLON.GUI {
  80424. /**
  80425. * Abstract class used to create a container panel deployed on the surface of a volume
  80426. */
  80427. export abstract class VolumeBasedPanel extends Container3D {
  80428. private _columns;
  80429. private _rows;
  80430. private _rowThenColum;
  80431. private _orientation;
  80432. protected _cellWidth: number;
  80433. protected _cellHeight: number;
  80434. /**
  80435. * Gets or sets the distance between elements
  80436. */
  80437. margin: number;
  80438. /**
  80439. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80440. * | Value | Type | Description |
  80441. * | ----- | ----------------------------------- | ----------- |
  80442. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80443. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80444. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80445. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80446. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80447. */
  80448. get orientation(): number;
  80449. set orientation(value: number);
  80450. /**
  80451. * Gets or sets the number of columns requested (10 by default).
  80452. * The panel will automatically compute the number of rows based on number of child controls.
  80453. */
  80454. get columns(): BABYLON.int;
  80455. set columns(value: BABYLON.int);
  80456. /**
  80457. * Gets or sets a the number of rows requested.
  80458. * The panel will automatically compute the number of columns based on number of child controls.
  80459. */
  80460. get rows(): BABYLON.int;
  80461. set rows(value: BABYLON.int);
  80462. /**
  80463. * Creates new VolumeBasedPanel
  80464. */
  80465. constructor();
  80466. protected _arrangeChildren(): void;
  80467. /** Child classes must implement this function to provide correct control positioning */
  80468. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80469. /** Child classes can implement this function to provide additional processing */
  80470. protected _finalProcessing(): void;
  80471. }
  80472. }
  80473. declare module BABYLON.GUI {
  80474. /**
  80475. * Class used to create a container panel deployed on the surface of a cylinder
  80476. */
  80477. export class CylinderPanel extends VolumeBasedPanel {
  80478. private _radius;
  80479. /**
  80480. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80481. */
  80482. get radius(): BABYLON.float;
  80483. set radius(value: BABYLON.float);
  80484. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80485. private _cylindricalMapping;
  80486. }
  80487. }
  80488. declare module BABYLON.GUI {
  80489. /** @hidden */
  80490. export var fluentVertexShader: {
  80491. name: string;
  80492. shader: string;
  80493. };
  80494. }
  80495. declare module BABYLON.GUI {
  80496. /** @hidden */
  80497. export var fluentPixelShader: {
  80498. name: string;
  80499. shader: string;
  80500. };
  80501. }
  80502. declare module BABYLON.GUI {
  80503. /** @hidden */
  80504. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80505. INNERGLOW: boolean;
  80506. BORDER: boolean;
  80507. HOVERLIGHT: boolean;
  80508. TEXTURE: boolean;
  80509. constructor();
  80510. }
  80511. /**
  80512. * Class used to render controls with fluent desgin
  80513. */
  80514. export class FluentMaterial extends BABYLON.PushMaterial {
  80515. /**
  80516. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80517. */
  80518. innerGlowColorIntensity: number;
  80519. /**
  80520. * Gets or sets the inner glow color (white by default)
  80521. */
  80522. innerGlowColor: BABYLON.Color3;
  80523. /**
  80524. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80525. */
  80526. albedoColor: BABYLON.Color3;
  80527. /**
  80528. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80529. */
  80530. renderBorders: boolean;
  80531. /**
  80532. * Gets or sets border width (default is 0.5)
  80533. */
  80534. borderWidth: number;
  80535. /**
  80536. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80537. */
  80538. edgeSmoothingValue: number;
  80539. /**
  80540. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80541. */
  80542. borderMinValue: number;
  80543. /**
  80544. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80545. */
  80546. renderHoverLight: boolean;
  80547. /**
  80548. * Gets or sets the radius used to render the hover light (default is 1.0)
  80549. */
  80550. hoverRadius: number;
  80551. /**
  80552. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80553. */
  80554. hoverColor: BABYLON.Color4;
  80555. /**
  80556. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80557. */
  80558. hoverPosition: BABYLON.Vector3;
  80559. private _albedoTexture;
  80560. /** Gets or sets the texture to use for albedo color */
  80561. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80562. /**
  80563. * Creates a new Fluent material
  80564. * @param name defines the name of the material
  80565. * @param scene defines the hosting scene
  80566. */
  80567. constructor(name: string, scene: BABYLON.Scene);
  80568. needAlphaBlending(): boolean;
  80569. needAlphaTesting(): boolean;
  80570. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80571. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80572. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80573. getActiveTextures(): BABYLON.BaseTexture[];
  80574. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80575. dispose(forceDisposeEffect?: boolean): void;
  80576. clone(name: string): FluentMaterial;
  80577. serialize(): any;
  80578. getClassName(): string;
  80579. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80580. }
  80581. }
  80582. declare module BABYLON.GUI {
  80583. /**
  80584. * Class used to create a holographic button in 3D
  80585. */
  80586. export class HolographicButton extends Button3D {
  80587. private _backPlate;
  80588. private _textPlate;
  80589. private _frontPlate;
  80590. private _text;
  80591. private _imageUrl;
  80592. private _shareMaterials;
  80593. private _frontMaterial;
  80594. private _backMaterial;
  80595. private _plateMaterial;
  80596. private _pickedPointObserver;
  80597. private _tooltipFade;
  80598. private _tooltipTextBlock;
  80599. private _tooltipTexture;
  80600. private _tooltipMesh;
  80601. private _tooltipHoverObserver;
  80602. private _tooltipOutObserver;
  80603. private _disposeTooltip;
  80604. /**
  80605. * Rendering ground id of all the mesh in the button
  80606. */
  80607. set renderingGroupId(id: number);
  80608. get renderingGroupId(): number;
  80609. /**
  80610. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80611. */
  80612. set tooltipText(text: BABYLON.Nullable<string>);
  80613. get tooltipText(): BABYLON.Nullable<string>;
  80614. /**
  80615. * Gets or sets text for the button
  80616. */
  80617. get text(): string;
  80618. set text(value: string);
  80619. /**
  80620. * Gets or sets the image url for the button
  80621. */
  80622. get imageUrl(): string;
  80623. set imageUrl(value: string);
  80624. /**
  80625. * Gets the back material used by this button
  80626. */
  80627. get backMaterial(): FluentMaterial;
  80628. /**
  80629. * Gets the front material used by this button
  80630. */
  80631. get frontMaterial(): FluentMaterial;
  80632. /**
  80633. * Gets the plate material used by this button
  80634. */
  80635. get plateMaterial(): BABYLON.StandardMaterial;
  80636. /**
  80637. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80638. */
  80639. get shareMaterials(): boolean;
  80640. /**
  80641. * Creates a new button
  80642. * @param name defines the control name
  80643. */
  80644. constructor(name?: string, shareMaterials?: boolean);
  80645. protected _getTypeName(): string;
  80646. private _rebuildContent;
  80647. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80648. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80649. private _createBackMaterial;
  80650. private _createFrontMaterial;
  80651. private _createPlateMaterial;
  80652. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80653. /**
  80654. * Releases all associated resources
  80655. */
  80656. dispose(): void;
  80657. }
  80658. }
  80659. declare module BABYLON.GUI {
  80660. /**
  80661. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80662. */
  80663. export class MeshButton3D extends Button3D {
  80664. /** @hidden */
  80665. protected _currentMesh: BABYLON.Mesh;
  80666. /**
  80667. * Creates a new 3D button based on a mesh
  80668. * @param mesh mesh to become a 3D button
  80669. * @param name defines the control name
  80670. */
  80671. constructor(mesh: BABYLON.Mesh, name?: string);
  80672. protected _getTypeName(): string;
  80673. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80674. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80675. }
  80676. }
  80677. declare module BABYLON.GUI {
  80678. /**
  80679. * Class used to create a container panel deployed on the surface of a plane
  80680. */
  80681. export class PlanePanel extends VolumeBasedPanel {
  80682. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80683. }
  80684. }
  80685. declare module BABYLON.GUI {
  80686. /**
  80687. * Class used to create a container panel where items get randomized planar mapping
  80688. */
  80689. export class ScatterPanel extends VolumeBasedPanel {
  80690. private _iteration;
  80691. /**
  80692. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80693. */
  80694. get iteration(): BABYLON.float;
  80695. set iteration(value: BABYLON.float);
  80696. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80697. private _scatterMapping;
  80698. protected _finalProcessing(): void;
  80699. }
  80700. }
  80701. declare module BABYLON.GUI {
  80702. /**
  80703. * Class used to create a container panel deployed on the surface of a sphere
  80704. */
  80705. export class SpherePanel extends VolumeBasedPanel {
  80706. private _radius;
  80707. /**
  80708. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80709. */
  80710. get radius(): BABYLON.float;
  80711. set radius(value: BABYLON.float);
  80712. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80713. private _sphericalMapping;
  80714. }
  80715. }
  80716. declare module BABYLON.GUI {
  80717. /**
  80718. * Class used to create a stack panel in 3D on XY plane
  80719. */
  80720. export class StackPanel3D extends Container3D {
  80721. private _isVertical;
  80722. /**
  80723. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80724. */
  80725. get isVertical(): boolean;
  80726. set isVertical(value: boolean);
  80727. /**
  80728. * Gets or sets the distance between elements
  80729. */
  80730. margin: number;
  80731. /**
  80732. * Creates new StackPanel
  80733. * @param isVertical
  80734. */
  80735. constructor(isVertical?: boolean);
  80736. protected _arrangeChildren(): void;
  80737. }
  80738. }
  80739. declare module BABYLON {
  80740. /**
  80741. * Configuration for glTF validation
  80742. */
  80743. export interface IGLTFValidationConfiguration {
  80744. /**
  80745. * The url of the glTF validator.
  80746. */
  80747. url: string;
  80748. }
  80749. /**
  80750. * glTF validation
  80751. */
  80752. export class GLTFValidation {
  80753. /**
  80754. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80755. */
  80756. static Configuration: IGLTFValidationConfiguration;
  80757. private static _LoadScriptPromise;
  80758. /**
  80759. * Validate a glTF asset using the glTF-Validator.
  80760. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80761. * @param rootUrl The root url for the glTF
  80762. * @param fileName The file name for the glTF
  80763. * @param getExternalResource The callback to get external resources for the glTF validator
  80764. * @returns A promise that resolves with the glTF validation results once complete
  80765. */
  80766. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80767. }
  80768. }
  80769. declare module BABYLON {
  80770. /**
  80771. * Mode that determines the coordinate system to use.
  80772. */
  80773. export enum GLTFLoaderCoordinateSystemMode {
  80774. /**
  80775. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80776. */
  80777. AUTO = 0,
  80778. /**
  80779. * Sets the useRightHandedSystem flag on the scene.
  80780. */
  80781. FORCE_RIGHT_HANDED = 1
  80782. }
  80783. /**
  80784. * Mode that determines what animations will start.
  80785. */
  80786. export enum GLTFLoaderAnimationStartMode {
  80787. /**
  80788. * No animation will start.
  80789. */
  80790. NONE = 0,
  80791. /**
  80792. * The first animation will start.
  80793. */
  80794. FIRST = 1,
  80795. /**
  80796. * All animations will start.
  80797. */
  80798. ALL = 2
  80799. }
  80800. /**
  80801. * Interface that contains the data for the glTF asset.
  80802. */
  80803. export interface IGLTFLoaderData {
  80804. /**
  80805. * The object that represents the glTF JSON.
  80806. */
  80807. json: Object;
  80808. /**
  80809. * The BIN chunk of a binary glTF.
  80810. */
  80811. bin: Nullable<IDataBuffer>;
  80812. }
  80813. /**
  80814. * Interface for extending the loader.
  80815. */
  80816. export interface 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 the order of this extension.
  80827. * The loader sorts the extensions using these values when loading.
  80828. */
  80829. order?: number;
  80830. }
  80831. /**
  80832. * Loader state.
  80833. */
  80834. export enum GLTFLoaderState {
  80835. /**
  80836. * The asset is loading.
  80837. */
  80838. LOADING = 0,
  80839. /**
  80840. * The asset is ready for rendering.
  80841. */
  80842. READY = 1,
  80843. /**
  80844. * The asset is completely loaded.
  80845. */
  80846. COMPLETE = 2
  80847. }
  80848. /** @hidden */
  80849. export interface IImportMeshAsyncOutput {
  80850. meshes: AbstractMesh[];
  80851. particleSystems: IParticleSystem[];
  80852. skeletons: Skeleton[];
  80853. animationGroups: AnimationGroup[];
  80854. lights: Light[];
  80855. transformNodes: TransformNode[];
  80856. }
  80857. /** @hidden */
  80858. export interface IGLTFLoader extends IDisposable {
  80859. readonly state: Nullable<GLTFLoaderState>;
  80860. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80861. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80862. }
  80863. /**
  80864. * File loader for loading glTF files into a scene.
  80865. */
  80866. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80867. /** @hidden */
  80868. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80869. /** @hidden */
  80870. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80871. /**
  80872. * Raised when the asset has been parsed
  80873. */
  80874. onParsedObservable: Observable<IGLTFLoaderData>;
  80875. private _onParsedObserver;
  80876. /**
  80877. * Raised when the asset has been parsed
  80878. */
  80879. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80880. /**
  80881. * 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.
  80882. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80883. * Defaults to true.
  80884. * @hidden
  80885. */
  80886. static IncrementalLoading: boolean;
  80887. /**
  80888. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80889. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80890. * @hidden
  80891. */
  80892. static HomogeneousCoordinates: boolean;
  80893. /**
  80894. * The coordinate system mode. Defaults to AUTO.
  80895. */
  80896. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80897. /**
  80898. * The animation start mode. Defaults to FIRST.
  80899. */
  80900. animationStartMode: GLTFLoaderAnimationStartMode;
  80901. /**
  80902. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80903. */
  80904. compileMaterials: boolean;
  80905. /**
  80906. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80907. */
  80908. useClipPlane: boolean;
  80909. /**
  80910. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80911. */
  80912. compileShadowGenerators: boolean;
  80913. /**
  80914. * Defines if the Alpha blended materials are only applied as coverage.
  80915. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80916. * If true, no extra effects are applied to transparent pixels.
  80917. */
  80918. transparencyAsCoverage: boolean;
  80919. /**
  80920. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80921. * Enabling will disable offline support and glTF validator.
  80922. * Defaults to false.
  80923. */
  80924. useRangeRequests: boolean;
  80925. /**
  80926. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80927. */
  80928. createInstances: boolean;
  80929. /**
  80930. * 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.
  80931. */
  80932. alwaysComputeBoundingBox: boolean;
  80933. /**
  80934. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80935. */
  80936. loadAllMaterials: boolean;
  80937. /**
  80938. * Function called before loading a url referenced by the asset.
  80939. */
  80940. preprocessUrlAsync: (url: string) => Promise<string>;
  80941. /**
  80942. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80943. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  80944. */
  80945. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80946. private _onMeshLoadedObserver;
  80947. /**
  80948. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80949. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  80950. */
  80951. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80952. /**
  80953. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80954. */
  80955. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80956. private _onTextureLoadedObserver;
  80957. /**
  80958. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80959. */
  80960. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80961. /**
  80962. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80963. */
  80964. readonly onMaterialLoadedObservable: Observable<Material>;
  80965. private _onMaterialLoadedObserver;
  80966. /**
  80967. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80968. */
  80969. set onMaterialLoaded(callback: (material: Material) => void);
  80970. /**
  80971. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80972. */
  80973. readonly onCameraLoadedObservable: Observable<Camera>;
  80974. private _onCameraLoadedObserver;
  80975. /**
  80976. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80977. */
  80978. set onCameraLoaded(callback: (camera: Camera) => void);
  80979. /**
  80980. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80981. * For assets with LODs, raised when all of the LODs are complete.
  80982. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80983. */
  80984. readonly onCompleteObservable: Observable<void>;
  80985. private _onCompleteObserver;
  80986. /**
  80987. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80988. * For assets with LODs, raised when all of the LODs are complete.
  80989. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80990. */
  80991. set onComplete(callback: () => void);
  80992. /**
  80993. * Observable raised when an error occurs.
  80994. */
  80995. readonly onErrorObservable: Observable<any>;
  80996. private _onErrorObserver;
  80997. /**
  80998. * Callback raised when an error occurs.
  80999. */
  81000. set onError(callback: (reason: any) => void);
  81001. /**
  81002. * Observable raised after the loader is disposed.
  81003. */
  81004. readonly onDisposeObservable: Observable<void>;
  81005. private _onDisposeObserver;
  81006. /**
  81007. * Callback raised after the loader is disposed.
  81008. */
  81009. set onDispose(callback: () => void);
  81010. /**
  81011. * Observable raised after a loader extension is created.
  81012. * Set additional options for a loader extension in this event.
  81013. */
  81014. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81015. private _onExtensionLoadedObserver;
  81016. /**
  81017. * Callback raised after a loader extension is created.
  81018. */
  81019. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81020. /**
  81021. * Defines if the loader logging is enabled.
  81022. */
  81023. get loggingEnabled(): boolean;
  81024. set loggingEnabled(value: boolean);
  81025. /**
  81026. * Defines if the loader should capture performance counters.
  81027. */
  81028. get capturePerformanceCounters(): boolean;
  81029. set capturePerformanceCounters(value: boolean);
  81030. /**
  81031. * Defines if the loader should validate the asset.
  81032. */
  81033. validate: boolean;
  81034. /**
  81035. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81036. */
  81037. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81038. private _onValidatedObserver;
  81039. /**
  81040. * Callback raised after a loader extension is created.
  81041. */
  81042. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81043. private _loader;
  81044. private _progressCallback?;
  81045. private _requests;
  81046. private static magicBase64Encoded;
  81047. /**
  81048. * Name of the loader ("gltf")
  81049. */
  81050. name: string;
  81051. /** @hidden */
  81052. extensions: ISceneLoaderPluginExtensions;
  81053. /**
  81054. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81055. */
  81056. dispose(): void;
  81057. /** @hidden */
  81058. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81059. /** @hidden */
  81060. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81061. /** @hidden */
  81062. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81063. meshes: AbstractMesh[];
  81064. particleSystems: IParticleSystem[];
  81065. skeletons: Skeleton[];
  81066. animationGroups: AnimationGroup[];
  81067. }>;
  81068. /** @hidden */
  81069. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81070. /** @hidden */
  81071. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81072. /** @hidden */
  81073. canDirectLoad(data: string): boolean;
  81074. /** @hidden */
  81075. directLoad(scene: Scene, data: string): Promise<any>;
  81076. /**
  81077. * The callback that allows custom handling of the root url based on the response url.
  81078. * @param rootUrl the original root url
  81079. * @param responseURL the response url if available
  81080. * @returns the new root url
  81081. */
  81082. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81083. /** @hidden */
  81084. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81085. /**
  81086. * The loader state or null if the loader is not active.
  81087. */
  81088. get loaderState(): Nullable<GLTFLoaderState>;
  81089. /**
  81090. * Returns a promise that resolves when the asset is completely loaded.
  81091. * @returns a promise that resolves when the asset is completely loaded.
  81092. */
  81093. whenCompleteAsync(): Promise<void>;
  81094. /** @hidden */
  81095. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81096. /** @hidden */
  81097. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81098. private _onProgress;
  81099. private _validate;
  81100. private _getLoader;
  81101. private _parseJson;
  81102. private _unpackBinaryAsync;
  81103. private _unpackBinaryV1Async;
  81104. private _unpackBinaryV2Async;
  81105. private static _parseVersion;
  81106. private static _compareVersion;
  81107. private static readonly _logSpaces;
  81108. private _logIndentLevel;
  81109. private _loggingEnabled;
  81110. /** @hidden */
  81111. _log: (message: string) => void;
  81112. /** @hidden */
  81113. _logOpen(message: string): void;
  81114. /** @hidden */
  81115. _logClose(): void;
  81116. private _logEnabled;
  81117. private _logDisabled;
  81118. private _capturePerformanceCounters;
  81119. /** @hidden */
  81120. _startPerformanceCounter: (counterName: string) => void;
  81121. /** @hidden */
  81122. _endPerformanceCounter: (counterName: string) => void;
  81123. private _startPerformanceCounterEnabled;
  81124. private _startPerformanceCounterDisabled;
  81125. private _endPerformanceCounterEnabled;
  81126. private _endPerformanceCounterDisabled;
  81127. }
  81128. }
  81129. declare module BABYLON.GLTF1 {
  81130. /**
  81131. * Enums
  81132. * @hidden
  81133. */
  81134. export enum EComponentType {
  81135. BYTE = 5120,
  81136. UNSIGNED_BYTE = 5121,
  81137. SHORT = 5122,
  81138. UNSIGNED_SHORT = 5123,
  81139. FLOAT = 5126
  81140. }
  81141. /** @hidden */
  81142. export enum EShaderType {
  81143. FRAGMENT = 35632,
  81144. VERTEX = 35633
  81145. }
  81146. /** @hidden */
  81147. export enum EParameterType {
  81148. BYTE = 5120,
  81149. UNSIGNED_BYTE = 5121,
  81150. SHORT = 5122,
  81151. UNSIGNED_SHORT = 5123,
  81152. INT = 5124,
  81153. UNSIGNED_INT = 5125,
  81154. FLOAT = 5126,
  81155. FLOAT_VEC2 = 35664,
  81156. FLOAT_VEC3 = 35665,
  81157. FLOAT_VEC4 = 35666,
  81158. INT_VEC2 = 35667,
  81159. INT_VEC3 = 35668,
  81160. INT_VEC4 = 35669,
  81161. BOOL = 35670,
  81162. BOOL_VEC2 = 35671,
  81163. BOOL_VEC3 = 35672,
  81164. BOOL_VEC4 = 35673,
  81165. FLOAT_MAT2 = 35674,
  81166. FLOAT_MAT3 = 35675,
  81167. FLOAT_MAT4 = 35676,
  81168. SAMPLER_2D = 35678
  81169. }
  81170. /** @hidden */
  81171. export enum ETextureWrapMode {
  81172. CLAMP_TO_EDGE = 33071,
  81173. MIRRORED_REPEAT = 33648,
  81174. REPEAT = 10497
  81175. }
  81176. /** @hidden */
  81177. export enum ETextureFilterType {
  81178. NEAREST = 9728,
  81179. LINEAR = 9728,
  81180. NEAREST_MIPMAP_NEAREST = 9984,
  81181. LINEAR_MIPMAP_NEAREST = 9985,
  81182. NEAREST_MIPMAP_LINEAR = 9986,
  81183. LINEAR_MIPMAP_LINEAR = 9987
  81184. }
  81185. /** @hidden */
  81186. export enum ETextureFormat {
  81187. ALPHA = 6406,
  81188. RGB = 6407,
  81189. RGBA = 6408,
  81190. LUMINANCE = 6409,
  81191. LUMINANCE_ALPHA = 6410
  81192. }
  81193. /** @hidden */
  81194. export enum ECullingType {
  81195. FRONT = 1028,
  81196. BACK = 1029,
  81197. FRONT_AND_BACK = 1032
  81198. }
  81199. /** @hidden */
  81200. export enum EBlendingFunction {
  81201. ZERO = 0,
  81202. ONE = 1,
  81203. SRC_COLOR = 768,
  81204. ONE_MINUS_SRC_COLOR = 769,
  81205. DST_COLOR = 774,
  81206. ONE_MINUS_DST_COLOR = 775,
  81207. SRC_ALPHA = 770,
  81208. ONE_MINUS_SRC_ALPHA = 771,
  81209. DST_ALPHA = 772,
  81210. ONE_MINUS_DST_ALPHA = 773,
  81211. CONSTANT_COLOR = 32769,
  81212. ONE_MINUS_CONSTANT_COLOR = 32770,
  81213. CONSTANT_ALPHA = 32771,
  81214. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81215. SRC_ALPHA_SATURATE = 776
  81216. }
  81217. /** @hidden */
  81218. export interface IGLTFProperty {
  81219. extensions?: {
  81220. [key: string]: any;
  81221. };
  81222. extras?: Object;
  81223. }
  81224. /** @hidden */
  81225. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81226. name?: string;
  81227. }
  81228. /** @hidden */
  81229. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81230. bufferView: string;
  81231. byteOffset: number;
  81232. byteStride: number;
  81233. count: number;
  81234. type: string;
  81235. componentType: EComponentType;
  81236. max?: number[];
  81237. min?: number[];
  81238. name?: string;
  81239. }
  81240. /** @hidden */
  81241. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81242. buffer: string;
  81243. byteOffset: number;
  81244. byteLength: number;
  81245. byteStride: number;
  81246. target?: number;
  81247. }
  81248. /** @hidden */
  81249. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81250. uri: string;
  81251. byteLength?: number;
  81252. type?: string;
  81253. }
  81254. /** @hidden */
  81255. export interface IGLTFShader extends IGLTFChildRootProperty {
  81256. uri: string;
  81257. type: EShaderType;
  81258. }
  81259. /** @hidden */
  81260. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81261. attributes: string[];
  81262. fragmentShader: string;
  81263. vertexShader: string;
  81264. }
  81265. /** @hidden */
  81266. export interface IGLTFTechniqueParameter {
  81267. type: number;
  81268. count?: number;
  81269. semantic?: string;
  81270. node?: string;
  81271. value?: number | boolean | string | Array<any>;
  81272. source?: string;
  81273. babylonValue?: any;
  81274. }
  81275. /** @hidden */
  81276. export interface IGLTFTechniqueCommonProfile {
  81277. lightingModel: string;
  81278. texcoordBindings: Object;
  81279. parameters?: Array<any>;
  81280. }
  81281. /** @hidden */
  81282. export interface IGLTFTechniqueStatesFunctions {
  81283. blendColor?: number[];
  81284. blendEquationSeparate?: number[];
  81285. blendFuncSeparate?: number[];
  81286. colorMask: boolean[];
  81287. cullFace: number[];
  81288. }
  81289. /** @hidden */
  81290. export interface IGLTFTechniqueStates {
  81291. enable: number[];
  81292. functions: IGLTFTechniqueStatesFunctions;
  81293. }
  81294. /** @hidden */
  81295. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81296. parameters: {
  81297. [key: string]: IGLTFTechniqueParameter;
  81298. };
  81299. program: string;
  81300. attributes: {
  81301. [key: string]: string;
  81302. };
  81303. uniforms: {
  81304. [key: string]: string;
  81305. };
  81306. states: IGLTFTechniqueStates;
  81307. }
  81308. /** @hidden */
  81309. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81310. technique?: string;
  81311. values: string[];
  81312. }
  81313. /** @hidden */
  81314. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81315. attributes: {
  81316. [key: string]: string;
  81317. };
  81318. indices: string;
  81319. material: string;
  81320. mode?: number;
  81321. }
  81322. /** @hidden */
  81323. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81324. primitives: IGLTFMeshPrimitive[];
  81325. }
  81326. /** @hidden */
  81327. export interface IGLTFImage extends IGLTFChildRootProperty {
  81328. uri: string;
  81329. }
  81330. /** @hidden */
  81331. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81332. magFilter?: number;
  81333. minFilter?: number;
  81334. wrapS?: number;
  81335. wrapT?: number;
  81336. }
  81337. /** @hidden */
  81338. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81339. sampler: string;
  81340. source: string;
  81341. format?: ETextureFormat;
  81342. internalFormat?: ETextureFormat;
  81343. target?: number;
  81344. type?: number;
  81345. babylonTexture?: Texture;
  81346. }
  81347. /** @hidden */
  81348. export interface IGLTFAmbienLight {
  81349. color?: number[];
  81350. }
  81351. /** @hidden */
  81352. export interface IGLTFDirectionalLight {
  81353. color?: number[];
  81354. }
  81355. /** @hidden */
  81356. export interface IGLTFPointLight {
  81357. color?: number[];
  81358. constantAttenuation?: number;
  81359. linearAttenuation?: number;
  81360. quadraticAttenuation?: number;
  81361. }
  81362. /** @hidden */
  81363. export interface IGLTFSpotLight {
  81364. color?: number[];
  81365. constantAttenuation?: number;
  81366. fallOfAngle?: number;
  81367. fallOffExponent?: number;
  81368. linearAttenuation?: number;
  81369. quadraticAttenuation?: number;
  81370. }
  81371. /** @hidden */
  81372. export interface IGLTFLight extends IGLTFChildRootProperty {
  81373. type: string;
  81374. }
  81375. /** @hidden */
  81376. export interface IGLTFCameraOrthographic {
  81377. xmag: number;
  81378. ymag: number;
  81379. zfar: number;
  81380. znear: number;
  81381. }
  81382. /** @hidden */
  81383. export interface IGLTFCameraPerspective {
  81384. aspectRatio: number;
  81385. yfov: number;
  81386. zfar: number;
  81387. znear: number;
  81388. }
  81389. /** @hidden */
  81390. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81391. type: string;
  81392. }
  81393. /** @hidden */
  81394. export interface IGLTFAnimationChannelTarget {
  81395. id: string;
  81396. path: string;
  81397. }
  81398. /** @hidden */
  81399. export interface IGLTFAnimationChannel {
  81400. sampler: string;
  81401. target: IGLTFAnimationChannelTarget;
  81402. }
  81403. /** @hidden */
  81404. export interface IGLTFAnimationSampler {
  81405. input: string;
  81406. output: string;
  81407. interpolation?: string;
  81408. }
  81409. /** @hidden */
  81410. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81411. channels?: IGLTFAnimationChannel[];
  81412. parameters?: {
  81413. [key: string]: string;
  81414. };
  81415. samplers?: {
  81416. [key: string]: IGLTFAnimationSampler;
  81417. };
  81418. }
  81419. /** @hidden */
  81420. export interface IGLTFNodeInstanceSkin {
  81421. skeletons: string[];
  81422. skin: string;
  81423. meshes: string[];
  81424. }
  81425. /** @hidden */
  81426. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81427. bindShapeMatrix: number[];
  81428. inverseBindMatrices: string;
  81429. jointNames: string[];
  81430. babylonSkeleton?: Skeleton;
  81431. }
  81432. /** @hidden */
  81433. export interface IGLTFNode extends IGLTFChildRootProperty {
  81434. camera?: string;
  81435. children: string[];
  81436. skin?: string;
  81437. jointName?: string;
  81438. light?: string;
  81439. matrix: number[];
  81440. mesh?: string;
  81441. meshes?: string[];
  81442. rotation?: number[];
  81443. scale?: number[];
  81444. translation?: number[];
  81445. babylonNode?: Node;
  81446. }
  81447. /** @hidden */
  81448. export interface IGLTFScene extends IGLTFChildRootProperty {
  81449. nodes: string[];
  81450. }
  81451. /** @hidden */
  81452. export interface IGLTFRuntime {
  81453. extensions: {
  81454. [key: string]: any;
  81455. };
  81456. accessors: {
  81457. [key: string]: IGLTFAccessor;
  81458. };
  81459. buffers: {
  81460. [key: string]: IGLTFBuffer;
  81461. };
  81462. bufferViews: {
  81463. [key: string]: IGLTFBufferView;
  81464. };
  81465. meshes: {
  81466. [key: string]: IGLTFMesh;
  81467. };
  81468. lights: {
  81469. [key: string]: IGLTFLight;
  81470. };
  81471. cameras: {
  81472. [key: string]: IGLTFCamera;
  81473. };
  81474. nodes: {
  81475. [key: string]: IGLTFNode;
  81476. };
  81477. images: {
  81478. [key: string]: IGLTFImage;
  81479. };
  81480. textures: {
  81481. [key: string]: IGLTFTexture;
  81482. };
  81483. shaders: {
  81484. [key: string]: IGLTFShader;
  81485. };
  81486. programs: {
  81487. [key: string]: IGLTFProgram;
  81488. };
  81489. samplers: {
  81490. [key: string]: IGLTFSampler;
  81491. };
  81492. techniques: {
  81493. [key: string]: IGLTFTechnique;
  81494. };
  81495. materials: {
  81496. [key: string]: IGLTFMaterial;
  81497. };
  81498. animations: {
  81499. [key: string]: IGLTFAnimation;
  81500. };
  81501. skins: {
  81502. [key: string]: IGLTFSkins;
  81503. };
  81504. currentScene?: Object;
  81505. scenes: {
  81506. [key: string]: IGLTFScene;
  81507. };
  81508. extensionsUsed: string[];
  81509. extensionsRequired?: string[];
  81510. buffersCount: number;
  81511. shaderscount: number;
  81512. scene: Scene;
  81513. rootUrl: string;
  81514. loadedBufferCount: number;
  81515. loadedBufferViews: {
  81516. [name: string]: ArrayBufferView;
  81517. };
  81518. loadedShaderCount: number;
  81519. importOnlyMeshes: boolean;
  81520. importMeshesNames?: string[];
  81521. dummyNodes: Node[];
  81522. forAssetContainer: boolean;
  81523. }
  81524. /** @hidden */
  81525. export interface INodeToRoot {
  81526. bone: Bone;
  81527. node: IGLTFNode;
  81528. id: string;
  81529. }
  81530. /** @hidden */
  81531. export interface IJointNode {
  81532. node: IGLTFNode;
  81533. id: string;
  81534. }
  81535. }
  81536. declare module BABYLON.GLTF1 {
  81537. /**
  81538. * Utils functions for GLTF
  81539. * @hidden
  81540. */
  81541. export class GLTFUtils {
  81542. /**
  81543. * Sets the given "parameter" matrix
  81544. * @param scene: the Scene object
  81545. * @param source: the source node where to pick the matrix
  81546. * @param parameter: the GLTF technique parameter
  81547. * @param uniformName: the name of the shader's uniform
  81548. * @param shaderMaterial: the shader material
  81549. */
  81550. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81551. /**
  81552. * Sets the given "parameter" matrix
  81553. * @param shaderMaterial: the shader material
  81554. * @param uniform: the name of the shader's uniform
  81555. * @param value: the value of the uniform
  81556. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81557. */
  81558. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81559. /**
  81560. * Returns the wrap mode of the texture
  81561. * @param mode: the mode value
  81562. */
  81563. static GetWrapMode(mode: number): number;
  81564. /**
  81565. * Returns the byte stride giving an accessor
  81566. * @param accessor: the GLTF accessor objet
  81567. */
  81568. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81569. /**
  81570. * Returns the texture filter mode giving a mode value
  81571. * @param mode: the filter mode value
  81572. */
  81573. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81574. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81575. /**
  81576. * Returns a buffer from its accessor
  81577. * @param gltfRuntime: the GLTF runtime
  81578. * @param accessor: the GLTF accessor
  81579. */
  81580. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81581. /**
  81582. * Decodes a buffer view into a string
  81583. * @param view: the buffer view
  81584. */
  81585. static DecodeBufferToText(view: ArrayBufferView): string;
  81586. /**
  81587. * Returns the default material of gltf. Related to
  81588. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81589. * @param scene: the Babylon.js scene
  81590. */
  81591. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81592. private static _DefaultMaterial;
  81593. }
  81594. }
  81595. declare module BABYLON.GLTF1 {
  81596. /**
  81597. * Implementation of the base glTF spec
  81598. * @hidden
  81599. */
  81600. export class GLTFLoaderBase {
  81601. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81602. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81603. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81604. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81605. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81606. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81607. }
  81608. /**
  81609. * glTF V1 Loader
  81610. * @hidden
  81611. */
  81612. export class GLTFLoader implements IGLTFLoader {
  81613. static Extensions: {
  81614. [name: string]: GLTFLoaderExtension;
  81615. };
  81616. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81617. state: Nullable<GLTFLoaderState>;
  81618. dispose(): void;
  81619. private _importMeshAsync;
  81620. /**
  81621. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81622. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81623. * @param scene the scene the meshes should be added to
  81624. * @param forAssetContainer defines if the entities must be stored in the scene
  81625. * @param data gltf data containing information of the meshes in a loaded file
  81626. * @param rootUrl root url to load from
  81627. * @param onProgress event that fires when loading progress has occured
  81628. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81629. */
  81630. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81631. private _loadAsync;
  81632. /**
  81633. * Imports all objects from a loaded gltf file and adds them to the scene
  81634. * @param scene the scene the objects should be added to
  81635. * @param data gltf data containing information of the meshes in a loaded file
  81636. * @param rootUrl root url to load from
  81637. * @param onProgress event that fires when loading progress has occured
  81638. * @returns a promise which completes when objects have been loaded to the scene
  81639. */
  81640. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81641. private _loadShadersAsync;
  81642. private _loadBuffersAsync;
  81643. private _createNodes;
  81644. }
  81645. /** @hidden */
  81646. export abstract class GLTFLoaderExtension {
  81647. private _name;
  81648. constructor(name: string);
  81649. get name(): string;
  81650. /**
  81651. * Defines an override for loading the runtime
  81652. * Return true to stop further extensions from loading the runtime
  81653. */
  81654. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81655. /**
  81656. * Defines an onverride for creating gltf runtime
  81657. * Return true to stop further extensions from creating the runtime
  81658. */
  81659. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81660. /**
  81661. * Defines an override for loading buffers
  81662. * Return true to stop further extensions from loading this buffer
  81663. */
  81664. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81665. /**
  81666. * Defines an override for loading texture buffers
  81667. * Return true to stop further extensions from loading this texture data
  81668. */
  81669. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81670. /**
  81671. * Defines an override for creating textures
  81672. * Return true to stop further extensions from loading this texture
  81673. */
  81674. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81675. /**
  81676. * Defines an override for loading shader strings
  81677. * Return true to stop further extensions from loading this shader data
  81678. */
  81679. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81680. /**
  81681. * Defines an override for loading materials
  81682. * Return true to stop further extensions from loading this material
  81683. */
  81684. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81685. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81686. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81687. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81688. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81689. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81690. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81691. private static LoadTextureBufferAsync;
  81692. private static CreateTextureAsync;
  81693. private static ApplyExtensions;
  81694. }
  81695. }
  81696. declare module BABYLON.GLTF1 {
  81697. /** @hidden */
  81698. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81699. private _bin;
  81700. constructor();
  81701. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81702. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81703. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81704. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81705. }
  81706. }
  81707. declare module BABYLON.GLTF1 {
  81708. /** @hidden */
  81709. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81710. constructor();
  81711. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81712. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81713. private _loadTexture;
  81714. }
  81715. }
  81716. declare module BABYLON.GLTF2.Loader {
  81717. /**
  81718. * Loader interface with an index field.
  81719. */
  81720. export interface IArrayItem {
  81721. /**
  81722. * The index of this item in the array.
  81723. */
  81724. index: number;
  81725. }
  81726. /**
  81727. * Loader interface with additional members.
  81728. */
  81729. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81730. /** @hidden */
  81731. _data?: Promise<ArrayBufferView>;
  81732. /** @hidden */
  81733. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81734. }
  81735. /**
  81736. * Loader interface with additional members.
  81737. */
  81738. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81739. }
  81740. /** @hidden */
  81741. export interface _IAnimationSamplerData {
  81742. input: Float32Array;
  81743. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81744. output: Float32Array;
  81745. }
  81746. /**
  81747. * Loader interface with additional members.
  81748. */
  81749. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81750. /** @hidden */
  81751. _data?: Promise<_IAnimationSamplerData>;
  81752. }
  81753. /**
  81754. * Loader interface with additional members.
  81755. */
  81756. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81757. channels: IAnimationChannel[];
  81758. samplers: IAnimationSampler[];
  81759. /** @hidden */
  81760. _babylonAnimationGroup?: AnimationGroup;
  81761. }
  81762. /**
  81763. * Loader interface with additional members.
  81764. */
  81765. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81766. /** @hidden */
  81767. _data?: Promise<ArrayBufferView>;
  81768. }
  81769. /**
  81770. * Loader interface with additional members.
  81771. */
  81772. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81773. /** @hidden */
  81774. _data?: Promise<ArrayBufferView>;
  81775. /** @hidden */
  81776. _babylonBuffer?: Promise<Buffer>;
  81777. }
  81778. /**
  81779. * Loader interface with additional members.
  81780. */
  81781. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81782. }
  81783. /**
  81784. * Loader interface with additional members.
  81785. */
  81786. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81787. /** @hidden */
  81788. _data?: Promise<ArrayBufferView>;
  81789. }
  81790. /**
  81791. * Loader interface with additional members.
  81792. */
  81793. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81794. }
  81795. /**
  81796. * Loader interface with additional members.
  81797. */
  81798. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81799. }
  81800. /**
  81801. * Loader interface with additional members.
  81802. */
  81803. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81804. baseColorTexture?: ITextureInfo;
  81805. metallicRoughnessTexture?: ITextureInfo;
  81806. }
  81807. /**
  81808. * Loader interface with additional members.
  81809. */
  81810. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81811. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81812. normalTexture?: IMaterialNormalTextureInfo;
  81813. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81814. emissiveTexture?: ITextureInfo;
  81815. /** @hidden */
  81816. _data?: {
  81817. [babylonDrawMode: number]: {
  81818. babylonMaterial: Material;
  81819. babylonMeshes: AbstractMesh[];
  81820. promise: Promise<void>;
  81821. };
  81822. };
  81823. }
  81824. /**
  81825. * Loader interface with additional members.
  81826. */
  81827. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81828. primitives: IMeshPrimitive[];
  81829. }
  81830. /**
  81831. * Loader interface with additional members.
  81832. */
  81833. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81834. /** @hidden */
  81835. _instanceData?: {
  81836. babylonSourceMesh: Mesh;
  81837. promise: Promise<any>;
  81838. };
  81839. }
  81840. /**
  81841. * Loader interface with additional members.
  81842. */
  81843. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81844. /**
  81845. * The parent glTF node.
  81846. */
  81847. parent?: INode;
  81848. /** @hidden */
  81849. _babylonTransformNode?: TransformNode;
  81850. /** @hidden */
  81851. _primitiveBabylonMeshes?: AbstractMesh[];
  81852. /** @hidden */
  81853. _babylonBones?: Bone[];
  81854. /** @hidden */
  81855. _numMorphTargets?: number;
  81856. }
  81857. /** @hidden */
  81858. export interface _ISamplerData {
  81859. noMipMaps: boolean;
  81860. samplingMode: number;
  81861. wrapU: number;
  81862. wrapV: number;
  81863. }
  81864. /**
  81865. * Loader interface with additional members.
  81866. */
  81867. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81868. /** @hidden */
  81869. _data?: _ISamplerData;
  81870. }
  81871. /**
  81872. * Loader interface with additional members.
  81873. */
  81874. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81875. }
  81876. /**
  81877. * Loader interface with additional members.
  81878. */
  81879. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81880. /** @hidden */
  81881. _data?: {
  81882. babylonSkeleton: Skeleton;
  81883. promise: Promise<void>;
  81884. };
  81885. }
  81886. /**
  81887. * Loader interface with additional members.
  81888. */
  81889. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81890. }
  81891. /**
  81892. * Loader interface with additional members.
  81893. */
  81894. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81895. }
  81896. /**
  81897. * Loader interface with additional members.
  81898. */
  81899. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81900. accessors?: IAccessor[];
  81901. animations?: IAnimation[];
  81902. buffers?: IBuffer[];
  81903. bufferViews?: IBufferView[];
  81904. cameras?: ICamera[];
  81905. images?: IImage[];
  81906. materials?: IMaterial[];
  81907. meshes?: IMesh[];
  81908. nodes?: INode[];
  81909. samplers?: ISampler[];
  81910. scenes?: IScene[];
  81911. skins?: ISkin[];
  81912. textures?: ITexture[];
  81913. }
  81914. }
  81915. declare module BABYLON.GLTF2 {
  81916. /**
  81917. * Interface for a glTF loader extension.
  81918. */
  81919. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81920. /**
  81921. * Called after the loader state changes to LOADING.
  81922. */
  81923. onLoading?(): void;
  81924. /**
  81925. * Called after the loader state changes to READY.
  81926. */
  81927. onReady?(): void;
  81928. /**
  81929. * Define this method to modify the default behavior when loading scenes.
  81930. * @param context The context when loading the asset
  81931. * @param scene The glTF scene property
  81932. * @returns A promise that resolves when the load is complete or null if not handled
  81933. */
  81934. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81935. /**
  81936. * Define this method to modify the default behavior when loading nodes.
  81937. * @param context The context when loading the asset
  81938. * @param node The glTF node property
  81939. * @param assign A function called synchronously after parsing the glTF properties
  81940. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81941. */
  81942. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81943. /**
  81944. * Define this method to modify the default behavior when loading cameras.
  81945. * @param context The context when loading the asset
  81946. * @param camera The glTF camera property
  81947. * @param assign A function called synchronously after parsing the glTF properties
  81948. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81949. */
  81950. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81951. /**
  81952. * @hidden
  81953. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81954. * @param context The context when loading the asset
  81955. * @param primitive The glTF mesh primitive property
  81956. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81957. */
  81958. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81959. /**
  81960. * @hidden
  81961. * Define this method to modify the default behavior when loading data for mesh primitives.
  81962. * @param context The context when loading the asset
  81963. * @param name The mesh name when loading the asset
  81964. * @param node The glTF node when loading the asset
  81965. * @param mesh The glTF mesh when loading the asset
  81966. * @param primitive The glTF mesh primitive property
  81967. * @param assign A function called synchronously after parsing the glTF properties
  81968. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81969. */
  81970. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81971. /**
  81972. * @hidden
  81973. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81974. * @param context The context when loading the asset
  81975. * @param material The glTF material property
  81976. * @param assign A function called synchronously after parsing the glTF properties
  81977. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81978. */
  81979. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81980. /**
  81981. * Define this method to modify the default behavior when creating materials.
  81982. * @param context The context when loading the asset
  81983. * @param material The glTF material property
  81984. * @param babylonDrawMode The draw mode for the Babylon material
  81985. * @returns The Babylon material or null if not handled
  81986. */
  81987. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81988. /**
  81989. * Define this method to modify the default behavior when loading material properties.
  81990. * @param context The context when loading the asset
  81991. * @param material The glTF material property
  81992. * @param babylonMaterial The Babylon material
  81993. * @returns A promise that resolves when the load is complete or null if not handled
  81994. */
  81995. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81996. /**
  81997. * Define this method to modify the default behavior when loading texture infos.
  81998. * @param context The context when loading the asset
  81999. * @param textureInfo The glTF texture info property
  82000. * @param assign A function called synchronously after parsing the glTF properties
  82001. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82002. */
  82003. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82004. /**
  82005. * @hidden
  82006. * Define this method to modify the default behavior when loading textures.
  82007. * @param context The context when loading the asset
  82008. * @param texture The glTF texture property
  82009. * @param assign A function called synchronously after parsing the glTF properties
  82010. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82011. */
  82012. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82013. /**
  82014. * Define this method to modify the default behavior when loading animations.
  82015. * @param context The context when loading the asset
  82016. * @param animation The glTF animation property
  82017. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82018. */
  82019. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82020. /**
  82021. * @hidden
  82022. * Define this method to modify the default behavior when loading skins.
  82023. * @param context The context when loading the asset
  82024. * @param node The glTF node property
  82025. * @param skin The glTF skin property
  82026. * @returns A promise that resolves when the load is complete or null if not handled
  82027. */
  82028. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82029. /**
  82030. * @hidden
  82031. * Define this method to modify the default behavior when loading uris.
  82032. * @param context The context when loading the asset
  82033. * @param property The glTF property associated with the uri
  82034. * @param uri The uri to load
  82035. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82036. */
  82037. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82038. /**
  82039. * Define this method to modify the default behavior when loading buffer views.
  82040. * @param context The context when loading the asset
  82041. * @param bufferView The glTF buffer view property
  82042. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82043. */
  82044. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82045. /**
  82046. * Define this method to modify the default behavior when loading buffers.
  82047. * @param context The context when loading the asset
  82048. * @param buffer The glTF buffer property
  82049. * @param byteOffset The byte offset to load
  82050. * @param byteLength The byte length to load
  82051. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82052. */
  82053. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82054. }
  82055. }
  82056. declare module BABYLON.GLTF2 {
  82057. /**
  82058. * Helper class for working with arrays when loading the glTF asset
  82059. */
  82060. export class ArrayItem {
  82061. /**
  82062. * Gets an item from the given array.
  82063. * @param context The context when loading the asset
  82064. * @param array The array to get the item from
  82065. * @param index The index to the array
  82066. * @returns The array item
  82067. */
  82068. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82069. /**
  82070. * Assign an `index` field to each item of the given array.
  82071. * @param array The array of items
  82072. */
  82073. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82074. }
  82075. /**
  82076. * The glTF 2.0 loader
  82077. */
  82078. export class GLTFLoader implements IGLTFLoader {
  82079. /** @hidden */
  82080. _completePromises: Promise<any>[];
  82081. /** @hidden */
  82082. _forAssetContainer: boolean;
  82083. /** Storage */
  82084. _babylonLights: Light[];
  82085. /** @hidden */
  82086. _disableInstancedMesh: number;
  82087. private _disposed;
  82088. private _parent;
  82089. private _state;
  82090. private _extensions;
  82091. private _rootUrl;
  82092. private _fileName;
  82093. private _uniqueRootUrl;
  82094. private _gltf;
  82095. private _bin;
  82096. private _babylonScene;
  82097. private _rootBabylonMesh;
  82098. private _defaultBabylonMaterialData;
  82099. private static _RegisteredExtensions;
  82100. /**
  82101. * The default glTF sampler.
  82102. */
  82103. static readonly DefaultSampler: ISampler;
  82104. /**
  82105. * Registers a loader extension.
  82106. * @param name The name of the loader extension.
  82107. * @param factory The factory function that creates the loader extension.
  82108. */
  82109. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82110. /**
  82111. * Unregisters a loader extension.
  82112. * @param name The name of the loader extension.
  82113. * @returns A boolean indicating whether the extension has been unregistered
  82114. */
  82115. static UnregisterExtension(name: string): boolean;
  82116. /**
  82117. * The loader state.
  82118. */
  82119. get state(): Nullable<GLTFLoaderState>;
  82120. /**
  82121. * The object that represents the glTF JSON.
  82122. */
  82123. get gltf(): IGLTF;
  82124. /**
  82125. * The BIN chunk of a binary glTF.
  82126. */
  82127. get bin(): Nullable<IDataBuffer>;
  82128. /**
  82129. * The parent file loader.
  82130. */
  82131. get parent(): GLTFFileLoader;
  82132. /**
  82133. * The Babylon scene when loading the asset.
  82134. */
  82135. get babylonScene(): Scene;
  82136. /**
  82137. * The root Babylon mesh when loading the asset.
  82138. */
  82139. get rootBabylonMesh(): Mesh;
  82140. /** @hidden */
  82141. constructor(parent: GLTFFileLoader);
  82142. /** @hidden */
  82143. dispose(): void;
  82144. /** @hidden */
  82145. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82146. /** @hidden */
  82147. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82148. private _loadAsync;
  82149. private _loadData;
  82150. private _setupData;
  82151. private _loadExtensions;
  82152. private _checkExtensions;
  82153. private _setState;
  82154. private _createRootNode;
  82155. /**
  82156. * Loads a glTF scene.
  82157. * @param context The context when loading the asset
  82158. * @param scene The glTF scene property
  82159. * @returns A promise that resolves when the load is complete
  82160. */
  82161. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82162. private _forEachPrimitive;
  82163. private _getMeshes;
  82164. private _getTransformNodes;
  82165. private _getSkeletons;
  82166. private _getAnimationGroups;
  82167. private _startAnimations;
  82168. /**
  82169. * Loads a glTF node.
  82170. * @param context The context when loading the asset
  82171. * @param node The glTF node property
  82172. * @param assign A function called synchronously after parsing the glTF properties
  82173. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82174. */
  82175. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82176. private _loadMeshAsync;
  82177. /**
  82178. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82179. * @param context The context when loading the asset
  82180. * @param name The mesh name when loading the asset
  82181. * @param node The glTF node when loading the asset
  82182. * @param mesh The glTF mesh when loading the asset
  82183. * @param primitive The glTF mesh primitive property
  82184. * @param assign A function called synchronously after parsing the glTF properties
  82185. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82186. */
  82187. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82188. private _loadVertexDataAsync;
  82189. private _createMorphTargets;
  82190. private _loadMorphTargetsAsync;
  82191. private _loadMorphTargetVertexDataAsync;
  82192. private static _LoadTransform;
  82193. private _loadSkinAsync;
  82194. private _loadBones;
  82195. private _loadBone;
  82196. private _loadSkinInverseBindMatricesDataAsync;
  82197. private _updateBoneMatrices;
  82198. private _getNodeMatrix;
  82199. /**
  82200. * Loads a glTF camera.
  82201. * @param context The context when loading the asset
  82202. * @param camera The glTF camera property
  82203. * @param assign A function called synchronously after parsing the glTF properties
  82204. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82205. */
  82206. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82207. private _loadAnimationsAsync;
  82208. /**
  82209. * Loads a glTF animation.
  82210. * @param context The context when loading the asset
  82211. * @param animation The glTF animation property
  82212. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82213. */
  82214. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82215. /**
  82216. * @hidden Loads a glTF animation channel.
  82217. * @param context The context when loading the asset
  82218. * @param animationContext The context of the animation when loading the asset
  82219. * @param animation The glTF animation property
  82220. * @param channel The glTF animation channel property
  82221. * @param babylonAnimationGroup The babylon animation group property
  82222. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82223. * @returns A void promise when the channel load is complete
  82224. */
  82225. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82226. private _loadAnimationSamplerAsync;
  82227. private _loadBufferAsync;
  82228. /**
  82229. * Loads a glTF buffer view.
  82230. * @param context The context when loading the asset
  82231. * @param bufferView The glTF buffer view property
  82232. * @returns A promise that resolves with the loaded data when the load is complete
  82233. */
  82234. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82235. private _loadAccessorAsync;
  82236. /** @hidden */
  82237. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82238. private _loadIndicesAccessorAsync;
  82239. private _loadVertexBufferViewAsync;
  82240. private _loadVertexAccessorAsync;
  82241. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82242. /** @hidden */
  82243. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82244. private _createDefaultMaterial;
  82245. /**
  82246. * Creates a Babylon material from a glTF material.
  82247. * @param context The context when loading the asset
  82248. * @param material The glTF material property
  82249. * @param babylonDrawMode The draw mode for the Babylon material
  82250. * @returns The Babylon material
  82251. */
  82252. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82253. /**
  82254. * Loads properties from a glTF material into a Babylon material.
  82255. * @param context The context when loading the asset
  82256. * @param material The glTF material property
  82257. * @param babylonMaterial The Babylon material
  82258. * @returns A promise that resolves when the load is complete
  82259. */
  82260. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82261. /**
  82262. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82263. * @param context The context when loading the asset
  82264. * @param material The glTF material property
  82265. * @param babylonMaterial The Babylon material
  82266. * @returns A promise that resolves when the load is complete
  82267. */
  82268. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82269. /**
  82270. * Loads the alpha properties from a glTF material into a Babylon material.
  82271. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82272. * @param context The context when loading the asset
  82273. * @param material The glTF material property
  82274. * @param babylonMaterial The Babylon material
  82275. */
  82276. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82277. /**
  82278. * Loads a glTF texture info.
  82279. * @param context The context when loading the asset
  82280. * @param textureInfo The glTF texture info property
  82281. * @param assign A function called synchronously after parsing the glTF properties
  82282. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82283. */
  82284. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82285. /** @hidden */
  82286. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82287. /** @hidden */
  82288. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82289. private _loadSampler;
  82290. /**
  82291. * Loads a glTF image.
  82292. * @param context The context when loading the asset
  82293. * @param image The glTF image property
  82294. * @returns A promise that resolves with the loaded data when the load is complete
  82295. */
  82296. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82297. /**
  82298. * Loads a glTF uri.
  82299. * @param context The context when loading the asset
  82300. * @param property The glTF property associated with the uri
  82301. * @param uri The base64 or relative uri
  82302. * @returns A promise that resolves with the loaded data when the load is complete
  82303. */
  82304. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82305. /**
  82306. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82307. * @param babylonObject the Babylon object with metadata
  82308. * @param pointer the JSON pointer
  82309. */
  82310. static AddPointerMetadata(babylonObject: {
  82311. metadata: any;
  82312. }, pointer: string): void;
  82313. private static _GetTextureWrapMode;
  82314. private static _GetTextureSamplingMode;
  82315. private static _GetTypedArrayConstructor;
  82316. private static _GetTypedArray;
  82317. private static _GetNumComponents;
  82318. private static _ValidateUri;
  82319. /** @hidden */
  82320. static _GetDrawMode(context: string, mode: number | undefined): number;
  82321. private _compileMaterialsAsync;
  82322. private _compileShadowGeneratorsAsync;
  82323. private _forEachExtensions;
  82324. private _applyExtensions;
  82325. private _extensionsOnLoading;
  82326. private _extensionsOnReady;
  82327. private _extensionsLoadSceneAsync;
  82328. private _extensionsLoadNodeAsync;
  82329. private _extensionsLoadCameraAsync;
  82330. private _extensionsLoadVertexDataAsync;
  82331. private _extensionsLoadMeshPrimitiveAsync;
  82332. private _extensionsLoadMaterialAsync;
  82333. private _extensionsCreateMaterial;
  82334. private _extensionsLoadMaterialPropertiesAsync;
  82335. private _extensionsLoadTextureInfoAsync;
  82336. private _extensionsLoadTextureAsync;
  82337. private _extensionsLoadAnimationAsync;
  82338. private _extensionsLoadSkinAsync;
  82339. private _extensionsLoadUriAsync;
  82340. private _extensionsLoadBufferViewAsync;
  82341. private _extensionsLoadBufferAsync;
  82342. /**
  82343. * Helper method called by a loader extension to load an glTF extension.
  82344. * @param context The context when loading the asset
  82345. * @param property The glTF property to load the extension from
  82346. * @param extensionName The name of the extension to load
  82347. * @param actionAsync The action to run
  82348. * @returns The promise returned by actionAsync or null if the extension does not exist
  82349. */
  82350. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82351. /**
  82352. * Helper method called by a loader extension to load a glTF extra.
  82353. * @param context The context when loading the asset
  82354. * @param property The glTF property to load the extra from
  82355. * @param extensionName The name of the extension to load
  82356. * @param actionAsync The action to run
  82357. * @returns The promise returned by actionAsync or null if the extra does not exist
  82358. */
  82359. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82360. /**
  82361. * Checks for presence of an extension.
  82362. * @param name The name of the extension to check
  82363. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82364. */
  82365. isExtensionUsed(name: string): boolean;
  82366. /**
  82367. * Increments the indentation level and logs a message.
  82368. * @param message The message to log
  82369. */
  82370. logOpen(message: string): void;
  82371. /**
  82372. * Decrements the indentation level.
  82373. */
  82374. logClose(): void;
  82375. /**
  82376. * Logs a message
  82377. * @param message The message to log
  82378. */
  82379. log(message: string): void;
  82380. /**
  82381. * Starts a performance counter.
  82382. * @param counterName The name of the performance counter
  82383. */
  82384. startPerformanceCounter(counterName: string): void;
  82385. /**
  82386. * Ends a performance counter.
  82387. * @param counterName The name of the performance counter
  82388. */
  82389. endPerformanceCounter(counterName: string): void;
  82390. }
  82391. }
  82392. declare module BABYLON.GLTF2.Loader.Extensions {
  82393. /** @hidden */
  82394. interface IEXTLightsImageBased_LightImageBased {
  82395. _babylonTexture?: BaseTexture;
  82396. _loaded?: Promise<void>;
  82397. }
  82398. /**
  82399. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82400. */
  82401. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82402. /**
  82403. * The name of this extension.
  82404. */
  82405. readonly name: string;
  82406. /**
  82407. * Defines whether this extension is enabled.
  82408. */
  82409. enabled: boolean;
  82410. private _loader;
  82411. private _lights?;
  82412. /** @hidden */
  82413. constructor(loader: GLTFLoader);
  82414. /** @hidden */
  82415. dispose(): void;
  82416. /** @hidden */
  82417. onLoading(): void;
  82418. /** @hidden */
  82419. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82420. private _loadLightAsync;
  82421. }
  82422. }
  82423. declare module BABYLON.GLTF2.Loader.Extensions {
  82424. /**
  82425. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82426. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82427. * !!! Experimental Extension Subject to Changes !!!
  82428. */
  82429. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82430. /**
  82431. * The name of this extension.
  82432. */
  82433. readonly name: string;
  82434. /**
  82435. * Defines whether this extension is enabled.
  82436. */
  82437. enabled: boolean;
  82438. private _loader;
  82439. /** @hidden */
  82440. constructor(loader: GLTFLoader);
  82441. /** @hidden */
  82442. dispose(): void;
  82443. /** @hidden */
  82444. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82445. }
  82446. }
  82447. declare module BABYLON.GLTF2.Loader.Extensions {
  82448. /**
  82449. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82450. */
  82451. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82452. /** The name of this extension. */
  82453. readonly name: string;
  82454. /** Defines whether this extension is enabled. */
  82455. enabled: boolean;
  82456. private _loader;
  82457. /** @hidden */
  82458. constructor(loader: GLTFLoader);
  82459. /** @hidden */
  82460. dispose(): void;
  82461. /** @hidden */
  82462. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82463. }
  82464. }
  82465. declare module BABYLON.GLTF2.Loader.Extensions {
  82466. /**
  82467. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82468. */
  82469. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82470. /**
  82471. * The name of this extension.
  82472. */
  82473. readonly name: string;
  82474. /**
  82475. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82476. */
  82477. dracoCompression?: DracoCompression;
  82478. /**
  82479. * Defines whether this extension is enabled.
  82480. */
  82481. enabled: boolean;
  82482. private _loader;
  82483. /** @hidden */
  82484. constructor(loader: GLTFLoader);
  82485. /** @hidden */
  82486. dispose(): void;
  82487. /** @hidden */
  82488. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82489. }
  82490. }
  82491. declare module BABYLON.GLTF2.Loader.Extensions {
  82492. /**
  82493. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82494. */
  82495. export class KHR_lights implements IGLTFLoaderExtension {
  82496. /**
  82497. * The name of this extension.
  82498. */
  82499. readonly name: string;
  82500. /**
  82501. * Defines whether this extension is enabled.
  82502. */
  82503. enabled: boolean;
  82504. private _loader;
  82505. private _lights?;
  82506. /** @hidden */
  82507. constructor(loader: GLTFLoader);
  82508. /** @hidden */
  82509. dispose(): void;
  82510. /** @hidden */
  82511. onLoading(): void;
  82512. /** @hidden */
  82513. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82514. }
  82515. }
  82516. declare module BABYLON.GLTF2.Loader.Extensions {
  82517. /**
  82518. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82519. */
  82520. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82521. /**
  82522. * The name of this extension.
  82523. */
  82524. readonly name: string;
  82525. /**
  82526. * Defines whether this extension is enabled.
  82527. */
  82528. enabled: boolean;
  82529. /**
  82530. * Defines a number that determines the order the extensions are applied.
  82531. */
  82532. order: number;
  82533. private _loader;
  82534. /** @hidden */
  82535. constructor(loader: GLTFLoader);
  82536. /** @hidden */
  82537. dispose(): void;
  82538. /** @hidden */
  82539. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82540. private _loadSpecularGlossinessPropertiesAsync;
  82541. }
  82542. }
  82543. declare module BABYLON.GLTF2.Loader.Extensions {
  82544. /**
  82545. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82546. */
  82547. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82548. /**
  82549. * The name of this extension.
  82550. */
  82551. readonly name: string;
  82552. /**
  82553. * Defines whether this extension is enabled.
  82554. */
  82555. enabled: boolean;
  82556. /**
  82557. * Defines a number that determines the order the extensions are applied.
  82558. */
  82559. order: number;
  82560. private _loader;
  82561. /** @hidden */
  82562. constructor(loader: GLTFLoader);
  82563. /** @hidden */
  82564. dispose(): void;
  82565. /** @hidden */
  82566. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82567. private _loadUnlitPropertiesAsync;
  82568. }
  82569. }
  82570. declare module BABYLON.GLTF2.Loader.Extensions {
  82571. /**
  82572. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82573. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82574. * !!! Experimental Extension Subject to Changes !!!
  82575. */
  82576. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82577. /**
  82578. * The name of this extension.
  82579. */
  82580. readonly name: string;
  82581. /**
  82582. * Defines whether this extension is enabled.
  82583. */
  82584. enabled: boolean;
  82585. /**
  82586. * Defines a number that determines the order the extensions are applied.
  82587. */
  82588. order: number;
  82589. private _loader;
  82590. /** @hidden */
  82591. constructor(loader: GLTFLoader);
  82592. /** @hidden */
  82593. dispose(): void;
  82594. /** @hidden */
  82595. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82596. private _loadClearCoatPropertiesAsync;
  82597. }
  82598. }
  82599. declare module BABYLON.GLTF2.Loader.Extensions {
  82600. /**
  82601. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82602. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82603. * !!! Experimental Extension Subject to Changes !!!
  82604. */
  82605. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82606. /**
  82607. * The name of this extension.
  82608. */
  82609. readonly name: string;
  82610. /**
  82611. * Defines whether this extension is enabled.
  82612. */
  82613. enabled: boolean;
  82614. /**
  82615. * Defines a number that determines the order the extensions are applied.
  82616. */
  82617. order: number;
  82618. private _loader;
  82619. /** @hidden */
  82620. constructor(loader: GLTFLoader);
  82621. /** @hidden */
  82622. dispose(): void;
  82623. /** @hidden */
  82624. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82625. private _loadSheenPropertiesAsync;
  82626. }
  82627. }
  82628. declare module BABYLON.GLTF2.Loader.Extensions {
  82629. /**
  82630. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82631. * !!! Experimental Extension Subject to Changes !!!
  82632. */
  82633. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82634. /**
  82635. * The name of this extension.
  82636. */
  82637. readonly name: string;
  82638. /**
  82639. * Defines whether this extension is enabled.
  82640. */
  82641. enabled: boolean;
  82642. /**
  82643. * Defines a number that determines the order the extensions are applied.
  82644. */
  82645. order: number;
  82646. private _loader;
  82647. /** @hidden */
  82648. constructor(loader: GLTFLoader);
  82649. /** @hidden */
  82650. dispose(): void;
  82651. /** @hidden */
  82652. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82653. private _loadSpecularPropertiesAsync;
  82654. }
  82655. }
  82656. declare module BABYLON.GLTF2.Loader.Extensions {
  82657. /**
  82658. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82659. * !!! Experimental Extension Subject to Changes !!!
  82660. */
  82661. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82662. /**
  82663. * Default ior Value from the spec.
  82664. */
  82665. private static readonly _DEFAULT_IOR;
  82666. /**
  82667. * The name of this extension.
  82668. */
  82669. readonly name: string;
  82670. /**
  82671. * Defines whether this extension is enabled.
  82672. */
  82673. enabled: boolean;
  82674. /**
  82675. * Defines a number that determines the order the extensions are applied.
  82676. */
  82677. order: number;
  82678. private _loader;
  82679. /** @hidden */
  82680. constructor(loader: GLTFLoader);
  82681. /** @hidden */
  82682. dispose(): void;
  82683. /** @hidden */
  82684. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82685. private _loadIorPropertiesAsync;
  82686. }
  82687. }
  82688. declare module BABYLON.GLTF2.Loader.Extensions {
  82689. /**
  82690. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82691. * !!! Experimental Extension Subject to Changes !!!
  82692. */
  82693. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82694. /**
  82695. * The name of this extension.
  82696. */
  82697. readonly name: string;
  82698. /**
  82699. * Defines whether this extension is enabled.
  82700. */
  82701. enabled: boolean;
  82702. private _loader;
  82703. private _variants?;
  82704. /** @hidden */
  82705. constructor(loader: GLTFLoader);
  82706. /** @hidden */
  82707. dispose(): void;
  82708. /**
  82709. * Gets the list of available variant names for this asset.
  82710. * @param rootMesh The glTF root mesh
  82711. * @returns the list of all the variant names for this model
  82712. */
  82713. static GetAvailableVariants(rootMesh: Mesh): string[];
  82714. /**
  82715. * Gets the list of available variant names for this asset.
  82716. * @param rootMesh The glTF root mesh
  82717. * @returns the list of all the variant names for this model
  82718. */
  82719. getAvailableVariants(rootMesh: Mesh): string[];
  82720. /**
  82721. * Select a variant given a variant name or a list of variant names.
  82722. * @param rootMesh The glTF root mesh
  82723. * @param variantName The variant name(s) to select.
  82724. */
  82725. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82726. /**
  82727. * Select a variant given a variant name or a list of variant names.
  82728. * @param rootMesh The glTF root mesh
  82729. * @param variantName The variant name(s) to select.
  82730. */
  82731. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82732. /**
  82733. * Reset back to the original before selecting a variant.
  82734. * @param rootMesh The glTF root mesh
  82735. */
  82736. static Reset(rootMesh: Mesh): void;
  82737. /**
  82738. * Reset back to the original before selecting a variant.
  82739. * @param rootMesh The glTF root mesh
  82740. */
  82741. reset(rootMesh: Mesh): void;
  82742. /**
  82743. * Gets the last selected variant name(s) or null if original.
  82744. * @param rootMesh The glTF root mesh
  82745. * @returns The selected variant name(s).
  82746. */
  82747. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82748. /**
  82749. * Gets the last selected variant name(s) or null if original.
  82750. * @param rootMesh The glTF root mesh
  82751. * @returns The selected variant name(s).
  82752. */
  82753. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82754. private static _GetExtensionMetadata;
  82755. /** @hidden */
  82756. onLoading(): void;
  82757. /** @hidden */
  82758. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82759. }
  82760. }
  82761. declare module BABYLON.GLTF2.Loader.Extensions {
  82762. /**
  82763. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82764. * !!! Experimental Extension Subject to Changes !!!
  82765. */
  82766. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82767. /**
  82768. * The name of this extension.
  82769. */
  82770. readonly name: string;
  82771. /**
  82772. * Defines whether this extension is enabled.
  82773. */
  82774. enabled: boolean;
  82775. /**
  82776. * Defines a number that determines the order the extensions are applied.
  82777. */
  82778. order: number;
  82779. private _loader;
  82780. /** @hidden */
  82781. constructor(loader: GLTFLoader);
  82782. /** @hidden */
  82783. dispose(): void;
  82784. /** @hidden */
  82785. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82786. private _loadTransparentPropertiesAsync;
  82787. }
  82788. }
  82789. declare module BABYLON.GLTF2.Loader.Extensions {
  82790. /**
  82791. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82792. */
  82793. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82794. /**
  82795. * The name of this extension.
  82796. */
  82797. readonly name: string;
  82798. /**
  82799. * Defines whether this extension is enabled.
  82800. */
  82801. enabled: boolean;
  82802. /** @hidden */
  82803. constructor(loader: GLTFLoader);
  82804. /** @hidden */
  82805. dispose(): void;
  82806. }
  82807. }
  82808. declare module BABYLON.GLTF2.Loader.Extensions {
  82809. /**
  82810. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82811. * !!! Experimental Extension Subject to Changes !!!
  82812. */
  82813. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82814. /** The name of this extension. */
  82815. readonly name: string;
  82816. /** Defines whether this extension is enabled. */
  82817. enabled: boolean;
  82818. private _loader;
  82819. /** @hidden */
  82820. constructor(loader: GLTFLoader);
  82821. /** @hidden */
  82822. dispose(): void;
  82823. /** @hidden */
  82824. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82825. }
  82826. }
  82827. declare module BABYLON.GLTF2.Loader.Extensions {
  82828. /**
  82829. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82830. */
  82831. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82832. /**
  82833. * The name of this extension.
  82834. */
  82835. readonly name: string;
  82836. /**
  82837. * Defines whether this extension is enabled.
  82838. */
  82839. enabled: boolean;
  82840. private _loader;
  82841. /** @hidden */
  82842. constructor(loader: GLTFLoader);
  82843. /** @hidden */
  82844. dispose(): void;
  82845. /** @hidden */
  82846. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82847. }
  82848. }
  82849. declare module BABYLON.GLTF2.Loader.Extensions {
  82850. /**
  82851. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82852. * !!! Experimental Extension Subject to Changes !!!
  82853. */
  82854. export class KHR_xmp implements IGLTFLoaderExtension {
  82855. /**
  82856. * The name of this extension.
  82857. */
  82858. readonly name: string;
  82859. /**
  82860. * Defines whether this extension is enabled.
  82861. */
  82862. enabled: boolean;
  82863. /**
  82864. * Defines a number that determines the order the extensions are applied.
  82865. */
  82866. order: number;
  82867. private _loader;
  82868. /** @hidden */
  82869. constructor(loader: GLTFLoader);
  82870. /** @hidden */
  82871. dispose(): void;
  82872. /**
  82873. * Called after the loader state changes to LOADING.
  82874. */
  82875. onLoading(): void;
  82876. }
  82877. }
  82878. declare module BABYLON.GLTF2.Loader.Extensions {
  82879. /**
  82880. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82881. */
  82882. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82883. /**
  82884. * The name of this extension.
  82885. */
  82886. readonly name: string;
  82887. /**
  82888. * Defines whether this extension is enabled.
  82889. */
  82890. enabled: boolean;
  82891. private _loader;
  82892. private _clips;
  82893. private _emitters;
  82894. /** @hidden */
  82895. constructor(loader: GLTFLoader);
  82896. /** @hidden */
  82897. dispose(): void;
  82898. /** @hidden */
  82899. onLoading(): void;
  82900. /** @hidden */
  82901. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82902. /** @hidden */
  82903. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82904. /** @hidden */
  82905. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82906. private _loadClipAsync;
  82907. private _loadEmitterAsync;
  82908. private _getEventAction;
  82909. private _loadAnimationEventAsync;
  82910. }
  82911. }
  82912. declare module BABYLON.GLTF2.Loader.Extensions {
  82913. /**
  82914. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82915. */
  82916. export class MSFT_lod implements IGLTFLoaderExtension {
  82917. /**
  82918. * The name of this extension.
  82919. */
  82920. readonly name: string;
  82921. /**
  82922. * Defines whether this extension is enabled.
  82923. */
  82924. enabled: boolean;
  82925. /**
  82926. * Defines a number that determines the order the extensions are applied.
  82927. */
  82928. order: number;
  82929. /**
  82930. * Maximum number of LODs to load, starting from the lowest LOD.
  82931. */
  82932. maxLODsToLoad: number;
  82933. /**
  82934. * Observable raised when all node LODs of one level are loaded.
  82935. * The event data is the index of the loaded LOD starting from zero.
  82936. * Dispose the loader to cancel the loading of the next level of LODs.
  82937. */
  82938. onNodeLODsLoadedObservable: Observable<number>;
  82939. /**
  82940. * Observable raised when all material LODs of one level are loaded.
  82941. * The event data is the index of the loaded LOD starting from zero.
  82942. * Dispose the loader to cancel the loading of the next level of LODs.
  82943. */
  82944. onMaterialLODsLoadedObservable: Observable<number>;
  82945. private _loader;
  82946. private _bufferLODs;
  82947. private _nodeIndexLOD;
  82948. private _nodeSignalLODs;
  82949. private _nodePromiseLODs;
  82950. private _nodeBufferLODs;
  82951. private _materialIndexLOD;
  82952. private _materialSignalLODs;
  82953. private _materialPromiseLODs;
  82954. private _materialBufferLODs;
  82955. /** @hidden */
  82956. constructor(loader: GLTFLoader);
  82957. /** @hidden */
  82958. dispose(): void;
  82959. /** @hidden */
  82960. onReady(): void;
  82961. /** @hidden */
  82962. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82963. /** @hidden */
  82964. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82965. /** @hidden */
  82966. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82967. /** @hidden */
  82968. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82969. /** @hidden */
  82970. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82971. private _loadBufferLOD;
  82972. /**
  82973. * Gets an array of LOD properties from lowest to highest.
  82974. */
  82975. private _getLODs;
  82976. private _disposeTransformNode;
  82977. private _disposeMaterials;
  82978. }
  82979. }
  82980. declare module BABYLON.GLTF2.Loader.Extensions {
  82981. /** @hidden */
  82982. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82983. readonly name: string;
  82984. enabled: boolean;
  82985. private _loader;
  82986. constructor(loader: GLTFLoader);
  82987. dispose(): void;
  82988. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82989. }
  82990. }
  82991. declare module BABYLON.GLTF2.Loader.Extensions {
  82992. /** @hidden */
  82993. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82994. readonly name: string;
  82995. enabled: boolean;
  82996. private _loader;
  82997. constructor(loader: GLTFLoader);
  82998. dispose(): void;
  82999. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83000. }
  83001. }
  83002. declare module BABYLON.GLTF2.Loader.Extensions {
  83003. /**
  83004. * Store glTF extras (if present) in BJS objects' metadata
  83005. */
  83006. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83007. /**
  83008. * The name of this extension.
  83009. */
  83010. readonly name: string;
  83011. /**
  83012. * Defines whether this extension is enabled.
  83013. */
  83014. enabled: boolean;
  83015. private _loader;
  83016. private _assignExtras;
  83017. /** @hidden */
  83018. constructor(loader: GLTFLoader);
  83019. /** @hidden */
  83020. dispose(): void;
  83021. /** @hidden */
  83022. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83023. /** @hidden */
  83024. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83025. /** @hidden */
  83026. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83027. }
  83028. }
  83029. declare module BABYLON {
  83030. /**
  83031. * Class reading and parsing the MTL file bundled with the obj file.
  83032. */
  83033. export class MTLFileLoader {
  83034. /**
  83035. * Invert Y-Axis of referenced textures on load
  83036. */
  83037. static INVERT_TEXTURE_Y: boolean;
  83038. /**
  83039. * All material loaded from the mtl will be set here
  83040. */
  83041. materials: StandardMaterial[];
  83042. /**
  83043. * This function will read the mtl file and create each material described inside
  83044. * This function could be improve by adding :
  83045. * -some component missing (Ni, Tf...)
  83046. * -including the specific options available
  83047. *
  83048. * @param scene defines the scene the material will be created in
  83049. * @param data defines the mtl data to parse
  83050. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83051. * @param forAssetContainer defines if the material should be registered in the scene
  83052. */
  83053. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83054. /**
  83055. * Gets the texture for the material.
  83056. *
  83057. * If the material is imported from input file,
  83058. * We sanitize the url to ensure it takes the textre from aside the material.
  83059. *
  83060. * @param rootUrl The root url to load from
  83061. * @param value The value stored in the mtl
  83062. * @return The Texture
  83063. */
  83064. private static _getTexture;
  83065. }
  83066. }
  83067. declare module BABYLON {
  83068. /**
  83069. * Options for loading OBJ/MTL files
  83070. */
  83071. type MeshLoadOptions = {
  83072. /**
  83073. * Defines if UVs are optimized by default during load.
  83074. */
  83075. OptimizeWithUV: boolean;
  83076. /**
  83077. * Defines custom scaling of UV coordinates of loaded meshes.
  83078. */
  83079. UVScaling: Vector2;
  83080. /**
  83081. * Invert model on y-axis (does a model scaling inversion)
  83082. */
  83083. InvertY: boolean;
  83084. /**
  83085. * Invert Y-Axis of referenced textures on load
  83086. */
  83087. InvertTextureY: boolean;
  83088. /**
  83089. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83090. */
  83091. ImportVertexColors: boolean;
  83092. /**
  83093. * Compute the normals for the model, even if normals are present in the file.
  83094. */
  83095. ComputeNormals: boolean;
  83096. /**
  83097. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83098. */
  83099. SkipMaterials: boolean;
  83100. /**
  83101. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83102. */
  83103. MaterialLoadingFailsSilently: boolean;
  83104. };
  83105. /**
  83106. * OBJ file type loader.
  83107. * This is a babylon scene loader plugin.
  83108. */
  83109. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83110. /**
  83111. * Defines if UVs are optimized by default during load.
  83112. */
  83113. static OPTIMIZE_WITH_UV: boolean;
  83114. /**
  83115. * Invert model on y-axis (does a model scaling inversion)
  83116. */
  83117. static INVERT_Y: boolean;
  83118. /**
  83119. * Invert Y-Axis of referenced textures on load
  83120. */
  83121. static get INVERT_TEXTURE_Y(): boolean;
  83122. static set INVERT_TEXTURE_Y(value: boolean);
  83123. /**
  83124. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83125. */
  83126. static IMPORT_VERTEX_COLORS: boolean;
  83127. /**
  83128. * Compute the normals for the model, even if normals are present in the file.
  83129. */
  83130. static COMPUTE_NORMALS: boolean;
  83131. /**
  83132. * Defines custom scaling of UV coordinates of loaded meshes.
  83133. */
  83134. static UV_SCALING: Vector2;
  83135. /**
  83136. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83137. */
  83138. static SKIP_MATERIALS: boolean;
  83139. /**
  83140. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83141. *
  83142. * Defaults to true for backwards compatibility.
  83143. */
  83144. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83145. /**
  83146. * Defines the name of the plugin.
  83147. */
  83148. name: string;
  83149. /**
  83150. * Defines the extension the plugin is able to load.
  83151. */
  83152. extensions: string;
  83153. /** @hidden */
  83154. obj: RegExp;
  83155. /** @hidden */
  83156. group: RegExp;
  83157. /** @hidden */
  83158. mtllib: RegExp;
  83159. /** @hidden */
  83160. usemtl: RegExp;
  83161. /** @hidden */
  83162. smooth: RegExp;
  83163. /** @hidden */
  83164. vertexPattern: RegExp;
  83165. /** @hidden */
  83166. normalPattern: RegExp;
  83167. /** @hidden */
  83168. uvPattern: RegExp;
  83169. /** @hidden */
  83170. facePattern1: RegExp;
  83171. /** @hidden */
  83172. facePattern2: RegExp;
  83173. /** @hidden */
  83174. facePattern3: RegExp;
  83175. /** @hidden */
  83176. facePattern4: RegExp;
  83177. /** @hidden */
  83178. facePattern5: RegExp;
  83179. private _forAssetContainer;
  83180. private _meshLoadOptions;
  83181. /**
  83182. * Creates loader for .OBJ files
  83183. *
  83184. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83185. */
  83186. constructor(meshLoadOptions?: MeshLoadOptions);
  83187. private static get currentMeshLoadOptions();
  83188. /**
  83189. * Calls synchronously the MTL file attached to this obj.
  83190. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83191. * Without this function materials are not displayed in the first frame (but displayed after).
  83192. * In consequence it is impossible to get material information in your HTML file
  83193. *
  83194. * @param url The URL of the MTL file
  83195. * @param rootUrl
  83196. * @param onSuccess Callback function to be called when the MTL file is loaded
  83197. * @private
  83198. */
  83199. private _loadMTL;
  83200. /**
  83201. * Instantiates a OBJ file loader plugin.
  83202. * @returns the created plugin
  83203. */
  83204. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83205. /**
  83206. * If the data string can be loaded directly.
  83207. *
  83208. * @param data string containing the file data
  83209. * @returns if the data can be loaded directly
  83210. */
  83211. canDirectLoad(data: string): boolean;
  83212. /**
  83213. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83214. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83215. * @param scene the scene the meshes should be added to
  83216. * @param data the OBJ data to load
  83217. * @param rootUrl root url to load from
  83218. * @param onProgress event that fires when loading progress has occured
  83219. * @param fileName Defines the name of the file to load
  83220. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83221. */
  83222. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83223. meshes: AbstractMesh[];
  83224. particleSystems: IParticleSystem[];
  83225. skeletons: Skeleton[];
  83226. animationGroups: AnimationGroup[];
  83227. }>;
  83228. /**
  83229. * Imports all objects from the loaded OBJ data and adds them to the scene
  83230. * @param scene the scene the objects should be added to
  83231. * @param data the OBJ data to load
  83232. * @param rootUrl root url to load from
  83233. * @param onProgress event that fires when loading progress has occured
  83234. * @param fileName Defines the name of the file to load
  83235. * @returns a promise which completes when objects have been loaded to the scene
  83236. */
  83237. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83238. /**
  83239. * Load into an asset container.
  83240. * @param scene The scene to load into
  83241. * @param data The data to import
  83242. * @param rootUrl The root url for scene and resources
  83243. * @param onProgress The callback when the load progresses
  83244. * @param fileName Defines the name of the file to load
  83245. * @returns The loaded asset container
  83246. */
  83247. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83248. /**
  83249. * Read the OBJ file and create an Array of meshes.
  83250. * Each mesh contains all information given by the OBJ and the MTL file.
  83251. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83252. *
  83253. * @param meshesNames
  83254. * @param scene Scene The scene where are displayed the data
  83255. * @param data String The content of the obj file
  83256. * @param rootUrl String The path to the folder
  83257. * @returns Array<AbstractMesh>
  83258. * @private
  83259. */
  83260. private _parseSolid;
  83261. }
  83262. }
  83263. declare module BABYLON {
  83264. /**
  83265. * STL file type loader.
  83266. * This is a babylon scene loader plugin.
  83267. */
  83268. export class STLFileLoader implements ISceneLoaderPlugin {
  83269. /** @hidden */
  83270. solidPattern: RegExp;
  83271. /** @hidden */
  83272. facetsPattern: RegExp;
  83273. /** @hidden */
  83274. normalPattern: RegExp;
  83275. /** @hidden */
  83276. vertexPattern: RegExp;
  83277. /**
  83278. * Defines the name of the plugin.
  83279. */
  83280. name: string;
  83281. /**
  83282. * Defines the extensions the stl loader is able to load.
  83283. * force data to come in as an ArrayBuffer
  83284. * we'll convert to string if it looks like it's an ASCII .stl
  83285. */
  83286. extensions: ISceneLoaderPluginExtensions;
  83287. /**
  83288. * Import meshes into a scene.
  83289. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83290. * @param scene The scene to import into
  83291. * @param data The data to import
  83292. * @param rootUrl The root url for scene and resources
  83293. * @param meshes The meshes array to import into
  83294. * @param particleSystems The particle systems array to import into
  83295. * @param skeletons The skeletons array to import into
  83296. * @param onError The callback when import fails
  83297. * @returns True if successful or false otherwise
  83298. */
  83299. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83300. /**
  83301. * Load into a scene.
  83302. * @param scene The scene to load into
  83303. * @param data The data to import
  83304. * @param rootUrl The root url for scene and resources
  83305. * @param onError The callback when import fails
  83306. * @returns true if successful or false otherwise
  83307. */
  83308. load(scene: Scene, data: any, rootUrl: string): boolean;
  83309. /**
  83310. * Load into an asset container.
  83311. * @param scene The scene to load into
  83312. * @param data The data to import
  83313. * @param rootUrl The root url for scene and resources
  83314. * @param onError The callback when import fails
  83315. * @returns The loaded asset container
  83316. */
  83317. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83318. private _isBinary;
  83319. private _parseBinary;
  83320. private _parseASCII;
  83321. }
  83322. }
  83323. declare module BABYLON {
  83324. /**
  83325. * Class for generating OBJ data from a Babylon scene.
  83326. */
  83327. export class OBJExport {
  83328. /**
  83329. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83330. * @param mesh defines the list of meshes to serialize
  83331. * @param materials defines if materials should be exported
  83332. * @param matlibname defines the name of the associated mtl file
  83333. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83334. * @returns the OBJ content
  83335. */
  83336. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83337. /**
  83338. * Exports the material(s) of a mesh in .MTL file format (text)
  83339. * @param mesh defines the mesh to extract the material from
  83340. * @returns the mtl content
  83341. */
  83342. static MTL(mesh: Mesh): string;
  83343. }
  83344. }
  83345. declare module BABYLON {
  83346. /** @hidden */
  83347. export var __IGLTFExporterExtension: number;
  83348. /**
  83349. * Interface for extending the exporter
  83350. * @hidden
  83351. */
  83352. export interface IGLTFExporterExtension {
  83353. /**
  83354. * The name of this extension
  83355. */
  83356. readonly name: string;
  83357. /**
  83358. * Defines whether this extension is enabled
  83359. */
  83360. enabled: boolean;
  83361. /**
  83362. * Defines whether this extension is required
  83363. */
  83364. required: boolean;
  83365. }
  83366. }
  83367. declare module BABYLON.GLTF2.Exporter {
  83368. /** @hidden */
  83369. export var __IGLTFExporterExtensionV2: number;
  83370. /**
  83371. * Interface for a glTF exporter extension
  83372. * @hidden
  83373. */
  83374. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83375. /**
  83376. * Define this method to modify the default behavior before exporting a texture
  83377. * @param context The context when loading the asset
  83378. * @param babylonTexture The Babylon.js texture
  83379. * @param mimeType The mime-type of the generated image
  83380. * @returns A promise that resolves with the exported texture
  83381. */
  83382. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83383. /**
  83384. * Define this method to get notified when a texture info is created
  83385. * @param context The context when loading the asset
  83386. * @param textureInfo The glTF texture info
  83387. * @param babylonTexture The Babylon.js texture
  83388. */
  83389. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83390. /**
  83391. * Define this method to modify the default behavior when exporting texture info
  83392. * @param context The context when loading the asset
  83393. * @param meshPrimitive glTF mesh primitive
  83394. * @param babylonSubMesh Babylon submesh
  83395. * @param binaryWriter glTF serializer binary writer instance
  83396. * @returns nullable IMeshPrimitive promise
  83397. */
  83398. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83399. /**
  83400. * Define this method to modify the default behavior when exporting a node
  83401. * @param context The context when exporting the node
  83402. * @param node glTF node
  83403. * @param babylonNode BabylonJS node
  83404. * @returns nullable INode promise
  83405. */
  83406. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83407. [key: number]: number;
  83408. }): Promise<Nullable<INode>>;
  83409. /**
  83410. * Define this method to modify the default behavior when exporting a material
  83411. * @param material glTF material
  83412. * @param babylonMaterial BabylonJS material
  83413. * @returns nullable IMaterial promise
  83414. */
  83415. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83416. /**
  83417. * Define this method to return additional textures to export from a material
  83418. * @param material glTF material
  83419. * @param babylonMaterial BabylonJS material
  83420. * @returns List of textures
  83421. */
  83422. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83423. /** Gets a boolean indicating that this extension was used */
  83424. wasUsed: boolean;
  83425. /** Gets a boolean indicating that this extension is required for the file to work */
  83426. required: boolean;
  83427. /**
  83428. * Called after the exporter state changes to EXPORTING
  83429. */
  83430. onExporting?(): void;
  83431. }
  83432. }
  83433. declare module BABYLON.GLTF2.Exporter {
  83434. /**
  83435. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83436. * @hidden
  83437. */
  83438. export class _GLTFMaterialExporter {
  83439. /**
  83440. * Represents the dielectric specular values for R, G and B
  83441. */
  83442. private static readonly _DielectricSpecular;
  83443. /**
  83444. * Allows the maximum specular power to be defined for material calculations
  83445. */
  83446. private static readonly _MaxSpecularPower;
  83447. /**
  83448. * Mapping to store textures
  83449. */
  83450. private _textureMap;
  83451. /**
  83452. * Numeric tolerance value
  83453. */
  83454. private static readonly _Epsilon;
  83455. /**
  83456. * Reference to the glTF Exporter
  83457. */
  83458. private _exporter;
  83459. constructor(exporter: _Exporter);
  83460. /**
  83461. * Specifies if two colors are approximately equal in value
  83462. * @param color1 first color to compare to
  83463. * @param color2 second color to compare to
  83464. * @param epsilon threshold value
  83465. */
  83466. private static FuzzyEquals;
  83467. /**
  83468. * Gets the materials from a Babylon scene and converts them to glTF materials
  83469. * @param scene babylonjs scene
  83470. * @param mimeType texture mime type
  83471. * @param images array of images
  83472. * @param textures array of textures
  83473. * @param materials array of materials
  83474. * @param imageData mapping of texture names to base64 textures
  83475. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83476. */
  83477. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83478. /**
  83479. * Makes a copy of the glTF material without the texture parameters
  83480. * @param originalMaterial original glTF material
  83481. * @returns glTF material without texture parameters
  83482. */
  83483. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83484. /**
  83485. * Specifies if the material has any texture parameters present
  83486. * @param material glTF Material
  83487. * @returns boolean specifying if texture parameters are present
  83488. */
  83489. _hasTexturesPresent(material: IMaterial): boolean;
  83490. /**
  83491. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83492. * @param babylonStandardMaterial
  83493. * @returns glTF Metallic Roughness Material representation
  83494. */
  83495. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83496. /**
  83497. * Computes the metallic factor
  83498. * @param diffuse diffused value
  83499. * @param specular specular value
  83500. * @param oneMinusSpecularStrength one minus the specular strength
  83501. * @returns metallic value
  83502. */
  83503. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83504. /**
  83505. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83506. * @param glTFMaterial glTF material
  83507. * @param babylonMaterial Babylon material
  83508. */
  83509. private static _SetAlphaMode;
  83510. /**
  83511. * Converts a Babylon Standard Material to a glTF Material
  83512. * @param babylonStandardMaterial BJS Standard Material
  83513. * @param mimeType mime type to use for the textures
  83514. * @param images array of glTF image interfaces
  83515. * @param textures array of glTF texture interfaces
  83516. * @param materials array of glTF material interfaces
  83517. * @param imageData map of image file name to data
  83518. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83519. */
  83520. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83521. private _finishMaterial;
  83522. /**
  83523. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83524. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83525. * @param mimeType mime type to use for the textures
  83526. * @param images array of glTF image interfaces
  83527. * @param textures array of glTF texture interfaces
  83528. * @param materials array of glTF material interfaces
  83529. * @param imageData map of image file name to data
  83530. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83531. */
  83532. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83533. /**
  83534. * Converts an image typed array buffer to a base64 image
  83535. * @param buffer typed array buffer
  83536. * @param width width of the image
  83537. * @param height height of the image
  83538. * @param mimeType mimetype of the image
  83539. * @returns base64 image string
  83540. */
  83541. private _createBase64FromCanvasAsync;
  83542. /**
  83543. * Generates a white texture based on the specified width and height
  83544. * @param width width of the texture in pixels
  83545. * @param height height of the texture in pixels
  83546. * @param scene babylonjs scene
  83547. * @returns white texture
  83548. */
  83549. private _createWhiteTexture;
  83550. /**
  83551. * 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
  83552. * @param texture1 first texture to resize
  83553. * @param texture2 second texture to resize
  83554. * @param scene babylonjs scene
  83555. * @returns resized textures or null
  83556. */
  83557. private _resizeTexturesToSameDimensions;
  83558. /**
  83559. * Converts an array of pixels to a Float32Array
  83560. * Throws an error if the pixel format is not supported
  83561. * @param pixels - array buffer containing pixel values
  83562. * @returns Float32 of pixels
  83563. */
  83564. private _convertPixelArrayToFloat32;
  83565. /**
  83566. * Convert Specular Glossiness Textures to Metallic Roughness
  83567. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83568. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83569. * @param diffuseTexture texture used to store diffuse information
  83570. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83571. * @param factors specular glossiness material factors
  83572. * @param mimeType the mime type to use for the texture
  83573. * @returns pbr metallic roughness interface or null
  83574. */
  83575. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83576. /**
  83577. * Converts specular glossiness material properties to metallic roughness
  83578. * @param specularGlossiness interface with specular glossiness material properties
  83579. * @returns interface with metallic roughness material properties
  83580. */
  83581. private _convertSpecularGlossinessToMetallicRoughness;
  83582. /**
  83583. * Calculates the surface reflectance, independent of lighting conditions
  83584. * @param color Color source to calculate brightness from
  83585. * @returns number representing the perceived brightness, or zero if color is undefined
  83586. */
  83587. private _getPerceivedBrightness;
  83588. /**
  83589. * Returns the maximum color component value
  83590. * @param color
  83591. * @returns maximum color component value, or zero if color is null or undefined
  83592. */
  83593. private _getMaxComponent;
  83594. /**
  83595. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83596. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83597. * @param mimeType mime type to use for the textures
  83598. * @param images array of glTF image interfaces
  83599. * @param textures array of glTF texture interfaces
  83600. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83601. * @param imageData map of image file name to data
  83602. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83603. * @returns glTF PBR Metallic Roughness factors
  83604. */
  83605. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83606. private _getGLTFTextureSampler;
  83607. private _getGLTFTextureWrapMode;
  83608. private _getGLTFTextureWrapModesSampler;
  83609. /**
  83610. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83611. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83612. * @param mimeType mime type to use for the textures
  83613. * @param images array of glTF image interfaces
  83614. * @param textures array of glTF texture interfaces
  83615. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83616. * @param imageData map of image file name to data
  83617. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83618. * @returns glTF PBR Metallic Roughness factors
  83619. */
  83620. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83621. /**
  83622. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83623. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83624. * @param mimeType mime type to use for the textures
  83625. * @param images array of glTF image interfaces
  83626. * @param textures array of glTF texture interfaces
  83627. * @param materials array of glTF material interfaces
  83628. * @param imageData map of image file name to data
  83629. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83630. */
  83631. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83632. private setMetallicRoughnessPbrMaterial;
  83633. private getPixelsFromTexture;
  83634. /**
  83635. * Extracts a texture from a Babylon texture into file data and glTF data
  83636. * @param babylonTexture Babylon texture to extract
  83637. * @param mimeType Mime Type of the babylonTexture
  83638. * @return glTF texture info, or null if the texture format is not supported
  83639. */
  83640. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83641. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83642. /**
  83643. * Builds a texture from base64 string
  83644. * @param base64Texture base64 texture string
  83645. * @param baseTextureName Name to use for the texture
  83646. * @param mimeType image mime type for the texture
  83647. * @param images array of images
  83648. * @param textures array of textures
  83649. * @param imageData map of image data
  83650. * @returns glTF texture info, or null if the texture format is not supported
  83651. */
  83652. private _getTextureInfoFromBase64;
  83653. }
  83654. }
  83655. declare module BABYLON {
  83656. /**
  83657. * Class for holding and downloading glTF file data
  83658. */
  83659. export class GLTFData {
  83660. /**
  83661. * Object which contains the file name as the key and its data as the value
  83662. */
  83663. glTFFiles: {
  83664. [fileName: string]: string | Blob;
  83665. };
  83666. /**
  83667. * Initializes the glTF file object
  83668. */
  83669. constructor();
  83670. /**
  83671. * Downloads the glTF data as files based on their names and data
  83672. */
  83673. downloadFiles(): void;
  83674. }
  83675. }
  83676. declare module BABYLON {
  83677. /**
  83678. * Holds a collection of exporter options and parameters
  83679. */
  83680. export interface IExportOptions {
  83681. /**
  83682. * Function which indicates whether a babylon node should be exported or not
  83683. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83684. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83685. */
  83686. shouldExportNode?(node: Node): boolean;
  83687. /**
  83688. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83689. * @param metadata source metadata to read from
  83690. * @returns the data to store to glTF node extras
  83691. */
  83692. metadataSelector?(metadata: any): any;
  83693. /**
  83694. * The sample rate to bake animation curves
  83695. */
  83696. animationSampleRate?: number;
  83697. /**
  83698. * Begin serialization without waiting for the scene to be ready
  83699. */
  83700. exportWithoutWaitingForScene?: boolean;
  83701. /**
  83702. * Indicates if coordinate system swapping root nodes should be included in export
  83703. */
  83704. includeCoordinateSystemConversionNodes?: boolean;
  83705. }
  83706. /**
  83707. * Class for generating glTF data from a Babylon scene.
  83708. */
  83709. export class GLTF2Export {
  83710. /**
  83711. * Exports the geometry of the scene to .gltf file format asynchronously
  83712. * @param scene Babylon scene with scene hierarchy information
  83713. * @param filePrefix File prefix to use when generating the glTF file
  83714. * @param options Exporter options
  83715. * @returns Returns an object with a .gltf file and associates texture names
  83716. * as keys and their data and paths as values
  83717. */
  83718. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83719. private static _PreExportAsync;
  83720. private static _PostExportAsync;
  83721. /**
  83722. * Exports the geometry of the scene to .glb file format asychronously
  83723. * @param scene Babylon scene with scene hierarchy information
  83724. * @param filePrefix File prefix to use when generating glb file
  83725. * @param options Exporter options
  83726. * @returns Returns an object with a .glb filename as key and data as value
  83727. */
  83728. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83729. }
  83730. }
  83731. declare module BABYLON.GLTF2.Exporter {
  83732. /**
  83733. * @hidden
  83734. */
  83735. export class _GLTFUtilities {
  83736. /**
  83737. * Creates a buffer view based on the supplied arguments
  83738. * @param bufferIndex index value of the specified buffer
  83739. * @param byteOffset byte offset value
  83740. * @param byteLength byte length of the bufferView
  83741. * @param byteStride byte distance between conequential elements
  83742. * @param name name of the buffer view
  83743. * @returns bufferView for glTF
  83744. */
  83745. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83746. /**
  83747. * Creates an accessor based on the supplied arguments
  83748. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83749. * @param name The name of the accessor
  83750. * @param type The type of the accessor
  83751. * @param componentType The datatype of components in the attribute
  83752. * @param count The number of attributes referenced by this accessor
  83753. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83754. * @param min Minimum value of each component in this attribute
  83755. * @param max Maximum value of each component in this attribute
  83756. * @returns accessor for glTF
  83757. */
  83758. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83759. /**
  83760. * Calculates the minimum and maximum values of an array of position floats
  83761. * @param positions Positions array of a mesh
  83762. * @param vertexStart Starting vertex offset to calculate min and max values
  83763. * @param vertexCount Number of vertices to check for min and max values
  83764. * @returns min number array and max number array
  83765. */
  83766. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83767. min: number[];
  83768. max: number[];
  83769. };
  83770. /**
  83771. * Converts a new right-handed Vector3
  83772. * @param vector vector3 array
  83773. * @returns right-handed Vector3
  83774. */
  83775. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83776. /**
  83777. * Converts a Vector3 to right-handed
  83778. * @param vector Vector3 to convert to right-handed
  83779. */
  83780. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83781. /**
  83782. * Converts a three element number array to right-handed
  83783. * @param vector number array to convert to right-handed
  83784. */
  83785. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83786. /**
  83787. * Converts a new right-handed Vector3
  83788. * @param vector vector3 array
  83789. * @returns right-handed Vector3
  83790. */
  83791. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83792. /**
  83793. * Converts a Vector3 to right-handed
  83794. * @param vector Vector3 to convert to right-handed
  83795. */
  83796. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83797. /**
  83798. * Converts a three element number array to right-handed
  83799. * @param vector number array to convert to right-handed
  83800. */
  83801. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83802. /**
  83803. * Converts a Vector4 to right-handed
  83804. * @param vector Vector4 to convert to right-handed
  83805. */
  83806. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83807. /**
  83808. * Converts a Vector4 to right-handed
  83809. * @param vector Vector4 to convert to right-handed
  83810. */
  83811. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83812. /**
  83813. * Converts a Quaternion to right-handed
  83814. * @param quaternion Source quaternion to convert to right-handed
  83815. */
  83816. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83817. /**
  83818. * Converts a Quaternion to right-handed
  83819. * @param quaternion Source quaternion to convert to right-handed
  83820. */
  83821. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83822. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83823. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83824. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83825. }
  83826. }
  83827. declare module BABYLON.GLTF2.Exporter {
  83828. /**
  83829. * Converts Babylon Scene into glTF 2.0.
  83830. * @hidden
  83831. */
  83832. export class _Exporter {
  83833. /**
  83834. * Stores the glTF to export
  83835. */
  83836. _glTF: IGLTF;
  83837. /**
  83838. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83839. */
  83840. _bufferViews: IBufferView[];
  83841. /**
  83842. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83843. */
  83844. _accessors: IAccessor[];
  83845. /**
  83846. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83847. */
  83848. _nodes: INode[];
  83849. /**
  83850. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83851. */
  83852. private _scenes;
  83853. /**
  83854. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83855. */
  83856. private _meshes;
  83857. /**
  83858. * Stores all the generated material information, which represents the appearance of each primitive
  83859. */
  83860. _materials: IMaterial[];
  83861. _materialMap: {
  83862. [materialID: number]: number;
  83863. };
  83864. /**
  83865. * Stores all the generated texture information, which is referenced by glTF materials
  83866. */
  83867. _textures: ITexture[];
  83868. /**
  83869. * Stores all the generated image information, which is referenced by glTF textures
  83870. */
  83871. _images: IImage[];
  83872. /**
  83873. * Stores all the texture samplers
  83874. */
  83875. _samplers: ISampler[];
  83876. /**
  83877. * Stores all the generated glTF skins
  83878. */
  83879. _skins: ISkin[];
  83880. /**
  83881. * Stores all the generated animation samplers, which is referenced by glTF animations
  83882. */
  83883. /**
  83884. * Stores the animations for glTF models
  83885. */
  83886. private _animations;
  83887. /**
  83888. * Stores the total amount of bytes stored in the glTF buffer
  83889. */
  83890. private _totalByteLength;
  83891. /**
  83892. * Stores a reference to the Babylon scene containing the source geometry and material information
  83893. */
  83894. _babylonScene: Scene;
  83895. /**
  83896. * Stores a map of the image data, where the key is the file name and the value
  83897. * is the image data
  83898. */
  83899. _imageData: {
  83900. [fileName: string]: {
  83901. data: Uint8Array;
  83902. mimeType: ImageMimeType;
  83903. };
  83904. };
  83905. protected _orderedImageData: Array<{
  83906. data: Uint8Array;
  83907. mimeType: ImageMimeType;
  83908. }>;
  83909. /**
  83910. * Stores a map of the unique id of a node to its index in the node array
  83911. */
  83912. _nodeMap: {
  83913. [key: number]: number;
  83914. };
  83915. /**
  83916. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83917. */
  83918. _convertToRightHandedSystem: boolean;
  83919. /**
  83920. * Specifies if a Babylon node should be converted to right-handed on export
  83921. */
  83922. _convertToRightHandedSystemMap: {
  83923. [nodeId: number]: boolean;
  83924. };
  83925. _includeCoordinateSystemConversionNodes: boolean;
  83926. /**
  83927. * Baked animation sample rate
  83928. */
  83929. private _animationSampleRate;
  83930. private _options;
  83931. private _localEngine;
  83932. _glTFMaterialExporter: _GLTFMaterialExporter;
  83933. private _extensions;
  83934. private static _ExtensionNames;
  83935. private static _ExtensionFactories;
  83936. private _applyExtension;
  83937. private _applyExtensions;
  83938. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83939. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83940. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83941. [key: number]: number;
  83942. }): Promise<Nullable<INode>>;
  83943. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83944. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83945. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83946. private _forEachExtensions;
  83947. private _extensionsOnExporting;
  83948. /**
  83949. * Load glTF serializer extensions
  83950. */
  83951. private _loadExtensions;
  83952. /**
  83953. * Creates a glTF Exporter instance, which can accept optional exporter options
  83954. * @param babylonScene Babylon scene object
  83955. * @param options Options to modify the behavior of the exporter
  83956. */
  83957. constructor(babylonScene: Scene, options?: IExportOptions);
  83958. dispose(): void;
  83959. /**
  83960. * Registers a glTF exporter extension
  83961. * @param name Name of the extension to export
  83962. * @param factory The factory function that creates the exporter extension
  83963. */
  83964. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83965. /**
  83966. * Un-registers an exporter extension
  83967. * @param name The name fo the exporter extension
  83968. * @returns A boolean indicating whether the extension has been un-registered
  83969. */
  83970. static UnregisterExtension(name: string): boolean;
  83971. /**
  83972. * Lazy load a local engine
  83973. */
  83974. _getLocalEngine(): Engine;
  83975. private reorderIndicesBasedOnPrimitiveMode;
  83976. /**
  83977. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83978. * clock-wise during export to glTF
  83979. * @param submesh BabylonJS submesh
  83980. * @param primitiveMode Primitive mode of the mesh
  83981. * @param sideOrientation the winding order of the submesh
  83982. * @param vertexBufferKind The type of vertex attribute
  83983. * @param meshAttributeArray The vertex attribute data
  83984. * @param byteOffset The offset to the binary data
  83985. * @param binaryWriter The binary data for the glTF file
  83986. * @param convertToRightHandedSystem Converts the values to right-handed
  83987. */
  83988. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83989. /**
  83990. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83991. * clock-wise during export to glTF
  83992. * @param submesh BabylonJS submesh
  83993. * @param primitiveMode Primitive mode of the mesh
  83994. * @param sideOrientation the winding order of the submesh
  83995. * @param vertexBufferKind The type of vertex attribute
  83996. * @param meshAttributeArray The vertex attribute data
  83997. * @param byteOffset The offset to the binary data
  83998. * @param binaryWriter The binary data for the glTF file
  83999. * @param convertToRightHandedSystem Converts the values to right-handed
  84000. */
  84001. private reorderTriangleFillMode;
  84002. /**
  84003. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84004. * clock-wise during export to glTF
  84005. * @param submesh BabylonJS submesh
  84006. * @param primitiveMode Primitive mode of the mesh
  84007. * @param sideOrientation the winding order of the submesh
  84008. * @param vertexBufferKind The type of vertex attribute
  84009. * @param meshAttributeArray The vertex attribute data
  84010. * @param byteOffset The offset to the binary data
  84011. * @param binaryWriter The binary data for the glTF file
  84012. * @param convertToRightHandedSystem Converts the values to right-handed
  84013. */
  84014. private reorderTriangleStripDrawMode;
  84015. /**
  84016. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84017. * clock-wise during export to glTF
  84018. * @param submesh BabylonJS submesh
  84019. * @param primitiveMode Primitive mode of the mesh
  84020. * @param sideOrientation the winding order of the submesh
  84021. * @param vertexBufferKind The type of vertex attribute
  84022. * @param meshAttributeArray The vertex attribute data
  84023. * @param byteOffset The offset to the binary data
  84024. * @param binaryWriter The binary data for the glTF file
  84025. * @param convertToRightHandedSystem Converts the values to right-handed
  84026. */
  84027. private reorderTriangleFanMode;
  84028. /**
  84029. * Writes the vertex attribute data to binary
  84030. * @param vertices The vertices to write to the binary writer
  84031. * @param byteOffset The offset into the binary writer to overwrite binary data
  84032. * @param vertexAttributeKind The vertex attribute type
  84033. * @param meshAttributeArray The vertex attribute data
  84034. * @param binaryWriter The writer containing the binary data
  84035. * @param convertToRightHandedSystem Converts the values to right-handed
  84036. */
  84037. private writeVertexAttributeData;
  84038. /**
  84039. * Writes mesh attribute data to a data buffer
  84040. * Returns the bytelength of the data
  84041. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84042. * @param meshAttributeArray Array containing the attribute data
  84043. * @param byteStride Specifies the space between data
  84044. * @param binaryWriter The buffer to write the binary data to
  84045. * @param convertToRightHandedSystem Converts the values to right-handed
  84046. */
  84047. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84048. /**
  84049. * Writes mesh attribute data to a data buffer
  84050. * Returns the bytelength of the data
  84051. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84052. * @param meshAttributeArray Array containing the attribute data
  84053. * @param byteStride Specifies the space between data
  84054. * @param binaryWriter The buffer to write the binary data to
  84055. * @param convertToRightHandedSystem Converts the values to right-handed
  84056. */
  84057. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84058. /**
  84059. * Generates glTF json data
  84060. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84061. * @param glTFPrefix Text to use when prefixing a glTF file
  84062. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84063. * @returns json data as string
  84064. */
  84065. private generateJSON;
  84066. /**
  84067. * Generates data for .gltf and .bin files based on the glTF prefix string
  84068. * @param glTFPrefix Text to use when prefixing a glTF file
  84069. * @param dispose Dispose the exporter
  84070. * @returns GLTFData with glTF file data
  84071. */
  84072. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84073. /**
  84074. * Creates a binary buffer for glTF
  84075. * @returns array buffer for binary data
  84076. */
  84077. private _generateBinaryAsync;
  84078. /**
  84079. * Pads the number to a multiple of 4
  84080. * @param num number to pad
  84081. * @returns padded number
  84082. */
  84083. private _getPadding;
  84084. /**
  84085. * @hidden
  84086. */
  84087. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84088. /**
  84089. * Sets the TRS for each node
  84090. * @param node glTF Node for storing the transformation data
  84091. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84092. * @param convertToRightHandedSystem Converts the values to right-handed
  84093. */
  84094. private setNodeTransformation;
  84095. private getVertexBufferFromMesh;
  84096. /**
  84097. * Creates a bufferview based on the vertices type for the Babylon mesh
  84098. * @param kind Indicates the type of vertices data
  84099. * @param componentType Indicates the numerical type used to store the data
  84100. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84101. * @param binaryWriter The buffer to write the bufferview data to
  84102. * @param convertToRightHandedSystem Converts the values to right-handed
  84103. */
  84104. private createBufferViewKind;
  84105. /**
  84106. * Creates a bufferview based on the vertices type for the Babylon mesh
  84107. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84108. * @param babylonMorphTarget the morph target to be exported
  84109. * @param binaryWriter The buffer to write the bufferview data to
  84110. * @param convertToRightHandedSystem Converts the values to right-handed
  84111. */
  84112. private setMorphTargetAttributes;
  84113. /**
  84114. * The primitive mode of the Babylon mesh
  84115. * @param babylonMesh The BabylonJS mesh
  84116. */
  84117. private getMeshPrimitiveMode;
  84118. /**
  84119. * Sets the primitive mode of the glTF mesh primitive
  84120. * @param meshPrimitive glTF mesh primitive
  84121. * @param primitiveMode The primitive mode
  84122. */
  84123. private setPrimitiveMode;
  84124. /**
  84125. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84126. * @param meshPrimitive glTF mesh primitive
  84127. * @param attributeKind vertex attribute
  84128. * @returns boolean specifying if uv coordinates are present
  84129. */
  84130. private setAttributeKind;
  84131. /**
  84132. * Sets data for the primitive attributes of each submesh
  84133. * @param mesh glTF Mesh object to store the primitive attribute information
  84134. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84135. * @param binaryWriter Buffer to write the attribute data to
  84136. * @param convertToRightHandedSystem Converts the values to right-handed
  84137. */
  84138. private setPrimitiveAttributesAsync;
  84139. /**
  84140. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84141. * @param node The node to check
  84142. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84143. */
  84144. private isBabylonCoordinateSystemConvertingNode;
  84145. /**
  84146. * Creates a glTF scene based on the array of meshes
  84147. * Returns the the total byte offset
  84148. * @param babylonScene Babylon scene to get the mesh data from
  84149. * @param binaryWriter Buffer to write binary data to
  84150. */
  84151. private createSceneAsync;
  84152. /**
  84153. * Creates a mapping of Node unique id to node index and handles animations
  84154. * @param babylonScene Babylon Scene
  84155. * @param nodes Babylon transform nodes
  84156. * @param binaryWriter Buffer to write binary data to
  84157. * @returns Node mapping of unique id to index
  84158. */
  84159. private createNodeMapAndAnimationsAsync;
  84160. /**
  84161. * Creates a glTF node from a Babylon mesh
  84162. * @param babylonMesh Source Babylon mesh
  84163. * @param binaryWriter Buffer for storing geometry data
  84164. * @param convertToRightHandedSystem Converts the values to right-handed
  84165. * @param nodeMap Node mapping of unique id to glTF node index
  84166. * @returns glTF node
  84167. */
  84168. private createNodeAsync;
  84169. /**
  84170. * Creates a glTF skin from a Babylon skeleton
  84171. * @param babylonScene Babylon Scene
  84172. * @param nodes Babylon transform nodes
  84173. * @param binaryWriter Buffer to write binary data to
  84174. * @returns Node mapping of unique id to index
  84175. */
  84176. private createSkinsAsync;
  84177. }
  84178. /**
  84179. * @hidden
  84180. *
  84181. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84182. */
  84183. export class _BinaryWriter {
  84184. /**
  84185. * Array buffer which stores all binary data
  84186. */
  84187. private _arrayBuffer;
  84188. /**
  84189. * View of the array buffer
  84190. */
  84191. private _dataView;
  84192. /**
  84193. * byte offset of data in array buffer
  84194. */
  84195. private _byteOffset;
  84196. /**
  84197. * Initialize binary writer with an initial byte length
  84198. * @param byteLength Initial byte length of the array buffer
  84199. */
  84200. constructor(byteLength: number);
  84201. /**
  84202. * Resize the array buffer to the specified byte length
  84203. * @param byteLength
  84204. */
  84205. private resizeBuffer;
  84206. /**
  84207. * Get an array buffer with the length of the byte offset
  84208. * @returns ArrayBuffer resized to the byte offset
  84209. */
  84210. getArrayBuffer(): ArrayBuffer;
  84211. /**
  84212. * Get the byte offset of the array buffer
  84213. * @returns byte offset
  84214. */
  84215. getByteOffset(): number;
  84216. /**
  84217. * Stores an UInt8 in the array buffer
  84218. * @param entry
  84219. * @param byteOffset If defined, specifies where to set the value as an offset.
  84220. */
  84221. setUInt8(entry: number, byteOffset?: number): void;
  84222. /**
  84223. * Stores an UInt16 in the array buffer
  84224. * @param entry
  84225. * @param byteOffset If defined, specifies where to set the value as an offset.
  84226. */
  84227. setUInt16(entry: number, byteOffset?: number): void;
  84228. /**
  84229. * Gets an UInt32 in the array buffer
  84230. * @param entry
  84231. * @param byteOffset If defined, specifies where to set the value as an offset.
  84232. */
  84233. getUInt32(byteOffset: number): number;
  84234. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84235. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84236. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84237. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84238. /**
  84239. * Stores a Float32 in the array buffer
  84240. * @param entry
  84241. */
  84242. setFloat32(entry: number, byteOffset?: number): void;
  84243. /**
  84244. * Stores an UInt32 in the array buffer
  84245. * @param entry
  84246. * @param byteOffset If defined, specifies where to set the value as an offset.
  84247. */
  84248. setUInt32(entry: number, byteOffset?: number): void;
  84249. }
  84250. }
  84251. declare module BABYLON.GLTF2.Exporter {
  84252. /**
  84253. * @hidden
  84254. * Interface to store animation data.
  84255. */
  84256. export interface _IAnimationData {
  84257. /**
  84258. * Keyframe data.
  84259. */
  84260. inputs: number[];
  84261. /**
  84262. * Value data.
  84263. */
  84264. outputs: number[][];
  84265. /**
  84266. * Animation interpolation data.
  84267. */
  84268. samplerInterpolation: AnimationSamplerInterpolation;
  84269. /**
  84270. * Minimum keyframe value.
  84271. */
  84272. inputsMin: number;
  84273. /**
  84274. * Maximum keyframe value.
  84275. */
  84276. inputsMax: number;
  84277. }
  84278. /**
  84279. * @hidden
  84280. */
  84281. export interface _IAnimationInfo {
  84282. /**
  84283. * The target channel for the animation
  84284. */
  84285. animationChannelTargetPath: AnimationChannelTargetPath;
  84286. /**
  84287. * The glTF accessor type for the data.
  84288. */
  84289. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84290. /**
  84291. * Specifies if quaternions should be used.
  84292. */
  84293. useQuaternion: boolean;
  84294. }
  84295. /**
  84296. * @hidden
  84297. * Utility class for generating glTF animation data from BabylonJS.
  84298. */
  84299. export class _GLTFAnimation {
  84300. /**
  84301. * @ignore
  84302. *
  84303. * Creates glTF channel animation from BabylonJS animation.
  84304. * @param babylonTransformNode - BabylonJS mesh.
  84305. * @param animation - animation.
  84306. * @param animationChannelTargetPath - The target animation channel.
  84307. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84308. * @param useQuaternion - Specifies if quaternions are used.
  84309. * @returns nullable IAnimationData
  84310. */
  84311. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84312. private static _DeduceAnimationInfo;
  84313. /**
  84314. * @ignore
  84315. * Create node animations from the transform node animations
  84316. * @param babylonNode
  84317. * @param runtimeGLTFAnimation
  84318. * @param idleGLTFAnimations
  84319. * @param nodeMap
  84320. * @param nodes
  84321. * @param binaryWriter
  84322. * @param bufferViews
  84323. * @param accessors
  84324. * @param convertToRightHandedSystem
  84325. * @param animationSampleRate
  84326. */
  84327. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84328. [key: number]: number;
  84329. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84330. /**
  84331. * @ignore
  84332. * Create individual morph animations from the mesh's morph target animation tracks
  84333. * @param babylonNode
  84334. * @param runtimeGLTFAnimation
  84335. * @param idleGLTFAnimations
  84336. * @param nodeMap
  84337. * @param nodes
  84338. * @param binaryWriter
  84339. * @param bufferViews
  84340. * @param accessors
  84341. * @param convertToRightHandedSystem
  84342. * @param animationSampleRate
  84343. */
  84344. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84345. [key: number]: number;
  84346. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84347. /**
  84348. * @ignore
  84349. * Create node and morph animations from the animation groups
  84350. * @param babylonScene
  84351. * @param glTFAnimations
  84352. * @param nodeMap
  84353. * @param nodes
  84354. * @param binaryWriter
  84355. * @param bufferViews
  84356. * @param accessors
  84357. * @param convertToRightHandedSystemMap
  84358. * @param animationSampleRate
  84359. */
  84360. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84361. [key: number]: number;
  84362. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84363. [nodeId: number]: boolean;
  84364. }, animationSampleRate: number): void;
  84365. private static AddAnimation;
  84366. /**
  84367. * Create a baked animation
  84368. * @param babylonTransformNode BabylonJS mesh
  84369. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84370. * @param animationChannelTargetPath animation target channel
  84371. * @param minFrame minimum animation frame
  84372. * @param maxFrame maximum animation frame
  84373. * @param fps frames per second of the animation
  84374. * @param inputs input key frames of the animation
  84375. * @param outputs output key frame data of the animation
  84376. * @param convertToRightHandedSystem converts the values to right-handed
  84377. * @param useQuaternion specifies if quaternions should be used
  84378. */
  84379. private static _CreateBakedAnimation;
  84380. private static _ConvertFactorToVector3OrQuaternion;
  84381. private static _SetInterpolatedValue;
  84382. /**
  84383. * Creates linear animation from the animation key frames
  84384. * @param babylonTransformNode BabylonJS mesh
  84385. * @param animation BabylonJS animation
  84386. * @param animationChannelTargetPath The target animation channel
  84387. * @param frameDelta The difference between the last and first frame of the animation
  84388. * @param inputs Array to store the key frame times
  84389. * @param outputs Array to store the key frame data
  84390. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84391. * @param useQuaternion Specifies if quaternions are used in the animation
  84392. */
  84393. private static _CreateLinearOrStepAnimation;
  84394. /**
  84395. * Creates cubic spline animation from the animation key frames
  84396. * @param babylonTransformNode BabylonJS mesh
  84397. * @param animation BabylonJS animation
  84398. * @param animationChannelTargetPath The target animation channel
  84399. * @param frameDelta The difference between the last and first frame of the animation
  84400. * @param inputs Array to store the key frame times
  84401. * @param outputs Array to store the key frame data
  84402. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84403. * @param useQuaternion Specifies if quaternions are used in the animation
  84404. */
  84405. private static _CreateCubicSplineAnimation;
  84406. private static _GetBasePositionRotationOrScale;
  84407. /**
  84408. * Adds a key frame value
  84409. * @param keyFrame
  84410. * @param animation
  84411. * @param outputs
  84412. * @param animationChannelTargetPath
  84413. * @param basePositionRotationOrScale
  84414. * @param convertToRightHandedSystem
  84415. * @param useQuaternion
  84416. */
  84417. private static _AddKeyframeValue;
  84418. /**
  84419. * Determine the interpolation based on the key frames
  84420. * @param keyFrames
  84421. * @param animationChannelTargetPath
  84422. * @param useQuaternion
  84423. */
  84424. private static _DeduceInterpolation;
  84425. /**
  84426. * Adds an input tangent or output tangent to the output data
  84427. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84428. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84429. * @param outputs The animation data by keyframe
  84430. * @param animationChannelTargetPath The target animation channel
  84431. * @param interpolation The interpolation type
  84432. * @param keyFrame The key frame with the animation data
  84433. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84434. * @param useQuaternion Specifies if quaternions are used
  84435. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84436. */
  84437. private static AddSplineTangent;
  84438. /**
  84439. * Get the minimum and maximum key frames' frame values
  84440. * @param keyFrames animation key frames
  84441. * @returns the minimum and maximum key frame value
  84442. */
  84443. private static calculateMinMaxKeyFrames;
  84444. }
  84445. }
  84446. declare module BABYLON.GLTF2.Exporter {
  84447. /** @hidden */
  84448. export var textureTransformPixelShader: {
  84449. name: string;
  84450. shader: string;
  84451. };
  84452. }
  84453. declare module BABYLON.GLTF2.Exporter.Extensions {
  84454. /**
  84455. * @hidden
  84456. */
  84457. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84458. private _recordedTextures;
  84459. /** Name of this extension */
  84460. readonly name: string;
  84461. /** Defines whether this extension is enabled */
  84462. enabled: boolean;
  84463. /** Defines whether this extension is required */
  84464. required: boolean;
  84465. /** Reference to the glTF exporter */
  84466. private _wasUsed;
  84467. constructor(exporter: _Exporter);
  84468. dispose(): void;
  84469. /** @hidden */
  84470. get wasUsed(): boolean;
  84471. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84472. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84473. /**
  84474. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84475. * @param babylonTexture
  84476. * @param offset
  84477. * @param rotation
  84478. * @param scale
  84479. * @param scene
  84480. */
  84481. private _textureTransformTextureAsync;
  84482. }
  84483. }
  84484. declare module BABYLON.GLTF2.Exporter.Extensions {
  84485. /**
  84486. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84487. */
  84488. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84489. /** The name of this extension. */
  84490. readonly name: string;
  84491. /** Defines whether this extension is enabled. */
  84492. enabled: boolean;
  84493. /** Defines whether this extension is required */
  84494. required: boolean;
  84495. /** Reference to the glTF exporter */
  84496. private _exporter;
  84497. private _lights;
  84498. /** @hidden */
  84499. constructor(exporter: _Exporter);
  84500. /** @hidden */
  84501. dispose(): void;
  84502. /** @hidden */
  84503. get wasUsed(): boolean;
  84504. /** @hidden */
  84505. onExporting(): void;
  84506. /**
  84507. * Define this method to modify the default behavior when exporting a node
  84508. * @param context The context when exporting the node
  84509. * @param node glTF node
  84510. * @param babylonNode BabylonJS node
  84511. * @param nodeMap Node mapping of unique id to glTF node index
  84512. * @returns nullable INode promise
  84513. */
  84514. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84515. [key: number]: number;
  84516. }): Promise<Nullable<INode>>;
  84517. }
  84518. }
  84519. declare module BABYLON.GLTF2.Exporter.Extensions {
  84520. /**
  84521. * @hidden
  84522. */
  84523. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84524. /** Name of this extension */
  84525. readonly name: string;
  84526. /** Defines whether this extension is enabled */
  84527. enabled: boolean;
  84528. /** Defines whether this extension is required */
  84529. required: boolean;
  84530. /** Reference to the glTF exporter */
  84531. private _textureInfos;
  84532. private _exportedTextures;
  84533. private _wasUsed;
  84534. constructor(exporter: _Exporter);
  84535. dispose(): void;
  84536. /** @hidden */
  84537. get wasUsed(): boolean;
  84538. private _getTextureIndex;
  84539. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84540. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84541. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84542. }
  84543. }
  84544. declare module BABYLON.GLTF2.Exporter.Extensions {
  84545. /**
  84546. * @hidden
  84547. */
  84548. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84549. /** Name of this extension */
  84550. readonly name: string;
  84551. /** Defines whether this extension is enabled */
  84552. enabled: boolean;
  84553. /** Defines whether this extension is required */
  84554. required: boolean;
  84555. private _wasUsed;
  84556. constructor(exporter: _Exporter);
  84557. /** @hidden */
  84558. get wasUsed(): boolean;
  84559. dispose(): void;
  84560. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84561. }
  84562. }
  84563. declare module BABYLON {
  84564. /**
  84565. * Class for generating STL data from a Babylon scene.
  84566. */
  84567. export class STLExport {
  84568. /**
  84569. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84570. * @param meshes list defines the mesh to serialize
  84571. * @param download triggers the automatic download of the file.
  84572. * @param fileName changes the downloads fileName.
  84573. * @param binary changes the STL to a binary type.
  84574. * @param isLittleEndian toggle for binary type exporter.
  84575. * @returns the STL as UTF8 string
  84576. */
  84577. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84578. }
  84579. }
  84580. declare module "babylonjs-gltf2interface" {
  84581. export = BABYLON.GLTF2;
  84582. }
  84583. /**
  84584. * Module for glTF 2.0 Interface
  84585. */
  84586. declare module BABYLON.GLTF2 {
  84587. /**
  84588. * The datatype of the components in the attribute
  84589. */
  84590. const enum AccessorComponentType {
  84591. /**
  84592. * Byte
  84593. */
  84594. BYTE = 5120,
  84595. /**
  84596. * Unsigned Byte
  84597. */
  84598. UNSIGNED_BYTE = 5121,
  84599. /**
  84600. * Short
  84601. */
  84602. SHORT = 5122,
  84603. /**
  84604. * Unsigned Short
  84605. */
  84606. UNSIGNED_SHORT = 5123,
  84607. /**
  84608. * Unsigned Int
  84609. */
  84610. UNSIGNED_INT = 5125,
  84611. /**
  84612. * Float
  84613. */
  84614. FLOAT = 5126,
  84615. }
  84616. /**
  84617. * Specifies if the attirbute is a scalar, vector, or matrix
  84618. */
  84619. const enum AccessorType {
  84620. /**
  84621. * Scalar
  84622. */
  84623. SCALAR = "SCALAR",
  84624. /**
  84625. * Vector2
  84626. */
  84627. VEC2 = "VEC2",
  84628. /**
  84629. * Vector3
  84630. */
  84631. VEC3 = "VEC3",
  84632. /**
  84633. * Vector4
  84634. */
  84635. VEC4 = "VEC4",
  84636. /**
  84637. * Matrix2x2
  84638. */
  84639. MAT2 = "MAT2",
  84640. /**
  84641. * Matrix3x3
  84642. */
  84643. MAT3 = "MAT3",
  84644. /**
  84645. * Matrix4x4
  84646. */
  84647. MAT4 = "MAT4",
  84648. }
  84649. /**
  84650. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84651. */
  84652. const enum AnimationChannelTargetPath {
  84653. /**
  84654. * Translation
  84655. */
  84656. TRANSLATION = "translation",
  84657. /**
  84658. * Rotation
  84659. */
  84660. ROTATION = "rotation",
  84661. /**
  84662. * Scale
  84663. */
  84664. SCALE = "scale",
  84665. /**
  84666. * Weights
  84667. */
  84668. WEIGHTS = "weights",
  84669. }
  84670. /**
  84671. * Interpolation algorithm
  84672. */
  84673. const enum AnimationSamplerInterpolation {
  84674. /**
  84675. * The animated values are linearly interpolated between keyframes
  84676. */
  84677. LINEAR = "LINEAR",
  84678. /**
  84679. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84680. */
  84681. STEP = "STEP",
  84682. /**
  84683. * The animation's interpolation is computed using a cubic spline with specified tangents
  84684. */
  84685. CUBICSPLINE = "CUBICSPLINE",
  84686. }
  84687. /**
  84688. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84689. */
  84690. const enum CameraType {
  84691. /**
  84692. * A perspective camera containing properties to create a perspective projection matrix
  84693. */
  84694. PERSPECTIVE = "perspective",
  84695. /**
  84696. * An orthographic camera containing properties to create an orthographic projection matrix
  84697. */
  84698. ORTHOGRAPHIC = "orthographic",
  84699. }
  84700. /**
  84701. * The mime-type of the image
  84702. */
  84703. const enum ImageMimeType {
  84704. /**
  84705. * JPEG Mime-type
  84706. */
  84707. JPEG = "image/jpeg",
  84708. /**
  84709. * PNG Mime-type
  84710. */
  84711. PNG = "image/png",
  84712. }
  84713. /**
  84714. * The alpha rendering mode of the material
  84715. */
  84716. const enum MaterialAlphaMode {
  84717. /**
  84718. * The alpha value is ignored and the rendered output is fully opaque
  84719. */
  84720. OPAQUE = "OPAQUE",
  84721. /**
  84722. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84723. */
  84724. MASK = "MASK",
  84725. /**
  84726. * 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)
  84727. */
  84728. BLEND = "BLEND",
  84729. }
  84730. /**
  84731. * The type of the primitives to render
  84732. */
  84733. const enum MeshPrimitiveMode {
  84734. /**
  84735. * Points
  84736. */
  84737. POINTS = 0,
  84738. /**
  84739. * Lines
  84740. */
  84741. LINES = 1,
  84742. /**
  84743. * Line Loop
  84744. */
  84745. LINE_LOOP = 2,
  84746. /**
  84747. * Line Strip
  84748. */
  84749. LINE_STRIP = 3,
  84750. /**
  84751. * Triangles
  84752. */
  84753. TRIANGLES = 4,
  84754. /**
  84755. * Triangle Strip
  84756. */
  84757. TRIANGLE_STRIP = 5,
  84758. /**
  84759. * Triangle Fan
  84760. */
  84761. TRIANGLE_FAN = 6,
  84762. }
  84763. /**
  84764. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84765. */
  84766. const enum TextureMagFilter {
  84767. /**
  84768. * Nearest
  84769. */
  84770. NEAREST = 9728,
  84771. /**
  84772. * Linear
  84773. */
  84774. LINEAR = 9729,
  84775. }
  84776. /**
  84777. * Minification filter. All valid values correspond to WebGL enums
  84778. */
  84779. const enum TextureMinFilter {
  84780. /**
  84781. * Nearest
  84782. */
  84783. NEAREST = 9728,
  84784. /**
  84785. * Linear
  84786. */
  84787. LINEAR = 9729,
  84788. /**
  84789. * Nearest Mip-Map Nearest
  84790. */
  84791. NEAREST_MIPMAP_NEAREST = 9984,
  84792. /**
  84793. * Linear Mipmap Nearest
  84794. */
  84795. LINEAR_MIPMAP_NEAREST = 9985,
  84796. /**
  84797. * Nearest Mipmap Linear
  84798. */
  84799. NEAREST_MIPMAP_LINEAR = 9986,
  84800. /**
  84801. * Linear Mipmap Linear
  84802. */
  84803. LINEAR_MIPMAP_LINEAR = 9987,
  84804. }
  84805. /**
  84806. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84807. */
  84808. const enum TextureWrapMode {
  84809. /**
  84810. * Clamp to Edge
  84811. */
  84812. CLAMP_TO_EDGE = 33071,
  84813. /**
  84814. * Mirrored Repeat
  84815. */
  84816. MIRRORED_REPEAT = 33648,
  84817. /**
  84818. * Repeat
  84819. */
  84820. REPEAT = 10497,
  84821. }
  84822. /**
  84823. * glTF Property
  84824. */
  84825. interface IProperty {
  84826. /**
  84827. * Dictionary object with extension-specific objects
  84828. */
  84829. extensions?: {
  84830. [key: string]: any;
  84831. };
  84832. /**
  84833. * Application-Specific data
  84834. */
  84835. extras?: any;
  84836. }
  84837. /**
  84838. * glTF Child of Root Property
  84839. */
  84840. interface IChildRootProperty extends IProperty {
  84841. /**
  84842. * The user-defined name of this object
  84843. */
  84844. name?: string;
  84845. }
  84846. /**
  84847. * Indices of those attributes that deviate from their initialization value
  84848. */
  84849. interface IAccessorSparseIndices extends IProperty {
  84850. /**
  84851. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84852. */
  84853. bufferView: number;
  84854. /**
  84855. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84856. */
  84857. byteOffset?: number;
  84858. /**
  84859. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84860. */
  84861. componentType: AccessorComponentType;
  84862. }
  84863. /**
  84864. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84865. */
  84866. interface IAccessorSparseValues extends IProperty {
  84867. /**
  84868. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84869. */
  84870. bufferView: number;
  84871. /**
  84872. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84873. */
  84874. byteOffset?: number;
  84875. }
  84876. /**
  84877. * Sparse storage of attributes that deviate from their initialization value
  84878. */
  84879. interface IAccessorSparse extends IProperty {
  84880. /**
  84881. * The number of attributes encoded in this sparse accessor
  84882. */
  84883. count: number;
  84884. /**
  84885. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84886. */
  84887. indices: IAccessorSparseIndices;
  84888. /**
  84889. * 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
  84890. */
  84891. values: IAccessorSparseValues;
  84892. }
  84893. /**
  84894. * 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
  84895. */
  84896. interface IAccessor extends IChildRootProperty {
  84897. /**
  84898. * The index of the bufferview
  84899. */
  84900. bufferView?: number;
  84901. /**
  84902. * The offset relative to the start of the bufferView in bytes
  84903. */
  84904. byteOffset?: number;
  84905. /**
  84906. * The datatype of components in the attribute
  84907. */
  84908. componentType: AccessorComponentType;
  84909. /**
  84910. * Specifies whether integer data values should be normalized
  84911. */
  84912. normalized?: boolean;
  84913. /**
  84914. * The number of attributes referenced by this accessor
  84915. */
  84916. count: number;
  84917. /**
  84918. * Specifies if the attribute is a scalar, vector, or matrix
  84919. */
  84920. type: AccessorType;
  84921. /**
  84922. * Maximum value of each component in this attribute
  84923. */
  84924. max?: number[];
  84925. /**
  84926. * Minimum value of each component in this attribute
  84927. */
  84928. min?: number[];
  84929. /**
  84930. * Sparse storage of attributes that deviate from their initialization value
  84931. */
  84932. sparse?: IAccessorSparse;
  84933. }
  84934. /**
  84935. * Targets an animation's sampler at a node's property
  84936. */
  84937. interface IAnimationChannel extends IProperty {
  84938. /**
  84939. * The index of a sampler in this animation used to compute the value for the target
  84940. */
  84941. sampler: number;
  84942. /**
  84943. * The index of the node and TRS property to target
  84944. */
  84945. target: IAnimationChannelTarget;
  84946. }
  84947. /**
  84948. * The index of the node and TRS property that an animation channel targets
  84949. */
  84950. interface IAnimationChannelTarget extends IProperty {
  84951. /**
  84952. * The index of the node to target
  84953. */
  84954. node: number;
  84955. /**
  84956. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84957. */
  84958. path: AnimationChannelTargetPath;
  84959. }
  84960. /**
  84961. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84962. */
  84963. interface IAnimationSampler extends IProperty {
  84964. /**
  84965. * The index of an accessor containing keyframe input values, e.g., time
  84966. */
  84967. input: number;
  84968. /**
  84969. * Interpolation algorithm
  84970. */
  84971. interpolation?: AnimationSamplerInterpolation;
  84972. /**
  84973. * The index of an accessor, containing keyframe output values
  84974. */
  84975. output: number;
  84976. }
  84977. /**
  84978. * A keyframe animation
  84979. */
  84980. interface IAnimation extends IChildRootProperty {
  84981. /**
  84982. * An array of channels, each of which targets an animation's sampler at a node's property
  84983. */
  84984. channels: IAnimationChannel[];
  84985. /**
  84986. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84987. */
  84988. samplers: IAnimationSampler[];
  84989. }
  84990. /**
  84991. * Metadata about the glTF asset
  84992. */
  84993. interface IAsset extends IChildRootProperty {
  84994. /**
  84995. * A copyright message suitable for display to credit the content creator
  84996. */
  84997. copyright?: string;
  84998. /**
  84999. * Tool that generated this glTF model. Useful for debugging
  85000. */
  85001. generator?: string;
  85002. /**
  85003. * The glTF version that this asset targets
  85004. */
  85005. version: string;
  85006. /**
  85007. * The minimum glTF version that this asset targets
  85008. */
  85009. minVersion?: string;
  85010. }
  85011. /**
  85012. * A buffer points to binary geometry, animation, or skins
  85013. */
  85014. interface IBuffer extends IChildRootProperty {
  85015. /**
  85016. * 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
  85017. */
  85018. uri?: string;
  85019. /**
  85020. * The length of the buffer in bytes
  85021. */
  85022. byteLength: number;
  85023. }
  85024. /**
  85025. * A view into a buffer generally representing a subset of the buffer
  85026. */
  85027. interface IBufferView extends IChildRootProperty {
  85028. /**
  85029. * The index of the buffer
  85030. */
  85031. buffer: number;
  85032. /**
  85033. * The offset into the buffer in bytes
  85034. */
  85035. byteOffset?: number;
  85036. /**
  85037. * The lenth of the bufferView in bytes
  85038. */
  85039. byteLength: number;
  85040. /**
  85041. * The stride, in bytes
  85042. */
  85043. byteStride?: number;
  85044. }
  85045. /**
  85046. * An orthographic camera containing properties to create an orthographic projection matrix
  85047. */
  85048. interface ICameraOrthographic extends IProperty {
  85049. /**
  85050. * The floating-point horizontal magnification of the view. Must not be zero
  85051. */
  85052. xmag: number;
  85053. /**
  85054. * The floating-point vertical magnification of the view. Must not be zero
  85055. */
  85056. ymag: number;
  85057. /**
  85058. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85059. */
  85060. zfar: number;
  85061. /**
  85062. * The floating-point distance to the near clipping plane
  85063. */
  85064. znear: number;
  85065. }
  85066. /**
  85067. * A perspective camera containing properties to create a perspective projection matrix
  85068. */
  85069. interface ICameraPerspective extends IProperty {
  85070. /**
  85071. * The floating-point aspect ratio of the field of view
  85072. */
  85073. aspectRatio?: number;
  85074. /**
  85075. * The floating-point vertical field of view in radians
  85076. */
  85077. yfov: number;
  85078. /**
  85079. * The floating-point distance to the far clipping plane
  85080. */
  85081. zfar?: number;
  85082. /**
  85083. * The floating-point distance to the near clipping plane
  85084. */
  85085. znear: number;
  85086. }
  85087. /**
  85088. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85089. */
  85090. interface ICamera extends IChildRootProperty {
  85091. /**
  85092. * An orthographic camera containing properties to create an orthographic projection matrix
  85093. */
  85094. orthographic?: ICameraOrthographic;
  85095. /**
  85096. * A perspective camera containing properties to create a perspective projection matrix
  85097. */
  85098. perspective?: ICameraPerspective;
  85099. /**
  85100. * Specifies if the camera uses a perspective or orthographic projection
  85101. */
  85102. type: CameraType;
  85103. }
  85104. /**
  85105. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85106. */
  85107. interface IImage extends IChildRootProperty {
  85108. /**
  85109. * 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
  85110. */
  85111. uri?: string;
  85112. /**
  85113. * The image's MIME type
  85114. */
  85115. mimeType?: ImageMimeType;
  85116. /**
  85117. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85118. */
  85119. bufferView?: number;
  85120. }
  85121. /**
  85122. * Material Normal Texture Info
  85123. */
  85124. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85125. /**
  85126. * The scalar multiplier applied to each normal vector of the normal texture
  85127. */
  85128. scale?: number;
  85129. }
  85130. /**
  85131. * Material Occlusion Texture Info
  85132. */
  85133. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85134. /**
  85135. * A scalar multiplier controlling the amount of occlusion applied
  85136. */
  85137. strength?: number;
  85138. }
  85139. /**
  85140. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85141. */
  85142. interface IMaterialPbrMetallicRoughness {
  85143. /**
  85144. * The material's base color factor
  85145. */
  85146. baseColorFactor?: number[];
  85147. /**
  85148. * The base color texture
  85149. */
  85150. baseColorTexture?: ITextureInfo;
  85151. /**
  85152. * The metalness of the material
  85153. */
  85154. metallicFactor?: number;
  85155. /**
  85156. * The roughness of the material
  85157. */
  85158. roughnessFactor?: number;
  85159. /**
  85160. * The metallic-roughness texture
  85161. */
  85162. metallicRoughnessTexture?: ITextureInfo;
  85163. }
  85164. /**
  85165. * The material appearance of a primitive
  85166. */
  85167. interface IMaterial extends IChildRootProperty {
  85168. /**
  85169. * 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
  85170. */
  85171. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85172. /**
  85173. * The normal map texture
  85174. */
  85175. normalTexture?: IMaterialNormalTextureInfo;
  85176. /**
  85177. * The occlusion map texture
  85178. */
  85179. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85180. /**
  85181. * The emissive map texture
  85182. */
  85183. emissiveTexture?: ITextureInfo;
  85184. /**
  85185. * 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
  85186. */
  85187. emissiveFactor?: number[];
  85188. /**
  85189. * The alpha rendering mode of the material
  85190. */
  85191. alphaMode?: MaterialAlphaMode;
  85192. /**
  85193. * The alpha cutoff value of the material
  85194. */
  85195. alphaCutoff?: number;
  85196. /**
  85197. * Specifies whether the material is double sided
  85198. */
  85199. doubleSided?: boolean;
  85200. }
  85201. /**
  85202. * Geometry to be rendered with the given material
  85203. */
  85204. interface IMeshPrimitive extends IProperty {
  85205. /**
  85206. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85207. */
  85208. attributes: {
  85209. [name: string]: number;
  85210. };
  85211. /**
  85212. * The index of the accessor that contains the indices
  85213. */
  85214. indices?: number;
  85215. /**
  85216. * The index of the material to apply to this primitive when rendering
  85217. */
  85218. material?: number;
  85219. /**
  85220. * The type of primitives to render. All valid values correspond to WebGL enums
  85221. */
  85222. mode?: MeshPrimitiveMode;
  85223. /**
  85224. * 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
  85225. */
  85226. targets?: {
  85227. [name: string]: number;
  85228. }[];
  85229. }
  85230. /**
  85231. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85232. */
  85233. interface IMesh extends IChildRootProperty {
  85234. /**
  85235. * An array of primitives, each defining geometry to be rendered with a material
  85236. */
  85237. primitives: IMeshPrimitive[];
  85238. /**
  85239. * Array of weights to be applied to the Morph Targets
  85240. */
  85241. weights?: number[];
  85242. }
  85243. /**
  85244. * A node in the node hierarchy
  85245. */
  85246. interface INode extends IChildRootProperty {
  85247. /**
  85248. * The index of the camera referenced by this node
  85249. */
  85250. camera?: number;
  85251. /**
  85252. * The indices of this node's children
  85253. */
  85254. children?: number[];
  85255. /**
  85256. * The index of the skin referenced by this node
  85257. */
  85258. skin?: number;
  85259. /**
  85260. * A floating-point 4x4 transformation matrix stored in column-major order
  85261. */
  85262. matrix?: number[];
  85263. /**
  85264. * The index of the mesh in this node
  85265. */
  85266. mesh?: number;
  85267. /**
  85268. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85269. */
  85270. rotation?: number[];
  85271. /**
  85272. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85273. */
  85274. scale?: number[];
  85275. /**
  85276. * The node's translation along the x, y, and z axes
  85277. */
  85278. translation?: number[];
  85279. /**
  85280. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85281. */
  85282. weights?: number[];
  85283. }
  85284. /**
  85285. * Texture sampler properties for filtering and wrapping modes
  85286. */
  85287. interface ISampler extends IChildRootProperty {
  85288. /**
  85289. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85290. */
  85291. magFilter?: TextureMagFilter;
  85292. /**
  85293. * Minification filter. All valid values correspond to WebGL enums
  85294. */
  85295. minFilter?: TextureMinFilter;
  85296. /**
  85297. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85298. */
  85299. wrapS?: TextureWrapMode;
  85300. /**
  85301. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85302. */
  85303. wrapT?: TextureWrapMode;
  85304. }
  85305. /**
  85306. * The root nodes of a scene
  85307. */
  85308. interface IScene extends IChildRootProperty {
  85309. /**
  85310. * The indices of each root node
  85311. */
  85312. nodes: number[];
  85313. }
  85314. /**
  85315. * Joints and matrices defining a skin
  85316. */
  85317. interface ISkin extends IChildRootProperty {
  85318. /**
  85319. * 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
  85320. */
  85321. inverseBindMatrices?: number;
  85322. /**
  85323. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85324. */
  85325. skeleton?: number;
  85326. /**
  85327. * 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)
  85328. */
  85329. joints: number[];
  85330. }
  85331. /**
  85332. * A texture and its sampler
  85333. */
  85334. interface ITexture extends IChildRootProperty {
  85335. /**
  85336. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85337. */
  85338. sampler?: number;
  85339. /**
  85340. * The index of the image used by this texture
  85341. */
  85342. source: number;
  85343. }
  85344. /**
  85345. * Reference to a texture
  85346. */
  85347. interface ITextureInfo extends IProperty {
  85348. /**
  85349. * The index of the texture
  85350. */
  85351. index: number;
  85352. /**
  85353. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85354. */
  85355. texCoord?: number;
  85356. }
  85357. /**
  85358. * The root object for a glTF asset
  85359. */
  85360. interface IGLTF extends IProperty {
  85361. /**
  85362. * An array of accessors. An accessor is a typed view into a bufferView
  85363. */
  85364. accessors?: IAccessor[];
  85365. /**
  85366. * An array of keyframe animations
  85367. */
  85368. animations?: IAnimation[];
  85369. /**
  85370. * Metadata about the glTF asset
  85371. */
  85372. asset: IAsset;
  85373. /**
  85374. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85375. */
  85376. buffers?: IBuffer[];
  85377. /**
  85378. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85379. */
  85380. bufferViews?: IBufferView[];
  85381. /**
  85382. * An array of cameras
  85383. */
  85384. cameras?: ICamera[];
  85385. /**
  85386. * Names of glTF extensions used somewhere in this asset
  85387. */
  85388. extensionsUsed?: string[];
  85389. /**
  85390. * Names of glTF extensions required to properly load this asset
  85391. */
  85392. extensionsRequired?: string[];
  85393. /**
  85394. * An array of images. An image defines data used to create a texture
  85395. */
  85396. images?: IImage[];
  85397. /**
  85398. * An array of materials. A material defines the appearance of a primitive
  85399. */
  85400. materials?: IMaterial[];
  85401. /**
  85402. * An array of meshes. A mesh is a set of primitives to be rendered
  85403. */
  85404. meshes?: IMesh[];
  85405. /**
  85406. * An array of nodes
  85407. */
  85408. nodes?: INode[];
  85409. /**
  85410. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85411. */
  85412. samplers?: ISampler[];
  85413. /**
  85414. * The index of the default scene
  85415. */
  85416. scene?: number;
  85417. /**
  85418. * An array of scenes
  85419. */
  85420. scenes?: IScene[];
  85421. /**
  85422. * An array of skins. A skin is defined by joints and matrices
  85423. */
  85424. skins?: ISkin[];
  85425. /**
  85426. * An array of textures
  85427. */
  85428. textures?: ITexture[];
  85429. }
  85430. /**
  85431. * The glTF validation results
  85432. * @ignore
  85433. */
  85434. interface IGLTFValidationResults {
  85435. info: {
  85436. generator: string;
  85437. hasAnimations: boolean;
  85438. hasDefaultScene: boolean;
  85439. hasMaterials: boolean;
  85440. hasMorphTargets: boolean;
  85441. hasSkins: boolean;
  85442. hasTextures: boolean;
  85443. maxAttributesUsed: number;
  85444. primitivesCount: number
  85445. };
  85446. issues: {
  85447. messages: Array<string>;
  85448. numErrors: number;
  85449. numHints: number;
  85450. numInfos: number;
  85451. numWarnings: number;
  85452. truncated: boolean
  85453. };
  85454. mimeType: string;
  85455. uri: string;
  85456. validatedAt: string;
  85457. validatorVersion: string;
  85458. }
  85459. /**
  85460. * The glTF validation options
  85461. */
  85462. interface IGLTFValidationOptions {
  85463. /** Uri to use */
  85464. uri?: string;
  85465. /** Function used to load external resources */
  85466. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85467. /** Boolean indicating that we need to validate accessor data */
  85468. validateAccessorData?: boolean;
  85469. /** max number of issues allowed */
  85470. maxIssues?: number;
  85471. /** Ignored issues */
  85472. ignoredIssues?: Array<string>;
  85473. /** Value to override severy settings */
  85474. severityOverrides?: Object;
  85475. }
  85476. /**
  85477. * The glTF validator object
  85478. * @ignore
  85479. */
  85480. interface IGLTFValidator {
  85481. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85482. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85483. }
  85484. /**
  85485. * Interfaces from the EXT_lights_image_based extension
  85486. */
  85487. /** @hidden */
  85488. interface IEXTLightsImageBased_LightReferenceImageBased {
  85489. light: number;
  85490. }
  85491. /** @hidden */
  85492. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85493. intensity: number;
  85494. rotation: number[];
  85495. specularImageSize: number;
  85496. specularImages: number[][];
  85497. irradianceCoefficients: number[][];
  85498. }
  85499. /** @hidden */
  85500. interface IEXTLightsImageBased {
  85501. lights: IEXTLightsImageBased_LightImageBased[];
  85502. }
  85503. /**
  85504. * Interfaces from the EXT_mesh_gpu_instancing extension
  85505. * !!! Experimental Extension Subject to Changes !!!
  85506. */
  85507. /** @hidden */
  85508. interface IEXTMeshGpuInstancing {
  85509. mesh?: number;
  85510. attributes: { [name: string]: number };
  85511. }
  85512. /**
  85513. * Interfaces from the KHR_draco_mesh_compression extension
  85514. */
  85515. /** @hidden */
  85516. interface IKHRDracoMeshCompression {
  85517. bufferView: number;
  85518. attributes: { [name: string]: number };
  85519. }
  85520. /**
  85521. * Interfaces from the KHR_lights_punctual extension
  85522. */
  85523. /** @hidden */
  85524. const enum IKHRLightsPunctual_LightType {
  85525. DIRECTIONAL = "directional",
  85526. POINT = "point",
  85527. SPOT = "spot"
  85528. }
  85529. /** @hidden */
  85530. interface IKHRLightsPunctual_LightReference {
  85531. light: number;
  85532. }
  85533. /** @hidden */
  85534. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85535. type: IKHRLightsPunctual_LightType;
  85536. color?: number[];
  85537. intensity?: number;
  85538. range?: number;
  85539. spot?: {
  85540. innerConeAngle?: number;
  85541. outerConeAngle?: number;
  85542. };
  85543. }
  85544. /** @hidden */
  85545. interface IKHRLightsPunctual {
  85546. lights: IKHRLightsPunctual_Light[];
  85547. }
  85548. /**
  85549. * Interfaces from the KHR_materials_clearcoat extension
  85550. * !!! Experimental Extension Subject to Changes !!!
  85551. */
  85552. /** @hidden */
  85553. interface IKHRMaterialsClearcoat {
  85554. clearcoatFactor: number;
  85555. clearcoatTexture: ITextureInfo;
  85556. clearcoatRoughnessFactor: number;
  85557. clearcoatRoughnessTexture: ITextureInfo;
  85558. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85559. }
  85560. /**
  85561. * Interfaces from the KHR_materials_ior extension
  85562. * !!! Experimental Extension Subject to Changes !!!
  85563. */
  85564. /** @hidden */
  85565. interface IKHRMaterialsIor {
  85566. ior: number;
  85567. }
  85568. /**
  85569. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85570. */
  85571. /** @hidden */
  85572. interface IKHRMaterialsPbrSpecularGlossiness {
  85573. diffuseFactor: number[];
  85574. diffuseTexture: ITextureInfo;
  85575. specularFactor: number[];
  85576. glossinessFactor: number;
  85577. specularGlossinessTexture: ITextureInfo;
  85578. }
  85579. /**
  85580. * Interfaces from the KHR_materials_sheen extension
  85581. * !!! Experimental Extension Subject to Changes !!!
  85582. */
  85583. /** @hidden */
  85584. interface IKHRMaterialsSheen {
  85585. sheenColorFactor?: number[];
  85586. sheenTexture?: ITextureInfo;
  85587. sheenRoughnessFactor?: number;
  85588. }
  85589. /**
  85590. * Interfaces from the KHR_materials_specular extension
  85591. * !!! Experimental Extension Subject to Changes !!!
  85592. */
  85593. /** @hidden */
  85594. interface IKHRMaterialsSpecular {
  85595. specularFactor: number;
  85596. specularColorFactor: number[];
  85597. specularTexture: ITextureInfo;
  85598. }
  85599. /**
  85600. * Interfaces from the KHR_materials_transmission extension
  85601. * !!! Experimental Extension Subject to Changes !!!
  85602. */
  85603. /** @hidden */
  85604. interface IKHRMaterialsTransmission {
  85605. transmissionFactor?: number;
  85606. transmissionTexture?: ITextureInfo;
  85607. }
  85608. /**
  85609. * Interfaces from the KHR_materials_variants extension
  85610. * !!! Experimental Extension Subject to Changes !!!
  85611. */
  85612. /** @hidden */
  85613. interface IKHRMaterialVariants_Mapping extends IProperty {
  85614. mappings: Array<{
  85615. variants: number[];
  85616. material: number;
  85617. }>;
  85618. }
  85619. /** @hidden */
  85620. interface IKHRMaterialVariants_Variant extends IProperty {
  85621. name: string;
  85622. }
  85623. /** @hidden */
  85624. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85625. variants: Array<IKHRMaterialVariants_Variant>;
  85626. }
  85627. /**
  85628. * Interfaces from the KHR_texture_basisu extension
  85629. * !!! Experimental Extension Subject to Changes !!!
  85630. */
  85631. /** @hidden */
  85632. interface IKHRTextureBasisU {
  85633. source: number;
  85634. }
  85635. /**
  85636. * Interfaces from the EXT_texture_webp extension
  85637. */
  85638. /** @hidden */
  85639. interface IEXTTextureWebP {
  85640. source: number;
  85641. }
  85642. /**
  85643. * Interfaces from the KHR_texture_transform extension
  85644. */
  85645. /** @hidden */
  85646. interface IKHRTextureTransform {
  85647. offset?: number[];
  85648. rotation?: number;
  85649. scale?: number[];
  85650. texCoord?: number;
  85651. }
  85652. /**
  85653. * Interfaces from the KHR_xmp extension
  85654. * !!! Experimental Extension Subject to Changes !!!
  85655. */
  85656. /** @hidden */
  85657. interface IKHRXmp_Data {
  85658. [key: string]: unknown;
  85659. }
  85660. /** @hidden */
  85661. interface IKHRXmp_Gltf {
  85662. packets: IKHRXmp_Data[];
  85663. }
  85664. /** @hidden */
  85665. interface IKHRXmp_Node {
  85666. packet: number;
  85667. }
  85668. /**
  85669. * Interfaces from the MSFT_audio_emitter extension
  85670. */
  85671. /** @hidden */
  85672. interface IMSFTAudioEmitter_ClipReference {
  85673. clip: number;
  85674. weight?: number;
  85675. }
  85676. /** @hidden */
  85677. interface IMSFTAudioEmitter_EmittersReference {
  85678. emitters: number[];
  85679. }
  85680. /** @hidden */
  85681. const enum IMSFTAudioEmitter_DistanceModel {
  85682. linear = "linear",
  85683. inverse = "inverse",
  85684. exponential = "exponential",
  85685. }
  85686. /** @hidden */
  85687. interface IMSFTAudioEmitter_Emitter {
  85688. name?: string;
  85689. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85690. refDistance?: number;
  85691. maxDistance?: number;
  85692. rolloffFactor?: number;
  85693. innerAngle?: number;
  85694. outerAngle?: number;
  85695. loop?: boolean;
  85696. volume?: number;
  85697. clips: IMSFTAudioEmitter_ClipReference[];
  85698. }
  85699. /** @hidden */
  85700. const enum IMSFTAudioEmitter_AudioMimeType {
  85701. WAV = "audio/wav",
  85702. }
  85703. /** @hidden */
  85704. interface IMSFTAudioEmitter_Clip extends IProperty {
  85705. uri?: string;
  85706. bufferView?: number;
  85707. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85708. }
  85709. /** @hidden */
  85710. const enum IMSFTAudioEmitter_AnimationEventAction {
  85711. play = "play",
  85712. pause = "pause",
  85713. stop = "stop",
  85714. }
  85715. /** @hidden */
  85716. interface IMSFTAudioEmitter_AnimationEvent {
  85717. action: IMSFTAudioEmitter_AnimationEventAction;
  85718. emitter: number;
  85719. time: number;
  85720. startOffset?: number;
  85721. }
  85722. /**
  85723. * Interfaces from the MSFT_lod extension
  85724. */
  85725. /** @hidden */
  85726. interface IMSFTLOD {
  85727. ids: number[];
  85728. }
  85729. }
  85730. declare module BABYLON {
  85731. /** @hidden */
  85732. export var cellPixelShader: {
  85733. name: string;
  85734. shader: string;
  85735. };
  85736. }
  85737. declare module BABYLON {
  85738. /** @hidden */
  85739. export var cellVertexShader: {
  85740. name: string;
  85741. shader: string;
  85742. };
  85743. }
  85744. declare module BABYLON {
  85745. export class CellMaterial extends BABYLON.PushMaterial {
  85746. private _diffuseTexture;
  85747. diffuseTexture: BABYLON.BaseTexture;
  85748. diffuseColor: BABYLON.Color3;
  85749. _computeHighLevel: boolean;
  85750. computeHighLevel: boolean;
  85751. private _disableLighting;
  85752. disableLighting: boolean;
  85753. private _maxSimultaneousLights;
  85754. maxSimultaneousLights: number;
  85755. constructor(name: string, scene: BABYLON.Scene);
  85756. needAlphaBlending(): boolean;
  85757. needAlphaTesting(): boolean;
  85758. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85759. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85760. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85761. getAnimatables(): BABYLON.IAnimatable[];
  85762. getActiveTextures(): BABYLON.BaseTexture[];
  85763. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85764. dispose(forceDisposeEffect?: boolean): void;
  85765. getClassName(): string;
  85766. clone(name: string): CellMaterial;
  85767. serialize(): any;
  85768. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85769. }
  85770. }
  85771. declare module BABYLON {
  85772. export class CustomShaderStructure {
  85773. FragmentStore: string;
  85774. VertexStore: string;
  85775. constructor();
  85776. }
  85777. export class ShaderSpecialParts {
  85778. constructor();
  85779. Fragment_Begin: string;
  85780. Fragment_Definitions: string;
  85781. Fragment_MainBegin: string;
  85782. Fragment_Custom_Diffuse: string;
  85783. Fragment_Before_Lights: string;
  85784. Fragment_Before_Fog: string;
  85785. Fragment_Custom_Alpha: string;
  85786. Fragment_Before_FragColor: string;
  85787. Vertex_Begin: string;
  85788. Vertex_Definitions: string;
  85789. Vertex_MainBegin: string;
  85790. Vertex_Before_PositionUpdated: string;
  85791. Vertex_Before_NormalUpdated: string;
  85792. Vertex_After_WorldPosComputed: string;
  85793. Vertex_MainEnd: string;
  85794. }
  85795. export class CustomMaterial extends BABYLON.StandardMaterial {
  85796. static ShaderIndexer: number;
  85797. CustomParts: ShaderSpecialParts;
  85798. _isCreatedShader: boolean;
  85799. _createdShaderName: string;
  85800. _customUniform: string[];
  85801. _newUniforms: string[];
  85802. _newUniformInstances: {
  85803. [name: string]: any;
  85804. };
  85805. _newSamplerInstances: {
  85806. [name: string]: BABYLON.Texture;
  85807. };
  85808. _customAttributes: string[];
  85809. FragmentShader: string;
  85810. VertexShader: string;
  85811. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85812. ReviewUniform(name: string, arr: string[]): string[];
  85813. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85814. constructor(name: string, scene: BABYLON.Scene);
  85815. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85816. AddAttribute(name: string): CustomMaterial;
  85817. Fragment_Begin(shaderPart: string): CustomMaterial;
  85818. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85819. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85820. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85821. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85822. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85823. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85824. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85825. Vertex_Begin(shaderPart: string): CustomMaterial;
  85826. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85827. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85828. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85829. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85830. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85831. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85832. }
  85833. }
  85834. declare module BABYLON {
  85835. export class ShaderAlebdoParts {
  85836. constructor();
  85837. Fragment_Begin: string;
  85838. Fragment_Definitions: string;
  85839. Fragment_MainBegin: string;
  85840. Fragment_Custom_Albedo: string;
  85841. Fragment_Before_Lights: string;
  85842. Fragment_Custom_MetallicRoughness: string;
  85843. Fragment_Custom_MicroSurface: string;
  85844. Fragment_Before_Fog: string;
  85845. Fragment_Custom_Alpha: string;
  85846. Fragment_Before_FragColor: string;
  85847. Vertex_Begin: string;
  85848. Vertex_Definitions: string;
  85849. Vertex_MainBegin: string;
  85850. Vertex_Before_PositionUpdated: string;
  85851. Vertex_Before_NormalUpdated: string;
  85852. Vertex_After_WorldPosComputed: string;
  85853. Vertex_MainEnd: string;
  85854. }
  85855. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85856. static ShaderIndexer: number;
  85857. CustomParts: ShaderAlebdoParts;
  85858. _isCreatedShader: boolean;
  85859. _createdShaderName: string;
  85860. _customUniform: string[];
  85861. _newUniforms: string[];
  85862. _newUniformInstances: {
  85863. [name: string]: any;
  85864. };
  85865. _newSamplerInstances: {
  85866. [name: string]: BABYLON.Texture;
  85867. };
  85868. _customAttributes: string[];
  85869. FragmentShader: string;
  85870. VertexShader: string;
  85871. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85872. ReviewUniform(name: string, arr: string[]): string[];
  85873. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85874. constructor(name: string, scene: BABYLON.Scene);
  85875. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85876. AddAttribute(name: string): PBRCustomMaterial;
  85877. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85878. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85879. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85880. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85881. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85882. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85883. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85884. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85885. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85886. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85887. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85888. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85889. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85890. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85891. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85892. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85893. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85894. }
  85895. }
  85896. declare module BABYLON {
  85897. /** @hidden */
  85898. export var firePixelShader: {
  85899. name: string;
  85900. shader: string;
  85901. };
  85902. }
  85903. declare module BABYLON {
  85904. /** @hidden */
  85905. export var fireVertexShader: {
  85906. name: string;
  85907. shader: string;
  85908. };
  85909. }
  85910. declare module BABYLON {
  85911. export class FireMaterial extends BABYLON.PushMaterial {
  85912. private _diffuseTexture;
  85913. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85914. private _distortionTexture;
  85915. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85916. private _opacityTexture;
  85917. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85918. diffuseColor: BABYLON.Color3;
  85919. speed: number;
  85920. private _scaledDiffuse;
  85921. private _lastTime;
  85922. constructor(name: string, scene: BABYLON.Scene);
  85923. needAlphaBlending(): boolean;
  85924. needAlphaTesting(): boolean;
  85925. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85926. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85927. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85928. getAnimatables(): BABYLON.IAnimatable[];
  85929. getActiveTextures(): BABYLON.BaseTexture[];
  85930. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85931. getClassName(): string;
  85932. dispose(forceDisposeEffect?: boolean): void;
  85933. clone(name: string): FireMaterial;
  85934. serialize(): any;
  85935. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85936. }
  85937. }
  85938. declare module BABYLON {
  85939. /** @hidden */
  85940. export var furPixelShader: {
  85941. name: string;
  85942. shader: string;
  85943. };
  85944. }
  85945. declare module BABYLON {
  85946. /** @hidden */
  85947. export var furVertexShader: {
  85948. name: string;
  85949. shader: string;
  85950. };
  85951. }
  85952. declare module BABYLON {
  85953. export class FurMaterial extends BABYLON.PushMaterial {
  85954. private _diffuseTexture;
  85955. diffuseTexture: BABYLON.BaseTexture;
  85956. private _heightTexture;
  85957. heightTexture: BABYLON.BaseTexture;
  85958. diffuseColor: BABYLON.Color3;
  85959. furLength: number;
  85960. furAngle: number;
  85961. furColor: BABYLON.Color3;
  85962. furOffset: number;
  85963. furSpacing: number;
  85964. furGravity: BABYLON.Vector3;
  85965. furSpeed: number;
  85966. furDensity: number;
  85967. furOcclusion: number;
  85968. furTexture: BABYLON.DynamicTexture;
  85969. private _disableLighting;
  85970. disableLighting: boolean;
  85971. private _maxSimultaneousLights;
  85972. maxSimultaneousLights: number;
  85973. highLevelFur: boolean;
  85974. _meshes: BABYLON.AbstractMesh[];
  85975. private _furTime;
  85976. constructor(name: string, scene: BABYLON.Scene);
  85977. get furTime(): number;
  85978. set furTime(furTime: number);
  85979. needAlphaBlending(): boolean;
  85980. needAlphaTesting(): boolean;
  85981. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85982. updateFur(): void;
  85983. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85984. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85985. getAnimatables(): BABYLON.IAnimatable[];
  85986. getActiveTextures(): BABYLON.BaseTexture[];
  85987. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85988. dispose(forceDisposeEffect?: boolean): void;
  85989. clone(name: string): FurMaterial;
  85990. serialize(): any;
  85991. getClassName(): string;
  85992. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85993. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85994. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85995. }
  85996. }
  85997. declare module BABYLON {
  85998. /** @hidden */
  85999. export var gradientPixelShader: {
  86000. name: string;
  86001. shader: string;
  86002. };
  86003. }
  86004. declare module BABYLON {
  86005. /** @hidden */
  86006. export var gradientVertexShader: {
  86007. name: string;
  86008. shader: string;
  86009. };
  86010. }
  86011. declare module BABYLON {
  86012. export class GradientMaterial extends BABYLON.PushMaterial {
  86013. private _maxSimultaneousLights;
  86014. maxSimultaneousLights: number;
  86015. topColor: BABYLON.Color3;
  86016. topColorAlpha: number;
  86017. bottomColor: BABYLON.Color3;
  86018. bottomColorAlpha: number;
  86019. offset: number;
  86020. scale: number;
  86021. smoothness: number;
  86022. private _disableLighting;
  86023. disableLighting: boolean;
  86024. constructor(name: string, scene: BABYLON.Scene);
  86025. needAlphaBlending(): boolean;
  86026. needAlphaTesting(): boolean;
  86027. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86028. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86029. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86030. getAnimatables(): BABYLON.IAnimatable[];
  86031. dispose(forceDisposeEffect?: boolean): void;
  86032. clone(name: string): GradientMaterial;
  86033. serialize(): any;
  86034. getClassName(): string;
  86035. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86036. }
  86037. }
  86038. declare module BABYLON {
  86039. /** @hidden */
  86040. export var gridPixelShader: {
  86041. name: string;
  86042. shader: string;
  86043. };
  86044. }
  86045. declare module BABYLON {
  86046. /** @hidden */
  86047. export var gridVertexShader: {
  86048. name: string;
  86049. shader: string;
  86050. };
  86051. }
  86052. declare module BABYLON {
  86053. /**
  86054. * The grid materials allows you to wrap any shape with a grid.
  86055. * Colors are customizable.
  86056. */
  86057. export class GridMaterial extends BABYLON.PushMaterial {
  86058. /**
  86059. * Main color of the grid (e.g. between lines)
  86060. */
  86061. mainColor: BABYLON.Color3;
  86062. /**
  86063. * Color of the grid lines.
  86064. */
  86065. lineColor: BABYLON.Color3;
  86066. /**
  86067. * The scale of the grid compared to unit.
  86068. */
  86069. gridRatio: number;
  86070. /**
  86071. * Allows setting an offset for the grid lines.
  86072. */
  86073. gridOffset: BABYLON.Vector3;
  86074. /**
  86075. * The frequency of thicker lines.
  86076. */
  86077. majorUnitFrequency: number;
  86078. /**
  86079. * The visibility of minor units in the grid.
  86080. */
  86081. minorUnitVisibility: number;
  86082. /**
  86083. * The grid opacity outside of the lines.
  86084. */
  86085. opacity: number;
  86086. /**
  86087. * Determine RBG output is premultiplied by alpha value.
  86088. */
  86089. preMultiplyAlpha: boolean;
  86090. private _opacityTexture;
  86091. opacityTexture: BABYLON.BaseTexture;
  86092. private _gridControl;
  86093. /**
  86094. * constructor
  86095. * @param name The name given to the material in order to identify it afterwards.
  86096. * @param scene The scene the material is used in.
  86097. */
  86098. constructor(name: string, scene: BABYLON.Scene);
  86099. /**
  86100. * Returns wehter or not the grid requires alpha blending.
  86101. */
  86102. needAlphaBlending(): boolean;
  86103. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86104. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86105. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86106. /**
  86107. * Dispose the material and its associated resources.
  86108. * @param forceDisposeEffect will also dispose the used effect when true
  86109. */
  86110. dispose(forceDisposeEffect?: boolean): void;
  86111. clone(name: string): GridMaterial;
  86112. serialize(): any;
  86113. getClassName(): string;
  86114. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86115. }
  86116. }
  86117. declare module BABYLON {
  86118. /** @hidden */
  86119. export var lavaPixelShader: {
  86120. name: string;
  86121. shader: string;
  86122. };
  86123. }
  86124. declare module BABYLON {
  86125. /** @hidden */
  86126. export var lavaVertexShader: {
  86127. name: string;
  86128. shader: string;
  86129. };
  86130. }
  86131. declare module BABYLON {
  86132. export class LavaMaterial extends BABYLON.PushMaterial {
  86133. private _diffuseTexture;
  86134. diffuseTexture: BABYLON.BaseTexture;
  86135. noiseTexture: BABYLON.BaseTexture;
  86136. fogColor: BABYLON.Color3;
  86137. speed: number;
  86138. movingSpeed: number;
  86139. lowFrequencySpeed: number;
  86140. fogDensity: number;
  86141. private _lastTime;
  86142. diffuseColor: BABYLON.Color3;
  86143. private _disableLighting;
  86144. disableLighting: boolean;
  86145. private _unlit;
  86146. unlit: boolean;
  86147. private _maxSimultaneousLights;
  86148. maxSimultaneousLights: number;
  86149. private _scaledDiffuse;
  86150. constructor(name: string, scene: BABYLON.Scene);
  86151. needAlphaBlending(): boolean;
  86152. needAlphaTesting(): boolean;
  86153. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86154. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86155. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86156. getAnimatables(): BABYLON.IAnimatable[];
  86157. getActiveTextures(): BABYLON.BaseTexture[];
  86158. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86159. dispose(forceDisposeEffect?: boolean): void;
  86160. clone(name: string): LavaMaterial;
  86161. serialize(): any;
  86162. getClassName(): string;
  86163. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86164. }
  86165. }
  86166. declare module BABYLON {
  86167. /** @hidden */
  86168. export var mixPixelShader: {
  86169. name: string;
  86170. shader: string;
  86171. };
  86172. }
  86173. declare module BABYLON {
  86174. /** @hidden */
  86175. export var mixVertexShader: {
  86176. name: string;
  86177. shader: string;
  86178. };
  86179. }
  86180. declare module BABYLON {
  86181. export class MixMaterial extends BABYLON.PushMaterial {
  86182. /**
  86183. * Mix textures
  86184. */
  86185. private _mixTexture1;
  86186. mixTexture1: BABYLON.BaseTexture;
  86187. private _mixTexture2;
  86188. mixTexture2: BABYLON.BaseTexture;
  86189. /**
  86190. * Diffuse textures
  86191. */
  86192. private _diffuseTexture1;
  86193. diffuseTexture1: BABYLON.Texture;
  86194. private _diffuseTexture2;
  86195. diffuseTexture2: BABYLON.Texture;
  86196. private _diffuseTexture3;
  86197. diffuseTexture3: BABYLON.Texture;
  86198. private _diffuseTexture4;
  86199. diffuseTexture4: BABYLON.Texture;
  86200. private _diffuseTexture5;
  86201. diffuseTexture5: BABYLON.Texture;
  86202. private _diffuseTexture6;
  86203. diffuseTexture6: BABYLON.Texture;
  86204. private _diffuseTexture7;
  86205. diffuseTexture7: BABYLON.Texture;
  86206. private _diffuseTexture8;
  86207. diffuseTexture8: BABYLON.Texture;
  86208. /**
  86209. * Uniforms
  86210. */
  86211. diffuseColor: BABYLON.Color3;
  86212. specularColor: BABYLON.Color3;
  86213. specularPower: number;
  86214. private _disableLighting;
  86215. disableLighting: boolean;
  86216. private _maxSimultaneousLights;
  86217. maxSimultaneousLights: number;
  86218. constructor(name: string, scene: BABYLON.Scene);
  86219. needAlphaBlending(): boolean;
  86220. needAlphaTesting(): boolean;
  86221. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86222. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86223. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86224. getAnimatables(): BABYLON.IAnimatable[];
  86225. getActiveTextures(): BABYLON.BaseTexture[];
  86226. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86227. dispose(forceDisposeEffect?: boolean): void;
  86228. clone(name: string): MixMaterial;
  86229. serialize(): any;
  86230. getClassName(): string;
  86231. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86232. }
  86233. }
  86234. declare module BABYLON {
  86235. /** @hidden */
  86236. export var normalPixelShader: {
  86237. name: string;
  86238. shader: string;
  86239. };
  86240. }
  86241. declare module BABYLON {
  86242. /** @hidden */
  86243. export var normalVertexShader: {
  86244. name: string;
  86245. shader: string;
  86246. };
  86247. }
  86248. declare module BABYLON {
  86249. export class NormalMaterial extends BABYLON.PushMaterial {
  86250. private _diffuseTexture;
  86251. diffuseTexture: BABYLON.BaseTexture;
  86252. diffuseColor: BABYLON.Color3;
  86253. private _disableLighting;
  86254. disableLighting: boolean;
  86255. private _maxSimultaneousLights;
  86256. maxSimultaneousLights: number;
  86257. constructor(name: string, scene: BABYLON.Scene);
  86258. needAlphaBlending(): boolean;
  86259. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86260. needAlphaTesting(): boolean;
  86261. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86262. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86263. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86264. getAnimatables(): BABYLON.IAnimatable[];
  86265. getActiveTextures(): BABYLON.BaseTexture[];
  86266. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86267. dispose(forceDisposeEffect?: boolean): void;
  86268. clone(name: string): NormalMaterial;
  86269. serialize(): any;
  86270. getClassName(): string;
  86271. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86272. }
  86273. }
  86274. declare module BABYLON {
  86275. /** @hidden */
  86276. export var shadowOnlyPixelShader: {
  86277. name: string;
  86278. shader: string;
  86279. };
  86280. }
  86281. declare module BABYLON {
  86282. /** @hidden */
  86283. export var shadowOnlyVertexShader: {
  86284. name: string;
  86285. shader: string;
  86286. };
  86287. }
  86288. declare module BABYLON {
  86289. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86290. private _activeLight;
  86291. private _needAlphaBlending;
  86292. constructor(name: string, scene: BABYLON.Scene);
  86293. shadowColor: BABYLON.Color3;
  86294. needAlphaBlending(): boolean;
  86295. needAlphaTesting(): boolean;
  86296. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86297. get activeLight(): BABYLON.IShadowLight;
  86298. set activeLight(light: BABYLON.IShadowLight);
  86299. private _getFirstShadowLightForMesh;
  86300. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86301. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86302. clone(name: string): ShadowOnlyMaterial;
  86303. serialize(): any;
  86304. getClassName(): string;
  86305. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86306. }
  86307. }
  86308. declare module BABYLON {
  86309. /** @hidden */
  86310. export var simplePixelShader: {
  86311. name: string;
  86312. shader: string;
  86313. };
  86314. }
  86315. declare module BABYLON {
  86316. /** @hidden */
  86317. export var simpleVertexShader: {
  86318. name: string;
  86319. shader: string;
  86320. };
  86321. }
  86322. declare module BABYLON {
  86323. export class SimpleMaterial extends BABYLON.PushMaterial {
  86324. private _diffuseTexture;
  86325. diffuseTexture: BABYLON.BaseTexture;
  86326. diffuseColor: BABYLON.Color3;
  86327. private _disableLighting;
  86328. disableLighting: boolean;
  86329. private _maxSimultaneousLights;
  86330. maxSimultaneousLights: number;
  86331. constructor(name: string, scene: BABYLON.Scene);
  86332. needAlphaBlending(): boolean;
  86333. needAlphaTesting(): boolean;
  86334. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86335. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86336. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86337. getAnimatables(): BABYLON.IAnimatable[];
  86338. getActiveTextures(): BABYLON.BaseTexture[];
  86339. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86340. dispose(forceDisposeEffect?: boolean): void;
  86341. clone(name: string): SimpleMaterial;
  86342. serialize(): any;
  86343. getClassName(): string;
  86344. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86345. }
  86346. }
  86347. declare module BABYLON {
  86348. /** @hidden */
  86349. export var skyPixelShader: {
  86350. name: string;
  86351. shader: string;
  86352. };
  86353. }
  86354. declare module BABYLON {
  86355. /** @hidden */
  86356. export var skyVertexShader: {
  86357. name: string;
  86358. shader: string;
  86359. };
  86360. }
  86361. declare module BABYLON {
  86362. /**
  86363. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86364. * @see https://doc.babylonjs.com/extensions/sky
  86365. */
  86366. export class SkyMaterial extends BABYLON.PushMaterial {
  86367. /**
  86368. * Defines the overall luminance of sky in interval ]0, 1[.
  86369. */
  86370. luminance: number;
  86371. /**
  86372. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86373. */
  86374. turbidity: number;
  86375. /**
  86376. * Defines the sky appearance (light intensity).
  86377. */
  86378. rayleigh: number;
  86379. /**
  86380. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86381. */
  86382. mieCoefficient: number;
  86383. /**
  86384. * Defines the amount of haze particles following the Mie scattering theory.
  86385. */
  86386. mieDirectionalG: number;
  86387. /**
  86388. * Defines the distance of the sun according to the active scene camera.
  86389. */
  86390. distance: number;
  86391. /**
  86392. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86393. * "inclined".
  86394. */
  86395. inclination: number;
  86396. /**
  86397. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86398. * an object direction and a reference direction.
  86399. */
  86400. azimuth: number;
  86401. /**
  86402. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86403. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86404. */
  86405. sunPosition: BABYLON.Vector3;
  86406. /**
  86407. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86408. * .sunPosition property.
  86409. */
  86410. useSunPosition: boolean;
  86411. /**
  86412. * Defines an offset vector used to get a horizon offset.
  86413. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86414. */
  86415. cameraOffset: BABYLON.Vector3;
  86416. private _cameraPosition;
  86417. /**
  86418. * Instantiates a new sky material.
  86419. * This material allows to create dynamic and texture free
  86420. * effects for skyboxes by taking care of the atmosphere state.
  86421. * @see https://doc.babylonjs.com/extensions/sky
  86422. * @param name Define the name of the material in the scene
  86423. * @param scene Define the scene the material belong to
  86424. */
  86425. constructor(name: string, scene: BABYLON.Scene);
  86426. /**
  86427. * Specifies if the material will require alpha blending
  86428. * @returns a boolean specifying if alpha blending is needed
  86429. */
  86430. needAlphaBlending(): boolean;
  86431. /**
  86432. * Specifies if this material should be rendered in alpha test mode
  86433. * @returns false as the sky material doesn't need alpha testing.
  86434. */
  86435. needAlphaTesting(): boolean;
  86436. /**
  86437. * Get the texture used for alpha test purpose.
  86438. * @returns null as the sky material has no texture.
  86439. */
  86440. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86441. /**
  86442. * Get if the submesh is ready to be used and all its information available.
  86443. * Child classes can use it to update shaders
  86444. * @param mesh defines the mesh to check
  86445. * @param subMesh defines which submesh to check
  86446. * @param useInstances specifies that instances should be used
  86447. * @returns a boolean indicating that the submesh is ready or not
  86448. */
  86449. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86450. /**
  86451. * Binds the submesh to this material by preparing the effect and shader to draw
  86452. * @param world defines the world transformation matrix
  86453. * @param mesh defines the mesh containing the submesh
  86454. * @param subMesh defines the submesh to bind the material to
  86455. */
  86456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86457. /**
  86458. * Get the list of animatables in the material.
  86459. * @returns the list of animatables object used in the material
  86460. */
  86461. getAnimatables(): BABYLON.IAnimatable[];
  86462. /**
  86463. * Disposes the material
  86464. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86465. */
  86466. dispose(forceDisposeEffect?: boolean): void;
  86467. /**
  86468. * Makes a duplicate of the material, and gives it a new name
  86469. * @param name defines the new name for the duplicated material
  86470. * @returns the cloned material
  86471. */
  86472. clone(name: string): SkyMaterial;
  86473. /**
  86474. * Serializes this material in a JSON representation
  86475. * @returns the serialized material object
  86476. */
  86477. serialize(): any;
  86478. /**
  86479. * Gets the current class name of the material e.g. "SkyMaterial"
  86480. * Mainly use in serialization.
  86481. * @returns the class name
  86482. */
  86483. getClassName(): string;
  86484. /**
  86485. * Creates a sky material from parsed material data
  86486. * @param source defines the JSON representation of the material
  86487. * @param scene defines the hosting scene
  86488. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86489. * @returns a new sky material
  86490. */
  86491. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86492. }
  86493. }
  86494. declare module BABYLON {
  86495. /** @hidden */
  86496. export var terrainPixelShader: {
  86497. name: string;
  86498. shader: string;
  86499. };
  86500. }
  86501. declare module BABYLON {
  86502. /** @hidden */
  86503. export var terrainVertexShader: {
  86504. name: string;
  86505. shader: string;
  86506. };
  86507. }
  86508. declare module BABYLON {
  86509. export class TerrainMaterial extends BABYLON.PushMaterial {
  86510. private _mixTexture;
  86511. mixTexture: BABYLON.BaseTexture;
  86512. private _diffuseTexture1;
  86513. diffuseTexture1: BABYLON.Texture;
  86514. private _diffuseTexture2;
  86515. diffuseTexture2: BABYLON.Texture;
  86516. private _diffuseTexture3;
  86517. diffuseTexture3: BABYLON.Texture;
  86518. private _bumpTexture1;
  86519. bumpTexture1: BABYLON.Texture;
  86520. private _bumpTexture2;
  86521. bumpTexture2: BABYLON.Texture;
  86522. private _bumpTexture3;
  86523. bumpTexture3: BABYLON.Texture;
  86524. diffuseColor: BABYLON.Color3;
  86525. specularColor: BABYLON.Color3;
  86526. specularPower: number;
  86527. private _disableLighting;
  86528. disableLighting: boolean;
  86529. private _maxSimultaneousLights;
  86530. maxSimultaneousLights: number;
  86531. constructor(name: string, scene: BABYLON.Scene);
  86532. needAlphaBlending(): boolean;
  86533. needAlphaTesting(): boolean;
  86534. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86535. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86536. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86537. getAnimatables(): BABYLON.IAnimatable[];
  86538. getActiveTextures(): BABYLON.BaseTexture[];
  86539. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86540. dispose(forceDisposeEffect?: boolean): void;
  86541. clone(name: string): TerrainMaterial;
  86542. serialize(): any;
  86543. getClassName(): string;
  86544. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86545. }
  86546. }
  86547. declare module BABYLON {
  86548. /** @hidden */
  86549. export var triplanarPixelShader: {
  86550. name: string;
  86551. shader: string;
  86552. };
  86553. }
  86554. declare module BABYLON {
  86555. /** @hidden */
  86556. export var triplanarVertexShader: {
  86557. name: string;
  86558. shader: string;
  86559. };
  86560. }
  86561. declare module BABYLON {
  86562. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86563. mixTexture: BABYLON.BaseTexture;
  86564. private _diffuseTextureX;
  86565. diffuseTextureX: BABYLON.BaseTexture;
  86566. private _diffuseTextureY;
  86567. diffuseTextureY: BABYLON.BaseTexture;
  86568. private _diffuseTextureZ;
  86569. diffuseTextureZ: BABYLON.BaseTexture;
  86570. private _normalTextureX;
  86571. normalTextureX: BABYLON.BaseTexture;
  86572. private _normalTextureY;
  86573. normalTextureY: BABYLON.BaseTexture;
  86574. private _normalTextureZ;
  86575. normalTextureZ: BABYLON.BaseTexture;
  86576. tileSize: number;
  86577. diffuseColor: BABYLON.Color3;
  86578. specularColor: BABYLON.Color3;
  86579. specularPower: number;
  86580. private _disableLighting;
  86581. disableLighting: boolean;
  86582. private _maxSimultaneousLights;
  86583. maxSimultaneousLights: number;
  86584. constructor(name: string, scene: BABYLON.Scene);
  86585. needAlphaBlending(): boolean;
  86586. needAlphaTesting(): boolean;
  86587. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86588. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86589. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86590. getAnimatables(): BABYLON.IAnimatable[];
  86591. getActiveTextures(): BABYLON.BaseTexture[];
  86592. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86593. dispose(forceDisposeEffect?: boolean): void;
  86594. clone(name: string): TriPlanarMaterial;
  86595. serialize(): any;
  86596. getClassName(): string;
  86597. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86598. }
  86599. }
  86600. declare module BABYLON {
  86601. /** @hidden */
  86602. export var waterPixelShader: {
  86603. name: string;
  86604. shader: string;
  86605. };
  86606. }
  86607. declare module BABYLON {
  86608. /** @hidden */
  86609. export var waterVertexShader: {
  86610. name: string;
  86611. shader: string;
  86612. };
  86613. }
  86614. declare module BABYLON {
  86615. export class WaterMaterial extends BABYLON.PushMaterial {
  86616. renderTargetSize: BABYLON.Vector2;
  86617. private _bumpTexture;
  86618. bumpTexture: BABYLON.BaseTexture;
  86619. diffuseColor: BABYLON.Color3;
  86620. specularColor: BABYLON.Color3;
  86621. specularPower: number;
  86622. private _disableLighting;
  86623. disableLighting: boolean;
  86624. private _maxSimultaneousLights;
  86625. maxSimultaneousLights: number;
  86626. /**
  86627. * @param {number}: Represents the wind force
  86628. */
  86629. windForce: number;
  86630. /**
  86631. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86632. */
  86633. windDirection: BABYLON.Vector2;
  86634. /**
  86635. * @param {number}: Wave height, represents the height of the waves
  86636. */
  86637. waveHeight: number;
  86638. /**
  86639. * @param {number}: Bump height, represents the bump height related to the bump map
  86640. */
  86641. bumpHeight: number;
  86642. /**
  86643. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86644. */
  86645. private _bumpSuperimpose;
  86646. bumpSuperimpose: boolean;
  86647. /**
  86648. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86649. */
  86650. private _fresnelSeparate;
  86651. fresnelSeparate: boolean;
  86652. /**
  86653. * @param {boolean}: bump Waves modify the reflection.
  86654. */
  86655. private _bumpAffectsReflection;
  86656. bumpAffectsReflection: boolean;
  86657. /**
  86658. * @param {number}: The water color blended with the refraction (near)
  86659. */
  86660. waterColor: BABYLON.Color3;
  86661. /**
  86662. * @param {number}: The blend factor related to the water color
  86663. */
  86664. colorBlendFactor: number;
  86665. /**
  86666. * @param {number}: The water color blended with the reflection (far)
  86667. */
  86668. waterColor2: BABYLON.Color3;
  86669. /**
  86670. * @param {number}: The blend factor related to the water color (reflection, far)
  86671. */
  86672. colorBlendFactor2: number;
  86673. /**
  86674. * @param {number}: Represents the maximum length of a wave
  86675. */
  86676. waveLength: number;
  86677. /**
  86678. * @param {number}: Defines the waves speed
  86679. */
  86680. waveSpeed: number;
  86681. /**
  86682. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86683. * will avoid calculating useless pixels in the pixel shader of the water material.
  86684. */
  86685. disableClipPlane: boolean;
  86686. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86687. private _mesh;
  86688. private _refractionRTT;
  86689. private _reflectionRTT;
  86690. private _reflectionTransform;
  86691. private _lastTime;
  86692. private _lastDeltaTime;
  86693. private _useLogarithmicDepth;
  86694. private _waitingRenderList;
  86695. private _imageProcessingConfiguration;
  86696. private _imageProcessingObserver;
  86697. /**
  86698. * Gets a boolean indicating that current material needs to register RTT
  86699. */
  86700. get hasRenderTargetTextures(): boolean;
  86701. /**
  86702. * Constructor
  86703. */
  86704. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86705. get useLogarithmicDepth(): boolean;
  86706. set useLogarithmicDepth(value: boolean);
  86707. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86708. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86709. addToRenderList(node: any): void;
  86710. enableRenderTargets(enable: boolean): void;
  86711. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86712. get renderTargetsEnabled(): boolean;
  86713. needAlphaBlending(): boolean;
  86714. needAlphaTesting(): boolean;
  86715. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86716. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86717. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86718. private _createRenderTargets;
  86719. getAnimatables(): BABYLON.IAnimatable[];
  86720. getActiveTextures(): BABYLON.BaseTexture[];
  86721. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86722. dispose(forceDisposeEffect?: boolean): void;
  86723. clone(name: string): WaterMaterial;
  86724. serialize(): any;
  86725. getClassName(): string;
  86726. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86727. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86728. }
  86729. }
  86730. declare module BABYLON {
  86731. /** @hidden */
  86732. export var asciiartPixelShader: {
  86733. name: string;
  86734. shader: string;
  86735. };
  86736. }
  86737. declare module BABYLON {
  86738. /**
  86739. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86740. *
  86741. * It basically takes care rendering the font front the given font size to a texture.
  86742. * This is used later on in the postprocess.
  86743. */
  86744. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86745. private _font;
  86746. private _text;
  86747. private _charSize;
  86748. /**
  86749. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86750. */
  86751. get charSize(): number;
  86752. /**
  86753. * Create a new instance of the Ascii Art FontTexture class
  86754. * @param name the name of the texture
  86755. * @param font the font to use, use the W3C CSS notation
  86756. * @param text the caracter set to use in the rendering.
  86757. * @param scene the scene that owns the texture
  86758. */
  86759. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86760. /**
  86761. * Gets the max char width of a font.
  86762. * @param font the font to use, use the W3C CSS notation
  86763. * @return the max char width
  86764. */
  86765. private getFontWidth;
  86766. /**
  86767. * Gets the max char height of a font.
  86768. * @param font the font to use, use the W3C CSS notation
  86769. * @return the max char height
  86770. */
  86771. private getFontHeight;
  86772. /**
  86773. * Clones the current AsciiArtTexture.
  86774. * @return the clone of the texture.
  86775. */
  86776. clone(): AsciiArtFontTexture;
  86777. /**
  86778. * Parses a json object representing the texture and returns an instance of it.
  86779. * @param source the source JSON representation
  86780. * @param scene the scene to create the texture for
  86781. * @return the parsed texture
  86782. */
  86783. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86784. }
  86785. /**
  86786. * Option available in the Ascii Art Post Process.
  86787. */
  86788. export interface IAsciiArtPostProcessOptions {
  86789. /**
  86790. * The font to use following the w3c font definition.
  86791. */
  86792. font?: string;
  86793. /**
  86794. * The character set to use in the postprocess.
  86795. */
  86796. characterSet?: string;
  86797. /**
  86798. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86799. * This number is defined between 0 and 1;
  86800. */
  86801. mixToTile?: number;
  86802. /**
  86803. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86804. * This number is defined between 0 and 1;
  86805. */
  86806. mixToNormal?: number;
  86807. }
  86808. /**
  86809. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86810. *
  86811. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86812. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86813. */
  86814. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86815. /**
  86816. * The font texture used to render the char in the post process.
  86817. */
  86818. private _asciiArtFontTexture;
  86819. /**
  86820. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86821. * This number is defined between 0 and 1;
  86822. */
  86823. mixToTile: number;
  86824. /**
  86825. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86826. * This number is defined between 0 and 1;
  86827. */
  86828. mixToNormal: number;
  86829. /**
  86830. * Instantiates a new Ascii Art Post Process.
  86831. * @param name the name to give to the postprocess
  86832. * @camera the camera to apply the post process to.
  86833. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86834. */
  86835. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86836. }
  86837. }
  86838. declare module BABYLON {
  86839. /** @hidden */
  86840. export var digitalrainPixelShader: {
  86841. name: string;
  86842. shader: string;
  86843. };
  86844. }
  86845. declare module BABYLON {
  86846. /**
  86847. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86848. *
  86849. * It basically takes care rendering the font front the given font size to a texture.
  86850. * This is used later on in the postprocess.
  86851. */
  86852. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86853. private _font;
  86854. private _text;
  86855. private _charSize;
  86856. /**
  86857. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86858. */
  86859. get charSize(): number;
  86860. /**
  86861. * Create a new instance of the Digital Rain FontTexture class
  86862. * @param name the name of the texture
  86863. * @param font the font to use, use the W3C CSS notation
  86864. * @param text the caracter set to use in the rendering.
  86865. * @param scene the scene that owns the texture
  86866. */
  86867. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86868. /**
  86869. * Gets the max char width of a font.
  86870. * @param font the font to use, use the W3C CSS notation
  86871. * @return the max char width
  86872. */
  86873. private getFontWidth;
  86874. /**
  86875. * Gets the max char height of a font.
  86876. * @param font the font to use, use the W3C CSS notation
  86877. * @return the max char height
  86878. */
  86879. private getFontHeight;
  86880. /**
  86881. * Clones the current DigitalRainFontTexture.
  86882. * @return the clone of the texture.
  86883. */
  86884. clone(): DigitalRainFontTexture;
  86885. /**
  86886. * Parses a json object representing the texture and returns an instance of it.
  86887. * @param source the source JSON representation
  86888. * @param scene the scene to create the texture for
  86889. * @return the parsed texture
  86890. */
  86891. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86892. }
  86893. /**
  86894. * Option available in the Digital Rain Post Process.
  86895. */
  86896. export interface IDigitalRainPostProcessOptions {
  86897. /**
  86898. * The font to use following the w3c font definition.
  86899. */
  86900. font?: string;
  86901. /**
  86902. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86903. * This number is defined between 0 and 1;
  86904. */
  86905. mixToTile?: number;
  86906. /**
  86907. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86908. * This number is defined between 0 and 1;
  86909. */
  86910. mixToNormal?: number;
  86911. }
  86912. /**
  86913. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86914. *
  86915. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86916. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86917. */
  86918. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86919. /**
  86920. * The font texture used to render the char in the post process.
  86921. */
  86922. private _digitalRainFontTexture;
  86923. /**
  86924. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86925. * This number is defined between 0 and 1;
  86926. */
  86927. mixToTile: number;
  86928. /**
  86929. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86930. * This number is defined between 0 and 1;
  86931. */
  86932. mixToNormal: number;
  86933. /**
  86934. * Instantiates a new Digital Rain Post Process.
  86935. * @param name the name to give to the postprocess
  86936. * @camera the camera to apply the post process to.
  86937. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86938. */
  86939. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86940. }
  86941. }
  86942. declare module BABYLON {
  86943. /** @hidden */
  86944. export var brickProceduralTexturePixelShader: {
  86945. name: string;
  86946. shader: string;
  86947. };
  86948. }
  86949. declare module BABYLON {
  86950. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86951. private _numberOfBricksHeight;
  86952. private _numberOfBricksWidth;
  86953. private _jointColor;
  86954. private _brickColor;
  86955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86956. updateShaderUniforms(): void;
  86957. get numberOfBricksHeight(): number;
  86958. set numberOfBricksHeight(value: number);
  86959. get numberOfBricksWidth(): number;
  86960. set numberOfBricksWidth(value: number);
  86961. get jointColor(): BABYLON.Color3;
  86962. set jointColor(value: BABYLON.Color3);
  86963. get brickColor(): BABYLON.Color3;
  86964. set brickColor(value: BABYLON.Color3);
  86965. /**
  86966. * Serializes this brick procedural texture
  86967. * @returns a serialized brick procedural texture object
  86968. */
  86969. serialize(): any;
  86970. /**
  86971. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86972. * @param parsedTexture defines parsed texture data
  86973. * @param scene defines the current scene
  86974. * @param rootUrl defines the root URL containing brick procedural texture information
  86975. * @returns a parsed Brick Procedural BABYLON.Texture
  86976. */
  86977. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86978. }
  86979. }
  86980. declare module BABYLON {
  86981. /** @hidden */
  86982. export var cloudProceduralTexturePixelShader: {
  86983. name: string;
  86984. shader: string;
  86985. };
  86986. }
  86987. declare module BABYLON {
  86988. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86989. private _skyColor;
  86990. private _cloudColor;
  86991. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86992. updateShaderUniforms(): void;
  86993. get skyColor(): BABYLON.Color4;
  86994. set skyColor(value: BABYLON.Color4);
  86995. get cloudColor(): BABYLON.Color4;
  86996. set cloudColor(value: BABYLON.Color4);
  86997. /**
  86998. * Serializes this cloud procedural texture
  86999. * @returns a serialized cloud procedural texture object
  87000. */
  87001. serialize(): any;
  87002. /**
  87003. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87004. * @param parsedTexture defines parsed texture data
  87005. * @param scene defines the current scene
  87006. * @param rootUrl defines the root URL containing cloud procedural texture information
  87007. * @returns a parsed Cloud Procedural BABYLON.Texture
  87008. */
  87009. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87010. }
  87011. }
  87012. declare module BABYLON {
  87013. /** @hidden */
  87014. export var fireProceduralTexturePixelShader: {
  87015. name: string;
  87016. shader: string;
  87017. };
  87018. }
  87019. declare module BABYLON {
  87020. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87021. private _time;
  87022. private _speed;
  87023. private _autoGenerateTime;
  87024. private _fireColors;
  87025. private _alphaThreshold;
  87026. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87027. updateShaderUniforms(): void;
  87028. render(useCameraPostProcess?: boolean): void;
  87029. static get PurpleFireColors(): BABYLON.Color3[];
  87030. static get GreenFireColors(): BABYLON.Color3[];
  87031. static get RedFireColors(): BABYLON.Color3[];
  87032. static get BlueFireColors(): BABYLON.Color3[];
  87033. get autoGenerateTime(): boolean;
  87034. set autoGenerateTime(value: boolean);
  87035. get fireColors(): BABYLON.Color3[];
  87036. set fireColors(value: BABYLON.Color3[]);
  87037. get time(): number;
  87038. set time(value: number);
  87039. get speed(): BABYLON.Vector2;
  87040. set speed(value: BABYLON.Vector2);
  87041. get alphaThreshold(): number;
  87042. set alphaThreshold(value: number);
  87043. /**
  87044. * Serializes this fire procedural texture
  87045. * @returns a serialized fire procedural texture object
  87046. */
  87047. serialize(): any;
  87048. /**
  87049. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87050. * @param parsedTexture defines parsed texture data
  87051. * @param scene defines the current scene
  87052. * @param rootUrl defines the root URL containing fire procedural texture information
  87053. * @returns a parsed Fire Procedural BABYLON.Texture
  87054. */
  87055. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87056. }
  87057. }
  87058. declare module BABYLON {
  87059. /** @hidden */
  87060. export var grassProceduralTexturePixelShader: {
  87061. name: string;
  87062. shader: string;
  87063. };
  87064. }
  87065. declare module BABYLON {
  87066. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87067. private _grassColors;
  87068. private _groundColor;
  87069. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87070. updateShaderUniforms(): void;
  87071. get grassColors(): BABYLON.Color3[];
  87072. set grassColors(value: BABYLON.Color3[]);
  87073. get groundColor(): BABYLON.Color3;
  87074. set groundColor(value: BABYLON.Color3);
  87075. /**
  87076. * Serializes this grass procedural texture
  87077. * @returns a serialized grass procedural texture object
  87078. */
  87079. serialize(): any;
  87080. /**
  87081. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87082. * @param parsedTexture defines parsed texture data
  87083. * @param scene defines the current scene
  87084. * @param rootUrl defines the root URL containing grass procedural texture information
  87085. * @returns a parsed Grass Procedural BABYLON.Texture
  87086. */
  87087. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87088. }
  87089. }
  87090. declare module BABYLON {
  87091. /** @hidden */
  87092. export var marbleProceduralTexturePixelShader: {
  87093. name: string;
  87094. shader: string;
  87095. };
  87096. }
  87097. declare module BABYLON {
  87098. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87099. private _numberOfTilesHeight;
  87100. private _numberOfTilesWidth;
  87101. private _amplitude;
  87102. private _jointColor;
  87103. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87104. updateShaderUniforms(): void;
  87105. get numberOfTilesHeight(): number;
  87106. set numberOfTilesHeight(value: number);
  87107. get amplitude(): number;
  87108. set amplitude(value: number);
  87109. get numberOfTilesWidth(): number;
  87110. set numberOfTilesWidth(value: number);
  87111. get jointColor(): BABYLON.Color3;
  87112. set jointColor(value: BABYLON.Color3);
  87113. /**
  87114. * Serializes this marble procedural texture
  87115. * @returns a serialized marble procedural texture object
  87116. */
  87117. serialize(): any;
  87118. /**
  87119. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87120. * @param parsedTexture defines parsed texture data
  87121. * @param scene defines the current scene
  87122. * @param rootUrl defines the root URL containing marble procedural texture information
  87123. * @returns a parsed Marble Procedural BABYLON.Texture
  87124. */
  87125. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87126. }
  87127. }
  87128. declare module BABYLON {
  87129. /** @hidden */
  87130. export var normalMapProceduralTexturePixelShader: {
  87131. name: string;
  87132. shader: string;
  87133. };
  87134. }
  87135. declare module BABYLON {
  87136. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87137. private _baseTexture;
  87138. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87139. updateShaderUniforms(): void;
  87140. render(useCameraPostProcess?: boolean): void;
  87141. resize(size: any, generateMipMaps: any): void;
  87142. get baseTexture(): BABYLON.Texture;
  87143. set baseTexture(texture: BABYLON.Texture);
  87144. /**
  87145. * Serializes this normal map procedural texture
  87146. * @returns a serialized normal map procedural texture object
  87147. */
  87148. serialize(): any;
  87149. /**
  87150. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87151. * @param parsedTexture defines parsed texture data
  87152. * @param scene defines the current scene
  87153. * @param rootUrl defines the root URL containing normal map procedural texture information
  87154. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87155. */
  87156. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87157. }
  87158. }
  87159. declare module BABYLON {
  87160. /** @hidden */
  87161. export var perlinNoiseProceduralTexturePixelShader: {
  87162. name: string;
  87163. shader: string;
  87164. };
  87165. }
  87166. declare module BABYLON {
  87167. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87168. time: number;
  87169. timeScale: number;
  87170. translationSpeed: number;
  87171. private _currentTranslation;
  87172. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87173. updateShaderUniforms(): void;
  87174. render(useCameraPostProcess?: boolean): void;
  87175. resize(size: any, generateMipMaps: any): void;
  87176. /**
  87177. * Serializes this perlin noise procedural texture
  87178. * @returns a serialized perlin noise procedural texture object
  87179. */
  87180. serialize(): any;
  87181. /**
  87182. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87183. * @param parsedTexture defines parsed texture data
  87184. * @param scene defines the current scene
  87185. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87186. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87187. */
  87188. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87189. }
  87190. }
  87191. declare module BABYLON {
  87192. /** @hidden */
  87193. export var roadProceduralTexturePixelShader: {
  87194. name: string;
  87195. shader: string;
  87196. };
  87197. }
  87198. declare module BABYLON {
  87199. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87200. private _roadColor;
  87201. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87202. updateShaderUniforms(): void;
  87203. get roadColor(): BABYLON.Color3;
  87204. set roadColor(value: BABYLON.Color3);
  87205. /**
  87206. * Serializes this road procedural texture
  87207. * @returns a serialized road procedural texture object
  87208. */
  87209. serialize(): any;
  87210. /**
  87211. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87212. * @param parsedTexture defines parsed texture data
  87213. * @param scene defines the current scene
  87214. * @param rootUrl defines the root URL containing road procedural texture information
  87215. * @returns a parsed Road Procedural BABYLON.Texture
  87216. */
  87217. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87218. }
  87219. }
  87220. declare module BABYLON {
  87221. /** @hidden */
  87222. export var starfieldProceduralTexturePixelShader: {
  87223. name: string;
  87224. shader: string;
  87225. };
  87226. }
  87227. declare module BABYLON {
  87228. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87229. private _time;
  87230. private _alpha;
  87231. private _beta;
  87232. private _zoom;
  87233. private _formuparam;
  87234. private _stepsize;
  87235. private _tile;
  87236. private _brightness;
  87237. private _darkmatter;
  87238. private _distfading;
  87239. private _saturation;
  87240. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87241. updateShaderUniforms(): void;
  87242. get time(): number;
  87243. set time(value: number);
  87244. get alpha(): number;
  87245. set alpha(value: number);
  87246. get beta(): number;
  87247. set beta(value: number);
  87248. get formuparam(): number;
  87249. set formuparam(value: number);
  87250. get stepsize(): number;
  87251. set stepsize(value: number);
  87252. get zoom(): number;
  87253. set zoom(value: number);
  87254. get tile(): number;
  87255. set tile(value: number);
  87256. get brightness(): number;
  87257. set brightness(value: number);
  87258. get darkmatter(): number;
  87259. set darkmatter(value: number);
  87260. get distfading(): number;
  87261. set distfading(value: number);
  87262. get saturation(): number;
  87263. set saturation(value: number);
  87264. /**
  87265. * Serializes this starfield procedural texture
  87266. * @returns a serialized starfield procedural texture object
  87267. */
  87268. serialize(): any;
  87269. /**
  87270. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87271. * @param parsedTexture defines parsed texture data
  87272. * @param scene defines the current scene
  87273. * @param rootUrl defines the root URL containing startfield procedural texture information
  87274. * @returns a parsed Starfield Procedural BABYLON.Texture
  87275. */
  87276. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87277. }
  87278. }
  87279. declare module BABYLON {
  87280. /** @hidden */
  87281. export var woodProceduralTexturePixelShader: {
  87282. name: string;
  87283. shader: string;
  87284. };
  87285. }
  87286. declare module BABYLON {
  87287. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87288. private _ampScale;
  87289. private _woodColor;
  87290. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87291. updateShaderUniforms(): void;
  87292. get ampScale(): number;
  87293. set ampScale(value: number);
  87294. get woodColor(): BABYLON.Color3;
  87295. set woodColor(value: BABYLON.Color3);
  87296. /**
  87297. * Serializes this wood procedural texture
  87298. * @returns a serialized wood procedural texture object
  87299. */
  87300. serialize(): any;
  87301. /**
  87302. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87303. * @param parsedTexture defines parsed texture data
  87304. * @param scene defines the current scene
  87305. * @param rootUrl defines the root URL containing wood procedural texture information
  87306. * @returns a parsed Wood Procedural BABYLON.Texture
  87307. */
  87308. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87309. }
  87310. }